2023-08-29 14:33:44 +02:00
|
|
|
function Panel_Animation_Scaler() : Panel_Linear_Setting() constructor {
|
|
|
|
title = __txtx("anim_scale_title", "Animation scaler");
|
|
|
|
|
|
|
|
w = ui(380);
|
2023-10-09 16:07:33 +02:00
|
|
|
scale_to = TOTAL_FRAMES;
|
2023-08-29 14:33:44 +02:00
|
|
|
|
|
|
|
#region data
|
|
|
|
properties = [
|
2023-10-31 15:24:54 +01:00
|
|
|
new __Panel_Linear_Setting_Item(
|
2023-08-29 14:33:44 +02:00
|
|
|
__txtx("anim_scale_target_frame_length", "Target frame length"),
|
2023-10-31 15:24:54 +01:00
|
|
|
new textBox(TEXTBOX_INPUT.number, function(to) { scale_to = toNumber(to); }),
|
2023-08-29 14:33:44 +02:00
|
|
|
function() { return scale_to; },
|
2023-10-31 15:24:54 +01:00
|
|
|
)
|
2023-08-29 14:33:44 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
setHeight();
|
|
|
|
h += ui(36);
|
|
|
|
|
|
|
|
b_apply = button(function() { scale(); })
|
|
|
|
.setIcon(THEME.accept_16, 0, COLORS._main_icon_dark);
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
static scale = function() {
|
2023-10-09 16:07:33 +02:00
|
|
|
var fac = scale_to / TOTAL_FRAMES;
|
2023-08-29 14:33:44 +02:00
|
|
|
var key = ds_map_find_first(PROJECT.nodeMap);
|
|
|
|
repeat(ds_map_size(PROJECT.nodeMap)) {
|
|
|
|
var _node = PROJECT.nodeMap[? key];
|
|
|
|
key = ds_map_find_next(PROJECT.nodeMap, key);
|
|
|
|
if(!_node || !_node.active) continue;
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(_node.inputs); i++) {
|
|
|
|
var in = _node.inputs[| i];
|
|
|
|
if(!in.is_anim) continue;
|
|
|
|
for(var j = 0; j < ds_list_size(in.animator.values); j++) {
|
|
|
|
var t = in.animator.values[| j];
|
|
|
|
t.time = t.ratio * scale_to;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-09 16:07:33 +02:00
|
|
|
TOTAL_FRAMES = scale_to;
|
2023-08-29 14:33:44 +02:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawContent(panel) {
|
|
|
|
drawSettings(panel);
|
|
|
|
|
|
|
|
var bs = ui(28);
|
|
|
|
var bx = w - ui(8) - bs;
|
|
|
|
var by = h - ui(8) - bs;
|
|
|
|
|
|
|
|
b_apply.setFocusHover(pFOCUS, pHOVER);
|
|
|
|
b_apply.register();
|
|
|
|
b_apply.draw(bx, by, bs, bs, [ mx, my ], THEME.button_lime);
|
|
|
|
}
|
|
|
|
}
|