- [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; globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11750; VERSION = 11760;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.5.005"; VERSION_STRING = "1.17.6";
BUILD_NUMBER = 11750; BUILD_NUMBER = 11760;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;
HOTKEYS = ds_map_create(); HOTKEYS = ds_map_create();

View file

@ -1,201 +1,199 @@
#region locale globalvar LOCALE, TEST_LOCALE, LOCALE_DEF;
globalvar LOCALE, TEST_LOCALE, LOCALE_DEF; LOCALE = {
LOCALE = { fontDir: "",
fontDir: "", config: { per_character_line_break: false },
config: { per_character_line_break: false }, };
}; global.missing_locale = {}
global.missing_locale = {}
TEST_LOCALE = false;
LOCALE_DEF = true;
function __initLocale() {
var lfile = $"data/Locale/en.zip";
var root = $"{DIRECTORY}Locale";
TEST_LOCALE = false; directory_verify(root);
LOCALE_DEF = true; if(check_version($"{root}/version")) {
zip_unzip(lfile, root);
file_copy($"data/Locale/LOCALIZATION GUIDES.txt", $"{DIRECTORY}Locale/LOCALIZATION GUIDES.txt");
}
function __initLocale() { #region if(LOCALE_DEF && !TEST_LOCALE) return;
var lfile = $"data/Locale/en.zip";
var root = $"{DIRECTORY}Locale"; loadLocale();
}
directory_verify(root);
if(check_version($"{root}/version")) { function __locale_file(file) {
zip_unzip(lfile, root); var dirr = $"{DIRECTORY}Locale/{PREFERENCES.local}";
file_copy($"data/Locale/LOCALIZATION GUIDES.txt", $"{DIRECTORY}Locale/LOCALIZATION GUIDES.txt"); if(!directory_exists(dirr) || !file_exists_empty(dirr + file))
dirr = $"{DIRECTORY}Locale/en";
return dirr + file;
}
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"));
LOCALE.config = json_load_struct(__locale_file("/config.json"));
var fontDir = $"{DIRECTORY}Locale/{PREFERENCES.local}/fonts/";
LOCALE.fontDir = directory_exists(fontDir)? fontDir : noone;
}
function __txtx(key, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(key != "" && !struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) {
global.missing_locale[$ key] = def;
show_debug_message($"LOCALE: {global.missing_locale}");
return def;
} }
return "";
if(LOCALE_DEF && !TEST_LOCALE) return; }
loadLocale();
} #endregion
function __locale_file(file) { #region if(struct_has(LOCALE.word, key)) return LOCALE.word[$ key];
var dirr = $"{DIRECTORY}Locale/{PREFERENCES.local}"; if(struct_has(LOCALE.ui, key)) return LOCALE.ui[$ key];
if(!directory_exists(dirr) || !file_exists_empty(dirr + file))
dirr = $"{DIRECTORY}Locale/en";
return dirr + file;
} #endregion
function loadLocale() { #region return def;
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")); function __txt(txt, prefix = "") {
LOCALE.config = json_load_struct(__locale_file("/config.json")); INLINE
var fontDir = $"{DIRECTORY}Locale/{PREFERENCES.local}/fonts/";
LOCALE.fontDir = directory_exists(fontDir)? fontDir : noone;
} #endregion
function __txtx(key, def = "") { #region if(LOCALE_DEF && !TEST_LOCALE) return txt;
INLINE
var key = string_lower(txt);
key = string_replace_all(key, " ", "_");
if(LOCALE_DEF && !TEST_LOCALE) return def; if(TEST_LOCALE) {
if(key != "" && !struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) {
if(TEST_LOCALE) { global.missing_locale[$ key] = txt;
if(key != "" && !struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) { show_debug_message($"LOCALE: {global.missing_locale}");
global.missing_locale[$ key] = def; return txt;
show_debug_message($"LOCALE: {global.missing_locale}"); }
return def; return "";
} }
return "";
return __txtx(prefix + key, txt);
}
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;
}
function __txt_node_name(node, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(node != "Node_Custom" && !struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [NODE]: \"{node}\": \"{def}\",");
return def;
} }
return "";
if(struct_has(LOCALE.word, key)) return LOCALE.word[$ key]; }
if(struct_has(LOCALE.ui, key)) return LOCALE.ui[$ key];
if(!struct_has(LOCALE.node, node))
return def; return def;
} #endregion
function __txt(txt, prefix = "") { #region return LOCALE.node[$ node].name;
INLINE }
if(LOCALE_DEF && !TEST_LOCALE) return txt; function __txt_node_tooltip(node, def = "") {
INLINE
var key = string_lower(txt);
key = string_replace_all(key, " ", "_");
if(TEST_LOCALE) {
if(key != "" && !struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) {
global.missing_locale[$ key] = txt;
show_debug_message($"LOCALE: {global.missing_locale}");
return txt;
}
return "";
}
return __txtx(prefix + key, txt);
} #endregion
function __txta(txt) { #region if(LOCALE_DEF && !TEST_LOCALE) return def;
var _txt = __txt(txt);
for(var i = 1; i < argument_count; i++)
_txt = string_replace_all(_txt, $"\{{i}\}", string(argument[i]));
return _txt; if(TEST_LOCALE) {
} #endregion if(node != "Node_Custom" && !struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [TIP]: \"{node}\": \"{def}\",");
function __txt_node_name(node, def = "") { #region
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(node != "Node_Custom" && !struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [NODE]: \"{node}\": \"{def}\",");
return def;
}
return "";
}
if(!struct_has(LOCALE.node, node))
return def; return def;
return LOCALE.node[$ node].name;
} #endregion
function __txt_node_tooltip(node, def = "") { #region
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(node != "Node_Custom" && !struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [TIP]: \"{node}\": \"{def}\",");
return def;
}
return "";
} }
return "";
if(!struct_has(LOCALE.node, node)) }
return def;
return LOCALE.node[$ node].tooltip;
} #endregion
function __txt_junction_name(node, type, index, def = "") { #region if(!struct_has(LOCALE.node, node))
INLINE return def;
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [JNAME]: \"{node}\": \"{def}\",");
return def;
}
return "";
}
if(!struct_has(LOCALE.node, node))
return def;
var nde = LOCALE.node[$ node];
var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs;
if(index >= array_length(lst)) return def;
return lst[index].name;
} #endregion
function __txt_junction_tooltip(node, type, index, def = "") { #region return LOCALE.node[$ node].tooltip;
INLINE }
if(LOCALE_DEF && !TEST_LOCALE) return def; function __txt_junction_name(node, type, index, def = "") {
INLINE
if(TEST_LOCALE) {
if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [JTIP]: \"{node}\": \"{def}\",");
return def;
}
return "";
}
if(!struct_has(LOCALE.node, node))
return def;
var nde = LOCALE.node[$ node];
var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs;
if(index >= array_length(lst)) return def;
return lst[index].tooltip;
} #endregion
function __txt_junction_data(node, type, index, def = []) { #region if(LOCALE_DEF && !TEST_LOCALE) return def;
INLINE
if(TEST_LOCALE) {
if(LOCALE_DEF && !TEST_LOCALE) return def; if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [JNAME]: \"{node}\": \"{def}\",");
if(TEST_LOCALE) { return def;
if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [DDATA]: \"{node}\": \"{def}\",");
return def;
}
return [ "" ];
} }
return "";
if(!struct_has(LOCALE.node, node)) }
if(!struct_has(LOCALE.node, node))
return def;
var nde = LOCALE.node[$ node];
var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs;
if(index >= array_length(lst)) return def;
return lst[index].name;
}
function __txt_junction_tooltip(node, type, index, def = "") {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [JTIP]: \"{node}\": \"{def}\",");
return def; return def;
}
var nde = LOCALE.node[$ node]; return "";
var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs; }
if(index >= array_length(lst)) return def;
if(!struct_has(LOCALE.node, node))
if(!struct_has(lst[index], "display_data")) return def;
var nde = LOCALE.node[$ node];
var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs;
if(index >= array_length(lst)) return def;
return lst[index].tooltip;
}
function __txt_junction_data(node, type, index, def = []) {
INLINE
if(LOCALE_DEF && !TEST_LOCALE) return def;
if(TEST_LOCALE) {
if(!struct_has(LOCALE.node, node)) {
show_debug_message($"LOCALE [DDATA]: \"{node}\": \"{def}\",");
return def; return def;
}
return [ "" ];
}
if(!struct_has(LOCALE.node, node))
return def;
return lst[index].display_data; var nde = LOCALE.node[$ node];
} #endregion var lst = type == JUNCTION_CONNECT.input? nde.inputs : nde.outputs;
#endregion if(index >= array_length(lst)) return def;
if(!struct_has(lst[index], "display_data"))
return def;
return lst[index].display_data;
}

View file

@ -356,18 +356,14 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
function deleteLayer(index) { #region function deleteLayer(index) { #region
var idx = input_fix_len + index * data_length; 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); 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++ ) { input_display_list = array_clone(input_display_list_raw, 1);
if(input_display_list[i] > idx)
input_display_list[i] = input_display_list[i] - data_length; 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(); doUpdate();
} #endregion } #endregion