diff --git a/objects/addon_key_displayer/Draw_75.gml b/objects/addon_key_displayer/Draw_75.gml index 9fe5cbe32..763483686 100644 --- a/objects/addon_key_displayer/Draw_75.gml +++ b/objects/addon_key_displayer/Draw_75.gml @@ -12,6 +12,7 @@ if(pres >= 32 && pres <= 126) { pres = string_upper(ansi_char(pres)); + if(pres == " ") pres = "space"; key += key == ""? pres : " + " + pres; } } diff --git a/objects/o_dialog_about/Create_0.gml b/objects/o_dialog_about/Create_0.gml index 9d4f477ee..548779b6b 100644 --- a/objects/o_dialog_about/Create_0.gml +++ b/objects/o_dialog_about/Create_0.gml @@ -11,10 +11,13 @@ event_inherited(); #region scroll credits = [ + [ "ImageMagick", "ImageMagick Studio LLC" ], + [ "File dialog module", "Samuel Venable" ], + [ "gif importer\nWindow commands\nApollow LUA compiler", "YellowAfterLife" ], + [ "The Book of Shaders", "Patricio Gonzalez Vivo & Jen Lowe" ], [ "Many noise and shape shaders", "Inigo Quilez" ], [ "Chromatic aberration shader", "jcant0n" ], - [ "gif importer\nWindow commands\nExecute shell simple", "YellowAfterLife" ], [ "Triangle grid", "Farini" ], [ "Pixel sort", "Ciphrd" ], [ "Simplex noise", "Ian McEwan" ], diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index 8a11a11b8..ee153c1ad 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -453,7 +453,7 @@ event_inherited(); var match = string_partial_match(string_lower(_node.name), search_lower); var param = ""; for( var k = 0; k < array_length(_node.tags); k++ ) { - var mat = string_partial_match(_node.tags[k], search_lower); + var mat = string_partial_match(_node.tags[k], search_lower) - 1000; if(mat > match) { match = mat; param = _node.tags[k]; diff --git a/objects/o_dialog_arrayBox/Create_0.gml b/objects/o_dialog_arrayBox/Create_0.gml index af985dbdc..cf95d5152 100644 --- a/objects/o_dialog_arrayBox/Create_0.gml +++ b/objects/o_dialog_arrayBox/Create_0.gml @@ -17,7 +17,7 @@ event_inherited(); var hght = line_height(f_p0, 8); var _h = array_length(arrayBox.data) * hght; var _dw = sc_content.surface_w; - var array = arrayBox.getArray(); + var array = arrayBox.arraySet; for(var i = 0; i < array_length(arrayBox.data); i++) { var _ly = _y + i * hght; diff --git a/objects/o_dialog_assetbox/Create_0.gml b/objects/o_dialog_assetbox/Create_0.gml index fda0178ff..1862f5916 100644 --- a/objects/o_dialog_assetbox/Create_0.gml +++ b/objects/o_dialog_assetbox/Create_0.gml @@ -7,16 +7,16 @@ event_inherited(); target = noone; - dialog_w = ui(608); - dialog_h = ui(320); + dialog_w = ui(632); + dialog_h = ui(360); anchor = ANCHOR.top | ANCHOR.right; dialog_resizable = true; dialog_w_min = ui(200); dialog_h_min = ui(120); - dialog_w_max = ui(640); - dialog_h_max = ui(480); + dialog_w_max = ui(1080); + dialog_h_max = ui(640); #endregion #region context @@ -40,17 +40,35 @@ event_inherited(); #endregion #region surface - folderW = ui(180); - content_w = dialog_w - ui(32) - folderW; + folderW = ui(200); + folderW_dragging = false; + folderW_drag_mx = 0; + folderW_drag_sx = 0; + + content_w = dialog_w - ui(36) - folderW; content_h = dialog_h - ui(32); function onResize() { - content_w = dialog_w - ui(32) - folderW; + content_w = dialog_w - ui(36) - folderW; content_h = dialog_h - ui(32); contentPane.resize(content_w, content_h); - folderPane.resize(folderW - ui(16), content_h - ui(32)); + folderPane.resize(folderW - ui(8), content_h - ui(32)); } + folderPane = new scrollPane(folderW - ui(8), content_h - ui(32), function(_y, _m) { + draw_clear_alpha(COLORS.panel_bg_clear, 0); + var hh = 8; + + for(var i = 0; i < ds_list_size(global.ASSETS.subDir); i++) { + var hg = global.ASSETS.subDir[| i].draw(self, ui(8), _y + 8, _m, folderPane.surface_w - ui(16), + sHOVER && folderPane.hover, sFOCUS, global.ASSETS); + hh += hg; + _y += hg; + } + + return hh + 8; + }); + contentPane = new scrollPane(content_w, content_h, function(_y, _m) { draw_clear_alpha(c_white, 0); @@ -62,7 +80,7 @@ event_inherited(); var grid_size = ui(64); var img_size = grid_size - ui(16); var grid_space = ui(12); - var col = max(1, floor(content_w / (grid_size + grid_space))); + var col = max(1, floor(contentPane.surface_w / (grid_size + grid_space))); var row = ceil(amo / col); var yy = _y + grid_space; @@ -75,9 +93,9 @@ event_inherited(); var content = contents[| index]; var xx = grid_space + (grid_size + grid_space) * j; - BLEND_OVERRIDE + BLEND_OVERRIDE; draw_sprite_stretched(THEME.node_bg, 0, xx, yy, grid_size, grid_size); - BLEND_NORMAL + BLEND_NORMAL; if(sHOVER && contentPane.hover && point_in_rectangle(_m[0], _m[1], xx, yy, xx + grid_size, yy + grid_size)) { draw_sprite_stretched_ext(THEME.node_active, 0, xx, yy, grid_size, grid_size, COLORS._main_accent, 1); @@ -96,6 +114,9 @@ event_inherited(); var sy = yy + (grid_size - sh * ss) / 2; draw_sprite_ext(spr, frame, sx, sy, ss, ss, 0, c_white, 1); + + draw_set_text(f_p3, fa_right, fa_bottom, COLORS._main_accent); + draw_text(xx + grid_size - ui(1), yy + grid_size - ui(0), string(sw) + "x" + string(sh)); } } } @@ -106,18 +127,4 @@ event_inherited(); return hh; }); - - folderPane = new scrollPane(folderW - ui(16), content_h - ui(32), function(_y, _m) { - draw_clear_alpha(COLORS.panel_bg_clear, 0); - var hh = 8; - - for(var i = 0; i < ds_list_size(global.ASSETS.subDir); i++) { - var hg = global.ASSETS.subDir[| i].draw(self, ui(8), _y + 8, _m, folderPane.w - ui(16), - sHOVER && folderPane.hover, sFOCUS, global.ASSETS); - hh += hg; - _y += hg; - } - - return hh + 8; - }); #endregion \ No newline at end of file diff --git a/objects/o_dialog_assetbox/Draw_64.gml b/objects/o_dialog_assetbox/Draw_64.gml index c031fe908..79e582c8d 100644 --- a/objects/o_dialog_assetbox/Draw_64.gml +++ b/objects/o_dialog_assetbox/Draw_64.gml @@ -6,12 +6,37 @@ #endregion #region draw + if(folderW_dragging) { + var w = folderW_drag_sx + (mouse_mx - folderW_drag_mx); + w = clamp(w, ui(200), dialog_w - ui(128)); + + folderW = w; + onResize(); + + if(mouse_check_button_released(mb_left)) + folderW_dragging = -1; + } + draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_title); - draw_text(dialog_x + ui(16), dialog_y + ui(16), "Assets"); + draw_text(dialog_x + ui(16), dialog_y + ui(16), get_text("assets", "Assets")); draw_sprite_stretched(THEME.ui_panel_bg, 0, dialog_x + ui(16), dialog_y + ui(48), folderW - ui(8), dialog_h - ui(64)); draw_sprite_stretched(THEME.ui_panel_bg, 0, dialog_x + ui(16) + folderW, dialog_y + ui(16), dialog_w - ui(32) - folderW, dialog_h - ui(32)); + var dx0 = dialog_x + ui(16) + folderW - ui(8); + var dx1 = dialog_x + ui(16) + folderW; + var dy0 = dialog_y + ui(48); + var dy1 = dialog_y + dialog_h - ui(16); + + if(point_in_rectangle(mouse_mx, mouse_my, dx0, dy0, dx1, dy1)) { + CURSOR = cr_size_we; + if(mouse_click(mb_left, sFOCUS)) { + folderW_dragging = true; + folderW_drag_mx = mouse_mx; + folderW_drag_sx = folderW; + } + } + folderPane.active = sHOVER; folderPane.draw(dialog_x + ui(16), dialog_y + ui(48)); diff --git a/objects/o_dialog_file_name_collection/Create_0.gml b/objects/o_dialog_file_name_collection/Create_0.gml index 5db9b98a3..3c8471bd2 100644 --- a/objects/o_dialog_file_name_collection/Create_0.gml +++ b/objects/o_dialog_file_name_collection/Create_0.gml @@ -24,7 +24,7 @@ event_inherited(); t_auth = new textArea(TEXTBOX_INPUT.text, function(str) { meta.author = str; }); t_cont = new textArea(TEXTBOX_INPUT.text, function(str) { meta.contact = str; }); t_alias = new textArea(TEXTBOX_INPUT.text, function(str) { meta.alias = str; }); - t_tags = new textArrayBox(function() { return meta.tags; } , META_TAGS); + t_tags = new textArrayBox(function() { return meta.tags; }, META_TAGS); t_desc.auto_update = true; t_auth.auto_update = true; diff --git a/objects/o_dialog_file_name_collection/Draw_64.gml b/objects/o_dialog_file_name_collection/Draw_64.gml index 098135a19..40a0b15c7 100644 --- a/objects/o_dialog_file_name_collection/Draw_64.gml +++ b/objects/o_dialog_file_name_collection/Draw_64.gml @@ -13,7 +13,7 @@ t_desc.interactable = !STEAM_UGC_ITEM_UPLOADING; t_auth.interactable = !STEAM_UGC_ITEM_UPLOADING && is_author; - t_cont.interactable = !STEAM_UGC_ITEM_UPLOADING; + t_cont.interactable = !STEAM_UGC_ITEM_UPLOADING && is_author; t_tags.interactable = !STEAM_UGC_ITEM_UPLOADING; t_alias.interactable = !STEAM_UGC_ITEM_UPLOADING; tb_name.interactable = !STEAM_UGC_ITEM_UPLOADING; @@ -33,10 +33,10 @@ txt = get_text("collection_update", "Update collection"); } if(ugc == 1) { - txt = get_text("workshop_upload", "Upload workshop"); + txt = get_text("workshop_upload", "Upload to Steam Workshop"); icon = THEME.workshop_upload; } else if(ugc == 2) { - txt = get_text("workshop_update", "Update workshop"); + txt = get_text("workshop_update", "Update Steam Workshop"); icon = THEME.workshop_update; } diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index 592e793e0..b4d3cc57f 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -60,6 +60,15 @@ event_inherited(); }) ]); + ds_list_add(pref_global, [ + get_text("auto_save_time", "Autosave delay (-1 to disable)"), + "auto_save_time", + new textBox(TEXTBOX_INPUT.number, function(val) { + PREF_MAP[? "auto_save_time"] = val; + PREF_SAVE(); + }) + ]); + ds_list_add(pref_global, [ get_text("pref_double_click_delay", "Double click delay"), "double_click_delay", diff --git a/objects/o_dialog_splash/Create_0.gml b/objects/o_dialog_splash/Create_0.gml index adbdfc519..5fb194dfb 100644 --- a/objects/o_dialog_splash/Create_0.gml +++ b/objects/o_dialog_splash/Create_0.gml @@ -6,6 +6,9 @@ event_inherited(); dialog_w = ui(960); dialog_h = ui(600); + + pages = ["Sample projects", "Steam Workshop"]; + project_page = 0; #endregion #region content @@ -56,11 +59,13 @@ event_inherited(); sp_sample = new scrollPane(x1 - x0 - ui(8), y1 - y0, function(_y, _m) { draw_clear_alpha(COLORS.panel_bg_clear_inner, 0); + var list = project_page? STEAM_PROJECTS : SAMPLE_PROJECTS; + var hh = 0; var grid_heigh = ui(96); var grid_width = ui(128); var grid_space = ui(20); - var node_count = ds_list_size(SAMPLE_PROJECTS); + var node_count = ds_list_size(list); var col = floor(sp_sample.surface_w / (grid_width + grid_space)); var row = ceil(node_count / col); var hh = grid_space; @@ -72,44 +77,56 @@ event_inherited(); for(var j = 0; j < col; j++) { var index = i * col + j; if(index < node_count) { - var _node = SAMPLE_PROJECTS[| index]; - var _nx = grid_space + (grid_width + grid_space) * j; - var _boxx = _nx; + var _project = list[| index]; + var _nx = grid_space + (grid_width + grid_space) * j; + var _boxx = _nx; draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_width, grid_heigh); if(sHOVER && sp_sample.hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_heigh)) { draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_width, grid_heigh, COLORS._main_accent, 1); if(mouse_press(mb_left, sFOCUS)) { - LOAD_PATH(_node.path, true); + LOAD_PATH(_project.path, true); + METADATA.steam = project_page; + if(project_page == 1) + METADATA.file_id = _project.getMetadata().file_id; instance_destroy(); } } - if(_node.spr) { + var spr = _project.getSpr(); + if(spr) { var gw = grid_width - ui(4); var gh = grid_heigh - ui(4); - var sw = sprite_get_width(_node.spr); - var sh = sprite_get_height(_node.spr); + var sw = sprite_get_width(spr); + var sh = sprite_get_height(spr); var s = min(gw / sw, gh / sh) * 2; - draw_sprite_ui_uniform(_node.spr, 0, _boxx + grid_width / 2, yy + grid_heigh / 2, s); + + var ox = (sprite_get_xoffset(spr) - sw / 2) * s / 2; + var oy = (sprite_get_yoffset(spr) - sh / 2) * s / 2; + + draw_sprite_ui_uniform(spr, 0, _boxx + grid_width / 2 + ox, yy + grid_heigh / 2 + ox, s); } var tx = _boxx + grid_width / 2; var ty = yy + grid_heigh + ui(4); draw_set_text(f_p2, fa_center, fa_top); - var _tw = string_width(_node.tag); - var _th = string_height(_node.tag); + if(project_page == 0) { + var _tw = string_width(_project.tag); + var _th = string_height(_project.tag); - draw_set_color(COLORS.dialog_splash_badge); - draw_roundrect_ext(tx - _tw / 2 - ui(6), ty - ui(2), tx + _tw / 2 + ui(6), ty + _th, ui(8), ui(8), 0); - draw_set_color(_node.tag == "Getting started"? COLORS._main_text_accent : COLORS._main_text_sub); - draw_text(tx, ty - ui(2), _node.tag); + draw_set_color(COLORS.dialog_splash_badge); + draw_roundrect_ext(tx - _tw / 2 - ui(6), ty - ui(2), tx + _tw / 2 + ui(6), ty + _th, ui(8), ui(8), 0); + draw_set_color(_project.tag == "Getting started"? COLORS._main_text_accent : COLORS._main_text_sub); + draw_text(tx, ty - ui(2), _project.tag); + + ty += line_height(); + } draw_set_text(f_p1, fa_center, fa_top, COLORS._main_text); - name_height = max(name_height, string_height_ext(_node.name, -1, grid_width) + ui(8)); - draw_text_ext_add(tx, ty + line_height() - ui(2), _node.name, -1, grid_width); + name_height = max(name_height, string_height_ext(_project.name, -1, grid_width) + ui(8)); + draw_text_ext_add(tx, ty - ui(2), _project.name, -1, grid_width); } } var hght = grid_heigh + grid_space + name_height + ui(20); diff --git a/objects/o_dialog_splash/Draw_64.gml b/objects/o_dialog_splash/Draw_64.gml index eea7768c6..db7d70a03 100644 --- a/objects/o_dialog_splash/Draw_64.gml +++ b/objects/o_dialog_splash/Draw_64.gml @@ -49,13 +49,40 @@ if !ready exit; x0 = x1 + ui(16); x1 = dialog_x + dialog_w - ui(16); - draw_set_text(f_p0, fa_left, fa_bottom, COLORS._main_text_sub); - draw_text(x0, y0 - ui(4), "Sample projects"); + var bx = x0; + + for( var i = 0; i < array_length(pages); i++ ) { + draw_set_text(f_p0, fa_left, fa_bottom, COLORS._main_text_sub); + var tw = string_width(pages[i]) + ui(16); + + if(project_page == i) + draw_sprite_stretched(THEME.ui_panel_bg, 0, bx, y0 - ui(32), tw, ui(40)); + else if(point_in_rectangle(mouse_mx, mouse_my, bx, y0 - ui(32), bx + tw, y0)) { + draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, bx, y0 - ui(32), tw, ui(40), c_white, 0.5); + + if(mouse_click(mb_left, sFOCUS)) + project_page = i; + } + + draw_text(bx + ui(8), y0 - ui(4), pages[i]); + + bx += tw; + } + draw_sprite_stretched(THEME.ui_panel_bg, 0, x0, y0, x1 - x0, y1 - y0); sp_sample.active = sFOCUS; sp_sample.draw(x0 + ui(6), y0); - draw_set_text(f_p1, fa_right, fa_bottom, COLORS._main_text_sub); - draw_text(x1 - ui(82), y0 - ui(4), "Art by "); - draw_sprite_ui_uniform(s_kenney, 0, x1, y0 - ui(4), 2, c_white, 0.5); + if(project_page == 0) { + draw_set_text(f_p1, fa_right, fa_bottom, COLORS._main_text_sub); + draw_text(x1 - ui(82), y0 - ui(4), "Art by "); + draw_sprite_ui_uniform(s_kenney, 0, x1, y0 - ui(4), 2, c_white, 0.5); + } else if(project_page == 1) { + var bx = x1 - ui(32); + var by = y0 - ui(32); + + if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), mouse_ui, sFOCUS, sHOVER, "Open Steam Workshop", THEME.steam) == 2) { + steam_activate_overlay_browser("https://steamcommunity.com/app/2299510/workshop/") + } + } #endregion \ No newline at end of file diff --git a/objects/o_main/Other_69.gml b/objects/o_main/Other_69.gml index 5cb0880ac..3f7a0b354 100644 --- a/objects/o_main/Other_69.gml +++ b/objects/o_main/Other_69.gml @@ -9,28 +9,16 @@ if(string(ev_id) == string(STEAM_UGC_ITEM_ID) && ev_type == "ugc_create_item") { steam_ugc_set_item_title(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.name); steam_ugc_set_item_description(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.description); steam_ugc_set_item_visibility(STEAM_UGC_UPDATE_HANDLE, ugc_visibility_public); - steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.tags); - - var spr = STEAM_UGC_ITEM_FILE.spr; - var spr_path = array_safe_get(STEAM_UGC_ITEM_FILE.spr_path, 0); - var prev_path = "steamUGCthumbnail"; - var prev_size = 512; - var _s = surface_create(prev_size, prev_size); - surface_set_target(_s); - draw_clear(COLORS._main_icon_dark); - draw_sprite_tiled(s_workshop_background, 0, -64, -64); - draw_sprite_stretched(s_workshop_frame, 0, 0, 0, prev_size, prev_size); - - if(spr == -1) spr = THEME.group; - var ss = (prev_size - 160) / max(sprite_get_width(spr), sprite_get_height(spr)); - var ox = (sprite_get_xoffset(spr) - sprite_get_width(spr) / 2) * ss; - var oy = (sprite_get_yoffset(spr) - sprite_get_height(spr) / 2) * ss; - draw_sprite_ext(spr, 0, prev_size / 2 + ox, prev_size / 2 + oy, ss, ss, 0, c_white, 1); - surface_reset_target(); - surface_save(_s, prev_path); - surface_free(_s); - steam_ugc_set_item_preview(STEAM_UGC_UPDATE_HANDLE, prev_path); + var tgs = array_clone(STEAM_UGC_ITEM_FILE.meta.tags); + switch(STEAM_UGC_TYPE) { + case STEAM_UGC_FILE_TYPE.collection : array_insert(tgs, 0, "Collection"); break; + case STEAM_UGC_FILE_TYPE.project : array_insert(tgs, 0, "Project"); break; + case STEAM_UGC_FILE_TYPE.node_preset : array_insert(tgs, 0, "Node preset"); break; + } + + steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, tgs); + steam_ugc_set_item_preview(STEAM_UGC_UPDATE_HANDLE, "steamUGCthumbnail.png"); steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, "steamUGC"); STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, "Uploaded"); @@ -40,12 +28,19 @@ if(string(ev_id) == string(STEAM_UGC_ITEM_ID) && ev_type == "ugc_create_item") { if(string(ev_id) == string(STEAM_UGC_SUBMIT_ID)) { STEAM_UGC_ITEM_UPLOADING = false; + var type = ""; + switch(STEAM_UGC_TYPE) { + case STEAM_UGC_FILE_TYPE.collection : type = "Collection"; break; + case STEAM_UGC_FILE_TYPE.project : type = "Project"; break; + case STEAM_UGC_FILE_TYPE.node_preset : type = "Node preset"; break; + } + if(async_load[? "result"] == ugc_result_success) { if(STEAM_UGC_UPDATE) { - log_message("WORKSHOP", "collection updated", THEME.workshop_update); + log_message("WORKSHOP", type + " updated", THEME.workshop_update); PANEL_MENU.setNotiIcon(THEME.workshop_update); } else { - log_message("WORKSHOP", "collection uploaded", THEME.workshop_upload); + log_message("WORKSHOP", type + " uploaded", THEME.workshop_upload); PANEL_MENU.setNotiIcon(THEME.workshop_upload); } exit; diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index e42c0978e..32a11f5fd 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -24,6 +24,27 @@ } #endregion +#region auto save + AUTO_SAVE_TIMER += delta_time / 1_000_000; + + if(PREF_MAP[? "auto_save_time"] > 0 && AUTO_SAVE_TIMER > PREF_MAP[? "auto_save_time"]) { + AUTO_SAVE_TIMER = 0; + var loc = DIRECTORY + "Autosave\\"; + if(!directory_exists(loc)) + directory_create(loc); + + var fname = string_replace(filename_name(CURRENT_PATH), filename_ext(CURRENT_PATH), "") + + "_autosave" + string(current_year) + "-" + + string_lead_zero(current_month, 2) + "-" + + string_lead_zero(current_day, 2) + "T" + + string_lead_zero(current_hour, 2) + + string_lead_zero(current_minute, 2) + + string_lead_zero(current_second, 2) + ".pxc"; + + SAVE_AT(loc + fname, "Autosaved "); + } +#endregion + #region nodes var _k = ds_map_find_first(NODE_MAP); var _a = ds_map_size(NODE_MAP); diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index 951d3c640..f7a182fc6 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -29,7 +29,6 @@ function FileObject(_name, _path) constructor { static getMetadata = function() { if(!file_exists(path)) return noone; - if(filename_ext(path) != ".pxcc") return noone; if(meta != noone) return meta; if(meta == undefined) return noone; @@ -39,11 +38,10 @@ function FileObject(_name, _path) constructor { var m = json_decode(_f); - if(ds_map_exists(m, "metadata")) { - meta = new MetaDataManager(); + meta = new MetaDataManager(); + if(ds_map_exists(m, "metadata")) meta.deserialize(m[? "metadata"]); - } else - meta = undefined; + meta.version = m[? "version"]; meta.name = name; diff --git a/scripts/meta_data/meta_data.gml b/scripts/meta_data/meta_data.gml index 3b657b8e1..bda36941d 100644 --- a/scripts/meta_data/meta_data.gml +++ b/scripts/meta_data/meta_data.gml @@ -20,6 +20,7 @@ function MetaDataManager() constructor { [ get_text("author", "Author"), function(meta) { return meta.author; } , line_height() ], [ get_text("contact_info", "Contact info"), function(meta) { return meta.contact; } , line_height() ], [ get_text("alias", "Alias"), function(meta) { return meta.alias; } , line_height() ], + [ get_text("tags", "Tags"), function(meta) { return meta.tags; } , line_height() ], ]; static serialize = function() { diff --git a/scripts/node_blend/node_blend.gml b/scripts/node_blend/node_blend.gml index e397b7ebc..35830f3d1 100644 --- a/scripts/node_blend/node_blend.gml +++ b/scripts/node_blend/node_blend.gml @@ -42,15 +42,23 @@ function Node_Blend(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constr active_index = 8; inputs[| 9] = nodeValue("Preserve alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); + + inputs[| 10] = nodeValue("Horizontal Align", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.enum_button, [ THEME.inspector_surface_halign, THEME.inspector_surface_halign, THEME.inspector_surface_halign]); + + inputs[| 11] = nodeValue("Vertical Align", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.enum_button, [ THEME.inspector_surface_valign, THEME.inspector_surface_valign, THEME.inspector_surface_valign]); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); input_display_list = [ 8, ["Surfaces", true], 0, 1, 4, 6, 7, ["Blend", false], 2, 3, 9, - ["Transform", false], 5, + ["Transform", false], 5, 10, 11, ] + temp = surface_create(1, 1); + static process_data = function(_outSurf, _data, _output_index, _array_index) { var _back = _data[0]; var _fore = _data[1]; @@ -63,8 +71,48 @@ function Node_Blend(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constr var _out_dim = _data[7]; var _pre_alp = _data[9]; + var _halign = _data[10]; + var _valign = _data[11]; + inputs[| 7].setVisible(_outp == 4); var ww = 1, hh = 1; + var _foreDraw = _fore; + + inputs[| 10].setVisible(_tile == 0); + inputs[| 11].setVisible(_tile == 0); + + if(_tile == 0) { + ww = surface_get_width(_back); + hh = surface_get_height(_back); + + var fw = surface_get_width(_fore); + var fh = surface_get_height(_fore); + + temp = surface_verify(temp, ww, hh); + _foreDraw = temp; + + var sx = 0; + var sy = 0; + + switch(_halign) { + case 0 : sx = 0; break; + case 1 : sx = ww / 2 - fw / 2; break; + case 2 : sx = ww - fw; break; + } + + switch(_valign) { + case 0 : sy = 0; break; + case 1 : sy = hh / 2 - fh / 2; break; + case 2 : sy = hh - fh; break; + } + + surface_set_target(temp); + draw_clear_alpha(0, 0); + BLEND_OVER_ALPHA + draw_surface(_fore, sx, sy); + BLEND_NORMAL + surface_reset_target(); + } switch(_outp) { case 0 : @@ -72,16 +120,16 @@ function Node_Blend(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constr hh = surface_get_height(_back); break; case 1 : - ww = surface_get_width(_fore); - hh = surface_get_height(_fore); + ww = surface_get_width(_foreDraw); + hh = surface_get_height(_foreDraw); break; case 2 : ww = surface_get_width(_mask); hh = surface_get_height(_mask); break; case 3 : - ww = max(surface_get_width(_back), surface_get_width(_fore), surface_get_width(_mask)); - hh = max(surface_get_height(_back), surface_get_height(_fore), surface_get_height(_mask)); + ww = max(surface_get_width(_back), surface_get_width(_foreDraw), surface_get_width(_mask)); + hh = max(surface_get_height(_back), surface_get_height(_foreDraw), surface_get_height(_mask)); break; case 4 : ww = _out_dim[0]; @@ -93,7 +141,7 @@ function Node_Blend(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constr surface_set_target(_outSurf); draw_clear_alpha(0, 0); - draw_surface_blend(_back, _fore, _type, _opacity, _pre_alp, _mask, _tile - 1); + draw_surface_blend(_back, _foreDraw, _type, _opacity, _pre_alp, _mask, max(0, _tile - 1)); surface_reset_target(); return _outSurf; diff --git a/scripts/node_export/node_export.gml b/scripts/node_export/node_export.gml index 3c0ea6105..2878e8e7b 100644 --- a/scripts/node_export/node_export.gml +++ b/scripts/node_export/node_export.gml @@ -90,7 +90,7 @@ function Node_Export(_x, _y, _group = -1) : Node(_x, _y, _group) constructor { directory = DIRECTORY + "temp\\" + string(irandom_range(100000, 999999)); converter = working_directory + "ImageMagick\\convert.exe"; magick = working_directory + "ImageMagick\\magick.exe"; - webp = working_directory + "webp\\bin\\webpmux.exe"; + webp = working_directory + "webp\\webpmux.exe"; static onValueUpdate = function(_index) { var form = inputs[| 3].getValue(); diff --git a/scripts/node_repeat/node_repeat.gml b/scripts/node_repeat/node_repeat.gml index 2a846e2cc..42056f895 100644 --- a/scripts/node_repeat/node_repeat.gml +++ b/scripts/node_repeat/node_repeat.gml @@ -44,7 +44,7 @@ function Node_Repeat(_x, _y, _group = -1) : Node(_x, _y, _group) constructor { inputs[| 15] = nodeValue("Alpha over copy", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11 ); - inputs[| 16] = nodeValue("Array select", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "Whether to select image from an array in order, or at random." ) + inputs[| 16] = nodeValue("Array select", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "Whether to select image from an array in order, at random, pr spread or each image to one output." ) .setDisplay(VALUE_DISPLAY.enum_button, [ "Order", "Random", "Spread" ]); inputs[| 17] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom(99999) ); diff --git a/scripts/notification_system/notification_system.gml b/scripts/notification_system/notification_system.gml index d7e2b6437..26d1264c1 100644 --- a/scripts/notification_system/notification_system.gml +++ b/scripts/notification_system/notification_system.gml @@ -61,7 +61,8 @@ ds_list_add(WARNING, noti); show_debug_message(str); - dialogCall(o_dialog_warning, mouse_mx + ui(16), mouse_my + ui(16)).warning_text = str; + if(!instance_exists(o_dialog_warning)) + dialogCall(o_dialog_warning, mouse_mx + ui(16), mouse_my + ui(16)).warning_text = str; if(PANEL_MENU) { PANEL_MENU.noti_flash = 1; diff --git a/scripts/sample_projects/sample_projects.gml b/scripts/sample_projects/sample_projects.gml index 50c9c077b..9fb350d52 100644 --- a/scripts/sample_projects/sample_projects.gml +++ b/scripts/sample_projects/sample_projects.gml @@ -6,8 +6,9 @@ function LOAD_FOLDER(list, folder) { var path = directory_get_current_working() + folder; var file = file_find_first(path + "/*", fa_directory); + while(file != "") { - if(filename_ext(file) == ".json" || filename_ext(file) == ".pxc") { + if(filename_ext(file) == ".pxc") { var full_path = path + "\\" + file; var f = new FileObject(string_replace(filename_name(file), filename_ext(file), ""), full_path); var icon_path = string_replace(full_path, filename_ext(full_path), ".png"); diff --git a/scripts/scrollPane/scrollPane.gml b/scripts/scrollPane/scrollPane.gml index 9ffb90bdd..ff400c5a5 100644 --- a/scripts/scrollPane/scrollPane.gml +++ b/scripts/scrollPane/scrollPane.gml @@ -3,6 +3,8 @@ function scrollPane(_w, _h, ondraw) : widget() constructor { scroll_y_raw = 0; scroll_y_to = 0; + x = 0; + y = 0; w = _w; h = _h; surface_w = _w - ui(12); @@ -34,6 +36,9 @@ function scrollPane(_w, _h, ondraw) : widget() constructor { } static draw = function(x, y, _mx = mouse_mx - x, _my = mouse_my - y) { + self.x = x; + self.y = y; + var mx = _mx, my = _my; hover = point_in_rectangle(mx, my, 0, 0, surface_w, surface_h); diff --git a/scripts/steam_ugc_functions/steam_ugc_functions.gml b/scripts/steam_ugc_functions/steam_ugc_functions.gml new file mode 100644 index 000000000..52f53dbfd --- /dev/null +++ b/scripts/steam_ugc_functions/steam_ugc_functions.gml @@ -0,0 +1,88 @@ +function __initSteamUGC() { + globalvar STEAM_SUBS, STEAM_COLLECTION, STEAM_PROJECTS; + STEAM_SUBS = ds_list_create(); + STEAM_COLLECTION = ds_list_create(); + STEAM_PROJECTS = ds_list_create(); + + if(!STEAM_ENABLED) return; + + steam_ugc_get_subscribed_items(STEAM_SUBS); + + for( var i = 0; i < ds_list_size(STEAM_SUBS); i++ ) { + var item_map = ds_map_create(); + //print("Querying item ID " + string(STEAM_SUBS[| i])); + + if (steam_ugc_get_item_install_info(STEAM_SUBS[| i], item_map)) { + var info_map = ds_map_create(); + var _update = false; + + if (steam_ugc_get_item_update_info(STEAM_SUBS[| i], info_map)) + _update = info_map[? "needs_update"]; + + ds_map_destroy(info_map); + + if(_update) { + steam_ugc_subscribe_item(STEAM_SUBS[| i]); + //print("Item need update"); + } else { + __loadSteamUGC(STEAM_SUBS[| i], item_map); + } + } else { + steam_ugc_subscribe_item(STEAM_SUBS[| i]); + //print("Item not downloaded"); + } + + ds_map_destroy(item_map); + } +} + +function __loadSteamUGC(file_id, item_map) { + var _path = item_map[? "folder"]; + + var f = file_find_first(_path + "\\*.pxcc", 0); + file_find_close(); + if(f != "") { + __loadSteamUGCCollection(file_id, f, _path); + return; + } + + var p = file_find_first(_path + "\\*.pxc", 0); + file_find_close(); + if(p != "") { + __loadSteamUGCProject(file_id, p, _path); + return; + } +} + +function __loadSteamUGCCollection(file_id, f, path) { + var name = string_replace(filename_name(f), ".pxc", ""); + var file = new FileObject(name, path + "\\" + f); + var icon_path = string_replace(path + "\\" + f, ".pxcc", ".png"); + if(file_exists(icon_path)) { + var _temp = sprite_add(icon_path, 0, false, false, 0, 0); + var ww = sprite_get_width(_temp); + var hh = sprite_get_height(_temp); + var amo = ww % hh == 0? ww / hh : 1; + sprite_delete(_temp); + file.spr_path = [icon_path, amo, false]; + } + + ds_list_add(STEAM_COLLECTION, file); + + var meta = file.getMetadata(); + meta.steam = true; + meta.file_id = file_id; +} + +function __loadSteamUGCProject(file_id, f, path) { + var name = string_replace(filename_name(f), ".pxc", ""); + var file = new FileObject(name, path + "\\" + f); + var icon_path = path + "\\thumbnail.png"; + file.spr_path = [icon_path, 1, false]; + + ds_list_add(STEAM_PROJECTS, file); + + var meta = file.getMetadata(); + meta.steam = true; + meta.file_id = file_id; +} diff --git a/scripts/steam_ugc_project/steam_ugc_project.gml b/scripts/steam_ugc_project/steam_ugc_project.gml new file mode 100644 index 000000000..8c96c05a8 --- /dev/null +++ b/scripts/steam_ugc_project/steam_ugc_project.gml @@ -0,0 +1,78 @@ +function steam_ugc_create_project() { + if(STEAM_UGC_ITEM_UPLOADING) return; + + var file = new FileObject(string_replace(filename_name(CURRENT_PATH), filename_ext(CURRENT_PATH), ""), CURRENT_PATH); + file.getMetadata(); + file.spr_path = "steamUGC/thumbnail.png"; + + STEAM_UGC_UPDATE = false; + STEAM_UGC_ITEM_UPLOADING = true; + STEAM_UGC_ITEM_FILE = file; + STEAM_UGC_TYPE = STEAM_UGC_FILE_TYPE.project; + + directory_destroy("steamUGC"); + directory_create("steamUGC"); + file_copy(file.path, "steamUGC/" + filename_name(file.path)); + + steam_ugc_project_generate(); + file_copy("steamUGCthumbnail.png", "steamUGC/thumbnail.png"); + + print(filename_dir("steamUGCthumbnail.png")) + + STEAM_UGC_ITEM_ID = steam_ugc_create_item(STEAM_APP_ID, ugc_filetype_community); +} + +function steam_ugc_update_project(update_preview = false) { + if(STEAM_UGC_ITEM_UPLOADING) return; + + var file = new FileObject(string_replace(filename_name(CURRENT_PATH), filename_ext(CURRENT_PATH), ""), CURRENT_PATH); + file.getMetadata(); + file.spr_path = "steamUGC/thumbnail.png"; + + STEAM_UGC_UPDATE = true; + STEAM_UGC_ITEM_UPLOADING = true; + STEAM_UGC_ITEM_FILE = file; + STEAM_UGC_TYPE = STEAM_UGC_FILE_TYPE.project; + + directory_destroy("steamUGC"); + directory_create("steamUGC"); + file_copy(file.path, "steamUGC/" + filename_name(file.path)); + file_copy(file.spr_path[0], "steamUGC/thumbnail.png"); + + STEAM_UGC_PUBLISH_ID = file.meta.file_id; + STEAM_UGC_UPDATE_HANDLE = steam_ugc_start_item_update(STEAM_APP_ID, STEAM_UGC_PUBLISH_ID); + + steam_ugc_set_item_title(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.name); + steam_ugc_set_item_description(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.description); + + array_insert(STEAM_UGC_ITEM_FILE.meta.tags, 0, "Project"); + steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.tags); + steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, "steamUGC"); + + STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, "Updated"); +} + +function steam_ugc_project_generate(dest_path = "steamUGCthumbnail.png") { + file_delete(dest_path); + + var preview_surface = PANEL_PREVIEW.getNodePreviewSurface(); + var prev_size = 512; + var _s = surface_create(prev_size, prev_size); + surface_set_target(_s); + draw_clear(COLORS._main_icon_dark); + draw_sprite_tiled(s_workshop_bg, 0, -64, -64); + draw_sprite_stretched(s_workshop_frame, 0, 0, 0, prev_size, prev_size); + + if(is_surface(preview_surface)) { + var ss = (prev_size - 160) / max(surface_get_width(preview_surface), surface_get_height(preview_surface)); + var ox = surface_get_width(preview_surface) / 2 * ss; + var oy = surface_get_height(preview_surface) / 2 * ss; + draw_surface_ext(preview_surface, prev_size / 2 - ox, prev_size / 2 - oy, ss, ss, 0, c_white, 1); + } + + draw_sprite_stretched(s_workshop_badge, 0, 8, 8, 88, 88); + draw_sprite_ext(THEME.project, 0, 40, 40, 1, 1, 0, COLORS._main_icon_dark, 1); + surface_reset_target(); + surface_save(_s, dest_path); + surface_free(_s); +} \ No newline at end of file diff --git a/scripts/string_function/string_function.gml b/scripts/string_function/string_function.gml index 033c0d53e..0bec1b1a8 100644 --- a/scripts/string_function/string_function.gml +++ b/scripts/string_function/string_function.gml @@ -24,7 +24,7 @@ function string_partial_match(str, key) { kchr = string_char_at(key, run); } else { consec = 0; - misMatch++; + misMatch += amo - i; } } diff --git a/scripts/textArrayBox/textArrayBox.gml b/scripts/textArrayBox/textArrayBox.gml index f0595e52d..bd2842a56 100644 --- a/scripts/textArrayBox/textArrayBox.gml +++ b/scripts/textArrayBox/textArrayBox.gml @@ -1,24 +1,27 @@ -function textArrayBox(array, data) : widget() constructor { - self.getArray = array; +function textArrayBox(arraySet, data) : widget() constructor { + self.getArray = arraySet; + self.arraySet = noone; + self.data = data; + hide = false; open = false; - static draw = function(_x, _y, _w, _h, _m) { + static draw = function(_x, _y, _w, _h, _m, _rx = 0, _ry = 0) { x = _x; y = _y; w = _w; - var array = getArray(); + if(getArray != noone) + arraySet = getArray(); var tx = _x + ui(4); var ty = _y + ui(4); - var array = getArray(); var hh = line_height(f_p0, ui(4)); var th = hh + ui(8); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); - for( var i = 0; i < array_length(array); i++ ) { - var ww = string_width(array[i]) + ui(16); + for( var i = 0; i < array_length(arraySet); i++ ) { + var ww = string_width(arraySet[i]) + ui(16); if(tx + ww + ui(2) > _x + _w - ui(8)) { tx = _x + ui(4); ty += hh + ui(2); @@ -37,12 +40,12 @@ function textArrayBox(array, data) : widget() constructor { if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + th)) { draw_sprite_stretched(THEME.textbox, 1, _x, _y, _w, th); if(mouse_press(mb_left, active)) { - with(dialogCall(o_dialog_arrayBox, _x, _y + th)) { + with(dialogCall(o_dialog_arrayBox, _rx + _x, _ry + _y + th)) { arrayBox = other; dialog_w = other.w; } } - } else + } else if(!hide) draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, th, c_white, 0.5 + 0.5 * interactable); } @@ -51,15 +54,15 @@ function textArrayBox(array, data) : widget() constructor { var hh = line_height(f_p0, ui(4)); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); - for( var i = 0; i < array_length(array); i++ ) { - var ww = string_width(array[i]) + ui(16); + for( var i = 0; i < array_length(arraySet); i++ ) { + var ww = string_width(arraySet[i]) + ui(16); if(tx + ww + ui(2) > _x + _w - ui(8)) { tx = _x + ui(4); ty += hh + ui(2); } draw_sprite_stretched_ext(THEME.group_label, 0, tx, ty, ww, hh, COLORS._main_icon, 1); - draw_text(tx + ui(8), ty + hh / 2, array[i]); + draw_text(tx + ui(8), ty + hh / 2, arraySet[i]); tx += ww + ui(2); } diff --git a/shaders/sh_blend_normal/sh_blend_normal.fsh b/shaders/sh_blend_normal/sh_blend_normal.fsh index eabceae4d..97023cba3 100644 --- a/shaders/sh_blend_normal/sh_blend_normal.fsh +++ b/shaders/sh_blend_normal/sh_blend_normal.fsh @@ -35,7 +35,7 @@ void main() { float al = _col0.a + _col1.a * (1. - _col0.a); vec4 res = ((_col0 * _col0.a) + (_col1 * _col1.a * (1. - _col0.a))) / al; res.a = al; - if(preserveAlpha == 1) res.a = _col0.a; + if(preserveAlpha == 1) res.a = _col1.a; gl_FragColor = res; }