- [Graph Panel] Dropping .hex, .gpl, .pal files will now create palette node.

This commit is contained in:
Tanasart 2024-07-29 09:40:08 +07:00
parent e1a5d54b8a
commit 017aa7ac2b
4 changed files with 43 additions and 74 deletions

View file

@ -34,6 +34,7 @@
COLOR_KEYS = [];
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
globalvar HOTKEYS, HOTKEY_CONTEXT;
LATEST_VERSION = 11700;
VERSION = 11780;
@ -41,7 +42,6 @@
VERSION_STRING = "1.17.9.004";
BUILD_NUMBER = 11780;
globalvar HOTKEYS, HOTKEY_CONTEXT;
HOTKEYS = ds_map_create();
HOTKEY_CONTEXT = ds_list_create();
HOTKEY_CONTEXT[| 0] = "";

View file

@ -15,7 +15,7 @@ function Node_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
["Trim", true], 1
];
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
static processData = function(_outSurf, _data, _output_index, _array_index) {
var pal = _data[0];
var ran = _data[1];
@ -27,9 +27,9 @@ function Node_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
ar[i - st] = array_safe_get_fast(pal, i);
return ar;
} #endregion
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
if(bbox.h < 1) return;
@ -48,5 +48,5 @@ function Node_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
if(_h != min_h) will_setHeight = true;
min_h = _h;
} #endregion
}
}

View file

@ -1,4 +1,4 @@
function isPaletteFile(path) { #region
function isPaletteFile(path) {
var ext = string_lower(filename_ext(path));
switch(ext) {
case ".hex" :
@ -9,9 +9,9 @@ function isPaletteFile(path) { #region
}
return false;
} #endregion
}
function loadPalette(path) { #region
function loadPalette(path) {
if(!file_exists_empty(path)) return [];
if(!isPaletteFile(path)) return [];
@ -77,7 +77,7 @@ function loadPalette(path) { #region
file_text_close(_t);
return pal;
} #endregion
}
globalvar PALETTES, PALETTE_LOSPEC;
@ -103,15 +103,13 @@ function __initPalette() {
file_find_close();
}
#region palette generate
function palette_string_hex(palette, alpha = true) {
var _str = "";
for (var i = 0, n = array_length(palette); i < n; i++) {
var _c = palette[i];
_str += $"{color_get_hex(_c, alpha)}\n";
}
return _str;
function palette_string_hex(palette, alpha = true) { //palette generate
var _str = "";
for (var i = 0, n = array_length(palette); i < n; i++) {
var _c = palette[i];
_str += $"{color_get_hex(_c, alpha)}\n";
}
#endregion
return _str;
}

View file

@ -2290,10 +2290,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _gx = _mx / graph_s - graph_x;
var _gy = _my / graph_s - graph_y;
if(FILE_IS_DROPPING) {
// draw_sprite_stretched_ext(THEME.node_bg, 1, _mx, _my, 128 * graph_s, 128 * graph_s, COLORS._main_value_positive, 1);
if(FILE_IS_DROPPING)
draw_sprite_stretched_ext(THEME.ui_panel_selection, 0, 8, 8, w - 16, h - 16, COLORS._main_value_positive, 1);
}
if(FILE_DROPPED && !array_empty(FILE_DROPPING)) {
_gx = mx / graph_s - graph_x;
@ -2964,7 +2962,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
}
//// ========== Graph Drop ==========
//// ========== File Drop ==========
function load_file_path(path, _x = undefined, _y = undefined) {
if(!is_array(path)) path = [ path ];
@ -3005,59 +3003,32 @@ function load_file_path(path, _x = undefined, _y = undefined) {
var ext = filename_ext_raw(p);
switch(ext) {
case "txt" :
node = Node_create_Text_File_Read_path(_x, _y, p);
break;
case "txt" : node = Node_create_Text_File_Read_path(_x, _y, p); break;
case "csv" : node = Node_create_CSV_File_Read_path(_x, _y, p); break;
case "json" : node = Node_create_Json_File_Read_path(_x, _y, p); break;
case "csv" :
node = Node_create_CSV_File_Read_path(_x, _y, p);
break;
case "ase" :
case "aseprite" : node = Node_create_ASE_File_Read_path(_x, _y, p); break;
case "json" :
node = Node_create_Json_File_Read_path(_x, _y, p);
break;
case "png" :
case "jpg" :
case "jpeg" : node = Node_create_Image_path(_x, _y, p); break;
case "ase" :
case "aseprite" :
node = Node_create_ASE_File_Read_path(_x, _y, p);
break;
case "png" :
case "jpg" :
case "jpeg" :
if(key_mod_press(SHIFT))
node = Node_create_Image_path(_x, _y, p);
else
node = Node_create_Image_path(_x, _y, p);
break;
case "gif" :
node = Node_create_Image_gif_path(_x, _y, p);
break;
case "obj" :
node = Node_create_3D_Obj_path(_x, _y, p);
break;
case "wav" :
node = Node_create_WAV_File_Read_path(_x, _y, p);
break;
case "xml" :
node = Node_create_XML_File_Read_path(_x, _y, p);
break;
case "svg" :
node = Node_create_SVG_path(_x, _y, p);
break;
case "pxc" :
case "cpxc" :
LOAD_PATH(p);
break;
case "pxcc" :
APPEND(p);
case "gif" : node = Node_create_Image_gif_path(_x, _y, p); break;
case "obj" : node = Node_create_3D_Obj_path(_x, _y, p); break;
case "wav" : node = Node_create_WAV_File_Read_path(_x, _y, p); break;
case "xml" : node = Node_create_XML_File_Read_path(_x, _y, p); break;
case "svg" : node = Node_create_SVG_path(_x, _y, p); break;
case "pxc" :
case "cpxc" : LOAD_PATH(p); break;
case "pxcc" : APPEND(p); break;
case "hex" :
case "gpl" :
case "pal" :
node = new Node_Palette(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(loadPalette(p));
break;
}