diff --git a/objects/o_main/Draw_75.gml b/objects/o_main/Draw_75.gml index f780b2ec7..cb6301d09 100644 --- a/objects/o_main/Draw_75.gml +++ b/objects/o_main/Draw_75.gml @@ -82,6 +82,16 @@ draw_rectangle(mouse_mx + ui(-16), mouse_my + ui(-16), mouse_mx + ui(-16 + 32), mouse_my + ui(-16 + 32), false); draw_set_alpha(1); break; + case "Asset" : + var ss = 32 / max(sprite_get_width(DRAGGING.data.spr), sprite_get_height(DRAGGING.data.spr)) + draw_sprite_ext(DRAGGING.data.spr, 0, mouse_mx, mouse_my, ss, ss, 0, c_white, 0.5); + break; + case "Collection" : + if(DRAGGING.data.spr) { + var ss = 32 / max(sprite_get_width(DRAGGING.data.spr), sprite_get_height(DRAGGING.data.spr)) + draw_sprite_ext(DRAGGING.data.spr, 0, mouse_mx, mouse_my, ss, ss, 0, c_white, 0.5); + } + break; } if(mouse_release(mb_left)) diff --git a/scripts/append_function/append_function.gml b/scripts/append_function/append_function.gml index b12d841d1..94fa07529 100644 --- a/scripts/append_function/append_function.gml +++ b/scripts/append_function/append_function.gml @@ -1,4 +1,4 @@ -function APPEND(_path, record = true) { +function APPEND(_path, context = PANEL_GRAPH.getCurrentContext()) { if(_path == "") return noone; var _map = json_load(_path); @@ -7,14 +7,14 @@ function APPEND(_path, record = true) { return noone; } - var node_create = __APPEND_MAP(_map); - if(record) recordAction(ACTION_TYPE.collection_loaded, array_create_from_list(node_create), _path); + var node_create = __APPEND_MAP(_map, context); + recordAction(ACTION_TYPE.collection_loaded, array_create_from_list(node_create), _path); log_message("FILE", "append file " + _path, THEME.noti_icon_file_load); return node_create; } -function __APPEND_MAP(_map) { +function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { static log = false; APPENDING = true; UNDO_HOLDING = true; @@ -48,7 +48,7 @@ function __APPEND_MAP(_map) { var _node = appended_list[| i]; _node.loadGroup(); - if(_node.group == PANEL_GRAPH.getCurrentContext()) + if(_node.group == context) ds_list_add(node_create, _node); } } catch(e) { diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index 8a2101c8c..affa10956 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -6,6 +6,18 @@ function FileObject(_name, _path) constructor { content = -1; surface = noone; meta = noone; + type = FILE_TYPE.collection; + + switch(string_lower(filename_ext(path))) { + case ".png" : + case ".jpg" : + case ".gif" : + type = FILE_TYPE.assets; + break; + case ".pxc" : + type = FILE_TYPE.project; + break; + } retrive_data = false; thumbnail_data = -1; diff --git a/scripts/panel_collection/panel_collection.gml b/scripts/panel_collection/panel_collection.gml index 257c94a5f..6407221eb 100644 --- a/scripts/panel_collection/panel_collection.gml +++ b/scripts/panel_collection/panel_collection.gml @@ -168,7 +168,7 @@ function Panel_Collection() : PanelContent() constructor { if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) { draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1); if(mouse_press(mb_left, pFOCUS)) - file_dragging = _node; + DRAGGING = { type : _node.type == FILE_TYPE.collection? "Collection" : "Asset", data : _node } if(!DEMO && mouse_press(mb_right, pFOCUS)) { _menu_node = _node; @@ -242,7 +242,7 @@ function Panel_Collection() : PanelContent() constructor { if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, list_width, yy + list_height - 1)) { draw_sprite_stretched_ext(THEME.node_active, 0, ui(4), yy, list_width - ui(8), list_height, COLORS._main_accent, 1); if(mouse_press(mb_left, pFOCUS)) - file_dragging = _node; + DRAGGING = { type : _node.type == FILE_TYPE.collection? "Collection" : "Asset", data : _node } if(!DEMO && mouse_press(mb_right, pFOCUS)) { _menu_node = _node; @@ -461,58 +461,4 @@ function Panel_Collection() : PanelContent() constructor { tb_search.draw(tb_x, tb_y, tb_w, TEXTBOX_HEIGHT, search_string, [mx, my]); } } - - function drawGUI() { - if(file_dragging) { - if(file_dragging.spr) - draw_sprite_ext(file_dragging.spr, 0, mouse_mx, mouse_my, 1, 1, 0, c_white, 0.5); - - if(panelHover(PANEL_GRAPH)) - dragToGraph(HOVER.getContent()); - - if(mouse_release(mb_left)) - file_dragging = noone; - } - } - - static dragToGraph = function(graph) { - var path = file_dragging.path; - ds_list_clear(graph.nodes_select_list); - - if(string_lower(filename_ext(path)) == ".png") { - var app = Node_create_Image_path(0, 0, path); - - graph.node_focus = app; - graph.node_dragging = app; - graph.node_drag_sx = app.x; - graph.node_drag_sy = app.y; - } else { - var app = APPEND(file_dragging.path); - - if(!is_struct(app) && ds_exists(app, ds_type_list)) { - graph.node_focus = noone; - ds_list_copy(graph.nodes_select_list, app); - - if(!ds_list_empty(app)) { - graph.node_dragging = app[| 0]; - graph.node_drag_sx = app[| 0].x; - graph.node_drag_sy = app[| 0].y; - } - ds_list_destroy(app); - } else { - graph.node_focus = app; - graph.node_dragging = app; - graph.node_drag_sx = app.x; - graph.node_drag_sy = app.y; - } - } - - graph.node_drag_mx = 0; - graph.node_drag_my = 0; - - graph.node_drag_ox = 0; - graph.node_drag_oy = 0; - - file_dragging = false; - } } \ No newline at end of file diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 8f1da7197..de383f54b 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1749,6 +1749,38 @@ function Panel_Graph() : PanelContent() constructor { var node = nodeBuild("Node_Palette", mouse_grid_x, mouse_grid_y, getCurrentContext()); node.inputs[| 0].setValue(DRAGGING.data); break; + case "Asset": + var app = Node_create_Image_path(mouse_grid_x, mouse_grid_y, DRAGGING.data.path); + break; + case "Collection": + var path = DRAGGING.data.path; + ds_list_clear(nodes_select_list); + + var app = APPEND(DRAGGING.data.path, getCurrentContext()); + + if(!is_struct(app) && ds_exists(app, ds_type_list)) { + var cx = 0; + var cy = 0; + + for( var i = 0; i < ds_list_size(app); i++ ) { + cx += app[| i].x; + cy += app[| i].y; + } + + cx /= ds_list_size(app); + cy /= ds_list_size(app); + + for( var i = 0; i < ds_list_size(app); i++ ) { + app[| i].x = app[| i].x - cx + mouse_grid_x; + app[| i].y = app[| i].y - cy + mouse_grid_y; + } + + ds_list_destroy(app); + } else { + app.x = mouse_grid_x; + app.y = mouse_grid_y; + } + break; } } diff --git a/scripts/surfaceBox/surfaceBox.gml b/scripts/surfaceBox/surfaceBox.gml index 44dbd2f34..0a0050482 100644 --- a/scripts/surfaceBox/surfaceBox.gml +++ b/scripts/surfaceBox/surfaceBox.gml @@ -23,11 +23,13 @@ function surfaceBox(_onModify, def_path = "") : widget() constructor { h = _h; open_rx = _rx; open_ry = _ry; - + + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); + if(!open) { draw_sprite_stretched(THEME.textbox, 3, _x, _y, _w, _h); - if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) { + if(hover && hoverRect) { draw_sprite_stretched(THEME.textbox, 1, _x, _y, _w, _h); if(mouse_press(mb_left, active)) trigger(); @@ -70,6 +72,12 @@ function surfaceBox(_onModify, def_path = "") : widget() constructor { if(WIDGET_CURRENT == self) draw_sprite_stretched(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6)); + if(DRAGGING && DRAGGING.type == "Asset" && hover && hoverRect) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, _h, COLORS._main_value_positive, 1); + if(mouse_release(mb_left)) + onModify(DRAGGING.data.path); + } + resetFocus(); } } \ No newline at end of file