- [Preview Panel] Add pixel grid.

This commit is contained in:
Tanasart 2024-05-08 12:27:29 +07:00
parent 72c4589379
commit 03e601cbda
8 changed files with 44 additions and 17 deletions

View file

@ -43,7 +43,6 @@ function __particleObject() constructor {
var _sh = surface_get_height(surf) * scy; var _sh = surface_get_height(surf) * scy;
point_rotate(-_sw / 2, -_sh / 2, 0, 0, rot, __temp_pt); point_rotate(-_sw / 2, -_sh / 2, 0, 0, rot, __temp_pt);
print($"Drawing {surf} at {x + __temp_pt[0]}, {y + __temp_pt[1]} > {scx}, {scy} > {blend}, {alp}");
draw_surface_ext(surf, x + __temp_pt[0], y + __temp_pt[1], scx, scy, rot, blend, alp); draw_surface_ext(surf, x + __temp_pt[0], y + __temp_pt[1], scx, scy, rot, blend, alp);
} #endregion } #endregion

View file

@ -164,6 +164,6 @@ function GetAppendID(old_id) { #region
if(ds_map_exists(APPEND_MAP, old_id)) if(ds_map_exists(APPEND_MAP, old_id))
return APPEND_MAP[? old_id]; return APPEND_MAP[? old_id];
print("Get append ID error: " + string(old_id)); // print("Get append ID error: " + string(old_id));
return noone; return noone;
} #endregion } #endregion

View file

@ -1,10 +1,7 @@
function Panel_Addon() : PanelContent() constructor { function Panel_Addon() : PanelContent() constructor {
title = __txt("Addons"); title = __txt("Addons");
icon = THEME.addon_icon; icon = THEME.addon_icon;
padding = 8;
showHeader = false;
title_height = 64;
padding = 24;
#region data #region data
w = ui(400); w = ui(400);
@ -37,7 +34,6 @@ function Panel_Addon() : PanelContent() constructor {
#endregion #endregion
function onResize() { function onResize() {
PANEL_PADDING
sc_addon.resize(w - ui(padding + padding), h - ui(title_height + padding + 40)); sc_addon.resize(w - ui(padding + padding), h - ui(title_height + padding + 40));
} }
@ -160,13 +156,11 @@ function Panel_Addon() : PanelContent() constructor {
function drawContent(panel) { function drawContent(panel) {
draw_clear_alpha(COLORS.panel_bg_clear, 0); draw_clear_alpha(COLORS.panel_bg_clear, 0);
PANEL_PADDING
PANEL_TITLE
var px = ui(padding); var px = ui(padding);
var py = ui(title_height); var py = ui(padding);
var pw = w - ui(padding + padding); var pw = w - ui(padding + padding);
var ph = h - ui(title_height + padding); var ph = h - ui(padding + padding);
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16)); draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
if(pFOCUS) WIDGET_CURRENT = tb_search; if(pFOCUS) WIDGET_CURRENT = tb_search;

View file

@ -1013,7 +1013,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_hover = node_hovering; node_hover = node_hovering;
if(value_focus) { if(value_focus) {
print($"Right click value focus {value_focus}"); // print($"Right click value focus {value_focus}");
__junction_hovering = value_focus; __junction_hovering = value_focus;
@ -1064,7 +1064,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
menuCall("graph_node_selected_menu",,, menu); menuCall("graph_node_selected_menu",,, menu);
} else if(node_hover && node_hover.draggable) { } else if(node_hover && node_hover.draggable) {
print($"Right click node hover {node_hover}"); // print($"Right click node hover {node_hover}");
var menu = []; var menu = [];
array_push(menu, menu_node_color, -1, menu_sent_to_preview, menu_send_to_window, menu_sent_to_inspector); array_push(menu, menu_node_color, -1, menu_sent_to_preview, menu_send_to_window, menu_sent_to_inspector);
@ -1088,7 +1088,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
menuCall("graph_node_selected_multiple_menu",,, menu ); menuCall("graph_node_selected_multiple_menu",,, menu );
} else if(node_hover == noone) { } else if(node_hover == noone) {
print($"Right click not node hover"); // print($"Right click not node hover");
var menu = []; var menu = [];
@ -1612,7 +1612,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_set_color(COLORS._main_text); draw_set_color(COLORS._main_text);
draw_set_alpha(i < ds_list_size(node_context) - 1? 0.33 : 1); draw_set_alpha(i < ds_list_size(node_context) - 1? 0.33 : 1);
draw_text(xx, tbh - 2, tt); draw_text(xx, tbh, tt);
draw_set_alpha(1); draw_set_alpha(1);
xx += tw; xx += tw;
xx += ui(32); xx += ui(32);

View file

@ -821,6 +821,30 @@ function Panel_Preview() : PanelContent() constructor {
} #endregion } #endregion
if(is_surface(preview_surfaces[0])) { #region outline if(is_surface(preview_surfaces[0])) { #region outline
if(PROJECT.previewGrid.pixel && canvas_s >= 16) {
var gw = pswd / canvas_s;
var gh = pshd / canvas_s;
var cx = canvas_x;
var cy = canvas_y;
draw_set_color(PROJECT.previewGrid.color);
draw_set_alpha(PROJECT.previewGrid.opacity * 0.5 * clamp((canvas_s - 16) / 16, 0, 1));
for( var i = 1; i < gw; i++ ) {
var _xx = cx + i * canvas_s;
draw_line(_xx, cy, _xx, cy + pshd);
}
for( var i = 1; i < gh; i++ ) {
var _yy = cy + i * canvas_s;
draw_line(cx, _yy - 1, cx + pswd, _yy - 1);
}
draw_set_alpha(1);
}
if(PROJECT.previewGrid.show) { if(PROJECT.previewGrid.show) {
var _gw = PROJECT.previewGrid.size[0] * canvas_s; var _gw = PROJECT.previewGrid.size[0] * canvas_s;
var _gh = PROJECT.previewGrid.size[1] * canvas_s; var _gh = PROJECT.previewGrid.size[1] * canvas_s;

View file

@ -5,6 +5,13 @@ function Panel_Preview_Grid_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
new __Panel_Linear_Setting_Item(
__txt("Pixel Grid"),
new checkBox(function() { PROJECT.previewGrid.pixel = !PROJECT.previewGrid.pixel; }),
function() { return PROJECT.previewGrid.pixel; },
function(val) { PROJECT.previewGrid.pixel = val; },
false,
),
new __Panel_Linear_Setting_Item( new __Panel_Linear_Setting_Item(
__txt("Enabled"), __txt("Enabled"),
new checkBox(function() { PROJECT.previewGrid.show = !PROJECT.previewGrid.show; }), new checkBox(function() { PROJECT.previewGrid.show = !PROJECT.previewGrid.show; }),

View file

@ -33,6 +33,8 @@
size : [ 16, 16 ], size : [ 16, 16 ],
opacity : 0.5, opacity : 0.5,
color : COLORS.panel_preview_grid, color : COLORS.panel_preview_grid,
pixel : false,
} #endregion } #endregion
graphGrid = { #region graphGrid = { #region

View file

@ -94,6 +94,7 @@ function __topoSort(_list, _nodeList) { #region
var _root = []; var _root = [];
var _leftOver = []; var _leftOver = [];
var _global = _nodeList == PROJECT.nodes; var _global = _nodeList == PROJECT.nodes;
__temp_nodeList = _nodeList;
for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) { for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) {
var _node = _nodeList[| i]; var _node = _nodeList[| i];
@ -112,7 +113,7 @@ function __topoSort(_list, _nodeList) { #region
var _to = _node.outputs[| j].getJunctionTo(); var _to = _node.outputs[| j].getJunctionTo();
if(_global) _isRoot &= array_empty(_to); if(_global) _isRoot &= array_empty(_to);
else _isRoot &= !array_any(_to, function(_val) { return ds_list_exist(_nodeList, _val.node); } ); else _isRoot &= !array_any(_to, function(_val) { return ds_list_exist(__temp_nodeList, _val.node); } );
if(!_isRoot) break; if(!_isRoot) break;
} }