- [Composite Node] Fix (potential) error when deleting layer.

This commit is contained in:
Tanasart 2024-06-28 08:46:33 +07:00
parent 536aeb09d9
commit e92e0a9f3d
3 changed files with 186 additions and 192 deletions

View file

@ -36,10 +36,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11700;
VERSION = 11750;
VERSION = 11760;
SAVE_VERSION = 11700;
VERSION_STRING = "1.17.5.005";
BUILD_NUMBER = 11750;
VERSION_STRING = "1.17.6";
BUILD_NUMBER = 11760;
globalvar HOTKEYS, HOTKEY_CONTEXT;
HOTKEYS = ds_map_create();

View file

@ -1,4 +1,3 @@
#region locale
globalvar LOCALE, TEST_LOCALE, LOCALE_DEF;
LOCALE = {
fontDir: "",
@ -9,7 +8,7 @@
TEST_LOCALE = false;
LOCALE_DEF = true;
function __initLocale() { #region
function __initLocale() {
var lfile = $"data/Locale/en.zip";
var root = $"{DIRECTORY}Locale";
@ -22,16 +21,16 @@
if(LOCALE_DEF && !TEST_LOCALE) return;
loadLocale();
} #endregion
}
function __locale_file(file) { #region
function __locale_file(file) {
var dirr = $"{DIRECTORY}Locale/{PREFERENCES.local}";
if(!directory_exists(dirr) || !file_exists_empty(dirr + file))
dirr = $"{DIRECTORY}Locale/en";
return dirr + file;
} #endregion
}
function loadLocale() { #region
function loadLocale() {
LOCALE.word = json_load_struct(__locale_file("/words.json"));
LOCALE.ui = json_load_struct(__locale_file("/UI.json"));
LOCALE.node = json_load_struct(__locale_file("/nodes.json"));
@ -39,9 +38,9 @@
var fontDir = $"{DIRECTORY}Locale/{PREFERENCES.local}/fonts/";
LOCALE.fontDir = directory_exists(fontDir)? fontDir : noone;
} #endregion
}
function __txtx(key, def = "") { #region
function __txtx(key, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -59,9 +58,9 @@
if(struct_has(LOCALE.ui, key)) return LOCALE.ui[$ key];
return def;
} #endregion
}
function __txt(txt, prefix = "") { #region
function __txt(txt, prefix = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return txt;
@ -79,17 +78,17 @@
}
return __txtx(prefix + key, txt);
} #endregion
}
function __txta(txt) { #region
function __txta(txt) {
var _txt = __txt(txt);
for(var i = 1; i < argument_count; i++)
_txt = string_replace_all(_txt, $"\{{i}\}", string(argument[i]));
return _txt;
} #endregion
}
function __txt_node_name(node, def = "") { #region
function __txt_node_name(node, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -106,9 +105,9 @@
return def;
return LOCALE.node[$ node].name;
} #endregion
}
function __txt_node_tooltip(node, def = "") { #region
function __txt_node_tooltip(node, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -125,9 +124,9 @@
return def;
return LOCALE.node[$ node].tooltip;
} #endregion
}
function __txt_junction_name(node, type, index, def = "") { #region
function __txt_junction_name(node, type, index, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -148,9 +147,9 @@
if(index >= array_length(lst)) return def;
return lst[index].name;
} #endregion
}
function __txt_junction_tooltip(node, type, index, def = "") { #region
function __txt_junction_tooltip(node, type, index, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -171,9 +170,9 @@
if(index >= array_length(lst)) return def;
return lst[index].tooltip;
} #endregion
}
function __txt_junction_data(node, type, index, def = []) { #region
function __txt_junction_data(node, type, index, def = []) {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
@ -197,5 +196,4 @@
return def;
return lst[index].display_data;
} #endregion
#endregion
}

View file

@ -356,18 +356,14 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
function deleteLayer(index) { #region
var idx = input_fix_len + index * data_length;
for( var i = 0; i < data_length; i++ ) {
for( var i = 0; i < data_length; i++ )
ds_list_delete(inputs, idx);
array_remove(input_display_list, idx + i);
}
for( var i = input_display_list_len; i < array_length(input_display_list); i++ ) {
if(input_display_list[i] > idx)
input_display_list[i] = input_display_list[i] - data_length;
}
input_display_list = array_clone(input_display_list_raw, 1);
for(var i = input_fix_len, n = ds_list_size(inputs); i < n; i++)
array_push(input_display_list, i);
if(ds_list_size(inputs) == input_fix_len)
createNewInput();
doUpdate();
} #endregion