2022-01-18 05:44:05 +01:00
|
|
|
function LOAD() {
|
|
|
|
var path = get_open_filename("*.pxc;*.json", "");
|
|
|
|
if(path == "") return;
|
|
|
|
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc") return;
|
|
|
|
|
|
|
|
LOAD_PATH(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
function LOAD_PATH(path, readonly = false) {
|
|
|
|
if(!file_exists(path)) {
|
|
|
|
PANEL_MENU.showNoti("File not found", s_noti_icon_warning);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc") {
|
|
|
|
PANEL_MENU.showNoti("File not a valid project", s_noti_icon_warning);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var temp_path = DIRECTORY + "\_temp";
|
|
|
|
if(file_exists(temp_path)) file_delete(temp_path);
|
|
|
|
file_copy(path, temp_path);
|
|
|
|
|
|
|
|
LOADING = true;
|
|
|
|
READONLY = readonly;
|
|
|
|
SET_PATH(path);
|
|
|
|
|
|
|
|
var file = file_text_open_read(temp_path);
|
|
|
|
var load_str = "";
|
|
|
|
|
|
|
|
while(!file_text_eof(file)) {
|
|
|
|
load_str += file_text_readln(file);
|
|
|
|
}
|
|
|
|
file_text_close(file);
|
|
|
|
|
|
|
|
var _map = json_decode(load_str);
|
|
|
|
if(ds_map_exists(_map, "version")) {
|
|
|
|
var _v = _map[? "version"];
|
|
|
|
if(_v != SAVEFILE_VERSION) {
|
|
|
|
var warn = "File version mismatch : loading file verion " + string(_v) + " to Pixel Composer " + string(SAVEFILE_VERSION);
|
|
|
|
log_warning("FILE", warn)
|
|
|
|
PANEL_MENU.addNotiExtra(warn);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var warn = "File version mismatch : loading old format to Pixel Composer " + string(SAVEFILE_VERSION);
|
|
|
|
log_warning("FILE", warn)
|
|
|
|
PANEL_MENU.addNotiExtra(warn);
|
|
|
|
}
|
|
|
|
|
2022-01-19 06:11:17 +01:00
|
|
|
nodeCleanUp();
|
2022-01-18 05:44:05 +01:00
|
|
|
|
|
|
|
var create_list = ds_list_create();
|
|
|
|
if(ds_map_exists(_map, "nodes")) {
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
var _node_list = _map[? "nodes"];
|
|
|
|
for(var i = 0; i < ds_list_size(_node_list); i++) {
|
|
|
|
var _node = nodeLoad(_node_list[| i]);
|
|
|
|
if(_node) ds_list_add(create_list, _node);
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Node load error : " + e.message);
|
|
|
|
log_warning("LOAD, node", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
if(ds_map_exists(_map, "animator")) {
|
|
|
|
var _anim_map = _map[? "animator"];
|
|
|
|
ANIMATOR.frames_total = ds_map_try_get(_anim_map, "frames_total");
|
|
|
|
ANIMATOR.framerate = ds_map_try_get(_anim_map, "framerate");
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Animator load error : " + e.message);
|
|
|
|
log_warning("LOAD, animator", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ds_queue_clear(CONNECTION_CONFLICT);
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
|
|
|
create_list[| i].loadGroup();
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Group load error : " + e.message);
|
|
|
|
log_warning("LOAD, group", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
|
|
|
create_list[| i].postDeserialize();
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Deserialize error : " + e.message);
|
|
|
|
log_warning("LOAD, deserialize", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
|
|
|
create_list[| i].preConnect();
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
|
|
|
create_list[| i].connect();
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
2022-01-18 05:44:05 +01:00
|
|
|
create_list[| i].postConnect();
|
2022-05-17 14:39:12 +02:00
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Connect error : " + e.message);
|
|
|
|
log_warning("LOAD, connect", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
for(var i = 0; i < ds_list_size(create_list); i++)
|
|
|
|
create_list[| i].doUpdate();
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Update error : " + e.message);
|
|
|
|
log_warning("LOAD, update", e.longMessage);
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
renderAll();
|
|
|
|
|
|
|
|
if(!ds_queue_empty(CONNECTION_CONFLICT)) {
|
|
|
|
var pass = 0;
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
try {
|
|
|
|
while(++pass < 4 && !ds_queue_empty(CONNECTION_CONFLICT)) {
|
|
|
|
var size = ds_queue_size(CONNECTION_CONFLICT);
|
|
|
|
log_message("LOAD", "[Connect] " + string(size) + " Connection conflict(s) detected ( pass: " + string(pass) + " )");
|
|
|
|
repeat(size) {
|
|
|
|
ds_queue_dequeue(CONNECTION_CONFLICT).connect();
|
|
|
|
}
|
|
|
|
renderAll();
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-17 14:39:12 +02:00
|
|
|
if(!ds_queue_empty(CONNECTION_CONFLICT))
|
|
|
|
PANEL_MENU.addNotiExtra("Some connection(s) is unsolved. This may caused by render node not being update properly, or image path is broken.");
|
|
|
|
} catch(e) {
|
|
|
|
PANEL_MENU.addNotiExtra("Conflict solver error : " + e.message);
|
|
|
|
log_warning("LOAD, connect solver", e.longMessage);
|
|
|
|
}
|
2022-01-18 05:44:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LOADING = false;
|
|
|
|
|
|
|
|
PANEL_GRAPH.fullView();
|
|
|
|
PANEL_ANIMATION.updatePropertyList();
|
|
|
|
|
|
|
|
log_message("FILE", "load at " + path);
|
2022-01-19 03:05:13 +01:00
|
|
|
PANEL_MENU.showNoti("File loaded", s_noti_icon_file_load);
|
2022-01-29 14:25:18 +01:00
|
|
|
|
|
|
|
ds_map_destroy(_map);
|
2022-01-18 05:44:05 +01:00
|
|
|
return true;
|
|
|
|
}
|