Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Aug 29, 2020
2 parents b1312ea + 3937588 commit 23fb69b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 45 deletions.
2 changes: 1 addition & 1 deletion options/windows/options_windows.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 29 additions & 29 deletions scripts/scribble_add_autotype_event/scribble_add_autotype_event.gml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)) + "\"");
}
16 changes: 9 additions & 7 deletions scripts/scribble_add_font/scribble_add_font.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/scribble_bake_shader/scribble_bake_shader.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 15 additions & 1 deletion scripts/scribble_cache/scribble_cache.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions scripts/scribble_draw/scribble_draw.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/scribble_init/scribble_init.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23fb69b

Please sign in to comment.