Skip to content

Commit

Permalink
Merge branch 'dev-9'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Oct 20, 2024
2 parents 2b0b153 + 5c46810 commit 53c4f9d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions scripts/__scribble_class_element/__scribble_class_element.gml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function __scribble_class_element(_string, _unique_id) constructor
static __scribble_state = __scribble_initialize().__state;
static __ecache_array = __scribble_initialize().__cache_state.__ecache_array;
static __ecache_dict = __scribble_initialize().__cache_state.__ecache_dict;
static __ecache_weak_array = __scribble_initialize().__cache_state.__ecache_weak_array;
static __ecache_name_array = __scribble_initialize().__cache_state.__ecache_name_array;

__text = _string;
Expand All @@ -26,6 +27,7 @@ function __scribble_class_element(_string, _unique_id) constructor
//Add this text element to the global cache
__ecache_dict[$ __cache_name] = weak_ref_create(self);
array_push(__ecache_array, self);
array_push(__ecache_weak_array, weak_ref_create(self));
array_push(__ecache_name_array, __cache_name);

__flushed = false;
Expand Down
3 changes: 1 addition & 2 deletions scripts/__scribble_gen_2_parser/__scribble_gen_2_parser.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,7 @@ function __scribble_gen_2_parser()
_tag_start = buffer_tell(_string_buffer);
_tag_open_count = 1;
_tag_parameter_count = 0;

array_resize(_tag_parameters, 0);
_tag_parameters = [];
}
}
else if ((_glyph_ord == 0x0A) //If we've hit a newline (\n)
Expand Down
1 change: 1 addition & 0 deletions scripts/__scribble_system/__scribble_system.gml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function __scribble_initialize()

__ecache_dict: {},
__ecache_array: [],
__ecache_weak_array: [],
__ecache_name_array: [],

__gc_vbuff_refs: [],
Expand Down
11 changes: 11 additions & 0 deletions scripts/__scribble_tick/__scribble_tick.gml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ function __scribble_tick()
static _cache_state = __scribble_initialize().__cache_state;

static _ecache_list_index = 0;
static _ecache_weak_index = 0;
static _ecache_name_index = 0;
static _ecache_array = _cache_state.__ecache_array;
static _ecache_dict = _cache_state.__ecache_dict;
static _ecache_weak_array = _cache_state.__ecache_weak_array;
static _ecache_name_array = _cache_state.__ecache_name_array;

static _mcache_name_index = 0;
Expand Down Expand Up @@ -73,6 +75,15 @@ function __scribble_tick()
}
}

if (array_length(_ecache_weak_array) > 0)
{
_ecache_weak_index = (_ecache_weak_index + 1) mod array_length(_ecache_weak_array);
if (not weak_ref_alive(_ecache_weak_array[_ecache_weak_index]))
{
array_delete(_ecache_weak_array, _ecache_weak_index, 1);
}
}

#endregion


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ function scribble_refresh_everything()

with(__scribble_initialize().__cache_state)
{
var _array = __ecache_weak_array;
var _i = 0;
repeat(array_length(__ecache_array))
repeat(array_length(_array))
{
__ecache_array[_i].refresh();
++_i;
var _weak_ref = _array[_i];
if (weak_ref_alive(_weak_ref))
{
_weak_ref.ref.refresh();
++_i;
}
else
{
array_delete(_array, _i, 1);
}
}
}
}

0 comments on commit 53c4f9d

Please sign in to comment.