Pixel-Composer/scripts/project_data/project_data.gml

153 lines
3.8 KiB
Plaintext
Raw Normal View History

2023-10-12 07:07:24 +02:00
#region global
globalvar PROJECTS, PROJECT;
2024-02-11 14:53:33 +01:00
PROJECT = noone;
2023-10-12 07:07:24 +02:00
#endregion
#region project
function Project() constructor {
active = true; /// @is {bool}
2023-12-08 03:50:09 +01:00
meta = __getdefaultMetaData();
path = ""; /// @is {string}
2023-12-08 03:50:09 +01:00
thumbnail = "";
version = SAVE_VERSION; /// @is {number}
seed = irandom_range(100000, 999999); /// @is {number}
2023-10-12 07:07:24 +02:00
2024-03-14 14:35:19 +01:00
modified = false; /// @is {bool}
readonly = false; /// @is {bool}
2024-03-14 14:35:19 +01:00
safeMode = false;
2023-10-12 07:07:24 +02:00
allNodes = [];
nodes = [];
nodeTopo = [];
2023-10-12 07:07:24 +02:00
nodeMap = ds_map_create();
nodeNameMap = ds_map_create();
2023-12-18 08:27:31 +01:00
animator = new AnimationManager();
globalNode = new Node_Global();
nodeController = new __Node_Controller(self);
2023-10-12 07:07:24 +02:00
previewGrid = { #region
show : false,
snap : false,
size : [ 16, 16 ],
opacity : 0.5,
color : COLORS.panel_preview_grid,
2024-05-08 07:27:29 +02:00
pixel : false,
2023-10-12 07:07:24 +02:00
} #endregion
graphGrid = { #region
show : true,
2023-10-18 14:58:55 +02:00
show_origin : false,
2023-10-12 07:07:24 +02:00
snap : true,
2023-10-18 14:58:55 +02:00
size : 16,
2023-10-12 07:07:24 +02:00
opacity : 0.05,
color : c_white,
2023-10-18 14:58:55 +02:00
highlight : 12,
2023-10-12 07:07:24 +02:00
} #endregion
addons = {};
onion_skin = { #region
enabled: false,
range: [ -1, 1 ],
step: 1,
color: [ c_red, c_blue ],
alpha: 0.5,
on_top: true,
}; #endregion
#region =================== ATTRIBUTES ===================
2024-05-17 05:19:11 +02:00
attributes = variable_clone(PROJECT_ATTRIBUTES);
attributeEditor = [
2024-05-17 05:19:11 +02:00
[ "Default Surface", "surface_dimension", new vectorBox(2,
function(ind, val) {
attributes.surface_dimension[ind] = val;
PROJECT_ATTRIBUTES.surface_dimension = array_clone(attributes.surface_dimension);
RENDER_ALL
return true;
}),
2024-03-14 14:35:19 +01:00
function(junc) {
if(!is_struct(junc)) return;
if(!is_instanceof(junc, NodeValue)) return;
var attr = attributes.surface_dimension;
var _val = junc.getValue();
var _res = [ attr[0], attr[1] ];
switch(junc.type) {
case VALUE_TYPE.float :
case VALUE_TYPE.integer :
if(is_real(_val))
_res = [ _val, _val ];
else if(is_array(_val) && array_length(_val) >= 2) {
_res[0] = is_real(_val[0])? _val[0] : 1;
_res[1] = is_real(_val[1])? _val[1] : 1;
}
break;
case VALUE_TYPE.surface :
2024-03-31 05:36:11 +02:00
if(is_array(_val)) _val = array_safe_get_fast(_val, 0);
2024-03-14 14:35:19 +01:00
if(is_surface(_val))
_res = surface_get_dimension(_val);
break;
}
attr[0] = _res[0];
attr[1] = _res[1];
} ],
2024-04-23 11:53:16 +02:00
[ "Palette", "palette", new buttonPalette(function(pal) { setPalette(pal); RENDER_ALL return true; }),
2024-03-14 14:35:19 +01:00
function(junc) {
if(!is_struct(junc)) return;
if(!is_instanceof(junc, NodeValue)) return;
if(junc.type != VALUE_TYPE.color) return;
if(junc.display_type != VALUE_DISPLAY.palette) return;
setPalette(junc.getValue());
}
],
2024-04-23 11:53:16 +02:00
2024-04-23 14:29:26 +02:00
//[ "Strict", "strict", new checkBox(function() { attributes.strict = !attributes.strict; RENDER_ALL return true; }), function() {} ],
];
static setPalette = function(pal = noone) {
2024-05-17 05:19:11 +02:00
if(pal != noone) {
for (var i = 0, n = array_length(pal); i < n; i++)
pal[i] = cola(pal[i], _color_get_alpha(pal[i]));
attributes.palette = pal;
PROJECT_ATTRIBUTES.palette = array_clone(pal);
}
2024-05-16 15:28:45 +02:00
palettes = paletteToArray(attributes.palette);
2024-05-16 15:28:45 +02:00
} setPalette();
#endregion
2023-10-12 07:07:24 +02:00
timelines = new timelineItemGroup();
2023-10-15 15:04:42 +02:00
notes = [];
2023-10-12 07:07:24 +02:00
static cleanup = function() { #region
array_foreach(allNodes, function(_node) {
_node.active = false;
_node.cleanUp();
});
2023-10-12 07:07:24 +02:00
ds_map_destroy(nodeMap);
ds_map_destroy(nodeNameMap);
gc_collect();
} #endregion
2024-02-04 07:33:42 +01:00
static toString = function() { return $"ProjectObject [{path}]"; }
2023-10-12 07:07:24 +02:00
}
function __initProject() {
PROJECT = new Project();
PROJECTS = [ PROJECT ];
}
#endregion