diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index 52108f10d..dbb898455 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -1,7 +1,7 @@ { "option_windows_display_name": "Scribble", "option_windows_executable_name": "${project_name}", - "option_windows_version": "6.0.10.0", + "option_windows_version": "6.0.12.0", "option_windows_company_info": "@jujuadams", "option_windows_product_info": "Scribble", "option_windows_copyright_info": "@jujuadams (c) 2020", diff --git a/scripts/scribble_add_autotype_event/scribble_add_autotype_event.gml b/scripts/scribble_add_autotype_event/scribble_add_autotype_event.gml index 5dbc5aa40..f5cdafb9c 100644 --- a/scripts/scribble_add_autotype_event/scribble_add_autotype_event.gml +++ b/scripts/scribble_add_autotype_event/scribble_add_autotype_event.gml @@ -1,7 +1,7 @@ /// Defines an event - a script that can be executed (with parameters) by an in-line command tag /// -/// @param name Name of the new formatting tag to add e.g. portrait adds the tag [portrait] for use -/// @param script Script asset to execute N.B. This is the asset index, not a string +/// @param name Name of the new formatting tag to add e.g. portrait adds the tag [portrait] for use +/// @param function/method Function or method to execute /// /// Events are scripts that are executed during an autotype fade in animation. As each character is revealed, /// Scribble will check if any events are present at that position in the text and, if so, Scribble will @@ -48,55 +48,55 @@ /// gamepad. Given that the formatting tag was [rumble,0.2], the function gamepad_set_vibration() will be /// given 0.2 as its input value. -function scribble_add_autotype_event(_name, _script) +function scribble_add_autotype_event(_name, _function) { if (!variable_global_exists("__scribble_lcg")) { show_error("Scribble:\nscribble_add_event() should be called after initialising Scribble.\n ", false); exit; } - - if (!is_string(_name) && !is_undefined(_name)) + + if (!is_string(_name)) { show_error("Scribble:\nEvent names should be strings.\n(Input to script was \"" + string(_name) + "\")\n ", false); exit; } - - if (!is_real(_script)) + + if (!is_method(_function)) { - show_error("Scribble:\nScripts should be numerical script indices e.g. scribble_add_event(\"example\", your_script);\n(Input to script was \"" + string(_name) + "\")\n ", false); - exit; - } - - if (!script_exists(_script)) - { - show_error("Scribble:\nScript (" + string(_script) + ") doesn't exist!\n ", false); - exit; + if (is_real(_function)) + { + if (!script_exists(_function)) + { + show_error("Scribble:\nScript with asset index " + string(_function) + " doesn't exist\n ", false); + exit; + } + } + else + { + show_error("Scribble:\nInvalid function provided\n(Input datatype was \"" + typeof(_function) + "\")\n ", false); + exit; + } } - + if (ds_map_exists(global.__scribble_colours, _name)) { show_debug_message("Scribble: WARNING! Event name \"" + _name + "\" has already been defined as a colour"); exit; } - + if (ds_map_exists(global.__scribble_effects, _name)) { show_debug_message("Scribble: WARNING! Event name \"" + _name + "\" has already been defined as an effect"); exit; } - - if (is_undefined(_name) || (_name == "")) + + var _old_function = global.__scribble_autotype_events[? _name]; + if (!is_undefined(_old_function)) { - _name = script_get_name(_script); + show_debug_message("Scribble: WARNING! Overwriting event [" + _name + "] tied to \"" + (is_method(_old_function)? string(_old_function) : script_get_name(_old_function)) + "\""); } - - var _old_script = global.__scribble_autotype_events[? _name]; - if (is_real(_old_script)) - { - show_debug_message("Scribble: WARNING! Overwriting event [" + _name + "] tied to script " + script_get_name(_old_script) + "()"); - } - - global.__scribble_autotype_events[? _name] = _script; - if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Tying event [" + _name + "] to script " + script_get_name(_script) + "()"); + + global.__scribble_autotype_events[? _name] = _function; + if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Tying event [" + _name + "] to \"" + (is_method(_function)? string(_function) : script_get_name(_function)) + "\""); } \ No newline at end of file diff --git a/scripts/scribble_add_font/scribble_add_font.gml b/scripts/scribble_add_font/scribble_add_font.gml index 81581095a..a87a949d5 100644 --- a/scripts/scribble_add_font/scribble_add_font.gml +++ b/scripts/scribble_add_font/scribble_add_font.gml @@ -27,16 +27,15 @@ function scribble_add_font() } var _font = argument[0]; - var _path = (argument_count > 1)? argument[1] : (_font + ".yy"); + var _path = (argument_count > 1)? argument[1] : undefined; var _texture = (argument_count > 2)? argument[2] : undefined; - _path = global.__scribble_font_directory + _path; - + if (ds_map_exists(global.__scribble_font_data, _font)) { show_error("Scribble:\nFont \"" + _font + "\" has already been defined\n ", false); return undefined; } - + if (!is_string(_font)) { if (is_real(_font) && (asset_get_type(font_get_name(_font)) == asset_font)) @@ -49,19 +48,22 @@ function scribble_add_font() } exit; } - + if (asset_get_type(_font) == asset_sprite) { show_error("Scribble:\nTo add a spritefont, please use scribble_add_spritefont()\n ", false); return scribble_add_spritefont(_font); } - + if (asset_get_type(_font) != asset_font) { show_error("Scribble:\nFont \"" + _font + "\" not found in the project.\nScribble font \"" + string(_font) + "\" will not be available.\n ", false); return undefined; } - + + if (_path == undefined) _path = _font + ".yy"; + _path = global.__scribble_font_directory + _path; + if (!file_exists(_path)) { show_error("Scribble:\nCould not find \"" + _path + "\" in Included Files. Please add this file to your project.\nScribble font \"" + string(_font) + "\" will not be available.\n ", false); diff --git a/scripts/scribble_bake_shader/scribble_bake_shader.gml b/scripts/scribble_bake_shader/scribble_bake_shader.gml index dcb98c933..793aed03f 100644 --- a/scripts/scribble_bake_shader/scribble_bake_shader.gml +++ b/scripts/scribble_bake_shader/scribble_bake_shader.gml @@ -287,7 +287,7 @@ function scribble_bake_shader() shader_set(_shader); shader_set_uniform_f(shader_get_uniform(_shader, "u_vTexel"), texture_get_texel_width(_texture), texture_get_texel_height(_texture)); - draw_surface(0, 0, _surface_0); + draw_surface(_surface_0, 0, 0); shader_reset(); gpu_set_tex_filter(_old_filter); diff --git a/scripts/scribble_cache/scribble_cache.gml b/scripts/scribble_cache/scribble_cache.gml index 35aab677e..b6b10bdde 100644 --- a/scripts/scribble_cache/scribble_cache.gml +++ b/scripts/scribble_cache/scribble_cache.gml @@ -402,9 +402,23 @@ function scribble_cache() { var _text_scale = real(_parameters_list[| 1]); } - + continue; //Skip the rest of the parser step break; + + case "scaleStack": + if (_command_tag_parameters <= 1) + { + show_error("Scribble:\nNot enough parameters for scaleStack tag!", false); + } + else + { + _text_scale *= real(_parameters_list[| 1]); + } + + continue; //Skip the rest of the parser step + break; + #endregion #region Slant (italics emulation) diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index 2e69a0cca..0eb89361c 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -205,10 +205,14 @@ function scribble_draw() else { //Otherwise try to find a custom event - var _script = global.__scribble_autotype_events[? _event_name]; - if (_script != undefined) + var _function = global.__scribble_autotype_events[? _event_name]; + if (is_method(_function)) + { + _function(_scribble_array, _event_data_array, _scan); + } + else if (is_real(_function) && script_exists(_function)) { - script_execute(_script, _scribble_array, _event_data_array, _scan); + script_execute(_function, _scribble_array, _event_data_array, _scan); } } @@ -305,7 +309,15 @@ function scribble_draw() #endregion var _callback = _occurance_array[__SCRIBBLE_OCCURANCE.FUNCTION]; - if ((_callback != undefined) && script_exists(_callback)) script_execute(_callback, _scribble_array, _typewriter_window_array[_typewriter_window] - 1); + + if (is_method(_callback)) + { + _callback(_scribble_array, _typewriter_window_array[_typewriter_window] - 1); + } + else if (is_real(_callback) && script_exists(_callback)) + { + script_execute(_callback, _scribble_array, _typewriter_window_array[_typewriter_window] - 1); + } } #endregion diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 69480ac66..4870bf41a 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -12,8 +12,8 @@ function scribble_init(_font_directory, _default_font, _auto_scan) // @jujuadams // With thanks to glitchroy, Mark Turner, DragoniteSpam, sp202, Rob van Saaze, soVes, and @stoozey_ - #macro __SCRIBBLE_VERSION "6.0.11" - #macro __SCRIBBLE_DATE "2020-08-19" + #macro __SCRIBBLE_VERSION "6.0.12" + #macro __SCRIBBLE_DATE "2020-08-29" #macro __SCRIBBLE_DEBUG false //You'll usually only want to modify SCRIBBLE_GLYPH.X_OFFSET, SCRIBBLE_GLYPH.Y_OFFSET, and SCRIBBLE_GLYPH.SEPARATION