mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 20:45:35 +01:00
- [Export Graph] Fix general crash.
This commit is contained in:
parent
0009a20ba3
commit
c506e06023
@ -1,15 +1,25 @@
|
|||||||
function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
|
function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
|
||||||
title = __txtx("panel_export_graph", "Export Graph");
|
title = __txtx("panel_export_graph", "Export Graph");
|
||||||
padding = ui(8);
|
padding = ui(8);
|
||||||
w = ui(640);
|
w = min(WIN_W, ui(800));
|
||||||
h = ui(400);
|
h = ui(400);
|
||||||
set_w = ui(240);
|
|
||||||
surf_s = w - set_w - padding * 2;
|
min_w = ui(640);
|
||||||
|
min_h = ui(320);
|
||||||
|
|
||||||
|
set_wm = ui(320);
|
||||||
|
surf_s = min(w - set_wm - padding * 3, h - padding * 2);
|
||||||
|
|
||||||
|
c_space = ui(24);
|
||||||
|
set_w = w - surf_s - padding * 2 - c_space;
|
||||||
|
set_h = h - padding * 2 - ui(32) - padding;
|
||||||
|
|
||||||
self.targetPanel = targetPanel;
|
self.targetPanel = targetPanel;
|
||||||
|
|
||||||
nodeList = targetPanel.nodes_list;
|
nodeList = targetPanel.nodes_list;
|
||||||
surface = noone;
|
surface = noone;
|
||||||
|
bg_surface = noone;
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
scale : 1,
|
scale : 1,
|
||||||
padding : 64,
|
padding : 64,
|
||||||
@ -77,10 +87,10 @@ function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
|
|||||||
|
|
||||||
b_export.text = __txt("Export") + "...";
|
b_export.text = __txt("Export") + "...";
|
||||||
|
|
||||||
sc_settings = new scrollPane(set_w, h - padding * 2, function(_y, _m) {
|
sc_settings = new scrollPane(set_w, set_h, function(_y, _m) {
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
|
|
||||||
var _ww = ui(160);
|
var _ww = max(set_w * 0.5, ui(160));
|
||||||
var _hh = ui(30);
|
var _hh = ui(30);
|
||||||
var _ss = ui(28);
|
var _ss = ui(28);
|
||||||
var ty = _y + _hh / 2;
|
var ty = _y + _hh / 2;
|
||||||
@ -108,9 +118,12 @@ function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function onResize() {
|
function onResize() {
|
||||||
surf_s = w - set_w - padding * 2;
|
surf_s = min(w - set_wm - padding * 3, h - padding * 2);
|
||||||
|
|
||||||
sc_settings.resize(set_w, h - padding * 2);
|
set_w = w - surf_s - padding * 2 - c_space;
|
||||||
|
set_h = h - padding * 2 - ui(32) - padding;
|
||||||
|
|
||||||
|
sc_settings.resize(set_w, set_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
@ -130,40 +143,54 @@ function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
|
|||||||
var sh = 160;
|
var sh = 160;
|
||||||
|
|
||||||
var _sx0 = tx, _sx1 = _sx0 + surf_s;
|
var _sx0 = tx, _sx1 = _sx0 + surf_s;
|
||||||
var _sy0 = ty, _sy1 = _sy0 + surf_s;
|
var _sy0 = h / 2 - surf_s / 2;
|
||||||
|
var _sy1 = h / 2 + surf_s / 2;
|
||||||
|
|
||||||
|
var _m = [ mx, my ];
|
||||||
|
|
||||||
if(is_surface(surface)) {
|
if(is_surface(surface)) {
|
||||||
var _sw = surface_get_width_safe(surface);
|
var _sw = surface_get_width_safe(surface);
|
||||||
var _sh = surface_get_height_safe(surface);
|
var _sh = surface_get_height_safe(surface);
|
||||||
var ss = min(surf_s / _sw, surf_s / _sh);
|
var ss = min(surf_s / _sw, surf_s / _sh);
|
||||||
|
|
||||||
draw_surface_ext_safe(surface, _sx0 + surf_s / 2 - _sw * ss / 2,
|
bg_surface = surface_verify(bg_surface, _sw * ss, _sh * ss);
|
||||||
_sy0 + surf_s / 2 - _sh * ss / 2, ss, ss, 0, c_white, 1);
|
surface_set_target(bg_surface);
|
||||||
|
draw_sprite_tiled_ext(s_transparent, 0, 0, 0, 1, 1, COLORS.panel_preview_transparent, 1);
|
||||||
|
surface_reset_target();
|
||||||
|
|
||||||
|
var _sx = _sx0 + surf_s / 2 - _sw * ss / 2;
|
||||||
|
var _sy = _sy0 + surf_s / 2 - _sh * ss / 2;
|
||||||
|
|
||||||
|
draw_surface(bg_surface, _sx, _sy);
|
||||||
|
draw_surface_ext_safe(surface, _sx, _sy, ss, ss, 0, c_white, 1);
|
||||||
|
|
||||||
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text_sub);
|
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text_sub);
|
||||||
draw_text_add(w / 2, ty + sh - ui(2), $"{_sw} x {_sh} px");
|
draw_text_add(_sx0 + surf_s / 2, _sy + _sh * ss - ui(2), $"{_sw} x {_sh} px");
|
||||||
|
|
||||||
|
draw_set_color(COLORS._main_icon);
|
||||||
|
draw_rectangle(_sx, _sy, _sx + _sw * ss, _sy + _sh * ss, 1);
|
||||||
|
|
||||||
|
var bx = _sx1 - ui(24) - ui(4);
|
||||||
|
var by = _sy + ui(1) + ui(4);
|
||||||
|
|
||||||
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, pFOCUS, pHOVER) == 2)
|
||||||
|
refresh();
|
||||||
|
draw_sprite_ui(THEME.refresh_16, 0, bx + ui(12), by + ui(12),,,, COLORS._main_icon, 1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
draw_set_color(COLORS._main_icon);
|
||||||
|
draw_rectangle(_sx0, _sy0, _sx1, _sy1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_set_color(COLORS._main_icon);
|
var sx = w - padding - set_w;
|
||||||
draw_rectangle(_sx0, _sy0, _sx1, _sy1, 1);
|
var sy = ty;
|
||||||
|
|
||||||
var bx = _sx1 - ui(24);
|
|
||||||
var by = _sy0;
|
|
||||||
var _m = [ mx, my ];
|
|
||||||
|
|
||||||
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, pFOCUS, pHOVER) == 2)
|
|
||||||
refresh();
|
|
||||||
draw_sprite_ui(THEME.refresh_16, 0, bx + ui(12), by + ui(12),,,, COLORS._main_icon, 1);
|
|
||||||
|
|
||||||
var sx = _sx1;
|
|
||||||
var sy = _sy0;
|
|
||||||
|
|
||||||
sc_settings.setFocusHover(pFOCUS, pHOVER);
|
sc_settings.setFocusHover(pFOCUS, pHOVER);
|
||||||
sc_settings.draw(sx, sy, mx - sx, my - sy);
|
sc_settings.draw(sx, sy, mx - sx, my - sy);
|
||||||
|
|
||||||
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
|
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
|
||||||
var _bw = ui(64);
|
var _bw = ui(96);
|
||||||
var _bh = ui(24);
|
var _bh = ui(32);
|
||||||
bx = w - padding - _bw;
|
bx = w - padding - _bw;
|
||||||
by = h - padding - _bh;
|
by = h - padding - _bh;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user