From f7442ea699f052382ea9d89465352b0c0c4e301e Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 14:18:09 +0000 Subject: [PATCH 01/40] Adds some framework for pages --- Scribble.yyp | 35 +++++++++ .../__scribble_config/__scribble_config.gml | 1 + scripts/scribble_draw/scribble_draw.gml | 8 +- .../scribble_draw_get_state.gml | 2 - .../scribble_draw_reset.gml | 4 +- .../scribble_draw_set_wrap.gml | 4 +- .../scribble_get_quad/scribble_get_quad.gml | 2 +- scripts/scribble_init/scribble_init.gml | 73 ++++++++++--------- .../scribble_page_get/scribble_page_get.gml | 7 ++ .../scribble_page_get/scribble_page_get.yy | 8 ++ .../scribble_page_get_count.gml | 29 ++++++++ .../scribble_page_get_count.yy | 8 ++ .../scribble_page_set/scribble_page_set.gml | 14 ++++ .../scribble_page_set/scribble_page_set.yy | 8 ++ views/85d381bf-3af3-491c-b197-63da24f6696b.yy | 15 ++++ views/dab40804-067d-4898-b5fd-736906e548cf.yy | 3 +- 16 files changed, 175 insertions(+), 46 deletions(-) create mode 100644 scripts/scribble_page_get/scribble_page_get.gml create mode 100644 scripts/scribble_page_get/scribble_page_get.yy create mode 100644 scripts/scribble_page_get_count/scribble_page_get_count.gml create mode 100644 scripts/scribble_page_get_count/scribble_page_get_count.yy create mode 100644 scripts/scribble_page_set/scribble_page_set.gml create mode 100644 scripts/scribble_page_set/scribble_page_set.yy create mode 100644 views/85d381bf-3af3-491c-b197-63da24f6696b.yy diff --git a/Scribble.yyp b/Scribble.yyp index 0a2e42daa..aea8ca56c 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": { @@ -382,6 +398,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": { @@ -582,6 +606,14 @@ "resourceType": "GMScript" } }, + { + "Key": "b7157de4-28d8-476e-b907-27576e4c9261", + "Value": { + "id": "aeb78a3e-1af2-4972-8be0-a37003b58052", + "resourcePath": "scripts\\scribble_page_get_count\\scribble_page_get_count.yy", + "resourceType": "GMScript" + } + }, { "Key": "b9c3b946-515e-4f7f-8f0e-687f9b63de18", "Value": { @@ -835,6 +867,9 @@ "c1f9a882-5c95-4baa-9aa2-288643547505", "853cc3dc-bb29-429c-b828-a68514d4f06e", "00322d5b-d6eb-4d4e-b389-bb26da697b1d", + "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", + "04acbfcf-ee17-4ded-b194-17bb72864ff0", + "b7157de4-28d8-476e-b907-27576e4c9261", "7f249531-321e-43d7-92bc-258842287e9d", "16333f16-885e-4b0b-98e8-9726a0f9c0b0", "acb5d2b0-8c3c-42de-b368-9e1978761cce" 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_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 1ee8d9ff8..51b65b440 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -41,7 +41,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 @@ -57,6 +57,7 @@ if (!is_array(_draw_string)) #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; @@ -121,6 +122,7 @@ if (!is_array(_draw_string)) _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 +130,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 --"; @@ -141,6 +144,7 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.VERTEX_BUFFER_LIST ] = _vertex_buffer_list; _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; + _scribble_array[@ __SCRIBBLE.PAGE ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = -1; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; @@ -155,7 +159,7 @@ if (!is_array(_draw_string)) _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 - + #endregion 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..2f6bc0bf1 100644 --- a/scripts/scribble_draw_get_state/scribble_draw_get_state.gml +++ b/scripts/scribble_draw_get_state/scribble_draw_get_state.gml @@ -8,9 +8,7 @@ _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; 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_wrap/scribble_draw_set_wrap.gml b/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml index e6661d989..459414f00 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 line 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[2]; +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 2f476949b..293c5aa0b 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -118,17 +118,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, @@ -145,42 +143,45 @@ enum __SCRIBBLE DEFAULT_COLOUR, // 4 DEFAULT_HALIGN, // 5 WIDTH_LIMIT, // 6 - LINE_HEIGHT, // 7 + HEIGHT_LIMIT, // 7 + LINE_HEIGHT, // 8 - __SECTION1, // 8 - WIDTH, // 9 - HEIGHT, //10 - CHARACTERS, //11 - LINES, //12 - GLOBAL_INDEX, //13 + __SECTION1, // 9 + WIDTH, //10 + HEIGHT, //11 + CHARACTERS, //12 + LINES, //13 + PAGES, //14 + GLOBAL_INDEX, //15 - __SECTION2, //14 - ANIMATION_TIME, //15 - TIME, //16 - FREED, //17 - SOUND_FINISH_TIME, //18 + __SECTION2, //16 + ANIMATION_TIME, //17 + TIME, //18 + FREED, //19 + SOUND_FINISH_TIME, //20 - __SECTION3, //19 - LINE_LIST, //20 - VERTEX_BUFFER_LIST, //21 + __SECTION3, //21 + LINE_LIST, //22 + VERTEX_BUFFER_LIST, //23 - __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 + __SECTION4, //24 + PAGE, //25 + AUTOTYPE_FADE_IN, //26 + AUTOTYPE_SPEED, //27 + AUTOTYPE_POSITION, //28 + AUTOTYPE_METHOD, //29 + AUTOTYPE_SMOOTHNESS, //30 + AUTOTYPE_SOUND_ARRAY, //31 + AUTOTYPE_SOUND_OVERLAP, //32 - __SECTION5, //30 - EVENT_PREVIOUS, //31 - EVENT_CHAR_PREVIOUS, //32 - EVENT_CHAR_ARRAY, //33 - EVENT_NAME_ARRAY, //34 - EVENT_DATA_ARRAY, //35 + __SECTION5, //33 + EVENT_PREVIOUS, //34 + EVENT_CHAR_PREVIOUS, //35 + EVENT_CHAR_ARRAY, //36 + EVENT_NAME_ARRAY, //37 + EVENT_DATA_ARRAY, //38 - __SIZE //36 + __SIZE //39 } #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_get/scribble_page_get.gml b/scripts/scribble_page_get/scribble_page_get.gml new file mode 100644 index 000000000..694fda530 --- /dev/null +++ b/scripts/scribble_page_get/scribble_page_get.gml @@ -0,0 +1,7 @@ +/// @param element +/// @param page +/// @param [relative] + +var _scribble_array = argument0; + +return _scribble_array[__SCRIBBLE.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_get_count/scribble_page_get_count.gml b/scripts/scribble_page_get_count/scribble_page_get_count.gml new file mode 100644 index 000000000..f5d33e9fb --- /dev/null +++ b/scripts/scribble_page_get_count/scribble_page_get_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_get_count/scribble_page_get_count.yy b/scripts/scribble_page_get_count/scribble_page_get_count.yy new file mode 100644 index 000000000..fd7f9ad70 --- /dev/null +++ b/scripts/scribble_page_get_count/scribble_page_get_count.yy @@ -0,0 +1,8 @@ +{ + "id": "b7157de4-28d8-476e-b907-27576e4c9261", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_get_count", + "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..eca953008 --- /dev/null +++ b/scripts/scribble_page_set/scribble_page_set.gml @@ -0,0 +1,14 @@ +/// @param element +/// @param page +/// @param [relative] + +var _scribble_array = argument[0]; +var _page = argument[1]; +var _relative = ((argument_count > 2) && (argument[2] != undefined))? argument[2] : false; + +if (_relative) _page += _scribble_array[__SCRIBBLE.PAGE]; + +_page = clamp(_page, 0, _scribble_array[__SCRIBBLE.PAGES]-1); +_scribble_array[@ __SCRIBBLE.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..39aa28950 --- /dev/null +++ b/views/85d381bf-3af3-491c-b197-63da24f6696b.yy @@ -0,0 +1,15 @@ +{ + "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" + ], + "filterType": "GMScript", + "folderName": "Pages", + "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..d39626d28 100644 --- a/views/dab40804-067d-4898-b5fd-736906e548cf.yy +++ b/views/dab40804-067d-4898-b5fd-736906e548cf.yy @@ -11,7 +11,8 @@ "bf269b8e-eb65-4528-b05e-d89efb7d6c87", "bcd14081-de72-4eef-8094-64efd4aac382", "95e57154-061e-41b9-87cb-88e21f8fa68c", - "d0797c70-f098-4e2c-912e-f1225887182b" + "d0797c70-f098-4e2c-912e-f1225887182b", + "85d381bf-3af3-491c-b197-63da24f6696b" ], "filterType": "GMScript", "folderName": "Scribble", From 052c7660cc3d9079276532b80bec65be9628d469 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 14:32:15 +0000 Subject: [PATCH 02/40] Fixes old enum elements being used --- .../scribble_draw_get_state.gml | 38 +++++++++--------- .../scribble_draw_set_state.gml | 40 +++++++++---------- 2 files changed, 38 insertions(+), 40 deletions(-) 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 2f6bc0bf1..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,23 +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.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.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_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 From 4a19d1bd50127af5f701bba08aee775b3bad52bb Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 14:32:32 +0000 Subject: [PATCH 03/40] Replaces lines list with lines array --- .../scribble_cache_group_flush.gml | 3 +- scripts/scribble_draw/scribble_draw.gml | 29 +++++++++---------- scripts/scribble_init/scribble_init.gml | 2 +- 3 files changed, 16 insertions(+), 18 deletions(-) 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..089996583 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -48,8 +48,7 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; vertex_delete_buffer(_vbuff); } - - 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 51b65b440..5dafd23fa 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -108,11 +108,11 @@ if (!is_array(_draw_string)) #region Create the text element (an array) 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 _lines_array = []; //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 = []; //Stores each event's triggering character + var _events_name_array = []; //Stores each event's name + var _events_data_array = []; //Stores each event's parameters var _texture_to_buffer_map = ds_map_create(); _scribble_array[@ __SCRIBBLE.__SECTION0 ] = "-- Parameters --"; @@ -140,7 +140,7 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.SOUND_FINISH_TIME ] = current_time; _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Lists --"; - _scribble_array[@ __SCRIBBLE.LINE_LIST ] = _line_list; + _scribble_array[@ __SCRIBBLE.LINES_ARRAY ] = _lines_array; _scribble_array[@ __SCRIBBLE.VERTEX_BUFFER_LIST ] = _vertex_buffer_list; _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; @@ -213,7 +213,7 @@ if (!is_array(_draw_string)) _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); + _lines_array[@ array_length_1d(_lines_array)] = _line_array; #endregion @@ -547,7 +547,7 @@ if (!is_array(_draw_string)) //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(_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); ++_image; } @@ -774,7 +774,7 @@ if (!is_array(_draw_string)) //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(_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); } //Update CHAR_START_TELL, and WORD_START_TELL if needed @@ -928,7 +928,7 @@ if (!is_array(_draw_string)) _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); + _lines_array[@ array_length_1d(_lines_array)] = _line_array; //Reset state _text_x += _line_offset_x; @@ -979,7 +979,7 @@ if (!is_array(_draw_string)) var _l = 0; repeat(ds_list_size(_line_break_list)-1) { - var _line_data = _line_list[| _l]; + var _line_data = _lines_array[_l]; var _line_halign = _line_data[__SCRIBBLE_LINE.HALIGN]; var _line_height = _line_data[__SCRIBBLE_LINE.HEIGHT]; @@ -1145,9 +1145,9 @@ 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 _scan_b = _line[__SCRIBBLE_LINE.LAST_CHAR]; + var _lines_array = _scribble_array[__SCRIBBLE.LINES_ARRAY]; + var _line = _lines_array[min(ceil(_typewriter_position + _typewriter_speed), _scribble_array[__SCRIBBLE.LINES]-1)]; + var _scan_b = _line[__SCRIBBLE_LINE.LAST_CHAR]; break; } @@ -1327,7 +1327,6 @@ if (SCRIBBLE_CACHE_TIMEOUT > 0) vertex_delete_buffer(_vbuff); } - ds_list_destroy(_cache_array[@ __SCRIBBLE.LINE_LIST]); ds_list_destroy(_vbuff_list); _cache_array[@ __SCRIBBLE.FREED] = true; diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 293c5aa0b..808422cbb 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -161,7 +161,7 @@ enum __SCRIBBLE SOUND_FINISH_TIME, //20 __SECTION3, //21 - LINE_LIST, //22 + LINES_ARRAY, //22 VERTEX_BUFFER_LIST, //23 __SECTION4, //24 From 521867df3c9846143a263290705b2babf3bb7d47 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 14:39:27 +0000 Subject: [PATCH 04/40] Replaces vertex buffer list with an array --- .../scribble_cache_group_flush.gml | 13 +++-- scripts/scribble_draw/scribble_draw.gml | 47 +++++++++---------- scripts/scribble_init/scribble_init.gml | 2 +- 3 files changed, 30 insertions(+), 32 deletions(-) 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 089996583..7350a507a 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -39,17 +39,16 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) && _scribble_array[__SCRIBBLE.FREED]) { 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++) + + var _vertex_buffers_array = _scribble_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; + var _i = 0; + repeat(array_length_1d(_vertex_buffers_array)) { - var _vbuff_data = _vbuff_list[| _i]; + var _vbuff_data = _vertex_buffers_array[_i]; var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; vertex_delete_buffer(_vbuff); + ++_i; } - - 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 5dafd23fa..8b5c4ba0a 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -109,7 +109,7 @@ if (!is_array(_draw_string)) var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array var _lines_array = []; //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 _vertex_buffers_array = []; //Stores all the vertex buffers needed to render the text and sprites 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 @@ -141,17 +141,17 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Lists --"; _scribble_array[@ __SCRIBBLE.LINES_ARRAY ] = _lines_array; - _scribble_array[@ __SCRIBBLE.VERTEX_BUFFER_LIST ] = _vertex_buffer_list; + _scribble_array[@ __SCRIBBLE.VERTEX_BUFFERS_ARRAY ] = _vertex_buffers_array; _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; - _scribble_array[@ __SCRIBBLE.PAGE ] = 0; + _scribble_array[@ __SCRIBBLE.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.AUTOTYPE_SOUND_OVERLAP] = 0; _scribble_array[@ __SCRIBBLE.__SECTION5 ] = "-- Events --"; _scribble_array[@ __SCRIBBLE.EVENT_PREVIOUS ] = -1; @@ -534,7 +534,7 @@ if (!is_array(_draw_string)) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_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); + _vertex_buffers_array[@ array_length_1d(_vertex_buffers_array)] = _vbuff_data; _texture_to_buffer_map[? _sprite_texture] = _vbuff_data; } @@ -706,9 +706,9 @@ if (!is_array(_draw_string)) //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(_vertex_buffers_array)) { - var _data = _vertex_buffer_list[| _v]; + var _data = _vertex_buffers_array[_v]; _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER]); ++_v; } @@ -763,7 +763,7 @@ if (!is_array(_draw_string)) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_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); + _vertex_buffers_array[@ array_length_1d(_vertex_buffers_array)] = _vbuff_data; _texture_to_buffer_map[? _font_texture] = _vbuff_data; } @@ -848,9 +848,9 @@ 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(_vertex_buffers_array)) { - var _data = _vertex_buffer_list[| _v]; + var _data = _vertex_buffers_array[_v]; var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; @@ -966,9 +966,9 @@ if (!is_array(_draw_string)) #region Move glyphs around on a line to finalise alignment var _v = 0; - repeat(ds_list_size(_vertex_buffer_list)) + repeat(array_length_1d(_vertex_buffers_array)) { - var _data = _vertex_buffer_list[| _v]; + var _data = _vertex_buffers_array[_v]; var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; @@ -1112,8 +1112,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 _vertex_buffers_array = _scribble_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; + var _count = array_length_1d(_vertex_buffers_array); if (_count > 0) { var _typewriter_method = _scribble_array[__SCRIBBLE.AUTOTYPE_METHOD]; @@ -1271,7 +1271,7 @@ if (global.scribble_state_allow_draw) var _i = 0; repeat(_count) { - var _vbuff_data = _vbuff_list[| _i]; + var _vbuff_data = _vertex_buffers_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; @@ -1318,17 +1318,16 @@ 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 _vertex_buffers_array = _cache_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; + var _i = 0; + repeat(array_length_1d(_vertex_buffers_array)) { - var _vbuff_data = _vbuff_list[| _i]; + var _vbuff_data = _vertex_buffers_array[_i]; var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; vertex_delete_buffer(_vbuff); + ++_i; } - ds_list_destroy(_vbuff_list); - _cache_array[@ __SCRIBBLE.FREED] = true; //Remove reference from cache diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 808422cbb..93b16fdfe 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -162,7 +162,7 @@ enum __SCRIBBLE __SECTION3, //21 LINES_ARRAY, //22 - VERTEX_BUFFER_LIST, //23 + VERTEX_BUFFERS_ARRAY, //23 __SECTION4, //24 PAGE, //25 From b3278874208914ff7d7129640b533731e568090f Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 15:15:40 +0000 Subject: [PATCH 05/40] Implements page array structure --- .../scribble_autotype_get.gml | 7 +- .../scribble_cache_group_flush.gml | 21 ++- scripts/scribble_draw/scribble_draw.gml | 152 +++++++++++------- scripts/scribble_init/scribble_init.gml | 49 +++--- 4 files changed, 138 insertions(+), 91 deletions(-) diff --git a/scripts/scribble_autotype_get/scribble_autotype_get.gml b/scripts/scribble_autotype_get/scribble_autotype_get.gml index d20e86368..479ce38d2 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -30,10 +30,13 @@ if (_typewriter_method == SCRIBBLE_AUTOTYPE_NONE) return -1; var _typewriter_fade_in = _scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN]; if (_scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN] < 0) return -2; +var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; +var _page_array = _pages_array[_scribble_array[__SCRIBBLE.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_cache_group_flush/scribble_cache_group_flush.gml b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml index 7350a507a..0eb63d4eb 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -40,14 +40,21 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) { ds_map_delete(global.scribble_alive, _scribble_array[__SCRIBBLE.GLOBAL_INDEX]); - var _vertex_buffers_array = _scribble_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; - var _i = 0; - repeat(array_length_1d(_vertex_buffers_array)) + var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _p = 0; + repeat(array_length_1d(_pages_array)) { - var _vbuff_data = _vertex_buffers_array[_i]; - var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; - vertex_delete_buffer(_vbuff); - ++_i; + var _page_array = _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; } _scribble_array[@ __SCRIBBLE.FREED] = true; diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 8b5c4ba0a..8d9214d4d 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -108,8 +108,7 @@ if (!is_array(_draw_string)) #region Create the text element (an array) var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array - var _lines_array = []; //Stores each line of text - var _vertex_buffers_array = []; //Stores all the vertex buffers needed to render the text and sprites + var _pages_array = []; //Stores each page of text 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 @@ -139,12 +138,11 @@ 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.LINES_ARRAY ] = _lines_array; - _scribble_array[@ __SCRIBBLE.VERTEX_BUFFERS_ARRAY ] = _vertex_buffers_array; + _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Pages --"; + _scribble_array[@ __SCRIBBLE.PAGE ] = 0; + _scribble_array[@ __SCRIBBLE.PAGES_ARRAY ] = _pages_array; _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; - _scribble_array[@ __SCRIBBLE.PAGE ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = -1; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; @@ -152,14 +150,25 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.AUTOTYPE_SMOOTHNESS ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_ARRAY ] = -1; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_OVERLAP] = 0; - + + //TODO - Move events into pages _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_CHAR_ARRAY ] = _events_char_array; //Stores each event's triggering character _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 + 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 _page_array = array_create(__SCRIBBLE.PAGES_ARRAY); + _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; + _pages_array[@ array_length_1d(_pages_array)] = _page_array; + #endregion @@ -196,14 +205,14 @@ if (!is_array(_draw_string)) var _parameters_list = ds_list_create(); - var _text_x = 0; - var _text_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 _text_x = 0; + var _text_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 _line_width = 0; var _line_height = _line_min_height; @@ -213,14 +222,16 @@ if (!is_array(_draw_string)) _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _def_halign; - _lines_array[@ array_length_1d(_lines_array)] = _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; + var _meta_page_characters = 0; + var _meta_page_lines = 0; + var _meta_element_characters = 0; + var _meta_element_lines = 0; + var _text_x_max = 0; + var _text_y_max = 0; var _command_tag_start = -1; var _command_tag_parameters = 0; @@ -378,7 +389,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; @@ -456,7 +467,7 @@ if (!is_array(_draw_string)) var _sprite_y = _text_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); @@ -534,7 +545,7 @@ if (!is_array(_draw_string)) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_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); - _vertex_buffers_array[@ array_length_1d(_vertex_buffers_array)] = _vbuff_data; + _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; _texture_to_buffer_map[? _sprite_texture] = _vbuff_data; } @@ -547,7 +558,7 @@ if (!is_array(_draw_string)) //Fill link break list var _tell = buffer_tell(_buffer); - repeat(array_length_1d(_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); ++_image; } @@ -599,7 +610,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 } @@ -706,9 +718,9 @@ if (!is_array(_draw_string)) //Iterate over all the vertex buffers we've been using and reset the word start position var _v = 0; - repeat(array_length_1d(_vertex_buffers_array)) + repeat(array_length_1d(_page_vbuffs_array)) { - var _data = _vertex_buffers_array[_v]; + var _data = _page_vbuffs_array[_v]; _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER]); ++_v; } @@ -763,7 +775,7 @@ if (!is_array(_draw_string)) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_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); - _vertex_buffers_array[@ array_length_1d(_vertex_buffers_array)] = _vbuff_data; + _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; _texture_to_buffer_map[? _font_texture] = _vbuff_data; } @@ -774,7 +786,7 @@ if (!is_array(_draw_string)) //Fill link break list var _tell = buffer_tell(_glyph_buffer); - repeat(array_length_1d(_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); } //Update CHAR_START_TELL, and WORD_START_TELL if needed @@ -809,7 +821,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); @@ -826,7 +838,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 @@ -848,9 +861,9 @@ if (!is_array(_draw_string)) var _line_offset_x = -_text_x; var _v = 0; - repeat(array_length_1d(_vertex_buffers_array)) + repeat(array_length_1d(_page_vbuffs_array)) { - var _data = _vertex_buffers_array[_v]; + var _data = _page_vbuffs_array[_v]; var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; @@ -914,21 +927,22 @@ if (!is_array(_draw_string)) ++_v; } - ++_meta_lines; + ++_meta_page_lines; + ++_meta_element_lines; _text_x_max = max(_text_x_max, _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.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; //Create a new line var _line_array = array_create(__SCRIBBLE_LINE.__SIZE); - _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_characters; + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters; _line_array[@ __SCRIBBLE_LINE.WIDTH ] = 0; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_min_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _text_halign; - _lines_array[@ array_length_1d(_lines_array)] = _line_array; + _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; //Reset state _text_x += _line_offset_x; @@ -945,17 +959,21 @@ if (!is_array(_draw_string)) _line_width = max(_line_width, _text_x); } - _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_characters; + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters; _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; - ++_meta_lines; + ++_meta_page_lines; + ++_meta_element_lines; _text_x_max = max(_text_x_max, _line_width); _text_y_max = _text_y + _line_height; - //Fill out metadata - _scribble_array[@ __SCRIBBLE.LINES ] = _meta_lines; - _scribble_array[@ __SCRIBBLE.CHARACTERS] = _meta_characters; + //Update metadata + _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; + _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; + + _scribble_array[@ __SCRIBBLE.LINES ] = _meta_element_lines; + _scribble_array[@ __SCRIBBLE.CHARACTERS] = _meta_element_characters; _scribble_array[@ __SCRIBBLE.WIDTH ] = _text_x_max; _scribble_array[@ __SCRIBBLE.HEIGHT ] = _text_y_max; @@ -966,9 +984,9 @@ if (!is_array(_draw_string)) #region Move glyphs around on a line to finalise alignment var _v = 0; - repeat(array_length_1d(_vertex_buffers_array)) + repeat(array_length_1d(_page_vbuffs_array)) { - var _data = _vertex_buffers_array[_v]; + var _data = _page_vbuffs_array[_v]; var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; @@ -979,7 +997,7 @@ if (!is_array(_draw_string)) var _l = 0; repeat(ds_list_size(_line_break_list)-1) { - var _line_data = _lines_array[_l]; + var _line_data = _page_lines_array[_l]; var _line_halign = _line_data[__SCRIBBLE_LINE.HALIGN]; var _line_height = _line_data[__SCRIBBLE_LINE.HEIGHT]; @@ -1067,6 +1085,9 @@ if (global.scribble_state_allow_draw) { #region Draw this text element + var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _page_array = _pages_array[_scribble_array[__SCRIBBLE.PAGE]]; + //Figure out the left/top offset switch(global.scribble_state_box_halign) { @@ -1112,8 +1133,8 @@ if (global.scribble_state_allow_draw) _matrix = matrix_multiply(_matrix, _old_matrix); matrix_set(matrix_world, _matrix); - var _vertex_buffers_array = _scribble_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; - var _count = array_length_1d(_vertex_buffers_array); + 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]; @@ -1145,9 +1166,9 @@ if (global.scribble_state_allow_draw) break; case SCRIBBLE_AUTOTYPE_PER_LINE: - var _lines_array = _scribble_array[__SCRIBBLE.LINES_ARRAY]; - var _line = _lines_array[min(ceil(_typewriter_position + _typewriter_speed), _scribble_array[__SCRIBBLE.LINES]-1)]; - var _scan_b = _line[__SCRIBBLE_LINE.LAST_CHAR]; + 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; } @@ -1166,6 +1187,7 @@ if (global.scribble_state_allow_draw) } } + //TODO - Move events into pages 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]; @@ -1232,8 +1254,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); @@ -1271,7 +1293,7 @@ if (global.scribble_state_allow_draw) var _i = 0; repeat(_count) { - var _vbuff_data = _vertex_buffers_array[_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; @@ -1317,15 +1339,21 @@ 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 _vertex_buffers_array = _cache_array[__SCRIBBLE.VERTEX_BUFFERS_ARRAY]; - var _i = 0; - repeat(array_length_1d(_vertex_buffers_array)) + var _pages_array = _cache_array[__SCRIBBLE.PAGES_ARRAY]; + var _p = 0; + repeat(array_length_1d(_pages_array)) { - var _vbuff_data = _vertex_buffers_array[_i]; - var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; - vertex_delete_buffer(_vbuff); - ++_i; + var _page_array = _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; } _cache_array[@ __SCRIBBLE.FREED] = true; diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 93b16fdfe..354d73d4e 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -67,8 +67,17 @@ enum __SCRIBBLE_FONT enum __SCRIBBLE_FONT_TYPE { - FONT, - SPRITE + FONT, //0 + SPRITE //1 +} + +enum __SCRIBBLE_PAGE +{ + LINES, + CHARACTERS, + LINES_ARRAY, + VERTEX_BUFFERS_ARRAY, + __SIZE } enum __SCRIBBLE_LINE @@ -161,27 +170,27 @@ enum __SCRIBBLE SOUND_FINISH_TIME, //20 __SECTION3, //21 - LINES_ARRAY, //22 - VERTEX_BUFFERS_ARRAY, //23 + PAGE, //24 + PAGES_ARRAY, //22 - __SECTION4, //24 - PAGE, //25 - AUTOTYPE_FADE_IN, //26 - AUTOTYPE_SPEED, //27 - AUTOTYPE_POSITION, //28 - AUTOTYPE_METHOD, //29 - AUTOTYPE_SMOOTHNESS, //30 - AUTOTYPE_SOUND_ARRAY, //31 - AUTOTYPE_SOUND_OVERLAP, //32 + __SECTION4, //23 + AUTOTYPE_FADE_IN, //25 + AUTOTYPE_SPEED, //26 + AUTOTYPE_POSITION, //27 + AUTOTYPE_METHOD, //28 + AUTOTYPE_SMOOTHNESS, //29 + AUTOTYPE_SOUND_ARRAY, //30 + AUTOTYPE_SOUND_OVERLAP, //31 - __SECTION5, //33 - EVENT_PREVIOUS, //34 - EVENT_CHAR_PREVIOUS, //35 - EVENT_CHAR_ARRAY, //36 - EVENT_NAME_ARRAY, //37 - EVENT_DATA_ARRAY, //38 + //TODO - Move events into pages + __SECTION5, //32 + EVENT_PREVIOUS, //33 + EVENT_CHAR_PREVIOUS, //34 + EVENT_CHAR_ARRAY, //35 + EVENT_NAME_ARRAY, //36 + EVENT_DATA_ARRAY, //37 - __SIZE //39 + __SIZE //38 } #macro __SCRIBBLE_ON_DIRECTX ((os_type == os_windows) || (os_type == os_xboxone) || (os_type == os_uwp) || (os_type == os_win8native) || (os_type == os_winphone)) From 544aae4443cd126fbcbbe52765fcefa3bd05d06c Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 15:17:48 +0000 Subject: [PATCH 06/40] Adds function to check if we're on the last page --- scripts/scribble_page_is_last/scribble_page_is_last.gml | 4 ++++ scripts/scribble_page_is_last/scribble_page_is_last.yy | 8 ++++++++ views/85d381bf-3af3-491c-b197-63da24f6696b.yy | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 scripts/scribble_page_is_last/scribble_page_is_last.gml create mode 100644 scripts/scribble_page_is_last/scribble_page_is_last.yy diff --git a/scripts/scribble_page_is_last/scribble_page_is_last.gml b/scripts/scribble_page_is_last/scribble_page_is_last.gml new file mode 100644 index 000000000..d6e3989e1 --- /dev/null +++ b/scripts/scribble_page_is_last/scribble_page_is_last.gml @@ -0,0 +1,4 @@ +/// @param element + + +return (argument0[__SCRIBBLE.PAGE] >= (argument0[__SCRIBBLE.PAGES]-1)); \ No newline at end of file diff --git a/scripts/scribble_page_is_last/scribble_page_is_last.yy b/scripts/scribble_page_is_last/scribble_page_is_last.yy new file mode 100644 index 000000000..e505a4f2d --- /dev/null +++ b/scripts/scribble_page_is_last/scribble_page_is_last.yy @@ -0,0 +1,8 @@ +{ + "id": "74d4828d-df60-4163-9a0f-713e1e653208", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_is_last", + "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 index 39aa28950..bf0529023 100644 --- a/views/85d381bf-3af3-491c-b197-63da24f6696b.yy +++ b/views/85d381bf-3af3-491c-b197-63da24f6696b.yy @@ -6,7 +6,8 @@ "children": [ "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", "04acbfcf-ee17-4ded-b194-17bb72864ff0", - "b7157de4-28d8-476e-b907-27576e4c9261" + "b7157de4-28d8-476e-b907-27576e4c9261", + "74d4828d-df60-4163-9a0f-713e1e653208" ], "filterType": "GMScript", "folderName": "Pages", From e898b670b963a3ce584a9c2768f8c28055d03a14 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 20:29:48 +0000 Subject: [PATCH 07/40] Changes function name --- Scribble.yyp | 17 +++++++++++++---- .../scribble_page_count.gml} | 0 .../scribble_page_count.yy} | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) rename scripts/{scribble_page_get_count/scribble_page_get_count.gml => scribble_page_count/scribble_page_count.gml} (100%) rename scripts/{scribble_page_get_count/scribble_page_get_count.yy => scribble_page_count/scribble_page_count.yy} (79%) diff --git a/Scribble.yyp b/Scribble.yyp index aea8ca56c..c339e1beb 100644 --- a/Scribble.yyp +++ b/Scribble.yyp @@ -318,6 +318,14 @@ "resourceType": "GMFolder" } }, + { + "Key": "74d4828d-df60-4163-9a0f-713e1e653208", + "Value": { + "id": "4c990981-3742-44f0-9749-f5a58ddb3ae2", + "resourcePath": "scripts\\scribble_page_is_last\\scribble_page_is_last.yy", + "resourceType": "GMScript" + } + }, { "Key": "75ac291e-7061-4bcb-8e8a-3b3545332d41", "Value": { @@ -610,7 +618,7 @@ "Key": "b7157de4-28d8-476e-b907-27576e4c9261", "Value": { "id": "aeb78a3e-1af2-4972-8be0-a37003b58052", - "resourcePath": "scripts\\scribble_page_get_count\\scribble_page_get_count.yy", + "resourcePath": "scripts\\scribble_page_count\\scribble_page_count.yy", "resourceType": "GMScript" } }, @@ -860,6 +868,10 @@ "24adc709-497e-43cb-9834-a1a8664cbe74", "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c", "498aa41e-7fb7-49e3-b663-74ba62e7a8e6", + "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", @@ -867,9 +879,6 @@ "c1f9a882-5c95-4baa-9aa2-288643547505", "853cc3dc-bb29-429c-b828-a68514d4f06e", "00322d5b-d6eb-4d4e-b389-bb26da697b1d", - "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", - "04acbfcf-ee17-4ded-b194-17bb72864ff0", - "b7157de4-28d8-476e-b907-27576e4c9261", "7f249531-321e-43d7-92bc-258842287e9d", "16333f16-885e-4b0b-98e8-9726a0f9c0b0", "acb5d2b0-8c3c-42de-b368-9e1978761cce" diff --git a/scripts/scribble_page_get_count/scribble_page_get_count.gml b/scripts/scribble_page_count/scribble_page_count.gml similarity index 100% rename from scripts/scribble_page_get_count/scribble_page_get_count.gml rename to scripts/scribble_page_count/scribble_page_count.gml diff --git a/scripts/scribble_page_get_count/scribble_page_get_count.yy b/scripts/scribble_page_count/scribble_page_count.yy similarity index 79% rename from scripts/scribble_page_get_count/scribble_page_get_count.yy rename to scripts/scribble_page_count/scribble_page_count.yy index fd7f9ad70..0c3e1c971 100644 --- a/scripts/scribble_page_get_count/scribble_page_get_count.yy +++ b/scripts/scribble_page_count/scribble_page_count.yy @@ -2,7 +2,7 @@ "id": "b7157de4-28d8-476e-b907-27576e4c9261", "modelName": "GMScript", "mvc": "1.0", - "name": "scribble_page_get_count", + "name": "scribble_page_count", "IsCompatibility": false, "IsDnD": false } \ No newline at end of file From 98e6db42a5aa077f6a20c9de4327996cdb0260df Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 20:29:56 +0000 Subject: [PATCH 08/40] Update dab40804-067d-4898-b5fd-736906e548cf.yy --- views/dab40804-067d-4898-b5fd-736906e548cf.yy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/dab40804-067d-4898-b5fd-736906e548cf.yy b/views/dab40804-067d-4898-b5fd-736906e548cf.yy index d39626d28..e6f3c7f28 100644 --- a/views/dab40804-067d-4898-b5fd-736906e548cf.yy +++ b/views/dab40804-067d-4898-b5fd-736906e548cf.yy @@ -11,8 +11,8 @@ "bf269b8e-eb65-4528-b05e-d89efb7d6c87", "bcd14081-de72-4eef-8094-64efd4aac382", "95e57154-061e-41b9-87cb-88e21f8fa68c", - "d0797c70-f098-4e2c-912e-f1225887182b", - "85d381bf-3af3-491c-b197-63da24f6696b" + "85d381bf-3af3-491c-b197-63da24f6696b", + "d0797c70-f098-4e2c-912e-f1225887182b" ], "filterType": "GMScript", "folderName": "Scribble", From 5acf6768060b8bceb721b97ff7065081584f48ca Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 20:30:35 +0000 Subject: [PATCH 09/40] Adds missing formatting tags to scribble_draw() function description --- scripts/scribble_draw/scribble_draw.gml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 8d9214d4d..8d104a1e5 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -29,6 +29,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 From 2796dc258ccb0a9809f7d39ace606358a5d7283f Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 20:30:50 +0000 Subject: [PATCH 10/40] Implements basic page system --- scripts/scribble_draw/scribble_draw.gml | 314 ++++++++++++++++-------- 1 file changed, 212 insertions(+), 102 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 8d104a1e5..d10b3ad20 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 @@ -52,8 +53,14 @@ 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 @@ -107,14 +114,18 @@ 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 _element_x_max = 0; + var _element_y_max = 0; - var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array - var _pages_array = []; //Stores each page of text - 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 - var _texture_to_buffer_map = ds_map_create(); + var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array + var _pages_array = []; //Stores each page of text + 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 _scribble_array[@ __SCRIBBLE.__SECTION0 ] = "-- Parameters --"; _scribble_array[@ __SCRIBBLE.VERSION ] = __SCRIBBLE_VERSION; @@ -161,16 +172,6 @@ if (!is_array(_draw_string)) _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 - 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 _page_array = array_create(__SCRIBBLE.PAGES_ARRAY); - _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; - _pages_array[@ array_length_1d(_pages_array)] = _page_array; - #endregion @@ -201,45 +202,66 @@ if (!is_array(_draw_string)) - #region Parse the string - - #region Initial parser state - - var _parameters_list = ds_list_create(); - - var _text_x = 0; - var _text_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) + + _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; + + _pages_array[@ array_length_1d(_pages_array)] = _page_array; + _scribble_array[@ __SCRIBBLE.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.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _def_halign; _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; - + #endregion - - var _meta_page_characters = 0; - var _meta_page_lines = 0; - var _meta_element_characters = 0; - var _meta_element_lines = 0; - var _text_x_max = 0; - var _text_y_max = 0; - + + + + #region Set the initial parser state + + var _text_x = 0; + var _text_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; //Write the string into a buffer for faster reading @@ -249,11 +271,14 @@ if (!is_array(_draw_string)) buffer_seek(_string_buffer, buffer_seek_start, 0); //Iterate over the entire string... + var _read_string = ""; repeat(_buffer_size) { var _character_code = buffer_read(_string_buffer, buffer_u8); if (_character_code == 0) break; - + + _read_string += chr(_character_code); + 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 ]) @@ -334,7 +359,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) @@ -929,9 +964,9 @@ if (!is_array(_draw_string)) ++_v; } - ++_meta_page_lines; ++_meta_element_lines; - _text_x_max = max(_text_x_max, _line_width); + ++_meta_page_lines; + _element_x_max = max(_element_x_max, _line_width); //Update the last line _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters-1; @@ -956,7 +991,73 @@ if (!is_array(_draw_string)) } #endregion - + + + + #region Handle new page creation + + if (_force_newpage + || ((_line_height + _text_y > _max_height) && (_max_height >= 0))) + { + _element_y_max = max(_element_y_max, _text_y + _line_height); + + //Update the metadata of the previous page + _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; + _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; + + if (_force_newpage) + { + _text_x = 0; + _line_width = 0; + _line_height = _line_min_height; + + _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 + //TODO - Update characters and steal vertex buffer data + _page_array[@ __SCRIBBLE_PAGE.LINES]--; + _page_lines_array[array_length_1d(_page_lines_array)-1] = undefined; + } + + //Create a new page + 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) + + _page_array[@ __SCRIBBLE_PAGE.LINES ] = 1; + _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; + + _pages_array[@ array_length_1d(_pages_array)] = _page_array; + _scribble_array[@ __SCRIBBLE.PAGES]++; + + //Add the line array to this page + _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; + + //Reset some state variables + _meta_page_characters = 0; + _meta_page_lines = 1; + _text_y = 0; + _previous_texture = -1; + + //Wipe the texture -> vertex buffer map + ds_list_clear(_line_break_list); + ds_map_clear(_texture_to_buffer_map); + + _force_newpage = false; + } + + #endregion + + + _text_x += _char_width; _line_width = max(_line_width, _text_x); } @@ -967,8 +1068,8 @@ if (!is_array(_draw_string)) ++_meta_page_lines; ++_meta_element_lines; - _text_x_max = max(_text_x_max, _line_width); - _text_y_max = _text_y + _line_height; + _element_x_max = max(_element_x_max, _line_width); + _element_y_max = max(_element_y_max, _text_y + _line_height); //Update metadata _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; @@ -976,79 +1077,88 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.LINES ] = _meta_element_lines; _scribble_array[@ __SCRIBBLE.CHARACTERS] = _meta_element_characters; - _scribble_array[@ __SCRIBBLE.WIDTH ] = _text_x_max; - _scribble_array[@ __SCRIBBLE.HEIGHT ] = _text_y_max; + _scribble_array[@ __SCRIBBLE.WIDTH ] = _element_x_max; + _scribble_array[@ __SCRIBBLE.HEIGHT ] = _element_y_max; #endregion #region Move glyphs around on a line to finalise alignment - - var _v = 0; - repeat(array_length_1d(_page_vbuffs_array)) + + var _p = 0; + repeat(array_length_1d(_pages_array)) { - var _data = _page_vbuffs_array[_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 = _pages_array[_p]; + _page_vbuffs_array = _page_array[__SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY]; + + var _v = 0; + repeat(array_length_1d(_page_vbuffs_array)) { - var _line_data = _page_lines_array[_l]; - 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]; - - if (_line_halign != fa_left) + 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 _line_width = _line_data[__SCRIBBLE_LINE.WIDTH]; + var _line_data = _page_lines_array[_l]; + var _line_halign = _line_data[__SCRIBBLE_LINE.HALIGN]; + var _line_height = _line_data[__SCRIBBLE_LINE.HEIGHT]; - var _offset = 0; - if (_line_halign == fa_right ) _offset = _text_x_max - _line_width; - if (_line_halign == fa_center) _offset = (_text_x_max - _line_width) div 2; + var _tell_a = _line_break_list[| _l ]; + var _tell_b = _line_break_list[| _l+1]; - var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_X; + if (_line_halign != fa_left) + { + var _line_width = _line_data[__SCRIBBLE_LINE.WIDTH]; + + var _offset = 0; + if (_line_halign == fa_right ) _offset = _element_x_max - _line_width; + if (_line_halign == fa_center) _offset = (_element_x_max - _line_width) div 2; + + var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_X; + repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) + { + buffer_poke(_buffer, _tell, buffer_f32, _offset + buffer_peek(_buffer, _tell, buffer_f32)); + _tell += __SCRIBBLE_VERTEX.__SIZE; + } + } + + var _offset = _line_height div 2; + var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) { buffer_poke(_buffer, _tell, buffer_f32, _offset + buffer_peek(_buffer, _tell, buffer_f32)); _tell += __SCRIBBLE_VERTEX.__SIZE; } + + ++_l; } - var _offset = _line_height div 2; - var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; - repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) - { - buffer_poke(_buffer, _tell, buffer_f32, _offset + 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(_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); - ++_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 From 4219786bbf59b580507b2537de518dd99071ca69 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 16 Feb 2020 20:30:56 +0000 Subject: [PATCH 11/40] Adds page test case --- objects/obj_test/Create_0.gml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 995593c88..8e11d7092 100644 --- a/objects/obj_test/Create_0.gml +++ b/objects/obj_test/Create_0.gml @@ -17,21 +17,25 @@ 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.[/page]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.[/page]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, 5); +scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 2, 10); +//scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_LINE, 0.05, 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 From 657f41dfa2e191679d79aa4ec6aa1ea64d812fbc Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Wed, 19 Feb 2020 22:07:04 +0000 Subject: [PATCH 12/40] Fixes vertical alignment for scaled text --- scripts/scribble_draw/scribble_draw.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index d10b3ad20..1dc00f0ca 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -847,7 +847,7 @@ if (!is_array(_draw_string)) if (_glyph_array != undefined) { var _quad_l = _text_x + _glyph_array[SCRIBBLE_GLYPH.X_OFFSET]*_text_scale; - var _quad_t = _text_y + _glyph_array[SCRIBBLE_GLYPH.Y_OFFSET]*_text_scale - (_font_line_height div 2); + var _quad_t = _text_y + _glyph_array[SCRIBBLE_GLYPH.Y_OFFSET]*_text_scale - ((_font_line_height*_text_scale) div 2); var _quad_r = _quad_l + _glyph_array[SCRIBBLE_GLYPH.WIDTH ]*_text_scale; var _quad_b = _quad_t + _glyph_array[SCRIBBLE_GLYPH.HEIGHT ]*_text_scale; From b9e203a9a68dacf8b5dbc3e1341eadda7cfb3b15 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 11:44:01 +0000 Subject: [PATCH 13/40] Moves text y-position tracking to per line --- scripts/scribble_draw/scribble_draw.gml | 35 ++++++++++++++----------- scripts/scribble_init/scribble_init.gml | 9 ++++--- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 1dc00f0ca..0dc3eb63b 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -242,7 +242,7 @@ if (!is_array(_draw_string)) #region Set the initial parser state var _text_x = 0; - var _text_y = 0; + var _line_y = 0; var _text_font = _def_font; var _text_colour = _def_colour; var _text_halign = _def_halign; @@ -496,12 +496,12 @@ if (!is_array(_draw_string)) if (SCRIBBLE_ADD_SPRITE_ORIGINS) { var _sprite_x = _text_x - _text_scale*sprite_get_xoffset(_sprite_index) + (_sprite_width div 2); - var _sprite_y = _text_y - _text_scale*sprite_get_yoffset(_sprite_index); + var _sprite_y = -_text_scale*sprite_get_yoffset(_sprite_index); } else { var _sprite_x = _text_x; - var _sprite_y = _text_y - (_sprite_height div 2); + var _sprite_y = -(_sprite_height div 2); } var _packed_indexes = _meta_page_characters*SCRIBBLE_MAX_LINES + _meta_page_lines; @@ -847,7 +847,7 @@ if (!is_array(_draw_string)) if (_glyph_array != undefined) { var _quad_l = _text_x + _glyph_array[SCRIBBLE_GLYPH.X_OFFSET]*_text_scale; - var _quad_t = _text_y + _glyph_array[SCRIBBLE_GLYPH.Y_OFFSET]*_text_scale - ((_font_line_height*_text_scale) div 2); + var _quad_t = _glyph_array[SCRIBBLE_GLYPH.Y_OFFSET]*_text_scale - ((_font_line_height*_text_scale) div 2); var _quad_r = _quad_l + _glyph_array[SCRIBBLE_GLYPH.WIDTH ]*_text_scale; var _quad_b = _quad_t + _glyph_array[SCRIBBLE_GLYPH.HEIGHT ]*_text_scale; @@ -970,23 +970,25 @@ if (!is_array(_draw_string)) //Update the last line _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; + //Reset state + _text_x += _line_offset_x; + _line_y += _line_height; + _line_width = 0; + _line_height = _line_min_height; + //Create a new line var _line_array = array_create(__SCRIBBLE_LINE.__SIZE); _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; _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; - //Reset state - _text_x += _line_offset_x; - _text_y = _text_y + _line_height; - _line_width = 0; - _line_height = _line_min_height; - _force_newline = false; } @@ -997,9 +999,9 @@ if (!is_array(_draw_string)) #region Handle new page creation if (_force_newpage - || ((_line_height + _text_y > _max_height) && (_max_height >= 0))) + || ((_line_height + _line_y > _max_height) && (_max_height >= 0))) { - _element_y_max = max(_element_y_max, _text_y + _line_height); + _element_y_max = max(_element_y_max, _line_y + _line_height); //Update the metadata of the previous page _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; @@ -1044,7 +1046,7 @@ if (!is_array(_draw_string)) //Reset some state variables _meta_page_characters = 0; _meta_page_lines = 1; - _text_y = 0; + _line_y = 0; _previous_texture = -1; //Wipe the texture -> vertex buffer map @@ -1063,13 +1065,14 @@ if (!is_array(_draw_string)) } _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_x_max = max(_element_x_max, _line_width); - _element_y_max = max(_element_y_max, _text_y + _line_height); + _element_y_max = max(_element_y_max, _line_y + _line_height); //Update metadata _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; @@ -1107,6 +1110,7 @@ if (!is_array(_draw_string)) repeat(ds_list_size(_line_break_list)-1) { 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]; @@ -1129,11 +1133,10 @@ if (!is_array(_draw_string)) } } - var _offset = _line_height div 2; var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) { - buffer_poke(_buffer, _tell, buffer_f32, _offset + buffer_peek(_buffer, _tell, buffer_f32)); + buffer_poke(_buffer, _tell, buffer_f32, _line_y + buffer_peek(_buffer, _tell, buffer_f32)); _tell += __SCRIBBLE_VERTEX.__SIZE; } diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 354d73d4e..5c383a7f5 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -83,10 +83,11 @@ enum __SCRIBBLE_PAGE enum __SCRIBBLE_LINE { LAST_CHAR, //0 - WIDTH, //1 - HEIGHT, //2 - HALIGN, //3 - __SIZE //4 + Y, //1 + WIDTH, //2 + HEIGHT, //3 + HALIGN, //4 + __SIZE //5 } enum __SCRIBBLE_VERTEX_BUFFER From ee552ee468918db5d1015742836324d4ebc28f09 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 12:15:09 +0000 Subject: [PATCH 14/40] Slowly restructing to allow for pages... --- .../scribble_autotype_get.gml | 4 +- .../scribble_cache_group_flush.gml | 6 +- scripts/scribble_draw/scribble_draw.gml | 112 ++++++++++-------- views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy | 6 +- 4 files changed, 69 insertions(+), 59 deletions(-) diff --git a/scripts/scribble_autotype_get/scribble_autotype_get.gml b/scripts/scribble_autotype_get/scribble_autotype_get.gml index 479ce38d2..469b8af71 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -30,8 +30,8 @@ if (_typewriter_method == SCRIBBLE_AUTOTYPE_NONE) return -1; var _typewriter_fade_in = _scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN]; if (_scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN] < 0) return -2; -var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; -var _page_array = _pages_array[_scribble_array[__SCRIBBLE.PAGE]]; +var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.PAGE]]; switch(_typewriter_method) { 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 0eb63d4eb..022e86142 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -40,11 +40,11 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) { ds_map_delete(global.scribble_alive, _scribble_array[__SCRIBBLE.GLOBAL_INDEX]); - var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; var _p = 0; - repeat(array_length_1d(_pages_array)) + repeat(array_length_1d(_element_pages_array)) { - var _page_array = _pages_array[_p]; + 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)) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 0dc3eb63b..82149b710 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -122,10 +122,10 @@ if (!is_array(_draw_string)) var _element_y_max = 0; var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array - var _pages_array = []; //Stores each page of text - 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 + var _element_pages_array = []; //Stores each page of text + 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 _scribble_array[@ __SCRIBBLE.__SECTION0 ] = "-- Parameters --"; _scribble_array[@ __SCRIBBLE.VERSION ] = __SCRIBBLE_VERSION; @@ -153,7 +153,7 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Pages --"; _scribble_array[@ __SCRIBBLE.PAGE ] = 0; - _scribble_array[@ __SCRIBBLE.PAGES_ARRAY ] = _pages_array; + _scribble_array[@ __SCRIBBLE.PAGES_ARRAY ] = _element_pages_array; _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; _scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = -1; @@ -216,7 +216,7 @@ if (!is_array(_draw_string)) _page_array[@ __SCRIBBLE_PAGE.LINES_ARRAY ] = _page_lines_array; _page_array[@ __SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY] = _page_vbuffs_array; - _pages_array[@ array_length_1d(_pages_array)] = _page_array; + _element_pages_array[@ array_length_1d(_element_pages_array)] = _page_array; _scribble_array[@ __SCRIBBLE.PAGES]++; #endregion @@ -570,7 +570,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 _line_start_tell_list = ds_list_create(); var _buffer = buffer_create(__SCRIBBLE_GLYPH_BYTE_SIZE, buffer_grow, 1); _vbuff_data = array_create(__SCRIBBLE_VERTEX_BUFFER.__SIZE); @@ -579,7 +579,7 @@ 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] = _line_start_tell_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); _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; @@ -595,7 +595,7 @@ if (!is_array(_draw_string)) //Fill link break list var _tell = buffer_tell(_buffer); - repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_start_tell_list)) ds_list_add(_line_start_tell_list, _tell); ++_image; } @@ -800,7 +800,7 @@ 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 _line_start_tell_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); @@ -809,7 +809,7 @@ if (!is_array(_draw_string)) _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] = _line_start_tell_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); _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; @@ -823,7 +823,7 @@ if (!is_array(_draw_string)) //Fill link break list var _tell = buffer_tell(_glyph_buffer); - repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_line_start_tell_list)) ds_list_add(_line_start_tell_list, _tell); } //Update CHAR_START_TELL, and WORD_START_TELL if needed @@ -889,7 +889,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 @@ -901,19 +903,19 @@ if (!is_array(_draw_string)) repeat(array_length_1d(_page_vbuffs_array)) { var _data = _page_vbuffs_array[_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 _line_start_tell_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(_line_start_tell_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(_line_start_tell_list, _tell_a); //If we've added anything to this buffer if (_tell_a < _tell_b) @@ -954,7 +956,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; } } @@ -987,7 +988,7 @@ if (!is_array(_draw_string)) _line_array[@ __SCRIBBLE_LINE.WIDTH ] = 0; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_min_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _text_halign; - _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; + _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; //Add this line to the page _force_newline = false; } @@ -1007,6 +1008,19 @@ if (!is_array(_draw_string)) _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; + //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) + + _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; + + _element_pages_array[@ array_length_1d(_element_pages_array)] = _new_page_array; + _scribble_array[@ __SCRIBBLE.PAGES]++; + if (_force_newpage) { _text_x = 0; @@ -1027,21 +1041,13 @@ if (!is_array(_draw_string)) _page_lines_array[array_length_1d(_page_lines_array)-1] = undefined; } - //Create a new page - 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) - - _page_array[@ __SCRIBBLE_PAGE.LINES ] = 1; - _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; - - _pages_array[@ array_length_1d(_pages_array)] = _page_array; - _scribble_array[@ __SCRIBBLE.PAGES]++; - //Add the line array to this page - _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; + _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 _meta_page_characters = 0; @@ -1050,7 +1056,6 @@ if (!is_array(_draw_string)) _previous_texture = -1; //Wipe the texture -> vertex buffer map - ds_list_clear(_line_break_list); ds_map_clear(_texture_to_buffer_map); _force_newpage = false; @@ -1089,33 +1094,36 @@ if (!is_array(_draw_string)) #region Move glyphs around on a line to finalise alignment + //Iterate over every page var _p = 0; - repeat(array_length_1d(_pages_array)) + repeat(array_length_1d(_element_pages_array)) { - var _page_array = _pages_array[_p]; + var _page_array = _element_pages_array[_p]; _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 _data = _page_vbuffs_array[_v]; - var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; - var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; + var _line_start_tell_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); + ds_list_add(_line_start_tell_list, _buffer_tell); + //Iterate over every line on the page var _l = 0; - repeat(ds_list_size(_line_break_list)-1) + repeat(ds_list_size(_line_start_tell_list)-1) { 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 = _line_break_list[| _l ]; - var _tell_b = _line_break_list[| _l+1]; + var _tell_a = _line_start_tell_list[| _l ]; + var _tell_b = _line_start_tell_list[| _l+1]; if (_line_halign != fa_left) { @@ -1133,6 +1141,8 @@ if (!is_array(_draw_string)) } } + show_debug_message("Adjusting line " + string(_l) + ", page " + string(_p) + " to " + string(_line_y)); + var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) { @@ -1145,7 +1155,7 @@ if (!is_array(_draw_string)) //Wipe buffer start positions _data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = undefined; - ds_list_destroy(_line_break_list); + ds_list_destroy(_line_start_tell_list); //Create vertex buffer var _vertex_buffer = vertex_create_buffer_from_buffer_ext(_buffer, global.__scribble_vertex_format, 0, _buffer_tell / __SCRIBBLE_VERTEX.__SIZE); @@ -1200,8 +1210,8 @@ if (global.scribble_state_allow_draw) { #region Draw this text element - var _pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; - var _page_array = _pages_array[_scribble_array[__SCRIBBLE.PAGE]]; + var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.PAGE]]; //Figure out the left/top offset switch(global.scribble_state_box_halign) @@ -1454,11 +1464,11 @@ if (SCRIBBLE_CACHE_TIMEOUT > 0) { if (__SCRIBBLE_DEBUG) show_debug_message("Scribble: Removing \"" + _cache_string + "\" from cache"); - var _pages_array = _cache_array[__SCRIBBLE.PAGES_ARRAY]; + var _element_pages_array = _cache_array[__SCRIBBLE.PAGES_ARRAY]; var _p = 0; - repeat(array_length_1d(_pages_array)) + repeat(array_length_1d(_element_pages_array)) { - var _page_array = _pages_array[_p]; + 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)) diff --git a/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy b/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy index 7e7f49f8e..698e37b01 100644 --- a/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy +++ b/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy @@ -4,10 +4,10 @@ "mvc": "1.1", "name": "84f15521-954c-4d2d-9709-5b2d9ca231f1", "children": [ - "9d531882-0dcf-4be8-8225-d8370e77e70b", + "94a2d6ab-abc6-4785-9bd3-09b66392e1e8", "dbcf1cbf-cbd0-40fa-9a88-c5c9e80976c1", - "fab0fef8-eab5-4e5b-bccd-f5ed6f43db50", - "94a2d6ab-abc6-4785-9bd3-09b66392e1e8" + "9d531882-0dcf-4be8-8225-d8370e77e70b", + "fab0fef8-eab5-4e5b-bccd-f5ed6f43db50" ], "filterType": "GMRoom", "folderName": "rooms", From 5b7d1629533eefbd10a01a76152ba0cda366b936 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 14:56:27 +0000 Subject: [PATCH 15/40] Implements vertex stealing for natural page breaks --- scripts/scribble_draw/scribble_draw.gml | 126 ++++++++++++++++++------ 1 file changed, 94 insertions(+), 32 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 82149b710..f0de99b2e 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -118,6 +118,7 @@ if (!is_array(_draw_string)) var _meta_element_characters = 0; var _meta_element_lines = 0; + var _meta_element_pages = 0; var _element_x_max = 0; var _element_y_max = 0; @@ -217,7 +218,7 @@ if (!is_array(_draw_string)) _page_array[@ __SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY] = _page_vbuffs_array; _element_pages_array[@ array_length_1d(_element_pages_array)] = _page_array; - _scribble_array[@ __SCRIBBLE.PAGES]++; + ++_meta_element_pages; #endregion @@ -570,7 +571,7 @@ if (!is_array(_draw_string)) var _vbuff_data = _texture_to_buffer_map[? _sprite_texture]; if (_vbuff_data == undefined) { - var _line_start_tell_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); @@ -579,7 +580,7 @@ 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_start_tell_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); _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; @@ -591,11 +592,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(array_length_1d(_page_lines_array) - ds_list_size(_line_start_tell_list)) ds_list_add(_line_start_tell_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; } @@ -800,30 +802,31 @@ if (!is_array(_draw_string)) var _vbuff_data = _texture_to_buffer_map[? _font_texture]; if (_vbuff_data == undefined) { - var _line_start_tell_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_start_tell_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); _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(array_length_1d(_page_lines_array) - ds_list_size(_line_start_tell_list)) ds_list_add(_line_start_tell_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 @@ -904,18 +907,18 @@ if (!is_array(_draw_string)) { var _data = _page_vbuffs_array[_v]; - var _line_start_tell_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; - var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; + 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_start_tell_list, buffer_tell(_buffer)); + ds_list_add(_vbuff_line_start_list, buffer_tell(_buffer)); } else { var _tell_a = _data[__SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL]; var _tell_b = buffer_tell(_buffer); - ds_list_add(_line_start_tell_list, _tell_a); + ds_list_add(_vbuff_line_start_list, _tell_a); //If we've added anything to this buffer if (_tell_a < _tell_b) @@ -1008,6 +1011,9 @@ if (!is_array(_draw_string)) _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) @@ -1019,14 +1025,16 @@ if (!is_array(_draw_string)) _new_page_array[@ __SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY] = _new_page_vbuffs_array; _element_pages_array[@ array_length_1d(_element_pages_array)] = _new_page_array; - _scribble_array[@ __SCRIBBLE.PAGES]++; + ++_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; @@ -1036,9 +1044,65 @@ if (!is_array(_draw_string)) else { //Steal the last line from the previous page - //TODO - Update characters and steal vertex buffer data _page_array[@ __SCRIBBLE_PAGE.LINES]--; - _page_lines_array[array_length_1d(_page_lines_array)-1] = undefined; + _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 @@ -1050,13 +1114,11 @@ if (!is_array(_draw_string)) _page_vbuffs_array = _new_page_vbuffs_array; //Reset some state variables - _meta_page_characters = 0; - _meta_page_lines = 1; - _line_y = 0; - _previous_texture = -1; - - //Wipe the texture -> vertex buffer map - ds_map_clear(_texture_to_buffer_map); + _meta_page_characters = 0; + _meta_page_lines = 0; + _line_y = 0; + _previous_texture = -1; + _vbuff_line_start_list = -1; _force_newpage = false; } @@ -1085,6 +1147,7 @@ if (!is_array(_draw_string)) _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_x_max; _scribble_array[@ __SCRIBBLE.HEIGHT ] = _element_y_max; @@ -1099,6 +1162,7 @@ if (!is_array(_draw_string)) repeat(array_length_1d(_element_pages_array)) { 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 @@ -1107,23 +1171,23 @@ if (!is_array(_draw_string)) { var _data = _page_vbuffs_array[_v]; - var _line_start_tell_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; - var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; + var _vbuff_line_start_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_start_tell_list, _buffer_tell); + ds_list_add(_vbuff_line_start_list, _buffer_tell); //Iterate over every line on the page var _l = 0; - repeat(ds_list_size(_line_start_tell_list)-1) + repeat(ds_list_size(_vbuff_line_start_list)-1) { 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 = _line_start_tell_list[| _l ]; - var _tell_b = _line_start_tell_list[| _l+1]; + var _tell_a = _vbuff_line_start_list[| _l ]; + var _tell_b = _vbuff_line_start_list[| _l+1]; if (_line_halign != fa_left) { @@ -1141,8 +1205,6 @@ if (!is_array(_draw_string)) } } - show_debug_message("Adjusting line " + string(_l) + ", page " + string(_p) + " to " + string(_line_y)); - var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) { @@ -1155,7 +1217,7 @@ if (!is_array(_draw_string)) //Wipe buffer start positions _data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = undefined; - ds_list_destroy(_line_start_tell_list); + 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); From 139b8fb325a97f006b8bfc92a9613f5fc0a6ee26 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 15:13:25 +0000 Subject: [PATCH 16/40] Fixes element width being inaccurate --- scripts/scribble_draw/scribble_draw.gml | 33 +++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index f0de99b2e..695a16738 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -119,8 +119,8 @@ if (!is_array(_draw_string)) var _meta_element_characters = 0; var _meta_element_lines = 0; var _meta_element_pages = 0; - var _element_x_max = 0; - var _element_y_max = 0; + var _element_width = 0; + var _element_height = 0; var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array var _element_pages_array = []; //Stores each page of text @@ -489,6 +489,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); @@ -753,8 +755,9 @@ if (!is_array(_draw_string)) { //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(array_length_1d(_page_vbuffs_array)) @@ -831,7 +834,11 @@ if (!is_array(_draw_string)) //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 @@ -940,6 +947,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 { @@ -970,7 +978,7 @@ if (!is_array(_draw_string)) ++_meta_element_lines; ++_meta_page_lines; - _element_x_max = max(_element_x_max, _line_width); + _element_width = max(_element_width, _line_width); //Update the last line _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters-1; @@ -1005,7 +1013,7 @@ if (!is_array(_draw_string)) if (_force_newpage || ((_line_height + _line_y > _max_height) && (_max_height >= 0))) { - _element_y_max = max(_element_y_max, _line_y + _line_height); + _element_height = max(_element_height, _line_y + _line_height); //Update the metadata of the previous page _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; @@ -1128,7 +1136,6 @@ if (!is_array(_draw_string)) _text_x += _char_width; - _line_width = max(_line_width, _text_x); } _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters; @@ -1138,8 +1145,8 @@ if (!is_array(_draw_string)) ++_meta_page_lines; ++_meta_element_lines; - _element_x_max = max(_element_x_max, _line_width); - _element_y_max = max(_element_y_max, _line_y + _line_height); + _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; @@ -1148,8 +1155,8 @@ if (!is_array(_draw_string)) _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_x_max; - _scribble_array[@ __SCRIBBLE.HEIGHT ] = _element_y_max; + _scribble_array[@ __SCRIBBLE.WIDTH ] = _element_width; + _scribble_array[@ __SCRIBBLE.HEIGHT ] = _element_height; #endregion @@ -1194,8 +1201,8 @@ if (!is_array(_draw_string)) var _line_width = _line_data[__SCRIBBLE_LINE.WIDTH]; var _offset = 0; - if (_line_halign == fa_right ) _offset = _element_x_max - _line_width; - if (_line_halign == fa_center) _offset = (_element_x_max - _line_width) div 2; + 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) From 0bfb05bca7bc01f4156bc125eea2fad400a8a86d Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 15:15:58 +0000 Subject: [PATCH 17/40] Fixes element height being inaccurate --- scripts/scribble_draw/scribble_draw.gml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 695a16738..5c94b5280 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -1013,8 +1013,6 @@ if (!is_array(_draw_string)) if (_force_newpage || ((_line_height + _line_y > _max_height) && (_max_height >= 0))) { - _element_height = max(_element_height, _line_y + _line_height); - //Update the metadata of the previous page _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; @@ -1122,6 +1120,7 @@ if (!is_array(_draw_string)) _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; From c7c15561553b9b9dda5fe7251b87fd6c326c2086 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 15:23:59 +0000 Subject: [PATCH 18/40] More element width fixes --- scripts/scribble_draw/scribble_draw.gml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 5c94b5280..27929d923 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -155,7 +155,7 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Pages --"; _scribble_array[@ __SCRIBBLE.PAGE ] = 0; _scribble_array[@ __SCRIBBLE.PAGES_ARRAY ] = _element_pages_array; - + _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; _scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = -1; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = 0; @@ -748,8 +748,9 @@ 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); } else if (_character_code == 32) //If we've hit a space { @@ -1136,6 +1137,8 @@ if (!is_array(_draw_string)) _text_x += _char_width; } + + _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); From 20147a4b4cd7fc7bcc7bec4e5915fc467d60e945 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 15:38:47 +0000 Subject: [PATCH 19/40] Removes forced newpages from test --- objects/obj_test/Create_0.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 8e11d7092..9f7eb1375 100644 --- a/objects/obj_test/Create_0.gml +++ b/objects/obj_test/Create_0.gml @@ -26,7 +26,7 @@ spritefont = font_add_sprite_ext(spr_sprite_font, _mapstring, true, 0); //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.[/page]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.[/page]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."; +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 From ff7b4530df498c5846a8afe8a55ec15b98291665 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 16:56:31 +0000 Subject: [PATCH 20/40] Fixes halign not working if it's the first tag on the line --- scripts/scribble_draw/scribble_draw.gml | 30 ++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 27929d923..fb545d22c 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -398,18 +398,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 From e3fdf08e1cc5e83e07f598d3581679687f445aea Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 17:37:14 +0000 Subject: [PATCH 21/40] Adds formatting tag escaping --- scripts/scribble_draw/scribble_draw.gml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index fb545d22c..823fb16a6 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -264,6 +264,7 @@ if (!is_array(_draw_string)) 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; @@ -277,6 +278,7 @@ if (!is_array(_draw_string)) { var _character_code = buffer_read(_string_buffer, buffer_u8); if (_character_code == 0) break; + _add_character = true; _read_string += chr(_character_code); @@ -284,6 +286,8 @@ if (!is_array(_draw_string)) { 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); @@ -753,6 +757,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 @@ -775,6 +783,8 @@ if (!is_array(_draw_string)) _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 { @@ -791,12 +801,15 @@ if (!is_array(_draw_string)) _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 From c4bf2aa9e9cf0152ffb3e01ca4f7940d80dfe822 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 18:35:13 +0000 Subject: [PATCH 22/40] Expands autotype functions to include pages --- Scribble.yyp | 13 +++++++-- .../scribble_autotype_fade_in.gml | 7 ++--- .../scribble_autotype_fade_out.gml | 2 +- .../scribble_autotype_skip.gml | 27 +++++++++++++++++++ .../scribble_autotype_skip.yy | 8 ++++++ .../scribble_page_on_last.gml} | 0 .../scribble_page_on_last.yy} | 2 +- .../scribble_page_set/scribble_page_set.gml | 8 ++---- views/95e57154-061e-41b9-87cb-88e21f8fa68c.yy | 5 ++-- 9 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 scripts/scribble_autotype_skip/scribble_autotype_skip.gml create mode 100644 scripts/scribble_autotype_skip/scribble_autotype_skip.yy rename scripts/{scribble_page_is_last/scribble_page_is_last.gml => scribble_page_on_last/scribble_page_on_last.gml} (100%) rename scripts/{scribble_page_is_last/scribble_page_is_last.yy => scribble_page_on_last/scribble_page_on_last.yy} (80%) diff --git a/Scribble.yyp b/Scribble.yyp index c339e1beb..ebb648f9b 100644 --- a/Scribble.yyp +++ b/Scribble.yyp @@ -322,7 +322,7 @@ "Key": "74d4828d-df60-4163-9a0f-713e1e653208", "Value": { "id": "4c990981-3742-44f0-9749-f5a58ddb3ae2", - "resourcePath": "scripts\\scribble_page_is_last\\scribble_page_is_last.yy", + "resourcePath": "scripts\\scribble_page_on_last\\scribble_page_on_last.yy", "resourceType": "GMScript" } }, @@ -382,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": { @@ -865,9 +873,10 @@ "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", 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..d69b84e28 100644 --- a/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml +++ b/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml @@ -14,13 +14,14 @@ if (!is_array(_scribble_array) || (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) || _scribble_array[__SCRIBBLE.FREED]) { - 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 ((_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 +29,7 @@ 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 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..8ae5a1af0 100644 --- a/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml +++ b/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml @@ -14,7 +14,7 @@ if (!is_array(_scribble_array) || (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) || _scribble_array[__SCRIBBLE.FREED]) { - 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; } 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..b4cb4081e --- /dev/null +++ b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml @@ -0,0 +1,27 @@ +/// @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) +|| _scribble_array[__SCRIBBLE.FREED]) +{ + if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_skip() is not a valid Scribble text element."); + exit; +} + +var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.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_page_is_last/scribble_page_is_last.gml b/scripts/scribble_page_on_last/scribble_page_on_last.gml similarity index 100% rename from scripts/scribble_page_is_last/scribble_page_is_last.gml rename to scripts/scribble_page_on_last/scribble_page_on_last.gml diff --git a/scripts/scribble_page_is_last/scribble_page_is_last.yy b/scripts/scribble_page_on_last/scribble_page_on_last.yy similarity index 80% rename from scripts/scribble_page_is_last/scribble_page_is_last.yy rename to scripts/scribble_page_on_last/scribble_page_on_last.yy index e505a4f2d..5e1483b95 100644 --- a/scripts/scribble_page_is_last/scribble_page_is_last.yy +++ b/scripts/scribble_page_on_last/scribble_page_on_last.yy @@ -2,7 +2,7 @@ "id": "74d4828d-df60-4163-9a0f-713e1e653208", "modelName": "GMScript", "mvc": "1.0", - "name": "scribble_page_is_last", + "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 index eca953008..abae7958c 100644 --- a/scripts/scribble_page_set/scribble_page_set.gml +++ b/scripts/scribble_page_set/scribble_page_set.gml @@ -1,12 +1,8 @@ /// @param element /// @param page -/// @param [relative] -var _scribble_array = argument[0]; -var _page = argument[1]; -var _relative = ((argument_count > 2) && (argument[2] != undefined))? argument[2] : false; - -if (_relative) _page += _scribble_array[__SCRIBBLE.PAGE]; +var _scribble_array = argument0; +var _page = argument1; _page = clamp(_page, 0, _scribble_array[__SCRIBBLE.PAGES]-1); _scribble_array[@ __SCRIBBLE.PAGE] = _page; 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", From eb9958e6dca5295b141d85d5b1da937b016f8ae1 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 18:37:34 +0000 Subject: [PATCH 23/40] Adds dialogue box example --- objects/obj_test/Create_0.gml | 4 ++-- objects/obj_test/Step_0.gml | 17 +++++++++++++++++ objects/obj_test/obj_test.yy | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 objects/obj_test/Step_0.gml diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 9f7eb1375..4a99d4b69 100644 --- a/objects/obj_test/Create_0.gml +++ b/objects/obj_test/Create_0.gml @@ -34,8 +34,8 @@ scribble_draw_set_cache_group("example cache group", false, true); scribble_draw_set_wrap(-1, 450, 100, false); element = scribble_draw(0, 0, demo_string); scribble_page_set(element, 5); -scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 2, 10); -//scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_LINE, 0.05, 10); +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/Step_0.gml b/objects/obj_test/Step_0.gml new file mode 100644 index 000000000..b51cdbed8 --- /dev/null +++ b/objects/obj_test/Step_0.gml @@ -0,0 +1,17 @@ +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 + { + 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", From 5d74751a87c89541c969883dc1c75e0e09f57a78 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 18:37:56 +0000 Subject: [PATCH 24/40] Update Create_0.gml --- objects/obj_test/Create_0.gml | 1 - 1 file changed, 1 deletion(-) diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 4a99d4b69..89eec71bb 100644 --- a/objects/obj_test/Create_0.gml +++ b/objects/obj_test/Create_0.gml @@ -33,7 +33,6 @@ demo_string = "Contrary to popular belief, Lorem Ipsum is not simply random text scribble_draw_set_cache_group("example cache group", false, true); scribble_draw_set_wrap(-1, 450, 100, false); element = scribble_draw(0, 0, demo_string); -scribble_page_set(element, 5); scribble_page_set(element, 0); scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 1, 10); From e3bacf205c6a332ac98074e80fc4444f2360d618 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 18:41:29 +0000 Subject: [PATCH 25/40] Renames "colour" functions to "color" --- objects/obj_example_autotype/Create_0.gml | 8 ++++---- objects/obj_example_autotype__/Create_0.gml | 8 ++++---- objects/obj_example_precache/Create_0.gml | 8 ++++---- objects/obj_example_precache__/Create_0.gml | 8 ++++---- objects/obj_test/Create_0.gml | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/objects/obj_example_autotype/Create_0.gml b/objects/obj_example_autotype/Create_0.gml index 0f124372b..0992b02e0 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); diff --git a/objects/obj_example_autotype__/Create_0.gml b/objects/obj_example_autotype__/Create_0.gml index 256ac5b53..a74044867 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); diff --git a/objects/obj_example_precache/Create_0.gml b/objects/obj_example_precache/Create_0.gml index 1b1a26a8c..b112fa8cb 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); diff --git a/objects/obj_example_precache__/Create_0.gml b/objects/obj_example_precache__/Create_0.gml index 802642f2f..cab9eac09 100644 --- a/objects/obj_example_precache__/Create_0.gml +++ b/objects/obj_example_precache__/Create_0.gml @@ -4,10 +4,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_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); diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 89eec71bb..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); From 36a5fb3d62e0366f682231a5637b55dbecd0819b Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 19:19:20 +0000 Subject: [PATCH 26/40] Moves event into page structure --- .../scribble_autotype_get.gml | 2 +- .../scribble_autotype_skip.gml | 2 +- scripts/scribble_draw/scribble_draw.gml | 55 +++++++++++-------- scripts/scribble_init/scribble_init.gml | 27 +++++---- .../scribble_page_get/scribble_page_get.gml | 4 +- .../scribble_page_on_last.gml | 2 +- .../scribble_page_set/scribble_page_set.gml | 2 +- 7 files changed, 49 insertions(+), 45 deletions(-) diff --git a/scripts/scribble_autotype_get/scribble_autotype_get.gml b/scripts/scribble_autotype_get/scribble_autotype_get.gml index 469b8af71..c1efc0bd9 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -31,7 +31,7 @@ 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.PAGE]]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; switch(_typewriter_method) { diff --git a/scripts/scribble_autotype_skip/scribble_autotype_skip.gml b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml index b4cb4081e..fe62aabe5 100644 --- a/scripts/scribble_autotype_skip/scribble_autotype_skip.gml +++ b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml @@ -13,7 +13,7 @@ if (!is_array(_scribble_array) } var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; -var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.PAGE]]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; var _max = 1; switch(_scribble_array[__SCRIBBLE.AUTOTYPE_METHOD]) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 823fb16a6..9621cb2eb 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -122,11 +122,8 @@ if (!is_array(_draw_string)) var _element_width = 0; var _element_height = 0; - var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array + var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array var _element_pages_array = []; //Stores each page of text - 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 _scribble_array[@ __SCRIBBLE.__SECTION0 ] = "-- Parameters --"; _scribble_array[@ __SCRIBBLE.VERSION ] = __SCRIBBLE_VERSION; @@ -153,10 +150,10 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.SOUND_FINISH_TIME ] = current_time; _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Pages --"; - _scribble_array[@ __SCRIBBLE.PAGE ] = 0; _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; @@ -165,14 +162,6 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_ARRAY ] = -1; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_OVERLAP] = 0; - //TODO - Move events into pages - _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 character - _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 - #endregion @@ -208,15 +197,24 @@ if (!is_array(_draw_string)) var _meta_page_characters = 0; var _meta_page_lines = 0; - var _page_array = array_create(__SCRIBBLE_PAGE.__SIZE); + 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; @@ -1059,15 +1057,24 @@ if (!is_array(_draw_string)) ds_map_clear(_texture_to_buffer_map); //Create a new page - var _new_page_array = array_create(__SCRIBBLE_PAGE.__SIZE); + 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; @@ -1319,7 +1326,7 @@ 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.PAGE]]; + var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; //Figure out the left/top offset switch(global.scribble_state_box_halign) @@ -1405,7 +1412,7 @@ if (global.scribble_state_allow_draw) 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 @@ -1421,10 +1428,10 @@ if (global.scribble_state_allow_draw) } //TODO - Move events into pages - 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 @@ -1443,7 +1450,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); } @@ -1465,11 +1472,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; } } } diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 5c383a7f5..b3ac012fb 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -73,10 +73,17 @@ enum __SCRIBBLE_FONT_TYPE enum __SCRIBBLE_PAGE { - LINES, - CHARACTERS, - LINES_ARRAY, - VERTEX_BUFFERS_ARRAY, + 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 } @@ -171,10 +178,10 @@ enum __SCRIBBLE SOUND_FINISH_TIME, //20 __SECTION3, //21 - PAGE, //24 PAGES_ARRAY, //22 __SECTION4, //23 + AUTOTYPE_PAGE, //24 AUTOTYPE_FADE_IN, //25 AUTOTYPE_SPEED, //26 AUTOTYPE_POSITION, //27 @@ -183,15 +190,7 @@ enum __SCRIBBLE AUTOTYPE_SOUND_ARRAY, //30 AUTOTYPE_SOUND_OVERLAP, //31 - //TODO - Move events into pages - __SECTION5, //32 - EVENT_PREVIOUS, //33 - EVENT_CHAR_PREVIOUS, //34 - EVENT_CHAR_ARRAY, //35 - EVENT_NAME_ARRAY, //36 - EVENT_DATA_ARRAY, //37 - - __SIZE //38 + __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_get/scribble_page_get.gml b/scripts/scribble_page_get/scribble_page_get.gml index 694fda530..68dc9c7be 100644 --- a/scripts/scribble_page_get/scribble_page_get.gml +++ b/scripts/scribble_page_get/scribble_page_get.gml @@ -2,6 +2,4 @@ /// @param page /// @param [relative] -var _scribble_array = argument0; - -return _scribble_array[__SCRIBBLE.PAGE] \ No newline at end of file +return argument0[__SCRIBBLE.AUTOTYPE_PAGE]; \ 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 index d6e3989e1..1dce6db14 100644 --- a/scripts/scribble_page_on_last/scribble_page_on_last.gml +++ b/scripts/scribble_page_on_last/scribble_page_on_last.gml @@ -1,4 +1,4 @@ /// @param element -return (argument0[__SCRIBBLE.PAGE] >= (argument0[__SCRIBBLE.PAGES]-1)); \ No newline at end of file +return (argument0[__SCRIBBLE.AUTOTYPE_PAGE] >= (argument0[__SCRIBBLE.PAGES]-1)); \ 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 index abae7958c..6ab4879d5 100644 --- a/scripts/scribble_page_set/scribble_page_set.gml +++ b/scripts/scribble_page_set/scribble_page_set.gml @@ -5,6 +5,6 @@ var _scribble_array = argument0; var _page = argument1; _page = clamp(_page, 0, _scribble_array[__SCRIBBLE.PAGES]-1); -_scribble_array[@ __SCRIBBLE.PAGE] = _page; +_scribble_array[@ __SCRIBBLE.AUTOTYPE_PAGE] = _page; return _page; \ No newline at end of file From fba393aa5c2e114db94b52bc86d04db415c60e96 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 19:19:28 +0000 Subject: [PATCH 27/40] Update Step_0.gml --- objects/obj_test/Step_0.gml | 1 + 1 file changed, 1 insertion(+) diff --git a/objects/obj_test/Step_0.gml b/objects/obj_test/Step_0.gml index b51cdbed8..0c9b70d35 100644 --- a/objects/obj_test/Step_0.gml +++ b/objects/obj_test/Step_0.gml @@ -11,6 +11,7 @@ if (keyboard_check_pressed(vk_space)) } else { + //Loop back round to the first page scribble_page_set(element, 0); scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 1, 10); } From 22885e1c4ea05138b871223376af60e13be5e39c Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 19:25:25 +0000 Subject: [PATCH 28/40] 5.4.0 --- README.md | 4 ++-- options/windows/options_windows.yy | 4 ++-- scripts/scribble_init/scribble_init.gml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2958426bd..449a60d7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -

Scribble 5.3.3

+

Scribble 5.4.0

-

Download .yymp here

+

Download .yymp here

### @jujuadams diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index d508f80b2..4820a60d0 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -31,9 +31,9 @@ "option_windows_texture_page": "2048x2048", "option_windows_use_splash": false, "option_windows_version": { - "build": 3, + "build": 0, "major": 5, - "minor": 3, + "minor": 4, "revision": 0 }, "option_windows_vsync": false diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index b3ac012fb..f6c0609ef 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -19,8 +19,8 @@ /// 8) Automatically scans Included Files for fonts (if enabled) /// /// -/// Scribble v5.3.3 -/// 2020/02/11 +/// Scribble v5.4.0 +/// 2020-02-23 /// @jujuadams /// With thanks to glitchroy, Mark Turner, Rob van Saaze, DragoniteSpam, and sp202 /// @@ -28,8 +28,8 @@ #region Internal Macro Definitions -#macro __SCRIBBLE_VERSION "5.3.3" -#macro __SCRIBBLE_DATE "2020/02/11" +#macro __SCRIBBLE_VERSION "5.4.0" +#macro __SCRIBBLE_DATE "2020-02-23" #macro __SCRIBBLE_DEBUG false //You'll usually only want to modify SCRIBBLE_GLYPH.X_OFFSET, SCRIBBLE_GLYPH.Y_OFFSET, and SCRIBBLE_GLYPH.SEPARATION From 81b0f73143b6eb5502712f48b01cafc92ed97afa Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 19:40:22 +0000 Subject: [PATCH 29/40] Update scribble_draw_set_wrap.gml --- scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 459414f00..e89a715f8 100644 --- a/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml +++ b/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml @@ -14,5 +14,5 @@ global.scribble_state_line_min_height = argument[0]; global.scribble_state_max_width = argument[1]; -global.scribble_state_max_height = argument[2]; +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 From c14d456a09cd43e771f7d582834ff4481446f95d Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 20:00:27 +0000 Subject: [PATCH 30/40] Update scribble_draw_set_wrap.gml --- scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e89a715f8..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,7 +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 line height for the whole textbox. 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 /// /// From bcfc754359f5ba16e77adfc0bf2e68d547980c48 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 23 Feb 2020 23:10:08 +0000 Subject: [PATCH 31/40] scribble_autotype_get() now returns 1 if no fade type is set --- scripts/scribble_autotype_get/scribble_autotype_get.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scribble_autotype_get/scribble_autotype_get.gml b/scripts/scribble_autotype_get/scribble_autotype_get.gml index c1efc0bd9..450efe490 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -21,9 +21,9 @@ if (!is_array(_scribble_array) exit; } -//Return an error code if the method is NONE +//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) From 6191c5b4cbe520be499f176001c27d6d2d18ce8e Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Mon, 24 Feb 2020 18:05:39 +0000 Subject: [PATCH 32/40] Removes unnecessary string handling from scribble_draw() --- objects/obj_example_precache/Create_0.gml | 2 +- scripts/scribble_draw/scribble_draw.gml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/objects/obj_example_precache/Create_0.gml b/objects/obj_example_precache/Create_0.gml index b112fa8cb..79e09349e 100644 --- a/objects/obj_example_precache/Create_0.gml +++ b/objects/obj_example_precache/Create_0.gml @@ -21,7 +21,7 @@ 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 += "[fa_center][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] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 9621cb2eb..81b5cc332 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -271,15 +271,12 @@ if (!is_array(_draw_string)) buffer_seek(_string_buffer, buffer_seek_start, 0); //Iterate over the entire string... - var _read_string = ""; repeat(_buffer_size) { var _character_code = buffer_read(_string_buffer, buffer_u8); if (_character_code == 0) break; _add_character = true; - _read_string += chr(_character_code); - 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 ]) From 055e0b3f7b83c7bc5ca90755b78e6497c06da092 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Mon, 24 Feb 2020 18:09:50 +0000 Subject: [PATCH 33/40] Updates examples --- objects/obj_example_autotype/Create_0.gml | 2 +- objects/obj_example_autotype__/Create_0.gml | 9 +++++---- objects/obj_example_basic/Draw_0.gml | 2 +- objects/obj_example_basic__/Draw_0.gml | 4 ++-- objects/obj_example_precache/Create_0.gml | 2 +- objects/obj_example_precache__/Create_0.gml | 15 ++++++++------- objects/obj_example_precache__/Draw_0.gml | 9 +++++---- objects/obj_test/Draw_0.gml | 13 +++---------- views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy | 6 +++--- 9 files changed, 29 insertions(+), 33 deletions(-) diff --git a/objects/obj_example_autotype/Create_0.gml b/objects/obj_example_autotype/Create_0.gml index 0992b02e0..2110baa36 100644 --- a/objects/obj_example_autotype/Create_0.gml +++ b/objects/obj_example_autotype/Create_0.gml @@ -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 a74044867..5ddf3c828 100644 --- a/objects/obj_example_autotype__/Create_0.gml +++ b/objects/obj_example_autotype__/Create_0.gml @@ -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 79e09349e..36bcdf283 100644 --- a/objects/obj_example_precache/Create_0.gml +++ b/objects/obj_example_precache/Create_0.gml @@ -22,7 +22,7 @@ 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 += "[fa_center][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_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 cab9eac09..b2c001641 100644 --- a/objects/obj_example_precache__/Create_0.gml +++ b/objects/obj_example_precache__/Create_0.gml @@ -1,4 +1,3 @@ -//Setup scribble_init("Fonts", "fnt_test_0", true); var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.-;:_+-*/\\'\"!?~^°<>|(){[]}%&=#@$ÄÖÜäöüß"; @@ -12,15 +11,17 @@ 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/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/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy b/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy index 698e37b01..7e7f49f8e 100644 --- a/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy +++ b/views/84f15521-954c-4d2d-9709-5b2d9ca231f1.yy @@ -4,10 +4,10 @@ "mvc": "1.1", "name": "84f15521-954c-4d2d-9709-5b2d9ca231f1", "children": [ - "94a2d6ab-abc6-4785-9bd3-09b66392e1e8", - "dbcf1cbf-cbd0-40fa-9a88-c5c9e80976c1", "9d531882-0dcf-4be8-8225-d8370e77e70b", - "fab0fef8-eab5-4e5b-bccd-f5ed6f43db50" + "dbcf1cbf-cbd0-40fa-9a88-c5c9e80976c1", + "fab0fef8-eab5-4e5b-bccd-f5ed6f43db50", + "94a2d6ab-abc6-4785-9bd3-09b66392e1e8" ], "filterType": "GMRoom", "folderName": "rooms", From ed03cb9fe5ef9c21f43c85fb5374b0eb28beef77 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Mon, 24 Feb 2020 18:51:25 +0000 Subject: [PATCH 34/40] 5.4.1.pre --- scripts/scribble_init/scribble_init.gml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index f6c0609ef..9e0e82acc 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -19,7 +19,7 @@ /// 8) Automatically scans Included Files for fonts (if enabled) /// /// -/// Scribble v5.4.0 +/// Scribble v5.4.1.pre /// 2020-02-23 /// @jujuadams /// With thanks to glitchroy, Mark Turner, Rob van Saaze, DragoniteSpam, and sp202 @@ -28,8 +28,8 @@ #region Internal Macro Definitions -#macro __SCRIBBLE_VERSION "5.4.0" -#macro __SCRIBBLE_DATE "2020-02-23" +#macro __SCRIBBLE_VERSION "5.4.1.pre" +#macro __SCRIBBLE_DATE "2020-02-24" #macro __SCRIBBLE_DEBUG false //You'll usually only want to modify SCRIBBLE_GLYPH.X_OFFSET, SCRIBBLE_GLYPH.Y_OFFSET, and SCRIBBLE_GLYPH.SEPARATION From 5c8503cf2abd5683ffd6d6074156a35cfd05c97b Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 10:35:26 +0000 Subject: [PATCH 35/40] Manually flushing now works properly; improves the behaviour of the FREED property --- .../scribble_autotype_fade_in/scribble_autotype_fade_in.gml | 5 +++-- .../scribble_autotype_fade_out.gml | 5 +++-- scripts/scribble_autotype_get/scribble_autotype_get.gml | 5 +++-- scripts/scribble_autotype_skip/scribble_autotype_skip.gml | 5 +++-- .../scribble_cache_group_flush.gml | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) 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 d69b84e28..a6cbb28ae 100644 --- a/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml +++ b/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.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_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) 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 8ae5a1af0..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_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 450efe490..0e8c74498 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -14,13 +14,14 @@ 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; } +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; diff --git a/scripts/scribble_autotype_skip/scribble_autotype_skip.gml b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml index fe62aabe5..0ccd25cc0 100644 --- a/scripts/scribble_autotype_skip/scribble_autotype_skip.gml +++ b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml @@ -5,13 +5,14 @@ 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_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]]; 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 022e86142..2feb8ca49 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -36,7 +36,7 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) 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]) { ds_map_delete(global.scribble_alive, _scribble_array[__SCRIBBLE.GLOBAL_INDEX]); From 43f1e76ea3ea544ad0d14aa355c9a59d8c3f1974 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 10:36:13 +0000 Subject: [PATCH 36/40] Fixes weird unintended cache behaviour --- .../scribble_cache_group_flush.gml | 4 ++++ scripts/scribble_draw/scribble_draw.gml | 6 ++++-- scripts/scribble_init/scribble_init.gml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) 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 2feb8ca49..da72d9ab8 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -38,6 +38,10 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) && (_scribble_array[__SCRIBBLE.VERSION] == __SCRIBBLE_VERSION) && !_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 _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 81b5cc332..3bf09c38a 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -128,6 +128,7 @@ if (!is_array(_draw_string)) _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; @@ -174,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) { @@ -1596,7 +1598,7 @@ if (SCRIBBLE_CACHE_TIMEOUT > 0) _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_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 9e0e82acc..c61da618d 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -156,6 +156,7 @@ enum __SCRIBBLE __SECTION0, // 0 VERSION, // 1 STRING, // 2 + CACHE_STRING, // 3 DEFAULT_FONT, // 3 DEFAULT_COLOUR, // 4 DEFAULT_HALIGN, // 5 From 33a0e9b3ad5980743013a0fab99f35dc323dd0f4 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 10:39:07 +0000 Subject: [PATCH 37/40] Fixes cache flushing using the wrong data type --- .../scribble_cache_group_flush/scribble_cache_group_flush.gml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 da72d9ab8..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,7 +31,7 @@ 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) @@ -44,6 +44,7 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) //Remove global reference ds_map_delete(global.scribble_alive, _scribble_array[__SCRIBBLE.GLOBAL_INDEX]); + //Destroy vertex buffers var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; var _p = 0; repeat(array_length_1d(_element_pages_array)) From bd9aba6b65f6f154ac2d74ae96676b4fab59892a Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 10:42:10 +0000 Subject: [PATCH 38/40] 5.4.2.pre --- README.md | 4 ++-- options/windows/options_windows.yy | 2 +- scripts/scribble_init/scribble_init.gml | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 449a60d7d..7e540d6da 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -

Scribble 5.4.0

+

Scribble 5.4.2.pre

-

Download .yymp here

+

Download .yymp here

### @jujuadams diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index 4820a60d0..07c0bafad 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -31,7 +31,7 @@ "option_windows_texture_page": "2048x2048", "option_windows_use_splash": false, "option_windows_version": { - "build": 0, + "build": 2, "major": 5, "minor": 4, "revision": 0 diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index c61da618d..8b6d959ec 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -19,8 +19,8 @@ /// 8) Automatically scans Included Files for fonts (if enabled) /// /// -/// Scribble v5.4.1.pre -/// 2020-02-23 +/// Scribble v5.4.2.pre +/// 2020-03-08 /// @jujuadams /// With thanks to glitchroy, Mark Turner, Rob van Saaze, DragoniteSpam, and sp202 /// @@ -28,8 +28,8 @@ #region Internal Macro Definitions -#macro __SCRIBBLE_VERSION "5.4.1.pre" -#macro __SCRIBBLE_DATE "2020-02-24" +#macro __SCRIBBLE_VERSION "5.4.2.pre" +#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 From 9c925eab003bc6b0c0567666dd66c6a884578ebb Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 10:58:33 +0000 Subject: [PATCH 39/40] Fixes autotype events not triggering on a second play --- .../scribble_autotype_fade_in.gml | 9 ++++++++- scripts/scribble_draw/scribble_draw.gml | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) 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 a6cbb28ae..b18de6aef 100644 --- a/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml +++ b/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml @@ -33,4 +33,11 @@ _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; 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_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 3bf09c38a..eb210595b 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -1426,7 +1426,6 @@ if (global.scribble_state_allow_draw) } } - //TODO - Move events into pages 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]; From 267697d748e5be0bb2c8a4d804ec1e52006e466e Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 8 Mar 2020 11:02:01 +0000 Subject: [PATCH 40/40] 5.4.3 --- README.md | 8 ++++---- Scribble.yyp | 8 ++++++++ options/windows/options_windows.yy | 2 +- scripts/scribble_init/scribble_init.gml | 6 +++--- views/a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy | 15 +++++++++++++++ views/dab40804-067d-4898-b5fd-736906e548cf.yy | 4 +--- 6 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 views/a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy diff --git a/README.md b/README.md index 7e540d6da..4f6cb8c41 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -

Scribble 5.4.2.pre

+

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 ebb648f9b..4f66513f3 100644 --- a/Scribble.yyp +++ b/Scribble.yyp @@ -542,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": { diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index 07c0bafad..8b5935853 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -31,7 +31,7 @@ "option_windows_texture_page": "2048x2048", "option_windows_use_splash": false, "option_windows_version": { - "build": 2, + "build": 3, "major": 5, "minor": 4, "revision": 0 diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 8b6d959ec..600813e34 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -19,16 +19,16 @@ /// 8) Automatically scans Included Files for fonts (if enabled) /// /// -/// Scribble v5.4.2.pre +/// 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.4.2.pre" +#macro __SCRIBBLE_VERSION "5.4.3" #macro __SCRIBBLE_DATE "2020-03-08" #macro __SCRIBBLE_DEBUG false 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 e6f3c7f28..0f09adba3 100644 --- a/views/dab40804-067d-4898-b5fd-736906e548cf.yy +++ b/views/dab40804-067d-4898-b5fd-736906e548cf.yy @@ -10,9 +10,7 @@ "5044992f-3fea-47aa-a11b-2b6d850ac7ee", "bf269b8e-eb65-4528-b05e-d89efb7d6c87", "bcd14081-de72-4eef-8094-64efd4aac382", - "95e57154-061e-41b9-87cb-88e21f8fa68c", - "85d381bf-3af3-491c-b197-63da24f6696b", - "d0797c70-f098-4e2c-912e-f1225887182b" + "a39a04ab-7eab-45b9-a5ac-dd51dc752f37" ], "filterType": "GMScript", "folderName": "Scribble",