Pixel-Composer/scripts/node_guide/node_guide.gml

94 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-06-05 18:27:53 +02:00
globalvar NODE_EXTRACT;
NODE_EXTRACT = false;
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-06-05 18:27:53 +02:00
NODE_EXTRACT = true;
2023-02-14 02:48:33 +01:00
2023-06-05 18:27:53 +02:00
var dir = DIRECTORY + "Nodes/";
2023-03-05 07:16:44 +01:00
if(!directory_exists(dir)) directory_create(dir);
2023-06-05 18:27:53 +02:00
var data = {};
var locale = {};
2023-03-05 07:16:44 +01:00
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;
2023-06-05 18:27:53 +02:00
var _data = {};
_data.node = _n.node;
var _loca = {};
_loca.name = _n.name;
_loca.tooltip = _n.tooltip;
2023-02-14 02:48:33 +01:00
2023-06-05 18:27:53 +02:00
var _din = [], _dot = [];
var _lin = [], _lot = [];
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.inputs); i++ ) {
2023-06-05 18:27:53 +02:00
_din[i] = {
type: _b.inputs[| i].type,
visible: _b.inputs[| i].visible? 1 : 0,
};
_lin[i] = {
2023-06-13 14:42:06 +02:00
name: _b.inputs[| i]._initName,
2023-03-05 07:16:44 +01:00
tooltip: _b.inputs[| i].tooltip,
};
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++ ) {
2023-06-05 18:27:53 +02:00
_dot[i] = {
type: _b.outputs[| i].type,
visible: _b.outputs[| i].visible? 1 : 0,
};
_lot[i] = {
2023-06-13 14:42:06 +02:00
name: _b.outputs[| i]._initName,
2023-03-05 07:16:44 +01:00
tooltip: _b.outputs[| i].tooltip,
};
}
2023-06-05 18:27:53 +02:00
_data.inputs = _din;
_data.outputs = _dot;
data[$ _n.name] = _data;
_loca.inputs = _lin;
_loca.outputs = _lot;
locale[$ _n.node] = _loca;
2023-02-14 02:48:33 +01:00
}
2023-06-05 18:27:53 +02:00
json_save_struct(dir + "nodes.json", data, false);
json_save_struct(dir + "lnodes.json", locale, 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 nodeDir = DIRECTORY + "Nodes/";
var _l = nodeDir + "/version";
2023-06-05 18:27:53 +02:00
//if(file_exists(_l)) {
// var res = json_load_struct(_l);
// if(res.version == BUILD_NUMBER) return;
//}
//json_save_struct(_l, { version: BUILD_NUMBER });
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
2023-06-05 18:27:53 +02:00
if(file_exists("data/nodes.json")) {
file_delete(nodeDir + "nodes.json");
file_copy("data/nodes.json", nodeDir + "nodes.json");
}
2023-02-14 02:48:33 +01:00
}