diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 48051bc66..a4c167b19 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -120,12 +120,12 @@ {"name":"texts","order":49,"path":"folders/nodes/icons/value/texts.yy",}, {"name":"VFX","order":134,"path":"folders/nodes/icons/VFX.yy",}, {"name":"panels","order":2,"path":"folders/panels.yy",}, - {"name":"colors","order":5,"path":"folders/panels/colors.yy",}, - {"name":"context menu","order":6,"path":"folders/panels/context menu.yy",}, + {"name":"colors","order":4,"path":"folders/panels/colors.yy",}, + {"name":"context menu","order":5,"path":"folders/panels/context menu.yy",}, {"name":"graph","order":1,"path":"folders/panels/graph.yy",}, {"name":"inspectors","order":2,"path":"folders/panels/inspectors.yy",}, {"name":"components","order":3,"path":"folders/panels/inspectors/components.yy",}, - {"name":"preview","order":4,"path":"folders/panels/preview.yy",}, + {"name":"preview","order":3,"path":"folders/panels/preview.yy",}, {"name":"overlay","order":2,"path":"folders/panels/preview/overlay.yy",}, {"name":"sprites","order":3,"path":"folders/panels/preview/sprites.yy",}, {"name":"shader","order":8,"path":"folders/shader.yy",}, @@ -345,6 +345,7 @@ {"name":"s_node_HSV","order":46,"path":"sprites/s_node_HSV/s_node_HSV.yy",}, {"name":"node_point_move","order":8,"path":"scripts/node_point_move/node_point_move.yy",}, {"name":"s_node_3d_cone","order":9,"path":"sprites/s_node_3d_cone/s_node_3d_cone.yy",}, + {"name":"__panel_empty","order":7,"path":"scripts/__panel_empty/__panel_empty.yy",}, {"name":"s_node_compose","order":1,"path":"sprites/s_node_compose/s_node_compose.yy",}, {"name":"s_node_switch","order":20,"path":"sprites/s_node_switch/s_node_switch.yy",}, {"name":"s_node_crop","order":2,"path":"sprites/s_node_crop/s_node_crop.yy",}, @@ -1048,7 +1049,7 @@ {"name":"sh_level","order":11,"path":"shaders/sh_level/sh_level.yy",}, {"name":"sh_grid_tri","order":20,"path":"shaders/sh_grid_tri/sh_grid_tri.yy",}, {"name":"s_node_text","order":1,"path":"sprites/s_node_text/s_node_text.yy",}, - {"name":"panel_menu","order":7,"path":"scripts/panel_menu/panel_menu.yy",}, + {"name":"panel_menu","order":6,"path":"scripts/panel_menu/panel_menu.yy",}, {"name":"s_node_ase_file","order":18,"path":"sprites/s_node_ase_file/s_node_ase_file.yy",}, {"name":"draw_line_round","order":4,"path":"scripts/draw_line_round/draw_line_round.yy",}, {"name":"vectorBox","order":18,"path":"scripts/vectorBox/vectorBox.yy",}, @@ -1220,6 +1221,7 @@ {"name":"sh_blend_luma","order":19,"path":"shaders/sh_blend_luma/sh_blend_luma.yy",}, {"name":"fd_rectangle_set_material_dissipation_value","order":5,"path":"scripts/fd_rectangle_set_material_dissipation_value/fd_rectangle_set_material_dissipation_value.yy",}, {"name":"node_iterator_output","order":2,"path":"scripts/node_iterator_output/node_iterator_output.yy",}, + {"name":"panel_graph_export_image_dialog","order":5,"path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",}, {"name":"debug","order":9,"path":"scripts/debug/debug.yy",}, {"name":"node_shadow_cast","order":15,"path":"scripts/node_shadow_cast/node_shadow_cast.yy",}, {"name":"node_strand_render","order":5,"path":"scripts/node_strand_render/node_strand_render.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 3d0535bc6..496b1a4a7 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1087,6 +1087,7 @@ {"id":{"name":"s_node_HSV","path":"sprites/s_node_HSV/s_node_HSV.yy",},}, {"id":{"name":"node_point_move","path":"scripts/node_point_move/node_point_move.yy",},}, {"id":{"name":"s_node_3d_cone","path":"sprites/s_node_3d_cone/s_node_3d_cone.yy",},}, + {"id":{"name":"__panel_empty","path":"scripts/__panel_empty/__panel_empty.yy",},}, {"id":{"name":"s_node_compose","path":"sprites/s_node_compose/s_node_compose.yy",},}, {"id":{"name":"s_node_switch","path":"sprites/s_node_switch/s_node_switch.yy",},}, {"id":{"name":"s_node_crop","path":"sprites/s_node_crop/s_node_crop.yy",},}, @@ -2083,6 +2084,7 @@ {"id":{"name":"sh_blend_luma","path":"shaders/sh_blend_luma/sh_blend_luma.yy",},}, {"id":{"name":"fd_rectangle_set_material_dissipation_value","path":"scripts/fd_rectangle_set_material_dissipation_value/fd_rectangle_set_material_dissipation_value.yy",},}, {"id":{"name":"node_iterator_output","path":"scripts/node_iterator_output/node_iterator_output.yy",},}, + {"id":{"name":"panel_graph_export_image_dialog","path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",},}, {"id":{"name":"debug","path":"scripts/debug/debug.yy",},}, {"id":{"name":"node_shadow_cast","path":"scripts/node_shadow_cast/node_shadow_cast.yy",},}, {"id":{"name":"node_strand_render","path":"scripts/node_strand_render/node_strand_render.yy",},}, diff --git a/scripts/__panel_empty/__panel_empty.gml b/scripts/__panel_empty/__panel_empty.gml new file mode 100644 index 000000000..f05d36cca --- /dev/null +++ b/scripts/__panel_empty/__panel_empty.gml @@ -0,0 +1,9 @@ +function Panel_Empty() : PanelContent() constructor { + title = "Title"; + w = ui(640); + h = ui(320); + + function drawContent(panel) { + //Implement draw code here + } +} \ No newline at end of file diff --git a/scripts/__panel_empty/__panel_empty.yy b/scripts/__panel_empty/__panel_empty.yy new file mode 100644 index 000000000..85d395461 --- /dev/null +++ b/scripts/__panel_empty/__panel_empty.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__panel_empty", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "panels", + "path": "folders/panels.yy", + }, +} \ No newline at end of file diff --git a/scripts/__panel_empty/panel_console.gml b/scripts/__panel_empty/panel_console.gml new file mode 100644 index 000000000..5dff86a32 --- /dev/null +++ b/scripts/__panel_empty/panel_console.gml @@ -0,0 +1,73 @@ +function Panel_Console() : PanelContent() constructor { + title = "Console"; + w = ui(640); + h = ui(320); + + command = ""; + history = []; + cmd_history = []; + + cmd_index = 0; + + keyboard_string = ""; + + static submit_command = function() { + if(command == "") return; + array_push(history, { txt: command, color: COLORS._main_text_sub }); + array_push(cmd_history, command); + + var cmd = string_splice(command, " "); + + switch(cmd[0]) { + case "flag": + if(array_length(cmd) < 2) break; + var flg = array_safe_get(cmd, 1, ""); + global.FLAG[$ flg] = !global.FLAG[$ flg]; + + array_push(history, { txt: $"Toggled debug flag: {flg} = {global.FLAG[$ flg]? "True" : "False"}", color: COLORS._main_value_positive }); + break; + } + + keyboard_string = ""; + command = ""; + } + + function drawContent(panel) { + HOTKEY_BLOCK = true; + command = keyboard_string; + + draw_clear_alpha(CDEF.main_dkblack, 1); + + draw_set_color(c_black); + draw_set_alpha(0.75); + draw_rectangle(0, h - ui(28), w, h, false); + draw_set_alpha(1); + + draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text); + draw_text(ui(8), h - ui(4), command); + draw_set_color(COLORS._main_text_sub); + draw_text(ui(8) + string_width(command), h - ui(4), "_"); + + var hy = h - ui(32); + for( var i = 0; i < array_length(history); i++ ) { + var his = history[array_length(history) - i - 1]; + var txt = his.txt; + + draw_set_color(his.color); + draw_text_ext(ui(8), hy, txt, -1, w - ui(16)); + hy -= string_height_ext(txt, -1, w - ui(16)); + + if(hy <= 0) break; + } + + if(keyboard_check_pressed(vk_enter)) + submit_command(); + + if(keyboard_check_pressed(vk_up)) { + cmd_index = max(0, cmd_index - 1); + keyboard_string = array_safe_get(cmd_history, cmd_index, ""); + command = keyboard_string; + } else if(keyboard_check_pressed(vk_anykey)) + cmd_index = array_length(cmd_history); + } +} \ No newline at end of file diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 7c93641bc..8143b5502 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -19,7 +19,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x recordAction(ACTION_TYPE.node_added, self); NODE_MAP[? node_id] = self; MODIFIED = true; - } else { + run_in(1, function() { var str = string_replace_all(name, " ", "_"); str = string_replace_all(str, "/", ""); diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index a45d7c539..1fccaaa8f 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1738,13 +1738,13 @@ function Panel_Graph() : PanelContent() constructor { var context = instanceof(getCurrentContext()); switch(context) { case "Node_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_collection, 0.05); break; - case "Node_Iterate" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_loop, 0.05); break; - case "Node_Iterate_Each" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_loop, 0.05); break; - case "Node_VFX_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_vfx, 0.05); break; - case "Node_Feedback" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_feedback, 0.05); break; + case "Node_Iterate" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_loop, 0.05); break; + case "Node_Iterate_Each" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_loop, 0.05); break; + case "Node_VFX_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_vfx, 0.05); break; + case "Node_Feedback" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_feedback, 0.05); break; case "Node_Rigid_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_simulation, 0.05); break; - case "Node_Fluid_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_fluid, 0.05); break; - case "Node_Strand_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_strand, 0.05); break; + case "Node_Fluid_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_fluid, 0.05); break; + case "Node_Strand_Group" : bg = merge_color(COLORS.panel_bg_clear, COLORS.node_blend_strand, 0.05); break; } draw_clear(bg); @@ -1875,4 +1875,8 @@ function Panel_Graph() : PanelContent() constructor { ds_list_remove(nodes_list, node); ds_list_add(nodes_list, node); } + + static exportNodeImage = function() { + var dia = dialogPanelCall(new Panel_Graph_Export_Image(self)); + } } \ No newline at end of file diff --git a/scripts/panel_graph_export_image/panel_graph_export_image.gml b/scripts/panel_graph_export_image/panel_graph_export_image.gml index ea08bd78d..07cbf5ba2 100644 --- a/scripts/panel_graph_export_image/panel_graph_export_image.gml +++ b/scripts/panel_graph_export_image/panel_graph_export_image.gml @@ -1,3 +1,85 @@ -function Script659(){ - +function graph_export_image(nodeList, settings = {}) { + var amo = ds_list_size(nodeList); + if(amo < 1) return; + + var scale = struct_try_get(settings, "scale", 1); + var padding = struct_try_get(settings, "padding", 0); + var bgEnable = struct_try_get(settings, "bgEnable", false); + var bgColor = struct_try_get(settings, "bgColor", c_black); + var gridEnable = struct_try_get(settings, "gridEnable", false); + var gridColor = struct_try_get(settings, "gridColor", c_black); + + var bbox_x0 = nodeList[| 0].x * scale; + var bbox_y0 = nodeList[| 0].y * scale; + var bbox_x1 = bbox_x0 + nodeList[| 0].w * scale; + var bbox_y1 = bbox_y0 + nodeList[| 0].h * scale; + + for( var i = 0; i < ds_list_size(nodeList); i++ ) { + var _node = nodeList[| i]; + + var _x = _node.x * scale; + var _y = _node.y * scale; + var _w = _node.w * scale; + var _h = _node.h * scale; + + bbox_x0 = min(bbox_x0, _x - padding); + bbox_y0 = min(bbox_y0, _y - padding); + bbox_x1 = max(bbox_x1, _x + _w + padding); + bbox_y1 = max(bbox_y1, _y + _h + padding); + } + + var bbox_w = bbox_x1 - bbox_x0; + var bbox_h = bbox_y1 - bbox_y0; + + var aa = PREF_MAP[? "connection_line_aa"]; + var s = surface_create(bbox_w, bbox_h); + var cs = surface_create(bbox_w * aa, bbox_h * aa); + + surface_set_target(s); //draw nodes + if(bgEnable) draw_clear(bgColor); + else draw_clear_alpha(0, 0); + + var gr_x = -bbox_x0; + var gr_y = -bbox_y0; + var mx = gr_x, my = gr_y; + + for(var i = 0; i < ds_list_size(nodeList); i++) + nodeList[| i].preDraw(gr_x, gr_y, scale); + + #region draw frame + for(var i = 0; i < ds_list_size(nodeList); i++) { + if(instanceof(nodeList[| i]) != "Node_Frame") continue; + nodeList[| i].drawNode(gr_x, gr_y, mx, my, scale); + } + #endregion + + #region draw conneciton + surface_set_target(cs); + DRAW_CLEAR + for(var i = 0; i < ds_list_size(nodeList); i++) + nodeList[| i].drawConnections(gr_x, gr_y, scale, mx, my, true, aa); + surface_reset_target(); + + shader_set(sh_downsample); + shader_set_f("down", aa); + shader_set_f("dimension", surface_get_width(cs), surface_get_height(cs)); + draw_surface(cs, 0, 0); + shader_reset(); + surface_free(cs); + #endregion + + #region draw node + for(var i = 0; i < ds_list_size(nodeList); i++) + nodeList[| i].onDrawNodeBehind(gr_x, gr_y, mx, my, scale); + + for(var i = 0; i < ds_list_size(nodeList); i++) { + var n = nodeList[| i]; + if(instanceof(n) == "Node_Frame") continue; + var val = n.drawNode(gr_x, gr_y, mx, my, scale); + } + #endregion + + surface_reset_target(); + + return s; } \ No newline at end of file diff --git a/scripts/panel_graph_export_image_dialog/panel_console.gml b/scripts/panel_graph_export_image_dialog/panel_console.gml new file mode 100644 index 000000000..5dff86a32 --- /dev/null +++ b/scripts/panel_graph_export_image_dialog/panel_console.gml @@ -0,0 +1,73 @@ +function Panel_Console() : PanelContent() constructor { + title = "Console"; + w = ui(640); + h = ui(320); + + command = ""; + history = []; + cmd_history = []; + + cmd_index = 0; + + keyboard_string = ""; + + static submit_command = function() { + if(command == "") return; + array_push(history, { txt: command, color: COLORS._main_text_sub }); + array_push(cmd_history, command); + + var cmd = string_splice(command, " "); + + switch(cmd[0]) { + case "flag": + if(array_length(cmd) < 2) break; + var flg = array_safe_get(cmd, 1, ""); + global.FLAG[$ flg] = !global.FLAG[$ flg]; + + array_push(history, { txt: $"Toggled debug flag: {flg} = {global.FLAG[$ flg]? "True" : "False"}", color: COLORS._main_value_positive }); + break; + } + + keyboard_string = ""; + command = ""; + } + + function drawContent(panel) { + HOTKEY_BLOCK = true; + command = keyboard_string; + + draw_clear_alpha(CDEF.main_dkblack, 1); + + draw_set_color(c_black); + draw_set_alpha(0.75); + draw_rectangle(0, h - ui(28), w, h, false); + draw_set_alpha(1); + + draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text); + draw_text(ui(8), h - ui(4), command); + draw_set_color(COLORS._main_text_sub); + draw_text(ui(8) + string_width(command), h - ui(4), "_"); + + var hy = h - ui(32); + for( var i = 0; i < array_length(history); i++ ) { + var his = history[array_length(history) - i - 1]; + var txt = his.txt; + + draw_set_color(his.color); + draw_text_ext(ui(8), hy, txt, -1, w - ui(16)); + hy -= string_height_ext(txt, -1, w - ui(16)); + + if(hy <= 0) break; + } + + if(keyboard_check_pressed(vk_enter)) + submit_command(); + + if(keyboard_check_pressed(vk_up)) { + cmd_index = max(0, cmd_index - 1); + keyboard_string = array_safe_get(cmd_history, cmd_index, ""); + command = keyboard_string; + } else if(keyboard_check_pressed(vk_anykey)) + cmd_index = array_length(cmd_history); + } +} \ No newline at end of file diff --git a/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.gml b/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.gml new file mode 100644 index 000000000..2e4863209 --- /dev/null +++ b/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.gml @@ -0,0 +1,34 @@ +function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor { + title = "Export Graph"; + w = ui(480); + h = ui(640); + + self.targetPanel = targetPanel; + + surface = noone; + settings = {}; + + nodeList = noone; + + function refresh() { + if(is_surface(surface)) + surface_free(surface); + surface = noone; + + if(nodeList == noone) + return; + + surface = graph_export_image(nodeList, settings); + } + + function drawContent(panel) { + + + if(is_surface(surface)) { + + } + + var tx = 0; + var ty = 0; + } +} \ No newline at end of file diff --git a/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy b/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy new file mode 100644 index 000000000..3a9c7482e --- /dev/null +++ b/scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "panel_graph_export_image_dialog", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "graph", + "path": "folders/panels/graph.yy", + }, +} \ No newline at end of file diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 50bae7fc2..cee271db9 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -544,7 +544,7 @@ function Panel_Inspector() : PanelContent() constructor { draw_set_text(f_p3, fa_center, fa_center, COLORS._main_text_sub); draw_set_alpha(0.65); - draw_text(w / 2, ui(76), inspecting.internalName); + draw_text_add(w / 2, ui(76), inspecting.internalName); draw_set_alpha(1); var lx = w / 2 - string_width(inspecting.name) / 2 - ui(16); diff --git a/scripts/struct_functions/struct_functions.gml b/scripts/struct_functions/struct_functions.gml index 6ab337b2e..88b3c094d 100644 --- a/scripts/struct_functions/struct_functions.gml +++ b/scripts/struct_functions/struct_functions.gml @@ -9,4 +9,8 @@ function struct_override(original, override) { } return original; +} + +function struct_try_get(struct, key, def = 0) { + return struct_has(struct, key)? struct[$ key] : def; } \ No newline at end of file