Pixel-Composer/scripts/node_guide/node_guide.gml

91 lines
1.9 KiB
Text
Raw Normal View History

2023-03-05 07:16:44 +01:00
function __generate_node_data() {
2023-02-14 02:48:33 +01:00
var amo = ds_map_size(ALL_NODES);
var k = ds_map_find_first(ALL_NODES);
CLONING = true;
2023-03-28 06:58:28 +02:00
var dir = DIRECTORY + "Nodes/Guides/";
2023-03-05 07:16:44 +01:00
if(!directory_exists(dir)) directory_create(dir);
2023-02-14 02:48:33 +01:00
repeat(amo) {
var _n = ALL_NODES[? k];
var _b = _n.build(0, 0);
2023-03-05 07:16:44 +01:00
k = ds_map_find_next(ALL_NODES, k);
if(_b.name == "") continue;
var data = {};
data.name = _n.name;
data.node = _n.node;
data.tooltip = _b.tooltip;
2023-02-14 02:48:33 +01:00
var _in = [];
var _ot = [];
2023-03-05 07:16:44 +01:00
for( var i = 0; i < ds_list_size(_b.inputs); i++ ) {
_in[i] = {
name: _b.inputs[| i].name,
tooltip: _b.inputs[| i].tooltip,
type: _b.inputs[| i].type,
2023-03-28 06:58:28 +02:00
visible: _b.inputs[| i].visible,
2023-03-05 07:16:44 +01:00
};
2023-02-14 02:48:33 +01:00
}
2023-03-05 07:16:44 +01:00
for( var i = 0; i < ds_list_size(_b.outputs); i++ ) {
_ot[i] = {
name: _b.outputs[| i].name,
tooltip: _b.outputs[| i].tooltip,
type: _b.outputs[| i].type,
2023-03-28 06:58:28 +02:00
visible: _b.outputs[| i].visible,
2023-03-05 07:16:44 +01:00
};
}
data.inputs = _in;
data.outputs = _ot;
var path = dir + data.name + ".json";
json_save_struct(path, data, true);
2023-02-14 02:48:33 +01:00
}
CLONING = false;
game_end();
}
2023-03-21 03:01:53 +01:00
function __initNodeData() {
2023-02-14 02:48:33 +01:00
global.NODE_GUIDE = {};
2023-03-28 06:58:28 +02:00
var dir = DIRECTORY + "Nodes/Guides/";
2023-03-05 07:16:44 +01:00
if(!directory_exists(dir))
directory_create(dir);
2023-03-28 06:58:28 +02:00
var f = file_find_first(dir + "*.json", 0);
2023-03-05 07:16:44 +01:00
while(f != "") {
var path = dir + f;
if(file_exists(path)) {
var _node = json_load_struct(path);
global.NODE_GUIDE[$ _node.node] = _node;
}
f = file_find_next();
}
2023-03-28 06:58:28 +02:00
var nodeDir = DIRECTORY + "Nodes/";
var _l = nodeDir + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(res.version >= VERSION) return;
}
json_save_struct(_l, { version: VERSION });
2023-03-05 07:16:44 +01:00
2023-03-08 12:14:01 +01:00
if(file_exists("data/tooltip.zip"))
2023-03-28 06:58:28 +02:00
zip_unzip("data/tooltip.zip", nodeDir);
2023-03-08 12:14:01 +01:00
else
noti_status("Tooltip image file not found.")
2023-03-28 06:58:28 +02:00
if(file_exists("data/Guides.zip"))
zip_unzip("data/Guides.zip", nodeDir);
else
noti_status("Node data file not found.")
2023-02-14 02:48:33 +01:00
}