Pixel-Composer/scripts/VCT/VCT.gml

86 lines
1.7 KiB
Text
Raw Normal View History

2023-07-15 20:01:29 +02:00
function VCT(node) constructor {
self.node = node;
panel = PanelVCT;
vars = [];
static reset = function() {
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(vars); i < n; i++ )
2023-07-15 20:01:29 +02:00
vars[i].set(vars[i].def_val);
}
static createDialog = function() {
var pane = new panel(self);
dialogPanelCall(pane);
}
static process = function(params) {}
static serialize = function() {
2023-07-18 17:51:40 +02:00
var s = {};
s.variables = [];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(vars); i < n; i++ )
2023-07-18 17:51:40 +02:00
s.variables[i] = vars[i].get();
doSerialize(s);
2023-07-15 20:01:29 +02:00
return s;
}
2023-07-18 17:51:40 +02:00
static doSerialize = function(s) {}
2023-07-15 20:01:29 +02:00
static deserialize = function(load_arr) {
2023-07-18 17:51:40 +02:00
var variables = load_arr.variables;
var amo = min(array_length(variables), array_length(vars));
2023-07-15 20:01:29 +02:00
for( var i = 0; i < amo; i++ )
2023-07-18 17:51:40 +02:00
vars[i].set(variables[i]);
doDeserialize(load_arr);
2023-07-15 20:01:29 +02:00
}
2023-07-18 17:51:40 +02:00
static doDeserialize = function(load_arr) {}
2023-07-15 20:01:29 +02:00
}
function PanelVCT(vct) : PanelContent() constructor {
self.vct = vct;
title = "VCT";
w = ui(480);
h = ui(320);
resizable = false;
function drawContent(panel) {}
}
function VCT_var(type, val) {
2023-07-17 19:58:33 +02:00
var v = new __VCT_var(self, type, val);
2023-07-15 20:01:29 +02:00
array_append(vars, v);
return v;
}
2023-07-17 19:58:33 +02:00
function __VCT_var(vct, type, val) constructor {
self.vct = vct;
2023-07-15 20:01:29 +02:00
self.type = type;
self.val = val;
def_val = val;
disp = VALUE_DISPLAY._default;
disp_data = 0;
static setDisplay = function(disp, disp_data = 0) {
self.disp = disp;
self.disp_data = disp_data;
return self;
}
2023-07-17 19:58:33 +02:00
static update = function() { vct.node.triggerRender(); }
static setDirect = function(val) { if(val == undefined) return; self.val = val; }
static set = function(val, _update = true) {
if(val == undefined) return;
self.val = val;
if(_update) update();
}
2023-07-15 20:01:29 +02:00
static get = function() { return val; }
}