mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-11 23:06:51 +01:00
Fix crash when canceling open file dialog.
This commit is contained in:
parent
3859bb0c7d
commit
482878b245
7 changed files with 89 additions and 56 deletions
|
@ -17,6 +17,7 @@ event_inherited();
|
||||||
show_icon = false;
|
show_icon = false;
|
||||||
context = noone;
|
context = noone;
|
||||||
submenu = noone;
|
submenu = noone;
|
||||||
|
submenuIt = noone;
|
||||||
|
|
||||||
_hovering_ch = true;
|
_hovering_ch = true;
|
||||||
init_press_l = MOUSE_POOL.lpress;
|
init_press_l = MOUSE_POOL.lpress;
|
||||||
|
|
|
@ -14,6 +14,8 @@ DIALOG_WINCLEAR1
|
||||||
item_sel_submenu = noone;
|
item_sel_submenu = noone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var to_del = noone;
|
||||||
|
|
||||||
draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h);
|
draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h);
|
||||||
|
|
||||||
for(var i = 0; i < array_length(menu); i++) {
|
for(var i = 0; i < array_length(menu); i++) {
|
||||||
|
@ -60,53 +62,50 @@ DIALOG_WINCLEAR1
|
||||||
|
|
||||||
if(_hovering_ch && is_instanceof(_menuItem, MenuItem)) {
|
if(_hovering_ch && is_instanceof(_menuItem, MenuItem)) {
|
||||||
if(_menuItem.active && _lclick) {
|
if(_menuItem.active && _lclick) {
|
||||||
|
|
||||||
var _par = _menuItem.params;
|
var _par = _menuItem.params;
|
||||||
var _dat = {
|
|
||||||
_x: dialog_x,
|
|
||||||
x: dialog_x + dialog_w,
|
|
||||||
y: yy,
|
|
||||||
name: _menuItem.name,
|
|
||||||
index: i,
|
|
||||||
depth: depth,
|
|
||||||
context: context,
|
|
||||||
params: _menuItem.params,
|
|
||||||
};
|
|
||||||
|
|
||||||
if(_menuItem.isShelf) {
|
if(_menuItem.isShelf) {
|
||||||
FOCUS_CONTENT = context;
|
FOCUS_CONTENT = context;
|
||||||
|
|
||||||
if(instance_exists(submenu)) {
|
if(instance_exists(submenu)) {
|
||||||
var _sfr = submenu.itemFrom;
|
|
||||||
instance_destroy(submenu);
|
instance_destroy(submenu);
|
||||||
|
submenu = noone;
|
||||||
if(_sfr == _menuItem) {
|
|
||||||
submenu = noone;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(submenuIt == _menuItem) {
|
||||||
|
submenuIt = noone;
|
||||||
|
} else {
|
||||||
|
var _dat = {
|
||||||
|
_x: dialog_x,
|
||||||
|
x: dialog_x + dialog_w,
|
||||||
|
y: yy,
|
||||||
|
name: _menuItem.name,
|
||||||
|
index: i,
|
||||||
|
depth: depth,
|
||||||
|
context: context,
|
||||||
|
params: _par,
|
||||||
|
};
|
||||||
|
|
||||||
var _res = _menuItem.func(_dat);
|
var _res = _menuItem.func(_dat);
|
||||||
submenu = _res;
|
submenu = _res;
|
||||||
submenu.itemFrom = _menuItem;
|
submenuIt = _menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
} else if(remove_parents) {
|
} else if(remove_parents) {
|
||||||
DIALOG_POSTDRAW
|
|
||||||
FOCUS_CONTENT = context;
|
FOCUS_CONTENT = context;
|
||||||
|
|
||||||
if(_par == noone) _menuItem.func();
|
if(_par == noone) _menuItem.func();
|
||||||
else _menuItem.func(_par);
|
else _menuItem.func(_par);
|
||||||
instance_destroy(o_dialog_menubox); // close all
|
|
||||||
exit;
|
to_del = o_dialog_menubox;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DIALOG_POSTDRAW
|
|
||||||
FOCUS_CONTENT = context;
|
FOCUS_CONTENT = context;
|
||||||
|
|
||||||
if(_par == noone) _menuItem.func();
|
if(_par == noone) _menuItem.func();
|
||||||
else _menuItem.func(_par);
|
else _menuItem.func(_par);
|
||||||
instance_destroy();
|
|
||||||
exit;
|
to_del = self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,4 +299,6 @@ DIALOG_WINCLEAR1
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
DIALOG_POSTDRAW
|
DIALOG_POSTDRAW
|
||||||
|
|
||||||
|
if(to_del != noone) instance_destroy(to_del);
|
|
@ -11,6 +11,9 @@ if(init_press_l) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(submenu != noone && !instance_exists(submenu))
|
||||||
|
submenu = noone;
|
||||||
|
|
||||||
var hov = point_in(mouse_raw_x, mouse_raw_y);
|
var hov = point_in(mouse_raw_x, mouse_raw_y);
|
||||||
if(instance_exists(submenu))
|
if(instance_exists(submenu))
|
||||||
hov |= submenu.point_in(mouse_raw_x, mouse_raw_y);
|
hov |= submenu.point_in(mouse_raw_x, mouse_raw_y);
|
||||||
|
|
|
@ -532,7 +532,7 @@ event_inherited();
|
||||||
#region node
|
#region node
|
||||||
pref_node = ds_list_create();
|
pref_node = ds_list_create();
|
||||||
|
|
||||||
ds_list_add(pref_node, __txt("Node"));
|
// ds_list_add(pref_node, __txt("Node"));
|
||||||
|
|
||||||
ds_list_add(pref_node, new __Panel_Linear_Setting_Item_Preference(
|
ds_list_add(pref_node, new __Panel_Linear_Setting_Item_Preference(
|
||||||
__txtx("pref_node_param_show", "Show paramater on new node"),
|
__txtx("pref_node_param_show", "Show paramater on new node"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function file_exists_empty(path) { INLINE return path != "" && file_exists(path); }
|
function file_exists_empty(path) { INLINE path = string(path); return path != "" && file_exists(path); }
|
||||||
|
|
||||||
function file_copy_override(src, dest) {
|
function file_copy_override(src, dest) {
|
||||||
if(file_exists_empty(dest)) file_delete(dest);
|
if(file_exists_empty(dest)) file_delete(dest);
|
||||||
|
@ -43,6 +43,8 @@ function get_save_filename_pxc(filter, name, caption = "Save as") {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
var path = get_save_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
|
var path = get_save_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
|
||||||
|
path = string(path);
|
||||||
|
|
||||||
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
|
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +53,8 @@ function get_open_filename_pxc(filter, name, caption = "Open") {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
var path = get_open_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
|
var path = get_open_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
|
||||||
|
path = string(path);
|
||||||
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
|
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@ function LOAD(safe = false) {
|
||||||
var path = get_open_filename_pxc("Pixel Composer project (.pxc)|*.pxc;*.cpxc", "");
|
var path = get_open_filename_pxc("Pixel Composer project (.pxc)|*.pxc;*.cpxc", "");
|
||||||
key_release();
|
key_release();
|
||||||
if(path == "") return;
|
if(path == "") return;
|
||||||
|
|
||||||
if(!path_is_project(path)) return;
|
if(!path_is_project(path)) return;
|
||||||
|
|
||||||
gc_collect();
|
gc_collect();
|
||||||
|
@ -279,16 +280,17 @@ function LOAD_AT(path, params = new __loadParams()) {
|
||||||
|
|
||||||
function __EXPORT_ZIP() { exportPortable(PROJECT); }
|
function __EXPORT_ZIP() { exportPortable(PROJECT); }
|
||||||
function __IMPORT_ZIP() {
|
function __IMPORT_ZIP() {
|
||||||
var path = get_open_filename_pxc("Pixel Composer portable project (.zip)|*.zip", "");
|
var _path = get_open_filename_pxc("Pixel Composer portable project (.zip)|*.zip", "");
|
||||||
|
if(!file_exists_empty(_path)) return;
|
||||||
|
|
||||||
var _fname = filename_name_only(path);
|
var _fname = filename_name_only(_path);
|
||||||
var _fext = filename_ext(path);
|
var _fext = filename_ext(_path);
|
||||||
if(_fext != ".zip") return false;
|
if(_fext != ".zip") return false;
|
||||||
|
|
||||||
directory_verify(TEMPDIR + "proj/");
|
directory_verify(TEMPDIR + "proj/");
|
||||||
var _dir = TEMPDIR + "proj/" + _fname;
|
var _dir = TEMPDIR + "proj/" + _fname;
|
||||||
directory_create(_dir);
|
directory_create(_dir);
|
||||||
zip_unzip(path, _dir);
|
zip_unzip(_path, _dir);
|
||||||
|
|
||||||
var _f = file_find_first(_dir + "/*.pxc", fa_none);
|
var _f = file_find_first(_dir + "/*.pxc", fa_none);
|
||||||
var _proj = $"{_dir}/{_f}";
|
var _proj = $"{_dir}/{_f}";
|
||||||
|
|
|
@ -619,27 +619,29 @@ function Panel_Menu() : PanelContent() constructor {
|
||||||
var sc = merge_color(c_white, COLORS._main_value_positive, min(1, version_name_copy));
|
var sc = merge_color(c_white, COLORS._main_value_positive, min(1, version_name_copy));
|
||||||
|
|
||||||
if(hori) {
|
if(hori) {
|
||||||
draw_set_text(f_p0, fa_center, fa_center, tc);
|
if(w > 1500) {
|
||||||
var ww = string_width(txt) + ui(12);
|
draw_set_text(f_p0, fa_center, fa_center, tc);
|
||||||
var _x0 = _xx1 - ww;
|
var ww = string_width(txt) + ui(12);
|
||||||
var _y0 = ui(6);
|
var _x0 = _xx1 - ww;
|
||||||
var _x1 = _xx1;
|
var _y0 = ui(6);
|
||||||
var _y1 = h - ui(6);
|
var _x1 = _xx1;
|
||||||
|
var _y1 = h - ui(6);
|
||||||
if(pHOVER && point_in_rectangle(mx, my, _x0, _y0, _x1, _y1)) {
|
|
||||||
_draggable = false;
|
|
||||||
draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0, sc, 1);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, pFOCUS))
|
if(pHOVER && point_in_rectangle(mx, my, _x0, _y0, _x1, _y1)) {
|
||||||
dialogCall(o_dialog_release_note);
|
_draggable = false;
|
||||||
if(mouse_press(mb_right, pFOCUS)) {
|
draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0, sc, 1);
|
||||||
clipboard_set_text(VERSION_STRING);
|
|
||||||
version_name_copy = 3;
|
if(mouse_press(mb_left, pFOCUS))
|
||||||
|
dialogCall(o_dialog_release_note);
|
||||||
|
if(mouse_press(mb_right, pFOCUS)) {
|
||||||
|
clipboard_set_text(VERSION_STRING);
|
||||||
|
version_name_copy = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw_text(round((_x0 + _x1) / 2), round((_y0 + _y1) / 2), txt);
|
||||||
|
_xx1 = _x0 - ui(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_text(round((_x0 + _x1) / 2), round((_y0 + _y1) / 2), txt);
|
|
||||||
_xx1 = _x0 - ui(8);
|
|
||||||
} else {
|
} else {
|
||||||
var _xx1 = ui(40);
|
var _xx1 = ui(40);
|
||||||
var y1 = h - ui(20);
|
var y1 = h - ui(20);
|
||||||
|
@ -667,7 +669,7 @@ function Panel_Menu() : PanelContent() constructor {
|
||||||
if(PROJECT.safeMode) txt += $"[{__txt("SAFE MODE")}] ";
|
if(PROJECT.safeMode) txt += $"[{__txt("SAFE MODE")}] ";
|
||||||
if(PROJECT.readonly) txt += $"[{__txt("READ ONLY")}] ";
|
if(PROJECT.readonly) txt += $"[{__txt("READ ONLY")}] ";
|
||||||
|
|
||||||
txt += PROJECT.path == ""? __txt("Untitled.pxc") : filename_name(PROJECT.path);
|
txt += PROJECT.path == ""? __txt("Untitled") : filename_name_only(PROJECT.path);
|
||||||
if(PROJECT.modified) txt += "*";
|
if(PROJECT.modified) txt += "*";
|
||||||
|
|
||||||
var tx0, tx1, tcx;
|
var tx0, tx1, tcx;
|
||||||
|
@ -696,6 +698,7 @@ function Panel_Menu() : PanelContent() constructor {
|
||||||
maxW = abs(tx0 - tx1);
|
maxW = abs(tx0 - tx1);
|
||||||
|
|
||||||
draw_set_font(f_p0b);
|
draw_set_font(f_p0b);
|
||||||
|
var full_name = string_width(txt + ".pxc") < maxW;
|
||||||
var tc = string_cut(txt, maxW);
|
var tc = string_cut(txt, maxW);
|
||||||
var tw = string_width(tc) + ui(16);
|
var tw = string_width(tc) + ui(16);
|
||||||
var th = ui(28);
|
var th = ui(28);
|
||||||
|
@ -730,27 +733,46 @@ function Panel_Menu() : PanelContent() constructor {
|
||||||
dia.tooltips = tip;
|
dia.tooltips = tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
draw_set_font(f_p0b);
|
||||||
|
var _tcw = string_width(tc);
|
||||||
|
|
||||||
if(hori) {
|
if(hori) {
|
||||||
draw_set_text(f_p0b, fa_center, fa_center, COLORS._main_text);
|
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text);
|
||||||
draw_text_int(tcx, (ty0 + ty1) / 2, tc);
|
draw_text_int(tcx - _tcw / 2, (ty0 + ty1) / 2, tc);
|
||||||
|
|
||||||
|
if(full_name) {
|
||||||
|
draw_set_color(COLORS._main_text_sub);
|
||||||
|
draw_text_int(tcx + _tcw / 2, (ty0 + ty1) / 2, ".pxc");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text);
|
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text);
|
||||||
draw_text_int(tx0 + ui(8), tby0 + th / 2, tc);
|
draw_text_int(tx0 + ui(8), tby0 + th / 2, tc);
|
||||||
|
|
||||||
|
if(full_name) {
|
||||||
|
draw_set_color(COLORS._main_text_sub);
|
||||||
|
draw_text_int(tx0 + ui(8) + _tcw, tby0 + th / 2, ".pxc");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_PATREON && PREFERENCES.show_supporter_icon) {
|
if(IS_PATREON && PREFERENCES.show_supporter_icon) {
|
||||||
var _tw = string_width(tc);
|
var _tw = string_width(tc);
|
||||||
var _th = string_height(tc);
|
var _th = string_height(tc);
|
||||||
var _cx, _cy;
|
var _cx, _cy;
|
||||||
|
|
||||||
if(hori) {
|
if(hori) {
|
||||||
_cx = tcx + _tw / 2;
|
_cx = tcx + _tw / 2;
|
||||||
_cy = (ty0 + ty1) / 2 - _th / 2;
|
_cy = (ty0 + ty1) / 2 - _th / 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_cx = tx0 + ui(8) + _tw;
|
_cx = tx0 + ui(8) + _tw;
|
||||||
_cy = tby0 + th / 2 - _th / 2;
|
_cy = tby0 + th / 2 - _th / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(full_name) _cx += string_width(".pxc");
|
||||||
|
|
||||||
_cx += ui(2);
|
_cx += ui(2);
|
||||||
_cy += ui(6);
|
_cy += ui(6);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue