mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
graph minimap
This commit is contained in:
parent
56ff68fe23
commit
9640608002
19 changed files with 254 additions and 50 deletions
|
@ -363,6 +363,8 @@
|
|||
{"$GMIncludedFile":"","%Name":"icons.afdesign","CopyToMask":-1,"filePath":"datafiles/data/Actions","name":"icons.afdesign","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Armature Build.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Armature Build.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Armature Build.png","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Armature Build.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Create Tilemap.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Create Tilemap.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Create Tilemap.png","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Create Tilemap.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Follow Path.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Follow Path.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Follow Path.png","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Follow Path.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Iso cube.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes","name":"Iso cube.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
|
Binary file not shown.
15
datafiles/data/Actions/Nodes/Create Tilemap.json
Normal file
15
datafiles/data/Actions/Nodes/Create Tilemap.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "Create Tilemap",
|
||||
"tooltip": "",
|
||||
"sprPath": "./Create Tilemap.png",
|
||||
"tags": [],
|
||||
"nodes": [
|
||||
{ "x": 176, "y": 0, "node": "Node_Tile_Drawer" },
|
||||
{ "x": 0, "y": 0, "node": "Node_Tile_Tileset" }
|
||||
],
|
||||
"connections": [
|
||||
{ "from": 1, "to": 0, "fromIndex": 0, "toIndex": 0 }
|
||||
],
|
||||
"location": [ "IO", "Tileset" ],
|
||||
"inputNode": 1,
|
||||
}
|
BIN
datafiles/data/Actions/Nodes/Create Tilemap.png
Normal file
BIN
datafiles/data/Actions/Nodes/Create Tilemap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
@ -194,8 +194,17 @@ event_inherited();
|
|||
PANEL_INSPECTOR.setInspecting(_new_node);
|
||||
|
||||
} else if(is_instanceof(_node, NodeAction)) { // NOT IMPLEMENTED
|
||||
_node.build(node_target_x, node_target_y,, _param);
|
||||
return;
|
||||
var _dat = _node.build(node_target_x, node_target_y,, _param);
|
||||
var _node_in = _dat.inputNode;
|
||||
var _node_out = _dat.outputNode;
|
||||
|
||||
if(_node_in != noone)
|
||||
for( var i = 0, n = array_length(_node_in.inputs); i < n; i++ )
|
||||
array_push(_inputs, _node_in.inputs[i]);
|
||||
|
||||
if(_node_out != noone)
|
||||
for( var i = 0, n = array_length(_node_out.outputs); i < n; i++ )
|
||||
array_push(_outputs, _node_out.outputs[i]);
|
||||
|
||||
} else {
|
||||
var _new_list = APPEND(_node.path);
|
||||
|
|
|
@ -61,13 +61,14 @@ function tiler_rule() constructor {
|
|||
array_push(__sel, _s);
|
||||
}
|
||||
|
||||
scanSize = [ max(1, maxX - minX + 1), max(1, maxY - minY + 1) ];
|
||||
scanSize = minX < maxX? [ max(1, maxX - minX + 1), max(1, maxY - minY + 1) ] : size;
|
||||
// print($"{maxX}, {minX} | {maxY}, {minY} | {scanSize}");
|
||||
|
||||
autI = array_unique(autI);
|
||||
for( var i = 0, n = array_length(autI); i < n; i++ ) {
|
||||
var _i = autI[i];
|
||||
var _t = tileset.autoterrain[_i];
|
||||
var _t = array_safe_get(tileset.autoterrain, _i, noone);
|
||||
if(_t == noone) continue;
|
||||
|
||||
var _ind = 64 * i;
|
||||
__aut[_ind] = array_length(_t.index);
|
||||
|
@ -332,8 +333,9 @@ function Tileset_Rule(_tileset) : Inspector_Custom_Renderer(noone, noone) constr
|
|||
var _aa = _rl_selected? 1 : .5 + _rl_hov * .5;
|
||||
|
||||
if(is_array(_rl_sel)) {
|
||||
var _autt = tileset.autoterrain[_rl_sel[1]];
|
||||
tileset.drawTile(_autt.index[0], _rl_x + ui(2), _rl_y + ui(2), _sls - ui(4), _sls - ui(4));
|
||||
var _autt = array_safe_get(tileset.autoterrain, _rl_sel[1], noone);
|
||||
|
||||
tileset.drawTile(_autt == noone? 0 : _autt.index[0], _rl_x + ui(2), _rl_y + ui(2), _sls - ui(4), _sls - ui(4));
|
||||
draw_sprite_uniform(THEME.circle, 0, _rl_x + _sls - ui(8), _rl_y + _sls - ui(8), 1, COLORS._main_accent);
|
||||
|
||||
} else if (_rl_sel == -10000) {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_01_0;
|
||||
SAVE_VERSION = 1_18_02_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.3.010";
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.3.011";
|
||||
BUILD_NUMBER = 1_18_03_0;
|
||||
|
||||
HOTKEYS = ds_map_create();
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
|
||||
var _n = {};
|
||||
var _node_in = noone;
|
||||
var _node_out = noone;
|
||||
|
||||
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
|
||||
var __n = nodes[i];
|
||||
|
@ -62,6 +64,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(i == inputNode) _node_in = _node;
|
||||
if(i == outputNode) _node_out = _node;
|
||||
}
|
||||
|
||||
for( var i = 0, n = array_length(connections); i < n; i++ ) {
|
||||
|
@ -77,7 +82,7 @@
|
|||
_toI.setFrom(_frO);
|
||||
}
|
||||
|
||||
return _n;
|
||||
return { nodes: _n, inputNode: _node_in, outputNode: _node_out };
|
||||
}
|
||||
|
||||
static serialize = function() {
|
||||
|
@ -94,7 +99,7 @@
|
|||
nodes = struct_try_get(map, "nodes", []);
|
||||
connections = struct_try_get(map, "connections", []);
|
||||
|
||||
inputNode = struct_try_get(map, "inputNode", noone);
|
||||
inputNode = struct_try_get(map, "inputNode", noone);
|
||||
outputNode = struct_try_get(map, "outputNode", noone);
|
||||
|
||||
location = struct_try_get(map, "location", noone);
|
||||
|
|
|
@ -209,12 +209,14 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
}
|
||||
|
||||
if(_node == noone)
|
||||
_node = nodeBuild("Node_ASE_layer", nx, ny + i * _nh);
|
||||
_node = nodeBuild("Node_ASE_layer", nx, ny + i * _nh).skipDefault();
|
||||
|
||||
_node.inputs[0].setFrom(outputs[1]);
|
||||
_node.inputs[1].setValue(use_cel);
|
||||
_node.inputs[2].setValue(_name);
|
||||
_node.setDisplayName(_name);
|
||||
|
||||
lvs[i] = _node;
|
||||
lvs[i].inputs[0].setFrom(outputs[1]);
|
||||
lvs[i].inputs[1].setValue(use_cel);
|
||||
lvs[i].setDisplayName(_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,17 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
newInput(1, nodeValue_Bool("Crop Output", self, false))
|
||||
.rejectArray();
|
||||
|
||||
newInput(2, nodeValue_Text("Layer name", self, ""))
|
||||
.rejectArray();
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
newOutput(1, nodeValue_Output("Layer name", self, VALUE_TYPE.text, ""));
|
||||
|
||||
input_display_list = [
|
||||
0, 2, 1,
|
||||
];
|
||||
|
||||
layer_object = noone;
|
||||
_name = "";
|
||||
|
||||
|
@ -22,8 +31,11 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
var data = getInputDataForce(0);
|
||||
if(data == noone) return;
|
||||
|
||||
var name = getInputData(2);
|
||||
setDisplayName(name);
|
||||
|
||||
for( var i = 0, n = array_length(data.layers); i < n; i++ ) {
|
||||
if(data.layers[i].name == display_name)
|
||||
if(data.layers[i].name == name)
|
||||
layer_object = data.layers[i];
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +48,8 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
var cel = layer_object.getCel(CURRENT_FRAME - data._tag_delay);
|
||||
|
||||
var celDim = getInputData(1);
|
||||
var name = getInputData(2);
|
||||
|
||||
var ww = data.content[$ "Width"];
|
||||
var hh = data.content[$ "Height"];
|
||||
var cw = cel? cel.data[$ "Width"] : 1;
|
||||
|
@ -45,6 +59,7 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
if(celDim) surf = surface_verify(surf, cw, ch);
|
||||
else surf = surface_verify(surf, ww, hh);
|
||||
outputs[0].setValue(surf);
|
||||
outputs[1].setValue(name);
|
||||
|
||||
if(cel == 0) { surface_clear(surf); return; }
|
||||
|
||||
|
|
|
@ -1177,6 +1177,17 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
}
|
||||
}
|
||||
|
||||
for(var i = 0; i < array_length(junc_meta); i++) {
|
||||
var _ot = junc_meta[i];
|
||||
var _tos = _ot.getJunctionTo();
|
||||
|
||||
for( var j = 0; j < array_length(_tos); j++ ) {
|
||||
var _to = _tos[j];
|
||||
array_push(nodes, _to.node);
|
||||
array_push(nodeNames, _to.node.internalName);
|
||||
}
|
||||
}
|
||||
|
||||
for(var i = 0; i < array_length(inputs); i++) {
|
||||
var _in = inputs[i];
|
||||
if(_in.bypass_junc == noone) continue;
|
||||
|
|
|
@ -295,7 +295,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var frames = [];
|
||||
|
||||
while(_path != "") {
|
||||
var _frame = string_quote(temp_path + string_replace_all(_path, ".png", "") + ".webp");
|
||||
var _frame = string_quote(temp_path + string_replace_all(_path, ".png", "") + ".webp");
|
||||
var _pathTemp = string_quote(temp_path + _path);
|
||||
var shell_cmd = $"{_pathTemp} -define webp:lossless=true {_frame}";
|
||||
|
||||
|
@ -565,6 +565,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
static export = function(log = true) {
|
||||
// print($">>>>>>>>>>>>>>>>>>>> export {CURRENT_FRAME} <<<<<<<<<<<<<<<<<<<<");
|
||||
|
||||
randomize();
|
||||
directory = $"{TEMPDIR}{irandom_range(100000, 999999)}";
|
||||
exportLog = log;
|
||||
|
||||
var surf = getInputData( 0);
|
||||
|
|
|
@ -256,7 +256,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
|
||||
temp_surface[0] = surface_verify(temp_surface[0], _mapSize[0], _mapSize[1], surface_rgba16float);
|
||||
temp_surface[1] = surface_verify(temp_surface[1], _mapSize[0], _mapSize[1], surface_rgba16float);
|
||||
temp_surface[2] = surface_verify(temp_surface[2], _mapSize[0], _mapSize[1], surface_r16float);
|
||||
temp_surface[2] = surface_verify(temp_surface[2], _mapSize[0], _mapSize[1], surface_rgba16float);
|
||||
|
||||
surface_set_shader(drawing_surface, noone, true, BLEND.over);
|
||||
draw_surface(canvas_surface, 0, 0);
|
||||
|
@ -272,8 +272,11 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
canvas_buffer = buffer_verify(canvas_buffer, _mapSize[0] * _mapSize[1] * 8);
|
||||
buffer_get_surface(canvas_buffer, canvas_surface, 0);
|
||||
|
||||
var _applied = tileset.rules.apply(canvas_surface, _seed);
|
||||
// var _applied = canvas_surface;
|
||||
surface_set_shader(temp_surface[2], sh_sample, true, BLEND.over);
|
||||
draw_surface(canvas_surface, 0, 0);
|
||||
surface_reset_shader();
|
||||
|
||||
var _applied = tileset.rules.apply(temp_surface[2], _seed);
|
||||
|
||||
surface_set_shader(_tileMap, sh_sample, true, BLEND.over);
|
||||
draw_surface(_applied, 0, 0);
|
||||
|
|
|
@ -45,7 +45,7 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||
|
||||
static setPencil = function() {
|
||||
var _n = PANEL_INSPECTOR.getInspecting();
|
||||
if(!is(_n, Node_Tile_Drawer)) continue;
|
||||
if(!is(_n, Node_Tile_Drawer)) return;
|
||||
if(PANEL_PREVIEW.tool_current != _n.tool_pencil)
|
||||
_n.tool_pencil.toggle();
|
||||
}
|
||||
|
|
|
@ -1963,8 +1963,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
_s *= 2;
|
||||
}
|
||||
|
||||
if(graph_selecting)
|
||||
__draw_sprite_ext(THEME.node_junction_selecting, 0, x, y, _s, _s, 0, _cfg, .8);
|
||||
if(graph_selecting) __draw_sprite_ext(THEME.node_junction_selecting, 0, x, y, _s, _s, 0, _cfg, .8);
|
||||
graph_selecting = false;
|
||||
|
||||
__draw_sprite_ext(_bgS, draw_junction_index, x, y, _s, _s, 0, _cbg, 1);
|
||||
|
|
|
@ -86,7 +86,7 @@ function Panel_Action_Create() : PanelContent() constructor {
|
|||
|
||||
#region content
|
||||
sc_node_content = new scrollPane(w - padding * 2 - ui(320) - ui(16), h - padding * 2 - ui(16), function(_y, _m) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||
draw_clear_alpha(COLORS.panel_bg_clear_inner, 1);
|
||||
var _w = sc_node_content.surface_w;
|
||||
var _h = ui(16);
|
||||
var yy = _y;
|
||||
|
|
|
@ -1935,19 +1935,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
if(value_focus)
|
||||
array_push_unique(value_draggings, value_focus);
|
||||
|
||||
for (var i = 0, n = array_length(value_draggings); i < n; i++) {
|
||||
var _v = value_draggings[i];
|
||||
var xx = _v.x - 1;
|
||||
var yy = _v.y - 1;
|
||||
|
||||
shader_set(sh_node_circle);
|
||||
shader_set_color("color", COLORS._main_accent);
|
||||
shader_set_f("thickness", 0.05);
|
||||
shader_set_f("antialias", 0.05);
|
||||
draw_rectangle(xx - 12 * graph_s, yy - 12 * graph_s, xx + 12 * graph_s, yy + 12 * graph_s, false);
|
||||
shader_reset();
|
||||
}
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
value_dragging = noone;
|
||||
connection_draw_mouse = noone;
|
||||
|
@ -2240,7 +2227,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
}
|
||||
|
||||
surface_set_target(minimap_surface);
|
||||
draw_clear_alpha(COLORS.panel_bg_clear_inner, 0.75);
|
||||
DRAW_CLEAR
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 0, 0, 0, minimap_w, minimap_h, COLORS.panel_bg_clear_inner, .75 + .25 * hover);
|
||||
|
||||
if(!array_empty(nodes_list)) {
|
||||
var minx = 99999;
|
||||
var maxx = -99999;
|
||||
|
@ -2262,7 +2251,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
var sph = maxy - miny;
|
||||
var ss = min(minimap_w / spw, minimap_h / sph);
|
||||
|
||||
draw_set_alpha(0.4);
|
||||
for(var i = 0; i < array_length(nodes_list); i++) {
|
||||
var _node = nodes_list[i];
|
||||
|
||||
|
@ -2276,16 +2264,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
draw_rectangle(nx, ny, nx + nw, ny + nh, false);
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
draw_set_alpha(1);
|
||||
|
||||
var gx = minimap_w / 2 - (graph_x + cx) * ss;
|
||||
var gy = minimap_h / 2 - (graph_y + cy) * ss;
|
||||
var gw = w / graph_s * ss;
|
||||
var gh = h / graph_s * ss;
|
||||
|
||||
draw_set_color(COLORS.panel_graph_minimap_focus);
|
||||
draw_rectangle(gx, gy, gx + gw, gy + gh, 1);
|
||||
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 1, gx, gy, gw, gh, COLORS._main_icon_light, 1);
|
||||
|
||||
if(minimap_panning) {
|
||||
graph_x = -((mx - mx0 - gw / 2) - minimap_w / 2) / ss - cx;
|
||||
graph_y = -((my - my0 - gh / 2) - minimap_h / 2) / ss - cy;
|
||||
|
@ -2301,11 +2287,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
minimap_panning = true;
|
||||
}
|
||||
|
||||
BLEND_MULTIPLY
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 0, 0, 0, minimap_w, minimap_h, c_white, 1);
|
||||
BLEND_NORMAL
|
||||
|
||||
surface_reset_target();
|
||||
|
||||
draw_surface_ext_safe(minimap_surface, mx0, my0, 1, 1, 0, c_white, 0.5 + 0.35 * hover);
|
||||
draw_set_color(COLORS.panel_graph_minimap_outline);
|
||||
draw_rectangle(mx0, my0, mx1 - 1, my1 - 1, true);
|
||||
draw_surface_ext_safe(minimap_surface, mx0, my0, 1, 1, 0, c_white, .75 + .25 * hover);
|
||||
draw_sprite_stretched_add(THEME.ui_panel, 1, mx0, my0, minimap_w, minimap_h, COLORS.panel_graph_minimap_outline, .5);
|
||||
|
||||
if(minimap_dragging) {
|
||||
mouse_on_graph = false;
|
||||
|
|
|
@ -157,6 +157,8 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_h = ui(128);
|
||||
canvas_a = 0;
|
||||
canvas_bg = -1;
|
||||
canvas_mx = 0;
|
||||
canvas_my = 0;
|
||||
do_fullView = false;
|
||||
|
||||
canvas_hover = true;
|
||||
|
@ -343,6 +345,20 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
#endregion
|
||||
#endregion
|
||||
|
||||
#region // ---- minimap ----
|
||||
minimap_show = false;
|
||||
minimap_w = ui(160);
|
||||
minimap_h = ui(160);
|
||||
minimap_surface = -1;
|
||||
|
||||
minimap_panning = false;
|
||||
minimap_dragging = false;
|
||||
minimap_drag_sx = 0;
|
||||
minimap_drag_sy = 0;
|
||||
minimap_drag_mx = 0;
|
||||
minimap_drag_my = 0;
|
||||
#endregion
|
||||
|
||||
#region ++++ toolbars & actions ++++
|
||||
static set_tile_off = function() /*=>*/ { tileMode = 0; }
|
||||
static set_tile_horizontal = function() /*=>*/ { tileMode = 1; }
|
||||
|
@ -452,24 +468,30 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
];
|
||||
|
||||
actions = [
|
||||
[
|
||||
THEME.lock,
|
||||
new tooltipHotkey(__txtx("panel_preview_lock_preview", "Lock previewing node"), "Preview", "Toggle Lock"),
|
||||
toggle_lock,
|
||||
function() /*=>*/ {return !locked},
|
||||
],
|
||||
[
|
||||
THEME.icon_preview_export,
|
||||
new tooltipHotkey(__txtx("panel_preview_export_canvas", "Export canvas"), "Preview", "Save current frame"),
|
||||
function() /*=>*/ { saveCurrentFrame(); },
|
||||
function() /*=>*/ {return 0},
|
||||
],
|
||||
[
|
||||
THEME.lock,
|
||||
new tooltipHotkey(__txtx("panel_preview_lock_preview", "Lock previewing node"), "Preview", "Toggle Lock"),
|
||||
toggle_lock,
|
||||
function() /*=>*/ {return !locked},
|
||||
],
|
||||
[
|
||||
THEME.icon_center_canvas,
|
||||
new tooltipHotkey(__txtx("panel_preview_center_canvas", "Center canvas"), "Preview", "Focus content"),
|
||||
function() /*=>*/ { fullView(); },
|
||||
function() /*=>*/ {return 0},
|
||||
],
|
||||
[
|
||||
THEME.icon_minimap,
|
||||
new tooltipHotkey(__txtx("panel_graph_toggle_minimap", "Toggle minimap"), "Graph", "Toggle Minimap"),
|
||||
function(param) /*=>*/ { minimap_show = !minimap_show; },
|
||||
function() /*=>*/ {return minimap_show},
|
||||
],
|
||||
[
|
||||
THEME.icon_visibility,
|
||||
new tooltipHotkey(__txtx("graph_visibility_title", "Visibility settings") + "...", "Preview", "View Settings"),
|
||||
|
@ -2249,6 +2271,9 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
tool_side_draw_l = false;
|
||||
tool_side_draw_r = false;
|
||||
|
||||
canvas_mx = (mx - canvas_x) / canvas_s;
|
||||
canvas_my = (my - canvas_y) / canvas_s;
|
||||
|
||||
if(PANEL_PREVIEW == self) {
|
||||
if(inspect_node) {
|
||||
tool = inspect_node.getTool();
|
||||
|
@ -2260,6 +2285,7 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
if(d3_active == NODE_3D.none) drawSplitView();
|
||||
|
||||
drawToolBar(tool, _prev_node);
|
||||
drawMinimap();
|
||||
|
||||
if(mouse_on_preview && mouse_press(mb_right, pFOCUS) && !key_mod_press(SHIFT)) {
|
||||
menuCall("preview_context_menu", [
|
||||
|
@ -2300,6 +2326,130 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
|
||||
}
|
||||
|
||||
function drawMinimap() { //
|
||||
if(!minimap_show) return;
|
||||
|
||||
var mx1 = w - ui(8);
|
||||
var my1 = h - toolbar_height - ui(8);
|
||||
var mx0 = mx1 - minimap_w;
|
||||
var my0 = my1 - minimap_h;
|
||||
|
||||
minimap_w = min(minimap_w, w - ui(16));
|
||||
minimap_h = min(minimap_h, h - ui(16) - toolbar_height);
|
||||
|
||||
var mini_hover = false;
|
||||
if(pHOVER && point_in_rectangle(mx, my, mx0, my0, mx1, my1)) {
|
||||
mouse_on_preview = false;
|
||||
mini_hover = true;
|
||||
}
|
||||
|
||||
var hover = mini_hover && !point_in_rectangle(mx, my, mx0, my0, mx0 + ui(16), my0 + ui(16)) && !minimap_dragging;
|
||||
minimap_surface = surface_verify(minimap_surface, minimap_w, minimap_h);
|
||||
|
||||
surface_set_target(minimap_surface);
|
||||
DRAW_CLEAR
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 0, 0, 0, minimap_w, minimap_h, COLORS.panel_bg_clear_inner, .75 + .25 * hover);
|
||||
|
||||
var _surf = getNodePreviewSurface();
|
||||
var minx, maxx, miny, maxy;
|
||||
var _dim;
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
_dim = surface_get_dimension(_surf);
|
||||
|
||||
minx = -32;
|
||||
maxx = 32 + _dim[0];
|
||||
miny = -32;
|
||||
maxy = 32 + _dim[1];
|
||||
|
||||
} else {
|
||||
minx = -32;
|
||||
maxx = 32;
|
||||
miny = -32;
|
||||
maxy = 32;
|
||||
}
|
||||
|
||||
var cx = (minx + maxx) / 2;
|
||||
var cy = (miny + maxy) / 2;
|
||||
var spw = maxx - minx;
|
||||
var sph = maxy - miny;
|
||||
var ss = min(minimap_w / spw, minimap_h / sph);
|
||||
|
||||
var nx0 = minimap_w / 2 + (0 - cx) * ss;
|
||||
var ny0 = minimap_h / 2 + (0 - cy) * ss;
|
||||
var nx1 = minimap_w / 2 + (_dim[0] - cx) * ss;
|
||||
var ny1 = minimap_h / 2 + (_dim[1] - cy) * ss;
|
||||
|
||||
var vx0 = (-canvas_x ) / canvas_s;
|
||||
var vy0 = (-canvas_y ) / canvas_s;
|
||||
var vx1 = (-canvas_x + w) / canvas_s;
|
||||
var vy1 = (-canvas_y + h) / canvas_s;
|
||||
|
||||
var gx0 = minimap_w / 2 + (vx0 - cx) * ss;
|
||||
var gy0 = minimap_h / 2 + (vy0 - cy) * ss;
|
||||
var gx1 = minimap_w / 2 + (vx1 - cx) * ss;
|
||||
var gy1 = minimap_h / 2 + (vy1 - cy) * ss;
|
||||
var gw = gx1 - gx0;
|
||||
var gh = gy1 - gy0;
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
draw_surface_ext(_surf, nx0, ny0, ss, ss, 0, c_white, 1);
|
||||
|
||||
// draw_set_color(COLORS.panel_graph_minimap_focus);
|
||||
// draw_rectangle(nx0, ny0, nx1, ny1, 1);
|
||||
|
||||
}
|
||||
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 1, gx0, gy0, gw, gh, COLORS._main_icon_light, 1);
|
||||
|
||||
var _mini_mx = minx + (mx - mx0) / minimap_w * spw;
|
||||
var _mini_my = miny + (my - my0) / minimap_h * sph;
|
||||
|
||||
if(minimap_panning) {
|
||||
canvas_x = w / 2 - _mini_mx * canvas_s;
|
||||
canvas_y = h / 2 - _mini_my * canvas_s;
|
||||
|
||||
if(mouse_release(mb_left))
|
||||
minimap_panning = false;
|
||||
}
|
||||
|
||||
if(mouse_click(mb_left, hover))
|
||||
minimap_panning = true;
|
||||
|
||||
BLEND_MULTIPLY
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 0, 0, 0, minimap_w, minimap_h, c_white, 1);
|
||||
BLEND_NORMAL
|
||||
|
||||
surface_reset_target();
|
||||
|
||||
draw_surface_ext_safe(minimap_surface, mx0, my0, 1, 1, 0, c_white, 1);
|
||||
draw_sprite_stretched_add(THEME.ui_panel, 1, mx0, my0, minimap_w, minimap_h, COLORS.panel_graph_minimap_outline, .5);
|
||||
|
||||
if(minimap_dragging) {
|
||||
mouse_on_graph = false;
|
||||
var sw = minimap_drag_sx + minimap_drag_mx - mx;
|
||||
var sh = minimap_drag_sy + minimap_drag_my - my;
|
||||
|
||||
minimap_w = max(ui(64), sw);
|
||||
minimap_h = max(ui(64), sh);
|
||||
|
||||
if(mouse_release(mb_left))
|
||||
minimap_dragging = false;
|
||||
}
|
||||
|
||||
if(pHOVER && point_in_rectangle(mx, my, mx0, my0, mx0 + ui(16), my0 + ui(16))) {
|
||||
draw_sprite_ui(THEME.node_resize, 0, mx0 + ui(10), my0 + ui(10), 0.5, 0.5, 180, c_white, 0.75);
|
||||
if(mouse_press(mb_left, pFOCUS)) {
|
||||
minimap_dragging = true;
|
||||
minimap_drag_sx = minimap_w;
|
||||
minimap_drag_sy = minimap_h;
|
||||
minimap_drag_mx = mx;
|
||||
minimap_drag_my = my;
|
||||
}
|
||||
} else
|
||||
draw_sprite_ui(THEME.node_resize, 0, mx0 + ui(10), my0 + ui(10), 0.5, 0.5, 180, c_white, 0.3);
|
||||
}
|
||||
|
||||
////=========== ACTION ===========
|
||||
|
||||
function copyCurrentFrame() {
|
||||
|
|
Loading…
Reference in a new issue