Project close fix, area data uncache

This commit is contained in:
Tanasart 2023-08-01 11:16:23 +02:00
parent 47480f6517
commit 6595ae4898
8 changed files with 121 additions and 42 deletions

View file

@ -27,54 +27,54 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
mode = AREA_MODE.area;
onModifySingle[0] = function(val) {
var v = toNumber(val);
if(mode == AREA_MODE.area) {
return onModify(0, toNumber(val));
return onModify(0, v);
} else if(mode == AREA_MODE.padding) {
var v = toNumber(val);
if(link_value) current_data = [ v, v, v, v ];
else current_data[0] = v;
return setAllData(current_data);
if(link_value) return onModify(0, v) || onModify(1, v) || onModify(2, v) || onModify(3, v);
else return onModify(0, v);
} else if(mode == AREA_MODE.two_point) {
return onModify(0, val);
return onModify(0, v);
}
}
onModifySingle[1] = function(val) {
var v = toNumber(val);
if(mode == AREA_MODE.area) {
return onModify(1, toNumber(val));
return onModify(1, v);
} else if(mode == AREA_MODE.padding) {
var v = toNumber(val);
if(link_value) current_data = [ v, v, v, v ];
else current_data[1] = v;
return setAllData(current_data);
if(link_value) return onModify(0, v) || onModify(1, v) || onModify(2, v) || onModify(3, v);
else return onModify(1, v);
} else if(mode == AREA_MODE.two_point) {
return onModify(1, val);
return onModify(1, v);
}
}
onModifySingle[2] = function(val) {
var v = toNumber(val);
if(mode == AREA_MODE.area) {
return onModify(2, toNumber(val));
return onModify(2, v);
} else if(mode == AREA_MODE.padding) {
var v = toNumber(val);
if(link_value) current_data = [ v, v, v, v ];
else current_data[2] = v;
return setAllData(current_data);
if(link_value) return onModify(0, v) || onModify(1, v) || onModify(2, v) || onModify(3, v);
else return onModify(2, v);
} else if(mode == AREA_MODE.two_point) {
return onModify(2, val);
return onModify(2, v);
}
}
onModifySingle[3] = function(val) {
var v = toNumber(val);
if(mode == AREA_MODE.area) {
return onModify(3, toNumber(val));
return onModify(3, v);
} else if(mode == AREA_MODE.padding) {
var v = toNumber(val);
if(link_value) current_data = [ v, v, v, v ];
else current_data[3] = v;
return setAllData(current_data);
if(link_value) return onModify(0, v) || onModify(1, v) || onModify(2, v) || onModify(3, v);
else return onModify(3, v);
} else if(mode == AREA_MODE.two_point) {
return onModify(3, val);
return onModify(3, v);
}
}
@ -88,15 +88,6 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
tb[i].slide_speed = speed;
}
static setAllData = function(data) {
var mod0 = onModify(0, data[0]);
var mod1 = onModify(1, data[1]);
var mod2 = onModify(2, data[2]);
var mod3 = onModify(3, data[3]);
return mod0 || mod1 || mod2 || mod3;
}
static setInteract = function(interactable = noone) {
self.interactable = interactable;
for(var i = 0; i < 4; i++)

View file

@ -99,4 +99,35 @@ function setException() {
function resetException() {
exception_unhandled_handler(undefined);
}
function printCallStack(maxDepth = 32) {
var stack = debug_get_callstack(maxDepth);
print($"Call Stack:");
for( var i = 2, n = array_length(stack) - 1; i < n; i++ ) {
var call = stack[i];
var sp = string_splice(call, ":");
if(array_length(sp) < 2) continue;
sp[0] = string_replace_all(sp[0], "anon_", "");
sp[0] = string_split(sp[0], "gml_", true);
for( var j = 0, m = array_length(sp[0]); j < m; j++ ) {
sp[0][j] = string_replace(sp[0][j], "GlobalScript_", "Global: ");
sp[0][j] = string_replace(sp[0][j], "Script_", "Script: ");
sp[0][j] = string_replace(sp[0][j], "Object_", "Object: ");
sp[0][j] = string_trim(sp[0][j], ["_"]);
var _txt = "";
repeat(j * 4) _txt += " ";
_txt += $" > {sp[0][j]}";
if(j == m - 1)
_txt += $" line: {sp[1]}";
print(_txt);
}
}
print("")
}

View file

@ -92,10 +92,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 11481;
VERSION = 11482;
SAVE_VERSION = 11480;
VERSION_STRING = "1.15rc1";
BUILD_NUMBER = 11481;
VERSION_STRING = "1.15rc2";
BUILD_NUMBER = 11482;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -213,6 +213,11 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
jun.editWidget.setInteract(false);
}
//if(jun.display_type == VALUE_DISPLAY.area) {
// print("======= Show value widget =====");
// print(jun.animator.values[| 0].value);
// print(jun.showValue());
//}
var param = new widgetParam(editBoxX, editBoxY, editBoxW, editBoxH, jun.showValue(), jun.extra_data, _m, rx, ry);
switch(jun.type) {
@ -221,7 +226,9 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
switch(jun.display_type) {
case VALUE_DISPLAY.padding : param.h = ui(192); break;
case VALUE_DISPLAY.corner : param.h = ui(192); break;
case VALUE_DISPLAY.area : param.h = ui(204); break;
case VALUE_DISPLAY.area :
param.h = ui(204);
break;
}
break;
case VALUE_TYPE.boolean : param.halign = lineBreak? fa_left : fa_center;

View file

@ -241,6 +241,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
if(!sep_axis && typeArray(prop.display_type) && is_array(_val)) {
for(var i = 0; i < array_length(_val); i++)
_val[i] = processValue(_val[i]);
return _val;
}
return processValue(_val);

View file

@ -986,6 +986,39 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return [ value ];
}
if(display_type == VALUE_DISPLAY.area) {
var dispType = struct_try_get(nodeFrom.extra_data, "area_type", AREA_MODE.area);
var surfGet = nodeFrom.display_data;
if(!applyUnit || surfGet == -1) {
//print($" {value}");
return value;
}
var surf = surfGet();
var ww = surf[0];
var hh = surf[1];
switch(dispType) {
case AREA_MODE.area :
return value;
case AREA_MODE.padding :
var cx = (ww - value[0] + value[2]) / 2
var cy = (value[1] + hh - value[3]) / 2;
var sw = abs((ww - value[0]) - value[2]) / 2;
var sh = abs(value[1] - (hh - value[3])) / 2;
return [cx, cy, sw, sh, value[4]];
case AREA_MODE.two_point :
var cx = (value[0] + value[2]) / 2
var cy = (value[1] + value[3]) / 2;
var sw = abs(value[0] - value[2]) / 2;
var sh = abs(value[1] - value[3]) / 2;
return [cx, cy, sw, sh, value[4]];
}
}
if(type == VALUE_TYPE.text) {
switch(display_type) {
case VALUE_DISPLAY.text_array :
@ -1176,7 +1209,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
static showValue = function() {
var val = getValue(, false,, true);
var val = _getValue(, false);
if(isArray()) {
if(array_length(val) == 0) return 0;
var v = val[safe_mod(node.preview_index, array_length(val))];
@ -1246,6 +1280,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static setValueDirect = function(val = 0, index = noone, record = true, time = PROJECT.animator.current_frame, _update = true) {
var updated = false;
//if(display_type == VALUE_DISPLAY.area) {
// print($"===== Set: {index} = {val} =====");
// printCallStack();
// print("");
//}
if(sep_axis) {
if(index == noone) {
for( var i = 0, n = array_length(animators); i < n; i++ )

View file

@ -492,7 +492,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
continue;
}
content[i].tab_x = lerp_float(content[i].tab_x, tbx, 5);
content[i].tab_x = content[i].tab_x == 0? tbx : lerp_float(content[i].tab_x, tbx, 5);
var _tbx = content[i].tab_x;
var _hov = point_in_rectangle(msx, msy, _tbx, tby, _tbx + tbw, tab_height);
var _tdh = tbh + THEME_VALUE.panel_tab_extend;

View file

@ -107,6 +107,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
toolbar_height = ui(40);
function toCenterNode() {
if(!project.active) return;
if(ds_list_empty(nodes_list)) {
graph_x = round(w / 2 / graph_s);
graph_y = round(h / 2 / graph_s);
@ -120,6 +122,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for(var i = 0; i < ds_list_size(nodes_list); i++) {
var _node = nodes_list[| i];
if(!is_struct(_node) || !is_instanceof(_node, Node) || !_node.active)
continue;
minx = min(_node.x - 32, minx);
maxx = max(_node.x + _node.w + 32, maxx);
@ -1975,9 +1980,13 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
function close() {
if(nodes_list != project.nodes) {
panel.remove(self);
return;
var panels = findPanels("Panel_Graph");
for( var i = 0, n = array_length(panels); i < n; i++ ) {
if(panels[i] == self) continue;
if(panels[i].project == project) {
panel.remove(self);
return;
}
}
if(!project.modified || project.readonly) {