- Fix crash when starting the software without prior appdata content.

This commit is contained in:
Tanasart 2023-11-18 17:49:25 +07:00
parent ed6785c22a
commit 0b28909dc0
12 changed files with 125 additions and 119 deletions

Binary file not shown.

View file

@ -356,8 +356,8 @@ event_inherited();
}
var _cont = PANEL_GRAPH.getCurrentContext();
if(_cont != noone)
array_append(sug, nodeReleatedQuery("context", instanceof(_cont)));
if(_cont != noone) array_append(sug, nodeReleatedQuery("context", instanceof(_cont)));
if(array_length(sug)) {
ds_list_add(_list, "Related");
for( var i = 0, n = array_length(sug); i < n; i++ )

View file

@ -42,7 +42,7 @@
PRESIST_PREF.path = DIRECTORY;
json_save_struct(perstPath, PRESIST_PREF);
directory_verify(DIRECTORY);
directory_set_current_working(DIRECTORY);
//directory_set_current_working(DIRECTORY);
METADATA = __getdefaultMetaData();
@ -83,9 +83,11 @@
log_message("SESSION", "> init Gradient"); __initGradient();
log_message("SESSION", "> init Ins Renderer"); __initInstanceRenderer();
log_message("SESSION", "> init Addons"); loadAddon();
log_message("SESSION", ">> Initialization complete");
__initPanel();
loadAddon();
if(file_exists("icon.png"))
file_copy("icon.png", DIRECTORY + "icon.png");
@ -98,6 +100,7 @@
var cmd = ".pxcc=\"" + string(program_directory) + "PixelComposer.exe\"";
shell_execute_async("assoc", cmd);
directory_set_current_working(DIRECTORY);
//print($"Setup time: {(current_time - t)/1000}s");
#endregion

View file

@ -34,7 +34,7 @@ function __Panel_Linear_Setting_Label(name, sprite, s_index = 0, s_color = c_whi
self.s_color = s_color;
} #endregion
function Panel_Linear_Setting() : PanelContent() constructor {
function Panel_Linear_Setting() : PanelContent() constructor { #region
title = __txtx("preview_3d_settings", "3D Preview Settings");
w = ui(400);
@ -46,7 +46,7 @@ function Panel_Linear_Setting() : PanelContent() constructor {
properties = []
static setHeight = function() { h = ui(12 + 36 * array_length(properties)); }
static drawSettings = function(panel) {
static drawSettings = function(panel) { #region
var yy = ui(24);
var th = ui(36);
var ww = w - ui(180);
@ -128,7 +128,7 @@ function Panel_Linear_Setting() : PanelContent() constructor {
if(bg_y == -1) bg_y = bg_y_to;
else bg_y = lerp_float(bg_y, bg_y_to, 2);
}
} #endregion
function drawContent(panel) { drawSettings(panel); }
}
} #endregion

View file

@ -1,4 +1,4 @@
function FileObject(_name, _path) constructor {
function FileObject(_name, _path) constructor { #region
static loadThumbnailAsync = false;
name = _name;
@ -16,7 +16,7 @@ function FileObject(_name, _path) constructor {
meta = noone;
type = FILE_TYPE.collection;
switch(string_lower(filename_ext(path))) {
switch(string_lower(filename_ext(path))) { #region
case ".png" :
case ".jpg" :
case ".gif" :
@ -25,7 +25,7 @@ function FileObject(_name, _path) constructor {
case ".pxc" :
type = FILE_TYPE.project;
break;
}
} #endregion
retrive_data = false;
thumbnail_data = -1;
@ -34,14 +34,14 @@ function FileObject(_name, _path) constructor {
static getName = function() { return name; }
static getSurface = function() {
static getSurface = function() { #region
if(is_surface(surface)) return surface;
var spr = getSpr();
surface = surface_create_from_sprite_ext(spr, 0);
return surface;
}
} #endregion
static getThumbnail = function() {
static getThumbnail = function() { #region
if(size > 100000) return noone;
if(!retrive_data) getMetadata();
@ -49,9 +49,9 @@ function FileObject(_name, _path) constructor {
if(thumbnail != noone && is_surface(thumbnail)) return thumbnail;
thumbnail = surface_decode(thumbnail_data);
}
} #endregion
static getSpr = function() {
static getSpr = function() { #region
if(spr != -1) return spr;
if(sprFetchID != noone) return -1;
@ -88,9 +88,9 @@ function FileObject(_name, _path) constructor {
}
return spr;
}
} #endregion
static getMetadata = function() {
static getMetadata = function() { #region
retrive_data = true;
if(meta != noone) return meta;
@ -117,21 +117,22 @@ function FileObject(_name, _path) constructor {
}
return meta;
}
}
} #endregion
} #endregion
function DirectoryObject(name, path) constructor {
function DirectoryObject(name, path) constructor { #region
self.name = name;
self.path = path;
subDir = ds_list_create();
content = ds_list_create();
open = false;
triggered = false;
static destroy = function() { ds_list_destroy(subDir); }
static getName = function() { return name; }
static scan = function(file_type) {
static scan = function(file_type) { #region
var _temp_name = ds_list_create();
var folder = file_find_first(path + "/*", fa_directory);
while(folder != "") {
@ -182,17 +183,14 @@ function DirectoryObject(name, path) constructor {
}
ds_list_destroy(_temp_name);
}
} #endregion
static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _colors = {}) {
static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _colors = {}) { #region
var hg = ui(28);
var hh = 0;
var color_selecting = struct_try_get(_colors, "selecting", COLORS.collection_path_current_bg);
//if(path == parent.context.path)
//draw_sprite_stretched_ext(THEME.group_label, 1, _x + ui(28), _y, _w - ui(36), hg, color_selecting, 1);
if(!ds_list_empty(subDir) && _hover && point_in_rectangle(_m[0], _m[1], _x, _y, ui(32), _y + hg - 1)) {
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _x, _y, ui(32), hg, CDEF.main_white, 1);
if(mouse_press(mb_left, _focus))
@ -201,16 +199,17 @@ function DirectoryObject(name, path) constructor {
if(_hover && point_in_rectangle(_m[0], _m[1], _x + ui(32), _y, _w, _y + hg - 1)) {
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _x + ui(28), _y, _w - ui(36), hg, CDEF.main_white, 1);
if(mouse_press(mb_left, _focus)) {
if(!triggered && mouse_click(mb_left, _focus)) {
if(!ds_list_empty(subDir))
open = !open;
if(parent.context == self)
parent.setContext(_homedir);
else
parent.setContext(self);
parent.setContext(parent.context == self? _homedir : self);
triggered = true;
}
}
} else
triggered = false;
if(triggered && mouse_release(mb_left))
triggered = false;
if(ds_list_empty(subDir)) draw_sprite_ui_uniform(THEME.folder_content, parent.context == self, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_empty);
else draw_sprite_ui_uniform(THEME.folder_content, open, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_nonempty);
@ -236,5 +235,5 @@ function DirectoryObject(name, path) constructor {
}
return hh;
}
}
} #endregion
} #endregion

View file

@ -25,10 +25,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 11600;
VERSION = 11581;
SAVE_VERSION = 11570;
VERSION_STRING = "1.16rc1";
BUILD_NUMBER = 11600;
BUILD_NUMBER = 11581;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -126,12 +126,12 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node contents");
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static inspector1Update = function() { onInspector1Update(); }
static onInspector1Update = function() { RenderListAction(nodes, group); }
static hasInspector1Update = function(group = false) { #region
if(!group) return false;
for( var i = 0; i < ds_list_size(nodes); i++ ) {
if(nodes[| i].hasInspector1Update())
return true;
@ -140,6 +140,22 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
return false;
} #endregion
static inspector2Update = function() { onInspector2Update(); }
static onInspector2Update = function() { #region
for( var i = 0; i < ds_list_size(nodes); i++ ) {
if(nodes[| i].hasInspector2Update())
nodes[| i].inspector2Update();
}
} #endregion
static hasInspector2Update = function(group = false) { #region
for( var i = 0; i < ds_list_size(nodes); i++ ) {
if(nodes[| i].hasInspector2Update())
return true;
}
return false;
} #endregion
static getNodeBase = function() { #region
if(instanceBase == noone) return self;
return instanceBase.getNodeBase();
@ -312,22 +328,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
}
} #endregion
static stepBegin = function() { #region
use_cache = CACHE_USE.none;
array_safe_set(cache_result, CURRENT_FRAME, true);
var node_list = getNodeList();
for(var i = 0; i < ds_list_size(node_list); i++) {
var _node = node_list[| i];
if(!_node.use_cache) continue;
use_cache = CACHE_USE.manual;
if(!array_safe_get(_node.cache_result, CURRENT_FRAME))
array_safe_set(cache_result, CURRENT_FRAME, false);
}
doStepBegin();
} #endregion
static stepBegin = function() { doStepBegin(); }
static step = function() { #region
if(combine_render_time) {

View file

@ -191,12 +191,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
updated = false;
passiveDynamic = false;
topoSorted = false;
use_cache = CACHE_USE.none;
cached_manual = false;
clearCacheOnChange = true;
cached_output = [];
cache_result = [];
temp_surface = [];
#endregion
@ -226,7 +220,13 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
#endregion
#region ---- cache ----
cache_group = noone;
use_cache = CACHE_USE.none;
cached_manual = false;
cached_output = [];
cache_result = [];
cache_group = noone;
clearCacheOnChange = true;
#endregion
static createNewInput = noone;
@ -1336,10 +1336,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
} #endregion
static cacheArrayCheck = function() { #region
if(array_length(cached_output) != TOTAL_FRAMES)
array_resize(cached_output, TOTAL_FRAMES);
if(array_length(cache_result) != TOTAL_FRAMES)
array_resize(cache_result, TOTAL_FRAMES);
cached_output = array_verify(cached_output, TOTAL_FRAMES);
cache_result = array_verify(cache_result, TOTAL_FRAMES);
} #endregion
static cacheCurrentFrame = function(_frame) { #region

View file

@ -148,20 +148,21 @@ function __initNodeData() {
global.NODE_GUIDE = {};
var nodeDir = DIRECTORY + "Nodes/";
var _l = nodeDir + "/version";
if(file_exists("data/tooltip.zip"))
zip_unzip("data/tooltip.zip", nodeDir);
else
noti_status("Tooltip image file not found.")
if(file_exists("data/nodes.json")) {
file_delete(nodeDir + "nodes.json");
file_copy_override("data/nodes.json", nodeDir + "nodes.json");
}
directory_verify(nodeDir + "/Related");
file_copy_override("data/related_node.json", nodeDir + "/Related/default.json");
var _relFrom = $"data/related_node.json";
var _relTo = nodeDir + "Related/default.json";
directory_verify(nodeDir + "Related");
file_copy_override(_relFrom, _relTo);
//print($"Copying related nodes from {_relFrom} to {_relTo}\n\t{file_exists(_relFrom)}, {file_exists(_relTo)}");
__initNodeReleated();
}

View file

@ -11,7 +11,6 @@ function Node_PC_Balls(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _sed = _data[0];
return _outSurf;
}
}

View file

@ -27,7 +27,7 @@
#endregion
#region functions
function clearPanel() {
function clearPanel() { #region
delete PANEL_MAIN;
delete PANEL_MENU;
delete PANEL_INSPECTOR;
@ -35,15 +35,15 @@
delete PANEL_GRAPH;
delete PANEL_COLLECTION;
PANEL_MAIN = {};
PANEL_MENU = {};
PANEL_INSPECTOR = {};
PANEL_PREVIEW = {};
PANEL_GRAPH = {};
PANEL_MAIN = {};
PANEL_MENU = {};
PANEL_INSPECTOR = {};
PANEL_PREVIEW = {};
PANEL_GRAPH = {};
PANEL_COLLECTION = {};
}
} #endregion
function getPanelFromName(name, create = false) {
function getPanelFromName(name, create = false) { #region
switch(name) {
case "Panel_Menu" : return (create || findPanel(name))? new Panel_Menu() : PANEL_MENU;
case "Panel_Inspector" : return (create || findPanel(name))? new Panel_Inspector() : PANEL_INSPECTOR;
@ -67,9 +67,9 @@
}
return noone;
}
} #endregion
function loadPanelStruct(panel, str) {
function loadPanelStruct(panel, str) { #region
var cont = str.content;
if(variable_struct_exists(str, "split")) {
@ -90,21 +90,21 @@
if(_cont != noone) panel.setContent(_cont);
}
}
}
} #endregion
function loadPanel(path, panel) {
function loadPanel(path, panel) { #region
CURRENT_PANEL = json_load_struct(path);
loadPanelStruct(panel, CURRENT_PANEL.panel);
}
} #endregion
function panelAdd(panel, create = false) {
function panelAdd(panel, create = false) { #region
var pan = getPanelFromName(panel, create);
if(pan == noone) return noone;
return dialogPanelCall(pan);
}
} #endregion
function panelObjectInit() {
function panelObjectInit() { #region
PANEL_MAIN = new Panel(noone, ui(2), ui(2), WIN_SW - ui(4), WIN_SH - ui(4));
PANEL_MENU = new Panel_Menu();
PANEL_INSPECTOR = new Panel_Inspector();
@ -112,22 +112,25 @@
PANEL_PREVIEW = new Panel_Preview();
PANEL_GRAPH = new Panel_Graph();
PANEL_COLLECTION = new Panel_Collection();
}
} #endregion
function resetPanel() {
function resetPanel() { #region
clearPanel();
panelObjectInit();
loadPanelStruct(PANEL_MAIN, CURRENT_PANEL.panel);
PANEL_MAIN.refresh();
}
} #endregion
function __initPanel() { #region
directory_verify($"{DIRECTORY}layouts");
function __initPanel() {
if(check_version($"{DIRECTORY}layouts/version"))
zip_unzip("data/Layouts.zip", DIRECTORY);
setPanel();
}
function setPanel() {
setPanel();
} #endregion
function setPanel() { #region
globalvar CURRENT_PANEL;
panelObjectInit();
@ -139,9 +142,9 @@
PANEL_MAIN.refresh();
PANEL_MAIN.refreshSize();
}
} #endregion
function findPanel(_type, _pane = PANEL_MAIN) {
function findPanel(_type, _pane = PANEL_MAIN) { #region
var pan = _findPanel(_type, _pane);
if(pan) return pan;
@ -151,9 +154,9 @@
}
return noone;
}
} #endregion
function _findPanel(_type, _pane, _res = noone) {
function _findPanel(_type, _pane, _res = noone) { #region
if(instanceof(_pane) != "Panel")
return _res;
if(!ds_exists(_pane.childs, ds_type_list))
@ -171,13 +174,13 @@
}
return _res;
}
} #endregion
function findPanels(_type, _pane = PANEL_MAIN) {
function findPanels(_type, _pane = PANEL_MAIN) { #region
return _findPanels(_type, _pane, []);
}
} #endregion
function _findPanels(_type, _pane, _arr = []) {
function _findPanels(_type, _pane, _arr = []) { #region
if(!is_instanceof(_pane, Panel))
return _arr;
if(!ds_exists(_pane.childs, ds_type_list))
@ -194,9 +197,9 @@
_arr = _findPanels(_type, _pane.childs[| i], _arr);
return _arr;
}
} #endregion
function panelInit() {
function panelInit() { #region
panel_dragging = noone;
panel_hovering = noone;
panel_split = 0;
@ -209,9 +212,9 @@
panel_draw_y1 = noone; panel_draw_y1_to = noone;
panel_draw_depth = 0;
}
} #endregion
function panelDraw() {
function panelDraw() { #region
panel_draw_x0 = panel_draw_x0 == noone? panel_draw_x0_to : lerp_float(panel_draw_x0, panel_draw_x0_to, 3);
panel_draw_y0 = panel_draw_y0 == noone? panel_draw_y0_to : lerp_float(panel_draw_y0, panel_draw_y0_to, 3);
panel_draw_x1 = panel_draw_x1 == noone? panel_draw_x1_to : lerp_float(panel_draw_x1, panel_draw_x1_to, 3);
@ -295,15 +298,15 @@
panel_draw_depth = 0;
}
}
}
} #endregion
function panelSerialize() {
function panelSerialize() { #region
var cont = {};
cont.panel = _panelSerialize(PANEL_MAIN);
return cont;
}
} #endregion
function _panelSerialize(panel) {
function _panelSerialize(panel) { #region
var cont = {};
var ind = 0;
@ -328,13 +331,13 @@
}
return cont;
}
} #endregion
function panelSerializeArray() {
function panelSerializeArray() { #region
return _panelSerializeArray(PANEL_MAIN);
}
} #endregion
function _panelSerializeArray(panel) {
function _panelSerializeArray(panel) { #region
var cont = [];
if(!ds_list_empty(panel.childs)) {
@ -346,7 +349,7 @@
}
return cont;
}
} #endregion
#endregion
#region fullscreen

View file

@ -4,6 +4,8 @@ function check_version(path) {
return true;
}
if(TESTING) return true;
var res = json_load_struct(path);
return struct_try_get(res, "version") != BUILD_NUMBER;
}