Pixel-Composer/scripts/panel_inspector/panel_inspector.gml

1023 lines
35 KiB
Plaintext
Raw Normal View History

2024-02-06 13:53:08 +01:00
#region funtion calls
function __fnInit_Inspector() {
__registerFunction("inspector_copy_prop", panel_inspector_copy_prop);
__registerFunction("inspector_paste_prop", panel_inspector_paste_prop);
__registerFunction("inspector_toggle_animation", panel_inspector_toggle_animation);
__registerFunction("inspector_color_pick", panel_inspector_color_pick);
}
function panel_inspector_copy_prop() { CALL("inspector_copy_prop"); PANEL_INSPECTOR.propSelectCopy(); }
function panel_inspector_paste_prop() { CALL("inspector_paste_prop"); PANEL_INSPECTOR.propSelectPaste(); }
function panel_inspector_toggle_animation() { CALL("inspector_toggle_animation"); PANEL_INSPECTOR.anim_toggling = true; }
function panel_inspector_color_pick() { CALL("inspector_color_pick"); if(!PREFERENCES.alt_picker) return; PANEL_INSPECTOR.color_picking = true; }
#endregion
function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constructor { #region
2022-09-23 13:28:42 +02:00
h = 64;
2023-07-21 12:40:20 +02:00
self.draw = drawFn;
2023-09-28 13:15:29 +02:00
if(registerFn != noone) register = registerFn;
2024-01-16 14:08:57 +01:00
else {
register = function(parent = noone) {
if(!interactable) return;
self.parent = parent;
}
}
2024-02-06 13:53:08 +01:00
} #endregion
2022-09-23 13:28:42 +02:00
2023-12-11 09:59:58 +01:00
function Inspector_Sprite(spr) constructor { self.spr = spr; }
2024-04-03 09:40:37 +02:00
function Inspector_Spacer(height, line = false) constructor { self.h = height; self.line = line; }
2022-11-14 03:16:15 +01:00
function Panel_Inspector() : PanelContent() constructor {
#region ---- main ----
title = __txt("Inspector");
context_str = "Inspector";
2024-03-31 05:36:11 +02:00
icon = THEME.panel_inspector_icon;
2023-03-21 03:01:53 +01:00
w = ui(400);
h = ui(640);
min_w = ui(160);
2022-01-13 05:24:03 +01:00
2024-02-01 05:26:02 +01:00
locked = false;
inspecting = noone;
inspectings = [];
inspectGroup = false;
top_bar_h = ui(100);
static initSize = function() {
content_w = w - ui(32);
content_h = h - top_bar_h - ui(12);
}
initSize();
view_mode_tooltip = new tooltipSelector("View", [ "Compact", "Spacious" ])
#endregion
2022-01-13 05:24:03 +01:00
#region ---- properties ----
prop_hover = noone;
prop_selecting = noone;
2023-10-15 15:04:42 +02:00
prop_highlight = noone;
prop_highlight_time = 0;
2023-07-30 13:56:22 +02:00
prop_dragging = noone;
prop_sel_drag_x = 0;
prop_sel_drag_y = 0;
2022-01-13 05:24:03 +01:00
color_picking = false;
picker_index = 0;
picker_change = false;
#endregion
2022-01-13 05:24:03 +01:00
2023-03-19 09:17:39 +01:00
globalvar_viewer_init();
drawWidgetInit();
2022-12-12 09:08:03 +01:00
#region ---- header labels ----
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) {
if(inspecting) inspecting.setDisplayName(txt);
})
2022-12-10 05:06:01 +01:00
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) { filter_text = txt; })
tb_prop_filter.no_empty = false;
tb_prop_filter.auto_update = true;
tb_prop_filter.font = f_p0;
tb_prop_filter.color = COLORS._main_text_sub;
tb_prop_filter.align = fa_center;
tb_prop_filter.hide = true;
filter_text = "";
2023-03-19 09:17:39 +01:00
prop_page_button = new buttonGroup([ "Properties", "Settings" ], function(val) { prop_page = val; });
prop_page_button.buttonSpr = [ THEME.button_hide_left, THEME.button_hide_middle, THEME.button_hide_right ];
prop_page_button.font = f_p1;
prop_page_button.fColor = COLORS._main_text_sub;
prop_page = 0;
#endregion
2023-06-19 20:28:30 +02:00
#region ---- metadata ----
current_meta = -1;
meta_tb[0] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.description = str; });
meta_tb[1] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.author = str; });
meta_tb[2] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.contact = str; });
meta_tb[3] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.alias = str; });
meta_tb[4] = new textArrayBox(noone, META_TAGS);
for( var i = 0, n = array_length(meta_tb); i < n; i++ )
meta_tb[i].hide = true;
2023-02-14 02:51:14 +01:00
meta_display = [
[ __txt("Project Settings"), false ],
[ __txt("Metadata"), true ],
2023-10-07 09:09:18 +02:00
[ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ],
[ __txt("Group Properties"), true ],
];
#endregion
2023-02-14 02:51:14 +01:00
#region ---- workshop ----
workshop_uploading = false;
#endregion
2023-02-15 10:04:49 +01:00
#region ++++ hotkeys ++++
2024-02-06 13:53:08 +01:00
addHotkey("Inspector", "Copy property", "C", MOD_KEY.ctrl, panel_inspector_copy_prop);
addHotkey("Inspector", "Paste property", "V", MOD_KEY.ctrl, panel_inspector_paste_prop);
addHotkey("Inspector", "Toggle animation", "I", MOD_KEY.none, panel_inspector_toggle_animation);
addHotkey("", "Color picker", "", MOD_KEY.alt, panel_inspector_color_pick);
#endregion
2023-07-30 13:56:22 +02:00
#region ++++ menus ++++
static nodeExpandAll = function(node) {
if(node.input_display_list == -1) return;
var dlist = node.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = false;
}
}
static nodeCollapseAll = function(node) {
if(node.input_display_list == -1) return;
var dlist = node.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = true;
}
}
group_menu = [
menuItem(__txt("Expand all"), function() {
if(inspecting != noone) nodeExpandAll(inspecting);
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeExpandAll(inspectings[i]);
}),
menuItem(__txt("Collapse all"), function() {
if(inspecting != noone) nodeCollapseAll(inspecting);
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeCollapseAll(inspectings[i]);
}),
]
2023-10-15 15:04:42 +02:00
__dialog_junction = noone;
menu_junc_reset_value = menuItem(__txtx("panel_inspector_reset", "Reset value"), function() { __dialog_junction.resetValue(); });
menu_junc_add_anim = menuItem(__txtx("panel_inspector_add", "Add animation"), function() { __dialog_junction.setAnim(true); });
menu_junc_rem_anim = menuItem(__txtx("panel_inspector_remove", "Remove animation"), function() { __dialog_junction.setAnim(false); });
menu_junc_combine_axis = menuItem(__txtx("panel_inspector_axis_combine", "Combine axis"), function() { __dialog_junction.sep_axis = false; });
menu_junc_separate_axis = menuItem(__txtx("panel_inspector_axis_separate", "Separate axis"), function() { __dialog_junction.sep_axis = true; });
menu_junc_expression_ena = menuItem(__txtx("panel_inspector_use_expression", "Use expression"), function() { __dialog_junction.expUse = true; });
menu_junc_expression_dis = menuItem(__txtx("panel_inspector_disable_expression", "Disable expression"), function() { __dialog_junction.expUse = false; });
menu_junc_extract = menuItem(__txtx("panel_inspector_extract_single", "Extract to node"), function() { __dialog_junction.extractNode(); });
menu_junc_copy = menuItem(__txt("Copy"), function() { clipboard_set_text(__dialog_junction.getShowString()); }, THEME.copy, ["Inspector", "Copy property"]);
menu_junc_paste = menuItem(__txt("Paste"), function() { __dialog_junction.setString(clipboard_get_text()); }, THEME.paste, ["Inspector", "Paste property"]);
function setSelectingItemColor(color) {
if(__dialog_junction == noone) return;
2023-12-08 12:53:31 +01:00
__dialog_junction.setColor(color);
2023-10-15 15:04:42 +02:00
var _val_to = __dialog_junction.getJunctionTo();
for( var i = 0, n = array_length(_val_to); i < n; i++ )
2023-12-08 12:53:31 +01:00
_val_to[i].setColor(color);
2023-10-15 15:04:42 +02:00
}
2023-10-18 14:58:55 +02:00
var _clrs = COLORS.labels;
2023-10-15 15:04:42 +02:00
var _item = array_create(array_length(_clrs));
for( var i = 0, n = array_length(_clrs); i < n; i++ ) {
_item[i] = [
[ THEME.timeline_color, i > 0, _clrs[i] ],
function(_data) {
setSelectingItemColor(_data.color);
}, "", { color: i == 0? -1 : _clrs[i] }
];
}
array_push(_item, [
[ THEME.timeline_color, 2 ],
function(_data) {
2024-01-28 09:53:41 +01:00
colorSelectorCall(__dialog_junction? __dialog_junction.color : c_white, setSelectingItemColor);
2023-10-15 15:04:42 +02:00
}
]);
menu_junc_color = menuItemGroup(__txt("Color"), _item);
menu_junc_color.spacing = ui(24);
#endregion
2022-12-10 05:06:01 +01:00
function setInspecting(inspecting) { #region
2023-06-19 20:28:30 +02:00
if(locked) return;
self.inspecting = inspecting;
if(inspecting != noone)
inspecting.onInspect();
contentPane.scroll_y = 0;
contentPane.scroll_y_to = 0;
picker_index = 0;
} #endregion
2023-06-19 20:28:30 +02:00
function getInspecting() { #region
if(inspecting == noone) return noone;
return inspecting.active? inspecting : noone;
} #endregion
2023-03-13 10:45:56 +01:00
function onFocusBegin() { PANEL_INSPECTOR = self; }
function onResize() { #region
2022-12-10 05:06:01 +01:00
initSize();
2022-11-14 03:16:15 +01:00
contentPane.resize(content_w, content_h);
} #endregion
2022-11-14 03:16:15 +01:00
static drawMeta = function(_y, _m) { #region
2024-03-14 14:35:19 +01:00
var con_w = contentPane.surface_w - ui(4);
2023-02-14 02:51:14 +01:00
var _hover = pHOVER && contentPane.hover;
var context = PANEL_GRAPH.getCurrentContext();
2023-11-27 14:50:20 +01:00
var meta = context == noone? PROJECT.meta : context.metadata;
2023-02-14 02:51:14 +01:00
if(meta == noone) return 0;
2023-03-07 14:29:47 +01:00
current_meta = meta;
2023-02-14 02:51:14 +01:00
var hh = ui(8);
var yy = _y + ui(8);
2023-07-21 12:40:20 +02:00
var rx = x + ui(16);
var ry = y + top_bar_h;
2024-03-14 14:35:19 +01:00
attribute_hovering = noone;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(meta_display); i < n; i++ ) {
2023-10-07 09:09:18 +02:00
if(i == 3) {
var context = PANEL_GRAPH.getCurrentContext();
if(context == noone) continue;
}
2023-03-23 13:38:50 +01:00
var _meta = meta_display[i];
2024-03-31 05:36:11 +02:00
var _txt = array_safe_get_fast(_meta, 0);
var _b = array_safe_get_fast(_meta, 2, noone);
2023-03-23 13:38:50 +01:00
var _x1 = con_w - (_b != noone) * ui(30);
if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, _x1, yy + ui(32))) {
2023-02-14 02:51:14 +01:00
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, con_w, ui(32), COLORS.panel_inspector_group_hover, 1);
if(mouse_press(mb_left, pFOCUS))
meta_display[i][1] = !meta_display[i][1];
} else
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, con_w, ui(32), COLORS.panel_inspector_group_bg, 1);
2023-03-23 13:38:50 +01:00
if(_b != noone) {
2023-06-21 20:36:53 +02:00
_b.setFocusHover(pFOCUS, _hover);
2023-03-23 13:38:50 +01:00
_b.draw(_x1, yy + ui(2), ui(28), ui(28), _m, THEME.button_hide_fill);
}
2023-02-14 02:51:14 +01:00
draw_sprite_ui(THEME.arrow, meta_display[i][1]? 0 : 3, ui(16), yy + ui(32) / 2, 1, 1, 0, COLORS.panel_inspector_group_bg, 1);
2023-03-07 14:29:47 +01:00
2023-06-10 13:59:45 +02:00
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner);
2023-06-17 14:30:49 +02:00
draw_text_add(ui(32), yy + ui(32) / 2, _txt);
2023-02-14 02:51:14 +01:00
yy += ui(32 + 8);
hh += ui(32 + 8);
if(meta_display[i][1]) {
yy += ui(4);
hh += ui(4);
continue;
}
2023-10-07 09:09:18 +02:00
switch(i) {
case 0 :
var _edt = PROJECT.attributeEditor;
for( var j = 0; j < array_length(_edt); j++ ) {
var title = _edt[j][0];
var param = _edt[j][1];
var editW = _edt[j][2];
2024-03-14 14:35:19 +01:00
var drpFn = _edt[j][3];
2023-07-21 12:40:20 +02:00
2024-03-14 14:35:19 +01:00
var widx = ui(8);
var widy = yy;
2023-10-07 09:09:18 +02:00
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner);
draw_text_add(ui(16), yy, __txt(title));
yy += line_get_height() + ui(6);
hh += line_get_height() + ui(6);
2023-07-21 12:40:20 +02:00
2023-10-07 09:09:18 +02:00
editW.setFocusHover(pFOCUS, _hover);
if(pFOCUS) editW.register(contentPane);
2024-03-14 14:35:19 +01:00
2023-10-07 09:09:18 +02:00
var wh = 0;
2024-03-14 14:35:19 +01:00
var _data = PROJECT.attributes[$ param];
var _param = new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry);
wh = editW.drawParam(_param);
var jun = PANEL_GRAPH.value_dragging;
var widw = con_w - ui(16);
var widh = line_get_height() + ui(6) + wh + ui(4);
if(jun != noone && _hover && point_in_rectangle(_m[0], _m[1], widx, widy, widx + widw, widy + widh)) {
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, widx, widy, widw, widh, COLORS._main_value_positive, 1);
attribute_hovering = drpFn;
}
2023-10-07 09:09:18 +02:00
yy += wh + ui(8);
hh += wh + ui(8);
}
break;
case 1 :
for( var j = 0; j < array_length(meta.displays); j++ ) {
var display = meta.displays[j];
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner);
draw_text_add(ui(16), yy, __txt(display[0]));
yy += line_get_height() + ui(6);
hh += line_get_height() + ui(6);
2023-02-14 02:51:14 +01:00
2023-10-07 09:09:18 +02:00
meta_tb[j].setFocusHover(pFOCUS, _hover);
if(pFOCUS) meta_tb[j].register(contentPane);
2023-02-14 02:51:14 +01:00
2023-10-07 09:09:18 +02:00
var wh = 0;
var _dataFunc = display[1];
var _data = _dataFunc(meta);
2023-10-07 09:09:18 +02:00
switch(instanceof(meta_tb[j])) {
case "textArea" :
wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m);
break;
case "textArrayBox" :
meta_tb[j].arraySet = current_meta.tags;
wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry);
break;
}
2023-02-15 10:04:49 +01:00
2023-10-07 09:09:18 +02:00
yy += wh + ui(8);
hh += wh + ui(8);
}
break;
case 2 :
if(findPanel("Panel_Globalvar")) {
yy += ui(4);
hh += ui(4);
continue;
}
2023-03-24 09:32:08 +01:00
2023-10-07 09:09:18 +02:00
var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y);
yy += gvh + ui(8);
hh += gvh + ui(8);
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
var bh = ui(36);
var bx = ui(16);
var by = yy;
var bbw = contentPane.surface_w - ui(24);
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
if(var_editing) {
var bw = bbw / 2 - ui(4);
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
var_editing = !var_editing;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
var txt = __txt("Apply");
var icon = THEME.accept;
var colr = COLORS._main_value_positive;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon)
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
2023-11-20 05:10:55 +01:00
2023-10-07 09:09:18 +02:00
bx += bw + ui(4);
2023-11-20 05:10:55 +01:00
2023-10-07 09:09:18 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
PROJECT.globalNode.createValue();
2023-03-19 09:17:39 +01:00
2023-10-07 09:09:18 +02:00
var txt = __txt("Add");
var icon = THEME.add;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon)
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
} else {
var bw = bbw;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
var_editing = !var_editing;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
var txt = __txt("Edit");
var icon = THEME.gear;
var colr = COLORS._main_icon;
2023-03-07 14:29:47 +01:00
2023-10-07 09:09:18 +02:00
draw_set_text(f_p0b, fa_left, fa_center, colr)
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
}
break;
case 3 :
var context = PANEL_GRAPH.getCurrentContext();
var _h = drawNodeProperties(yy, _m, context);
yy += _h;
hh += _h;
break;
2023-02-14 02:51:14 +01:00
}
yy += ui(8);
hh += ui(8);
}
2023-10-07 09:09:18 +02:00
2023-02-14 02:51:14 +01:00
return hh;
} #endregion
2023-02-14 02:51:14 +01:00
2023-10-15 15:04:42 +02:00
static highlightProp = function(prop) { #region
prop_highlight = prop;
prop_highlight_time = 60;
} #endregion
2023-10-07 09:09:18 +02:00
static drawNodeProperties = function(_y, _m, _inspecting = inspecting) { #region
2024-02-01 05:26:02 +01:00
var con_w = contentPane.surface_w - ui(4);
2023-02-14 02:51:14 +01:00
var _hover = pHOVER && contentPane.hover;
2023-10-07 09:09:18 +02:00
_inspecting.inspecting = true;
2023-03-19 09:17:39 +01:00
prop_hover = noone;
var jun = noone;
2023-10-07 09:09:18 +02:00
var amoIn = _inspecting.input_display_list == -1? ds_list_size(_inspecting.inputs) : array_length(_inspecting.input_display_list);
var amoOut = ds_list_size(_inspecting.outputs);
2024-02-01 05:26:02 +01:00
var amo = inspectGroup == 0? amoIn + 1 + amoOut : amoIn;
var hh = 0;
2023-02-14 02:51:14 +01:00
2023-03-19 09:17:39 +01:00
//tb_prop_filter.register(contentPane);
2023-06-21 20:36:53 +02:00
//tb_prop_filter.setFocusHover(pHOVER, pFOCUS);
2023-03-19 09:17:39 +01:00
//tb_prop_filter.draw(ui(32), _y + ui(4), con_w - ui(64), ui(28), filter_text, _m);
//draw_sprite_ui(THEME.search, 0, ui(32 + 16), _y + ui(4 + 14), 1, 1, 0, COLORS._main_icon, 1);
2023-02-21 07:38:25 +01:00
var xc = con_w / 2;
if(prop_page == 1) { #region attribute/settings editor
2023-03-19 09:17:39 +01:00
hh += ui(8);
var hg = ui(32);
2024-02-01 05:26:02 +01:00
var yy = _y + hh;
2023-03-19 09:17:39 +01:00
var wx1 = con_w - ui(8);
var ww = max(ui(180), con_w / 3);
var wx0 = wx1 - ww;
2023-10-07 09:09:18 +02:00
for( var i = 0, n = array_length(_inspecting.attributeEditors); i < n; i++ ) {
var edt = _inspecting.attributeEditors[i];
2023-03-19 09:17:39 +01:00
if(is_string(edt)) {
var lby = yy + ui(12);
draw_set_alpha(0.5);
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text_sub);
2023-06-10 13:59:45 +02:00
draw_text_add(xc, lby, edt);
2023-03-19 09:17:39 +01:00
var lbw = string_width(edt) / 2;
draw_set_color(COLORS._main_text_sub);
draw_line_round(xc + lbw + ui(16), lby, wx1, lby, 2);
draw_line_round(xc - lbw - ui(16), lby, ui(8), lby, 2);
draw_set_alpha(1.0);
yy += ui(32);
hh += ui(32);
continue;
}
2023-07-14 20:34:35 +02:00
var val = edt[1]();
2023-06-21 20:36:53 +02:00
edt[2].setFocusHover(pFOCUS, pHOVER);
2023-03-19 09:17:39 +01:00
if(instanceof(edt[2]) == "buttonClass") {
edt[2].text = edt[0];
edt[2].draw(ui(8), yy, con_w - ui(16), hg, _m);
yy += hg + ui(8);
hh += hg + ui(8);
continue;
}
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
2023-06-10 13:59:45 +02:00
draw_text_add(ui(8), yy + hg / 2, edt[0]);
2023-03-19 09:17:39 +01:00
2023-09-28 13:15:29 +02:00
var _param = new widgetParam(wx0, yy, ww, hg, val, {}, _m, x + contentPane.x, y + contentPane.y);
_param.s = hg;
edt[2].drawParam(_param);
2023-03-19 09:17:39 +01:00
yy += hg + ui(8);
hh += hg + ui(8);
}
return hh;
} #endregion
2023-03-19 09:17:39 +01:00
2023-06-19 20:28:30 +02:00
var color_picker_selecting = noone;
2024-01-08 08:10:50 +01:00
var color_picker_index = 0;
2023-06-19 20:28:30 +02:00
var pickers = [];
2024-01-08 08:10:50 +01:00
var _colsp = false;
2023-06-19 20:28:30 +02:00
2022-09-21 06:09:40 +02:00
for(var i = 0; i < amo; i++) {
2022-11-03 11:44:49 +01:00
var yy = hh + _y;
2022-01-13 05:24:03 +01:00
if(i < amoIn) { #region inputs
2023-10-07 09:09:18 +02:00
if(_inspecting.input_display_list == -1) {
jun = _inspecting.inputs[| i];
2023-02-21 07:38:25 +01:00
} else {
2023-10-07 09:09:18 +02:00
if(i >= array_length(_inspecting.input_display_list)) break;
var jun_disp = _inspecting.input_display_list[i];
2024-04-03 09:40:37 +02:00
if(is_instanceof(jun_disp, Inspector_Spacer)) { // SPACER
var _hh = ui(jun_disp.h);
var _yy = yy + _hh / 2 - ui(2);
if(jun_disp.line) {
draw_set_color(COLORS.panel_inspector_key_separator);
draw_line(ui(8), _yy, con_w - ui(8), _yy);
}
hh += _hh;
continue;
} else if(is_instanceof(jun_disp, Inspector_Sprite)) { // SPRITE
2023-12-11 05:45:12 +01:00
var _spr = jun_disp.spr;
var _sh = sprite_get_height(_spr);
draw_sprite(_spr, 0, xc, yy);
hh += _sh + ui(8);
continue;
2024-01-07 12:18:20 +01:00
2024-04-03 09:40:37 +02:00
} else if(is_array(jun_disp)) { // LABEL
2024-01-08 08:10:50 +01:00
var pad = i && _colsp == false? ui(4) : 0
_colsp = false;
yy += pad;
2023-06-05 18:27:53 +02:00
var txt = __txt(jun_disp[0]);
2023-02-21 07:38:25 +01:00
var coll = jun_disp[1] && filter_text == "";
2024-03-24 04:58:08 +01:00
var lbh = viewMode? ui(32) : ui(26);
2024-03-31 05:36:11 +02:00
var togl = array_safe_get_fast(jun_disp, 2, noone);
2024-01-07 12:18:20 +01:00
if(togl != noone) var toging = _inspecting.getInputData(togl);
2024-01-10 08:37:15 +01:00
var lbx = (togl != noone) * ui(40);
2024-01-07 12:18:20 +01:00
var lbw = con_w - lbx;
var ltx = lbx + ui(32);
2024-01-07 12:18:20 +01:00
if(_hover && point_in_rectangle(_m[0], _m[1], lbx, yy, con_w, yy + lbh)) {
draw_sprite_stretched_ext(THEME.group_label, 0, lbx, yy, lbw, lbh, COLORS.panel_inspector_group_hover, 1);
2022-11-01 03:06:03 +01:00
2023-02-21 07:38:25 +01:00
if(mouse_press(mb_left, pFOCUS))
jun_disp[@ 1] = !coll;
if(mouse_press(mb_right, pFOCUS))
2023-10-07 09:09:18 +02:00
menuCall("inspector_group_menu",,, group_menu,, _inspecting);
2023-02-21 07:38:25 +01:00
} else
2024-01-07 12:18:20 +01:00
draw_sprite_stretched_ext(THEME.group_label, 0, lbx, yy, lbw, lbh, COLORS.panel_inspector_group_bg, 1);
2022-11-01 03:06:03 +01:00
2024-01-07 12:18:20 +01:00
if(filter_text == "")
draw_sprite_ui(THEME.arrow, 0, lbx + ui(16), yy + lbh / 2, 1, 1, -90 + coll * 90, COLORS.panel_inspector_group_bg, 1);
var cc, aa = 1;
if(togl != noone) {
if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, ui(32), yy + lbh)) {
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, ui(32), lbh, COLORS.panel_inspector_group_hover, 1);
if(mouse_press(mb_left, pFOCUS))
_inspecting.inputs[| togl].setValue(!toging);
} else
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, ui(32), lbh, COLORS.panel_inspector_group_bg, 1);
cc = toging? COLORS._main_accent : COLORS.panel_inspector_group_bg;
aa = 0.5 + toging * 0.5;
draw_sprite_ui(THEME.inspector_checkbox, 0, ui(16), yy + lbh / 2, 1, 1, 0, cc, 1);
if(toging)
draw_sprite_ui(THEME.inspector_checkbox, 1, ui(16), yy + lbh / 2, 1, 1, 0, cc, 1);
}
2023-06-05 18:27:53 +02:00
2024-01-07 12:18:20 +01:00
draw_set_alpha(aa);
2024-03-24 04:58:08 +01:00
draw_set_text(viewMode? f_p0 : f_p1, fa_left, fa_center, COLORS._main_text);
2024-01-07 12:18:20 +01:00
draw_text_add(ltx, yy + lbh / 2, txt);
draw_set_alpha(1);
2024-03-24 04:58:08 +01:00
hh += lbh + ui(viewMode? 8 : 6) + pad;
2023-09-07 20:59:14 +02:00
2024-01-07 12:18:20 +01:00
if(coll) { // skip
2024-01-08 08:10:50 +01:00
_colsp = true;
2023-09-07 20:59:14 +02:00
var j = i + 1;
2023-10-07 09:09:18 +02:00
var _len = array_length(_inspecting.input_display_list);
2023-09-07 20:59:14 +02:00
while(j < _len) {
2023-10-07 09:09:18 +02:00
var j_jun = _inspecting.input_display_list[j];
2023-02-21 07:38:25 +01:00
if(is_array(j_jun))
break;
2023-09-07 20:59:14 +02:00
j++;
2023-02-21 07:38:25 +01:00
}
2023-09-07 20:59:14 +02:00
2023-02-21 07:38:25 +01:00
i = j - 1;
2022-09-21 06:09:40 +02:00
}
2023-09-07 20:59:14 +02:00
2022-09-21 06:09:40 +02:00
continue;
2024-01-07 12:18:20 +01:00
2023-02-21 07:38:25 +01:00
} else if(is_struct(jun_disp) && instanceof(jun_disp) == "Inspector_Custom_Renderer") {
2023-10-04 09:49:31 +02:00
jun_disp.register(contentPane);
2023-02-21 07:38:25 +01:00
jun_disp.rx = ui(16) + x;
jun_disp.ry = top_bar_h + y;
2023-02-21 07:38:25 +01:00
hh += jun_disp.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8);
continue;
}
2023-10-07 09:09:18 +02:00
jun = _inspecting.inputs[| _inspecting.input_display_list[i]];
2022-01-13 05:24:03 +01:00
}
#endregion
} else if(i == amoIn) { #region output label
2023-02-21 07:38:25 +01:00
hh += ui(8 + 32 + 8);
2024-02-01 05:26:02 +01:00
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy + ui(8), con_w, ui(32), COLORS.panel_inspector_output_label, 0.8);
2023-02-21 07:38:25 +01:00
draw_set_text(f_p0b, fa_center, fa_center, COLORS._main_text_sub);
2023-06-17 14:30:49 +02:00
draw_text_add(xc, yy + ui(8 + 16), __txt("Outputs"));
2023-02-21 07:38:25 +01:00
continue;
#endregion
} else { #region outputs
2023-02-21 07:38:25 +01:00
var outInd = i - amoIn - 1;
2023-10-07 09:09:18 +02:00
jun = _inspecting.outputs[| outInd];
#endregion
}
2022-12-10 05:06:01 +01:00
2023-02-14 02:51:14 +01:00
if(!is_struct(jun)) continue;
if(instanceof(jun) != "NodeValue") continue;
2022-09-27 06:37:28 +02:00
if(!jun.show_in_inspector || jun.type == VALUE_TYPE.object) continue;
2022-12-10 05:06:01 +01:00
if(filter_text != "") {
var pos = string_pos(filter_text, string_lower(jun.getName()));
2022-12-10 05:06:01 +01:00
if(pos == 0) continue;
}
2022-09-23 13:28:42 +02:00
2023-09-07 20:59:14 +02:00
#region ++++ draw widget ++++
2024-03-24 04:58:08 +01:00
var _font = viewMode == INSP_VIEW_MODE.spacious? f_p0 : f_p2;
var lb_h = line_get_height(_font) + ui(8);
var lb_w = line_get_width(jun.getName(), _font) + ui(16);
2023-10-15 15:04:42 +02:00
var lb_x = ui(48) + (ui(24) * (jun.color != -1));
var padd = ui(8);
2023-03-08 07:35:51 +01:00
2023-10-15 15:04:42 +02:00
var _selY = yy;
2023-03-26 07:13:36 +02:00
var widg = drawWidget(ui(16), yy, contentPane.surface_w - ui(24), _m, jun, false, pHOVER && contentPane.hover, pFOCUS, contentPane, ui(16) + x, top_bar_h + y);
var widH = widg[0];
var mbRight = widg[1];
2023-10-15 15:04:42 +02:00
2024-03-26 04:03:45 +01:00
var lbHov = point_in_rectangle(_m[0], _m[1], lb_x, _selY + ui(2), lb_x + lb_w, _selY + lb_h - ui(4));
if(lbHov) draw_sprite_stretched_ext(THEME.button_hide, 1, lb_x, _selY + ui(2), lb_w, lb_h - ui(6), COLORS._main_icon, 1);
hh += lb_h + widH + padd;
2022-09-21 06:09:40 +02:00
var _selY1 = yy + lb_h + widH + ui(2);
2024-03-24 04:58:08 +01:00
var _selH = _selY1 - _selY + (viewMode * ui(4));
2023-10-15 15:04:42 +02:00
if(jun == prop_highlight && prop_highlight_time) {
if(prop_highlight_time == 60)
contentPane.setScroll(_y - yy);
var aa = min(1, prop_highlight_time / 30);
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, ui(4), yy, contentPane.surface_w - ui(4), _selH, COLORS._main_accent, aa);
}
2023-12-29 14:30:54 +01:00
if(_hover && lbHov && prop_dragging == noone && mouse_press(mb_left, pFOCUS)) {
prop_dragging = jun;
2023-10-15 15:04:42 +02:00
2023-12-29 14:30:54 +01:00
prop_sel_drag_x = mouse_mx;
prop_sel_drag_y = mouse_my;
2023-03-26 07:13:36 +02:00
}
#endregion
2023-03-26 07:13:36 +02:00
if(jun.connect_type == JUNCTION_CONNECT.input && jun.type == VALUE_TYPE.color && jun.display_type == VALUE_DISPLAY._default) { #region color picker
2023-06-19 20:28:30 +02:00
pickers[color_picker_index] = jun;
color_picker_index++;
} #endregion
2023-06-19 20:28:30 +02:00
if(_hover && point_in_rectangle(_m[0], _m[1], ui(4), _selY, contentPane.surface_w - ui(4), _selY + _selH)) { #region mouse in widget
2023-05-03 21:42:17 +02:00
_HOVERING_ELEMENT = jun;
2023-12-29 14:30:54 +01:00
var hov = PANEL_GRAPH.value_dragging != noone || (NODE_DROPPER_TARGET != noone && NODE_DROPPER_TARGET != jun);
if(hov) {
2023-06-17 14:30:49 +02:00
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, ui(4), _selY, contentPane.surface_w - ui(8), _selH, COLORS._main_value_positive, 1);
if(mouse_press(mb_left, NODE_DROPPER_TARGET_CAN)) {
NODE_DROPPER_TARGET.expression += $"{jun.node.internalName}.{jun.connect_type == JUNCTION_CONNECT.input? "inputs" : "outputs"}.{jun.internalName}";
NODE_DROPPER_TARGET.expressionUpdate();
}
} else
2023-10-15 15:04:42 +02:00
draw_sprite_stretched_ext(THEME.prop_selecting, 0, ui(4), _selY, contentPane.surface_w - ui(8), _selH, COLORS._main_accent, 1);
2023-06-17 14:30:49 +02:00
2022-12-12 09:08:03 +01:00
if(anim_toggling) {
2023-03-21 03:01:53 +01:00
jun.setAnim(!jun.is_anim);
2022-12-12 09:08:03 +01:00
anim_toggling = false;
}
2022-09-21 06:09:40 +02:00
prop_hover = jun;
2022-01-13 05:24:03 +01:00
2022-12-10 05:06:01 +01:00
if(mouse_press(mb_left, pFOCUS))
prop_selecting = jun;
2022-01-13 05:24:03 +01:00
if(mouse_press(mb_right, pFOCUS && mbRight)) { #region right click menu
2023-10-15 15:04:42 +02:00
var _menuItem = [ menu_junc_color, -1 ];
2023-02-21 07:38:25 +01:00
if(i < amoIn) {
2023-10-15 15:04:42 +02:00
array_push(_menuItem, menu_junc_reset_value, jun.is_anim? menu_junc_rem_anim : menu_junc_add_anim);
if(jun.sepable) array_push(_menuItem, jun.sep_axis? menu_junc_combine_axis : menu_junc_separate_axis);
2023-03-21 03:01:53 +01:00
array_push(_menuItem, -1);
2023-02-21 07:38:25 +01:00
}
2023-01-09 03:14:20 +01:00
2023-11-20 05:10:55 +01:00
array_push(_menuItem, jun.expUse? menu_junc_expression_dis : menu_junc_expression_ena, -1, menu_junc_copy);
if(jun.connect_type == JUNCTION_CONNECT.input)
array_push(_menuItem, menu_junc_paste);
if(jun.connect_type == JUNCTION_CONNECT.input && jun.extract_node != "") {
2023-07-15 20:01:29 +02:00
if(is_array(jun.extract_node)) {
var ext = menuItem(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) {
var arr = [];
for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) {
var _rec = __dialog_junction.extract_node[i];
array_push(arr, menuItem(_rec, function(_dat) { __dialog_junction.extractNode(_dat.name); }));
}
return submenuCall(_dat, arr);
}).setIsShelf();
2023-10-15 15:04:42 +02:00
array_push(_menuItem, ext);
} else
array_push(_menuItem, menu_junc_extract);
2023-01-09 03:14:20 +01:00
}
var dia = menuCall("inspector_value_menu",,, _menuItem,, jun);
2023-02-19 02:13:19 +01:00
__dialog_junction = jun;
} #endregion
} #endregion
2022-01-13 05:24:03 +01:00
}
2023-10-04 09:49:31 +02:00
#region color picker
2024-03-31 11:10:14 +02:00
if(key_mod_press(ALT) && color_picker_index) {
pickers[picker_index].editWidget.onColorPick();
2023-06-19 20:28:30 +02:00
}
2023-10-04 09:49:31 +02:00
if(MESSAGE != noone && MESSAGE.type == "Color") {
2024-03-31 05:36:11 +02:00
var inp = array_safe_get_fast(pickers, picker_index, 0);
2023-10-04 09:49:31 +02:00
if(is_struct(inp)) {
inp.setValue(MESSAGE.data);
MESSAGE = noone;
}
2023-03-26 07:13:36 +02:00
}
2023-10-04 09:49:31 +02:00
color_picking = false;
#endregion
2023-03-26 07:13:36 +02:00
2023-10-04 09:49:31 +02:00
#region drag
if(prop_dragging) {
if(DRAGGING == noone && point_distance(prop_sel_drag_x, prop_sel_drag_y, mouse_mx, mouse_my) > 16) {
prop_dragging.dragValue();
prop_dragging = noone;
}
if(mouse_release(mb_left))
prop_dragging = noone;
}
#endregion
2023-07-30 13:56:22 +02:00
2023-10-15 15:04:42 +02:00
if(prop_highlight_time) {
prop_highlight_time--;
if(prop_highlight_time == 0)
prop_highlight = noone;
}
2022-01-13 05:24:03 +01:00
return hh;
2023-10-07 09:09:18 +02:00
} #endregion
contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region
var con_w = contentPane.surface_w - ui(4);
draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(point_in_rectangle(_m[0], _m[1], 0, 0, con_w, content_h) && mouse_press(mb_left, pFOCUS))
prop_selecting = noone;
if(inspecting == noone) return drawMeta(_y, _m);
2024-02-01 05:26:02 +01:00
prop_page_button.setFocusHover(pFOCUS, pHOVER);
prop_page_button.draw(ui(32), _y + ui(4), contentPane.w - ui(76), ui(28), prop_page, _m, x + contentPane.x, y + contentPane.y);
var _hh = ui(40);
_y += _hh;
if(inspectGroup >= 0) return drawNodeProperties(_y, _m, inspecting);
for( var i = 0, n = min(10, array_length(inspectings)); i < n; i++ ) {
if(i) {
_y += ui(8);
_hh += ui(8);
}
if(n > 1) {
draw_sprite_stretched_ext(THEME.group_label, 0, 0, _y, con_w, ui(32), COLORS.panel_inspector_output_label, 0.9);
draw_set_text(f_p0b, fa_center, fa_center, COLORS._main_text_sub);
var _tx = inspectings[i].getFullName();
draw_text_add(con_w / 2, _y + ui(16), _tx);
_y += ui(32 + 8);
_hh += ui(32 + 8);
}
var _h = drawNodeProperties(_y, _m, inspectings[i]);
_y += _h;
_hh += _h;
}
return _hh;
}); #endregion
2022-01-13 05:24:03 +01:00
function propSelectCopy() { #region
2022-01-13 05:24:03 +01:00
if(!prop_selecting) return;
clipboard_set_text(prop_selecting.getShowString());
} #endregion
function propSelectPaste() { #region
2022-01-13 05:24:03 +01:00
if(!prop_selecting) return;
2023-11-20 05:10:55 +01:00
2022-01-13 05:24:03 +01:00
prop_selecting.setString(clipboard_get_text());
} #endregion
2022-01-13 05:24:03 +01:00
function drawInspectingNode() { #region
2024-02-01 05:26:02 +01:00
tb_node_name.font = f_h5;
tb_node_name.hide = true;
2023-08-13 13:10:20 +02:00
tb_node_name.align = fa_center;
tb_node_name.format = TEXT_AREA_FORMAT.node_title;
2024-02-01 05:26:02 +01:00
tb_node_name.setFocusHover(pFOCUS, pHOVER);
var txt = inspecting.renamed? inspecting.display_name : inspecting.name;
2024-02-01 05:26:02 +01:00
if(inspectGroup == 1) txt = $"[{array_length(PANEL_GRAPH.nodes_selecting)}] {txt}";
else if(inspectGroup == -1) txt = $"[{array_length(PANEL_GRAPH.nodes_selecting)}] Multiple nodes";
2022-01-13 05:24:03 +01:00
2024-02-01 05:26:02 +01:00
tb_node_name.draw(ui(64), ui(14), w - ui(128), ui(32), txt, [mx, my]);
2022-12-10 05:06:01 +01:00
2024-02-01 05:26:02 +01:00
if(inspectGroup >= 0) {
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text_sub);
draw_text_add(w / 2 + ui(8), ui(56), inspecting.name);
2023-04-15 14:48:29 +02:00
2024-02-01 05:26:02 +01:00
draw_set_text(f_p3, fa_center, fa_center, COLORS._main_text_sub);
draw_set_alpha(0.65);
draw_text_add(w / 2, ui(76), inspecting.internalName);
draw_set_alpha(1);
}
2023-03-13 10:45:56 +01:00
2022-12-10 05:06:01 +01:00
var bx = ui(8);
var by = ui(12);
2024-02-01 05:26:02 +01:00
if(inspectGroup == 0) {
draw_set_font(f_p1);
var lx = w / 2 - string_width(inspecting.name) / 2 - ui(10);
var ly = ui(56 - 8);
2024-03-27 11:51:14 +01:00
if(buttonInstant(THEME.button_hide, lx, ly, ui(16), ui(16), [mx, my], pFOCUS, pHOVER, __txt("Lock"), THEME.lock_12, !locked, locked? COLORS._main_icon_light : COLORS._main_icon) == 2)
2024-02-01 05:26:02 +01:00
locked = !locked;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txt("Presets"), THEME.preset, 1) == 2)
dialogCall(o_dialog_preset, x + bx, y + by + ui(36), { "node": inspecting });
} else {
draw_sprite_ui_uniform(THEME.preset, 1, bx + ui(32) / 2, by + ui(32) / 2, 1, COLORS._main_icon_dark);
}
2022-12-10 05:06:01 +01:00
by += ui(36);
2024-03-24 04:58:08 +01:00
view_mode_tooltip.index = viewMode;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, view_mode_tooltip, THEME.inspector_view, viewMode) == 2) {
viewMode = !viewMode;
PREFERENCES.inspector_view_default = viewMode;
}
2024-02-01 05:26:02 +01:00
//////////////////////////////////////////////////////////////////// INSPECTOR ACTIONS ////////////////////////////////////////////////////////////////////
2022-12-23 04:45:52 +01:00
var bx = w - ui(44);
var by = ui(12);
2023-03-28 06:58:28 +02:00
if(inspecting.hasInspector1Update(true)) {
var icon = inspecting.insp1UpdateIcon;
2023-11-04 13:22:52 +01:00
var ac = inspecting.insp1UpdateActive;
var cc = ac? icon[2] : COLORS._main_icon_dark;
2024-02-01 05:26:02 +01:00
var tt = inspecting.insp1UpdateTooltip;
if(inspectGroup) tt += " [All]";
2023-11-04 13:22:52 +01:00
2024-02-01 05:26:02 +01:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && ac, pHOVER && ac, tt, icon[0], icon[1], cc) == 2) {
if(inspectGroup == 1) {
for( var i = 0, n = array_length(inspectings); i < n; i++ ) inspectings[i].inspector1Update();
} else
inspecting.inspector1Update();
}
2022-12-23 04:45:52 +01:00
} else
draw_sprite_ui(THEME.sequence_control, 1, bx + ui(16), by + ui(16),,,, COLORS._main_icon_dark);
2022-01-13 05:24:03 +01:00
2023-02-14 02:51:14 +01:00
if(inspecting.hasInspector2Update()) {
by += ui(36);
2023-03-02 07:59:14 +01:00
var icon = inspecting.insp2UpdateIcon;
2023-11-04 13:22:52 +01:00
var ac = inspecting.insp2UpdateActive;
var cc = ac? icon[2] : COLORS._main_icon_dark;
2024-02-01 05:26:02 +01:00
var tt = inspecting.insp2UpdateTooltip;
if(inspectGroup) tt += " [All]";
2022-01-13 05:24:03 +01:00
2024-02-01 05:26:02 +01:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && ac, pHOVER && ac, tt, icon[0], icon[1], cc) = 2) {
if(inspectGroup) {
for( var i = 0, n = array_length(inspectings); i < n; i++ ) inspectings[i].inspector2Update();
} else
inspecting.inspector2Update();
}
2022-01-13 05:24:03 +01:00
}
} #endregion
2022-01-13 05:24:03 +01:00
function drawContent(panel) { #region >>>>>>>>>>>>>>>>>>>> MAIN DRAW <<<<<<<<<<<<<<<<<<<<
2023-05-08 19:14:30 +02:00
draw_clear_alpha(COLORS.panel_bg_clear, 0);
2022-01-13 05:24:03 +01:00
2022-11-18 03:20:31 +01:00
draw_sprite_stretched(THEME.ui_panel_bg, 1, ui(8), top_bar_h - ui(8), w - ui(16), h - top_bar_h);
2022-01-13 05:24:03 +01:00
2023-07-28 19:41:57 +02:00
if(inspecting && !inspecting.active)
inspecting = noone;
2023-03-21 03:01:53 +01:00
if(inspecting) {
2024-02-01 05:26:02 +01:00
var _ins = instanceof(inspecting);
var _nodes = PANEL_GRAPH.nodes_selecting;
inspectGroup = array_length(_nodes) > 1;
inspectings = array_empty(_nodes)? [ inspecting ] : _nodes;
for( var i = 0, n = array_length(_nodes); i < n; i++ )
if(instanceof(_nodes[i]) != _ins) { inspectGroup = -1; break; }
title = inspecting.renamed? inspecting.display_name : inspecting.name;
2023-07-25 20:12:40 +02:00
inspecting.inspectorStep();
2022-01-13 05:24:03 +01:00
drawInspectingNode();
2023-03-21 03:01:53 +01:00
} else {
2023-06-04 18:28:29 +02:00
title = __txt("Inspector");
2023-03-21 03:01:53 +01:00
2023-02-14 02:51:14 +01:00
var txt = "Untitled";
var context = PANEL_GRAPH.getCurrentContext();
2023-12-08 03:50:09 +01:00
if(context == noone && file_exists_empty(PROJECT.path))
2023-07-06 19:49:16 +02:00
txt = string_replace(filename_name(PROJECT.path), filename_ext(PROJECT.path), "");
2023-02-28 09:43:01 +01:00
else if(context != noone)
2023-02-14 02:51:14 +01:00
txt = context.name;
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
2023-03-13 10:45:56 +01:00
draw_text_add(w / 2, ui(30), txt);
2023-02-14 02:51:14 +01:00
2023-11-27 14:50:20 +01:00
if(PROJECT.meta.steam == FILE_STEAM_TYPE.steamOpen) {
var _tw = string_width(txt) / 2;
draw_sprite_ui(THEME.steam, 0, w / 2 - _tw - ui(16), ui(32),,,, COLORS._main_icon);
}
2023-02-14 02:51:14 +01:00
var bx = w - ui(44);
var by = ui(12);
2023-07-25 20:12:40 +02:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_inspector_set_default", "Set Metadata as default"), THEME.save, 0, COLORS._main_icon) == 2) {
2023-02-14 02:51:14 +01:00
var path = DIRECTORY + "meta.json";
2023-11-27 14:50:20 +01:00
json_save_struct(path, PROJECT.meta.serialize());
2023-02-14 02:51:14 +01:00
}
2023-02-15 10:04:49 +01:00
by += ui(36);
2023-02-28 09:43:01 +01:00
if(STEAM_ENABLED && !workshop_uploading) {
2023-07-06 19:49:16 +02:00
if(PROJECT.path == "") {
2023-06-04 18:28:29 +02:00
buttonInstant(noone, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_inspector_workshop_save", "Save file before upload"), THEME.workshop_upload, 0, COLORS._main_icon, 0.5);
2023-02-28 09:43:01 +01:00
} else {
2023-11-27 14:50:20 +01:00
if(PROJECT.meta.steam == FILE_STEAM_TYPE.local) { //project made locally
2023-06-04 18:28:29 +02:00
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_inspector_workshop_upload", "Upload to Steam Workshop"), THEME.workshop_upload, 0, COLORS._main_icon) == 2) {
2023-05-07 20:55:13 +02:00
var s = PANEL_PREVIEW.getNodePreviewSurface();
if(is_surface(s)) {
2023-11-27 14:50:20 +01:00
PROJECT.meta.author_steam_id = STEAM_USER_ID;
PROJECT.meta.steam = FILE_STEAM_TYPE.steamUpload;
2023-11-27 11:40:28 +01:00
SAVE_AT(PROJECT, PROJECT.path);
2023-05-07 20:55:13 +02:00
steam_ugc_create_project();
workshop_uploading = true;
} else
noti_warning("Please send any node to preview panel to use as a thumbnail.")
2023-02-28 09:43:01 +01:00
}
2023-02-15 10:04:49 +01:00
}
2023-11-27 11:40:28 +01:00
2023-11-27 14:50:20 +01:00
if(PROJECT.meta.steam && PROJECT.meta.author_steam_id == STEAM_USER_ID) {
if(PROJECT.meta.steam == FILE_STEAM_TYPE.steamUpload) {
2023-11-27 11:40:28 +01:00
buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], false, pHOVER, __txtx("panel_inspector_workshop_restart", "Open project from the workshop tab to update."), THEME.workshop_update, 0, COLORS._main_icon);
} else if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_inspector_workshop_update", "Update Steam Workshop content"), THEME.workshop_update, 0, COLORS._main_icon) == 2) {
SAVE_AT(PROJECT, PROJECT.path);
2023-02-28 09:43:01 +01:00
steam_ugc_update_project();
workshop_uploading = true;
}
2023-02-15 10:04:49 +01:00
}
}
}
if(workshop_uploading) {
draw_sprite_ui(THEME.loading_s, 0, bx + ui(16), by + ui(16),,, current_time / 5, COLORS._main_icon);
if(STEAM_UGC_ITEM_UPLOADING == false)
workshop_uploading = false;
}
2023-02-14 02:51:14 +01:00
}
2022-01-13 05:24:03 +01:00
2023-06-21 20:36:53 +02:00
contentPane.setFocusHover(pFOCUS, pHOVER);
2022-11-03 11:44:49 +01:00
contentPane.draw(ui(16), top_bar_h, mx - ui(16), my - top_bar_h);
2022-01-13 05:24:03 +01:00
if(!locked && PANEL_GRAPH.getFocusingNode() && inspecting != PANEL_GRAPH.getFocusingNode())
setInspecting(PANEL_GRAPH.getFocusingNode());
} #endregion
2022-01-13 05:24:03 +01:00
}