From 92d33dc1ea6dba274a5cf6c3301b38d54f1da773 Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:48:54 +0700 Subject: [PATCH] Palette sort, decimal precision --- PixelComposer.yyp | 25 +++++---- .../o_dialog_file_name_collection/Draw_64.gml | 6 +-- objects/o_dialog_palette/Create_0.gml | 32 ----------- objects/o_dialog_palette/Draw_64.gml | 10 +++- objects/o_main/Draw_75.gml | 2 +- scripts/color_function/color_function.gml | 22 +++++++- scripts/globals/globals.gml | 6 +-- scripts/node_array_sort/node_array_sort.gml | 2 +- scripts/node_composite/node_composite.gml | 2 +- scripts/node_data/node_data.gml | 8 ++- scripts/node_keyframe/node_keyframe.gml | 2 +- scripts/node_palette_sort/node_counter.yy | 12 +++++ .../node_palette_sort/node_palette_sort.gml | 54 +++++++++++++++++++ .../node_palette_sort/node_palette_sort.yy | 11 ++++ scripts/node_registry/node_registry.gml | 1 + scripts/node_shadow_cast/node_shadow_cast.gml | 3 +- scripts/node_value/node_value.gml | 4 +- scripts/panel_inspector/panel_inspector.gml | 6 +-- scripts/string_function/string_function.gml | 18 +++++++ scripts/textArea/textArea.gml | 4 +- scripts/textArrayBox/textArrayBox.gml | 2 +- scripts/textBox/textBox.gml | 13 +++-- 22 files changed, 170 insertions(+), 75 deletions(-) create mode 100644 scripts/node_palette_sort/node_counter.yy create mode 100644 scripts/node_palette_sort/node_palette_sort.gml create mode 100644 scripts/node_palette_sort/node_palette_sort.yy diff --git a/PixelComposer.yyp b/PixelComposer.yyp index c2e55a7aa..70335c3b2 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -178,6 +178,7 @@ {"id":{"name":"s_node_vfx_attract","path":"sprites/s_node_vfx_attract/s_node_vfx_attract.yy",},"order":8,}, {"id":{"name":"s_node_pixel_cloud","path":"sprites/s_node_pixel_cloud/s_node_pixel_cloud.yy",},"order":30,}, {"id":{"name":"node_noise_grid","path":"scripts/node_noise_grid/node_noise_grid.yy",},"order":8,}, + {"id":{"name":"node_palette_sort","path":"scripts/node_palette_sort/node_palette_sort.yy",},"order":9,}, {"id":{"name":"node_path_wave","path":"scripts/node_path_wave/node_path_wave.yy",},"order":28,}, {"id":{"name":"s_node_HSV","path":"sprites/s_node_HSV/s_node_HSV.yy",},"order":44,}, {"id":{"name":"s_node_3d_cone","path":"sprites/s_node_3d_cone/s_node_3d_cone.yy",},"order":9,}, @@ -213,7 +214,7 @@ {"id":{"name":"fd_draw_surface_to_collision_mask_surface","path":"scripts/fd_draw_surface_to_collision_mask_surface/fd_draw_surface_to_collision_mask_surface.yy",},"order":2,}, {"id":{"name":"sh_blur_box_contrast","path":"shaders/sh_blur_box_contrast/sh_blur_box_contrast.yy",},"order":3,}, {"id":{"name":"sh_fd_calculate_pressure_jacobi_glsl","path":"shaders/sh_fd_calculate_pressure_jacobi_glsl/sh_fd_calculate_pressure_jacobi_glsl.yy",},"order":8,}, - {"id":{"name":"node_color_from_rgb","path":"scripts/node_color_from_rgb/node_color_from_rgb.yy",},"order":5,}, + {"id":{"name":"node_color_from_rgb","path":"scripts/node_color_from_rgb/node_color_from_rgb.yy",},"order":7,}, {"id":{"name":"node_transform","path":"scripts/node_transform/node_transform.yy",},"order":0,}, {"id":{"name":"curveBox","path":"scripts/curveBox/curveBox.yy",},"order":8,}, {"id":{"name":"preview_overlay_vector","path":"scripts/preview_overlay_vector/preview_overlay_vector.yy",},"order":2,}, @@ -288,7 +289,7 @@ {"id":{"name":"node_color","path":"scripts/node_color/node_color.yy",},"order":0,}, {"id":{"name":"node_string_split","path":"scripts/node_string_split/node_string_split.yy",},"order":14,}, {"id":{"name":"meta_data","path":"scripts/meta_data/meta_data.yy",},"order":11,}, - {"id":{"name":"node_find_pixel","path":"scripts/node_find_pixel/node_find_pixel.yy",},"order":0,}, + {"id":{"name":"node_find_pixel","path":"scripts/node_find_pixel/node_find_pixel.yy",},"order":1,}, {"id":{"name":"node_scatter_points","path":"scripts/node_scatter_points/node_scatter_points.yy",},"order":24,}, {"id":{"name":"o_dialog_lua_reference","path":"objects/o_dialog_lua_reference/o_dialog_lua_reference.yy",},"order":5,}, {"id":{"name":"node_surface_data","path":"scripts/node_surface_data/node_surface_data.yy",},"order":4,}, @@ -325,7 +326,7 @@ {"id":{"name":"s_node_warp","path":"sprites/s_node_warp/s_node_warp.yy",},"order":9,}, {"id":{"name":"color_function","path":"scripts/color_function/color_function.yy",},"order":9,}, {"id":{"name":"fd_rectangle_set_pressure_size","path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},"order":11,}, - {"id":{"name":"node_color_data","path":"scripts/node_color_data/node_color_data.yy",},"order":4,}, + {"id":{"name":"node_color_data","path":"scripts/node_color_data/node_color_data.yy",},"order":6,}, {"id":{"name":"node_noise_ani","path":"scripts/node_noise_ani/node_noise_ani.yy",},"order":5,}, {"id":{"name":"s_node_transform","path":"sprites/s_node_transform/s_node_transform.yy",},"order":8,}, {"id":{"name":"node_canvas","path":"scripts/node_canvas/node_canvas.yy",},"order":5,}, @@ -383,11 +384,11 @@ {"id":{"name":"sh_scale2x","path":"shaders/sh_scale2x/sh_scale2x.yy",},"order":27,}, {"id":{"name":"ds_priority","path":"scripts/ds_priority/ds_priority.yy",},"order":3,}, {"id":{"name":"node_vector","path":"scripts/node_vector/node_vector.yy",},"order":0,}, - {"id":{"name":"node_palette","path":"scripts/node_palette/node_palette.yy",},"order":2,}, + {"id":{"name":"node_palette","path":"scripts/node_palette/node_palette.yy",},"order":4,}, {"id":{"name":"buttonColor","path":"scripts/buttonColor/buttonColor.yy",},"order":3,}, {"id":{"name":"notification_system","path":"scripts/notification_system/notification_system.yy",},"order":6,}, {"id":{"name":"sh_shadow_cast","path":"shaders/sh_shadow_cast/sh_shadow_cast.yy",},"order":0,}, - {"id":{"name":"node_color_from_hsv","path":"scripts/node_color_from_hsv/node_color_from_hsv.yy",},"order":6,}, + {"id":{"name":"node_color_from_hsv","path":"scripts/node_color_from_hsv/node_color_from_hsv.yy",},"order":8,}, {"id":{"name":"s_node_image_copy","path":"sprites/s_node_image_copy/s_node_image_copy.yy",},"order":6,}, {"id":{"name":"node_boolean","path":"scripts/node_boolean/node_boolean.yy",},"order":17,}, {"id":{"name":"node_grid_tri","path":"scripts/node_grid_tri/node_grid_tri.yy",},"order":21,}, @@ -526,7 +527,7 @@ {"id":{"name":"sh_outline","path":"shaders/sh_outline/sh_outline.yy",},"order":18,}, {"id":{"name":"s_node_scatter_point","path":"sprites/s_node_scatter_point/s_node_scatter_point.yy",},"order":4,}, {"id":{"name":"node_checkerboard","path":"scripts/node_checkerboard/node_checkerboard.yy",},"order":13,}, - {"id":{"name":"node_gradient_output","path":"scripts/node_gradient_output/node_gradient_output.yy",},"order":3,}, + {"id":{"name":"node_gradient_output","path":"scripts/node_gradient_output/node_gradient_output.yy",},"order":5,}, {"id":{"name":"display_refresh","path":"scripts/display_refresh/display_refresh.yy",},"order":17,}, {"id":{"name":"fd_rectangle_assure_surfaces_exist","path":"scripts/fd_rectangle_assure_surfaces_exist/fd_rectangle_assure_surfaces_exist.yy",},"order":2,}, {"id":{"name":"fd_rectangle_material_surface_was_created","path":"scripts/fd_rectangle_material_surface_was_created/fd_rectangle_material_surface_was_created.yy",},"order":13,}, @@ -641,7 +642,7 @@ {"id":{"name":"node_convolution","path":"scripts/node_convolution/node_convolution.yy",},"order":5,}, {"id":{"name":"sh_outline_only","path":"shaders/sh_outline_only/sh_outline_only.yy",},"order":35,}, {"id":{"name":"s_node_destray","path":"sprites/s_node_destray/s_node_destray.yy",},"order":16,}, - {"id":{"name":"node_color_sampler","path":"scripts/node_color_sampler/node_color_sampler.yy",},"order":1,}, + {"id":{"name":"node_color_sampler","path":"scripts/node_color_sampler/node_color_sampler.yy",},"order":3,}, {"id":{"name":"s_node_fluidSim_update","path":"sprites/s_node_fluidSim_update/s_node_fluidSim_update.yy",},"order":5,}, {"id":{"name":"ase_reader","path":"scripts/ase_reader/ase_reader.yy",},"order":1,}, {"id":{"name":"fd_rectangle_inherit_velocity","path":"scripts/fd_rectangle_inherit_velocity/fd_rectangle_inherit_velocity.yy",},"order":12,}, @@ -812,6 +813,7 @@ {"id":{"name":"_f_h3","path":"fonts/_f_h3/_f_h3.yy",},"order":3,}, {"id":{"name":"s_node_math","path":"sprites/s_node_math/s_node_math.yy",},"order":1,}, {"id":{"name":"node_iterator_index","path":"scripts/node_iterator_index/node_iterator_index.yy",},"order":2,}, + {"id":{"name":"s_node_palette_sort","path":"sprites/s_node_palette_sort/s_node_palette_sort.yy",},"order":14,}, {"id":{"name":"node_greyscale","path":"scripts/node_greyscale/node_greyscale.yy",},"order":5,}, {"id":{"name":"node_color_adjustment","path":"scripts/node_color_adjustment/node_color_adjustment.yy",},"order":1,}, {"id":{"name":"s_node_array_reverse","path":"sprites/s_node_array_reverse/s_node_array_reverse.yy",},"order":8,}, @@ -863,7 +865,7 @@ {"id":{"name":"sh_blend_screen","path":"shaders/sh_blend_screen/sh_blend_screen.yy",},"order":3,}, {"id":{"name":"node_group_output","path":"scripts/node_group_output/node_group_output.yy",},"order":2,}, {"id":{"name":"s_node_palette_extract","path":"sprites/s_node_palette_extract/s_node_palette_extract.yy",},"order":12,}, - {"id":{"name":"node_palette_replacement","path":"scripts/node_palette_replacement/node_palette_replacement.yy",},"order":0,}, + {"id":{"name":"node_palette_replacement","path":"scripts/node_palette_replacement/node_palette_replacement.yy",},"order":2,}, {"id":{"name":"s_node_scatter","path":"sprites/s_node_scatter/s_node_scatter.yy",},"order":19,}, {"id":{"name":"s_node_bokeh","path":"sprites/s_node_bokeh/s_node_bokeh.yy",},"order":49,}, {"id":{"name":"sh_vertex_depth_pass","path":"shaders/sh_vertex_depth_pass/sh_vertex_depth_pass.yy",},"order":6,}, @@ -1323,7 +1325,6 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_search_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_sequence_control_strip7.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_slider.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, - {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_sort_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_text_bullet_strip2.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_timeline_clock.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_timeline_graph.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, @@ -1432,9 +1433,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"workshop_badge.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_project.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workshop_update.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, - {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_noti_icon_file_save.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, - {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"magick.exe","CopyToMask":-1,"filePath":"datafiles/ImageMagick",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Collections.zip","CopyToMask":-1,"filePath":"datafiles/data",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"0 introduction.pxc","CopyToMask":-1,"filePath":"datafiles/Getting started",}, @@ -1447,6 +1446,10 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Cards flipping.pxc","CopyToMask":-1,"filePath":"datafiles/Sample Projects",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Dice.pxc","CopyToMask":-1,"filePath":"datafiles/Sample Projects",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Shiny gem.pxc","CopyToMask":-1,"filePath":"datafiles/Sample Projects",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_sort_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_reverse.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",}, ], "MetaData": { "IDEVersion": "2022.11.1.56", diff --git a/objects/o_dialog_file_name_collection/Draw_64.gml b/objects/o_dialog_file_name_collection/Draw_64.gml index 40a0b15c7..b2046d622 100644 --- a/objects/o_dialog_file_name_collection/Draw_64.gml +++ b/objects/o_dialog_file_name_collection/Draw_64.gml @@ -9,11 +9,11 @@ draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_title); draw_text(dialog_x + ui(16), dialog_y + ui(32), get_text("name", "Name")); - var is_author = !meta.steam || meta.author_steam_id == 0 || meta.author_steam_id == STEAM_USER_ID; + //var is_author = !meta.steam || meta.author_steam_id == 0 || meta.author_steam_id == STEAM_USER_ID; t_desc.interactable = !STEAM_UGC_ITEM_UPLOADING; - t_auth.interactable = !STEAM_UGC_ITEM_UPLOADING && is_author; - t_cont.interactable = !STEAM_UGC_ITEM_UPLOADING && is_author; + t_auth.interactable = !STEAM_UGC_ITEM_UPLOADING; + t_cont.interactable = !STEAM_UGC_ITEM_UPLOADING; t_tags.interactable = !STEAM_UGC_ITEM_UPLOADING; t_alias.interactable = !STEAM_UGC_ITEM_UPLOADING; tb_name.interactable = !STEAM_UGC_ITEM_UPLOADING; diff --git a/objects/o_dialog_palette/Create_0.gml b/objects/o_dialog_palette/Create_0.gml index 62b0f9ee3..d12a27aa3 100644 --- a/objects/o_dialog_palette/Create_0.gml +++ b/objects/o_dialog_palette/Create_0.gml @@ -105,38 +105,6 @@ event_inherited(); #endregion #region tools - function __sortBright(c1, c2) { - var r1 = color_get_red(c1); - var g1 = color_get_green(c1); - var b1 = color_get_blue(c1); - var l1 = 0.299 * r1 + 0.587 * g1 + 0.114 * b1; - - var r2 = color_get_red(c2); - var g2 = color_get_green(c2); - var b2 = color_get_blue(c2); - var l2 = 0.299 * r2 + 0.587 * g2 + 0.224 * b2; - - return l2 - l1; - } - - function __sortDark(c1, c2) { - return -__sortBright(c1, c2); - } - - function __sortHue(c1, c2) { - var h1 = color_get_hue(c1); - var s1 = color_get_saturation(c1); - var v1 = color_get_value(c1); - var l1 = 0.8 * h1 + 0.1 * s1 + 0.1 * v1; - - var h2 = color_get_hue(c2); - var s2 = color_get_saturation(c2); - var v2 = color_get_value(c2); - var l2 = 0.8 * h2 + 0.1 * s2 + 0.1 * v2; - - return l2 - l1; - } - function sortPalette(sortFunc) { array_sort(palette, sortFunc); onApply(palette); diff --git a/objects/o_dialog_palette/Draw_64.gml b/objects/o_dialog_palette/Draw_64.gml index 338feb458..9c35945ff 100644 --- a/objects/o_dialog_palette/Draw_64.gml +++ b/objects/o_dialog_palette/Draw_64.gml @@ -95,11 +95,19 @@ if palette == 0 exit; var dia = dialogCall(o_dialog_menubox, bx + ui(32), by); dia.setMenu([ [ get_text("palette_editor_sort_brighter", "Brighter"), function() { sortPalette(__sortBright); } ], - [ get_text("palette_editor_sort_darker", "Darker"), function() { sortPalette(__sortDark); } ], + [ get_text("palette_editor_sort_darker", "Darker"), function() { sortPalette(__sortDark); } ], + -1, [ get_text("palette_editor_sort_hue", "Hue"), function() { sortPalette(__sortHue); } ], + [ get_text("palette_editor_sort_sat", "Saturation"), function() { sortPalette(__sortSat); } ], + [ get_text("palette_editor_sort_val", "Value"), function() { sortPalette(__sortVal); } ], ]); } + bx -= ui(32); + if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, sFOCUS, sHOVER, get_text("palette_editor_reverse", "Reverse palette"), THEME.reverse) == 2) { + palette = array_reverse(palette); + onApply(palette); + } bx -= ui(32); #endregion diff --git a/objects/o_main/Draw_75.gml b/objects/o_main/Draw_75.gml index 9badd7e13..1888613fe 100644 --- a/objects/o_main/Draw_75.gml +++ b/objects/o_main/Draw_75.gml @@ -12,7 +12,7 @@ case VALUE_TYPE.integer : case VALUE_TYPE.text : case VALUE_TYPE.path : - draw_tooltip_text(string(content)); + draw_tooltip_text(string_real(content)); break; case VALUE_TYPE.boolean : draw_tooltip_text(content? get_text("true", "True") : get_text("false", "False")); diff --git a/scripts/color_function/color_function.gml b/scripts/color_function/color_function.gml index 37d35ca51..a819cbccd 100644 --- a/scripts/color_function/color_function.gml +++ b/scripts/color_function/color_function.gml @@ -51,4 +51,24 @@ function color_diff(c1, c2) { var dist = sqrt(sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a)); return dist; -} \ No newline at end of file +} + +#region sorting functions + function __valHSV(c, h, s, v) { return color_get_hue(c) * h + color_get_saturation(c) * s + color_get_value(c) * v; } + function __valRGB(c, r, g, b) { return color_get_red(c) * r + color_get_green(c) * g + color_get_blue(c) * b; } + + function __sortBright(c1, c2) { + var l1 = 0.299 * color_get_red(c1) + 0.587 * color_get_green(c1) + 0.114 * color_get_blue(c1); + var l2 = 0.299 * color_get_red(c2) + 0.587 * color_get_green(c2) + 0.114 * color_get_blue(c2); + return l2 - l1; + } + function __sortDark(c1, c2) { return -__sortBright(c1, c2); } + + function __sortHue(c1, c2) { return __valHSV(c2, 65536, 256, 1) - __valHSV(c1, 65536, 256, 1); } + function __sortSat(c1, c2) { return __valHSV(c2, 256, 65536, 1) - __valHSV(c1, 256, 65536, 1); } + function __sortVal(c1, c2) { return __valHSV(c2, 256, 1, 65536) - __valHSV(c1, 256, 1, 65536); } + + function __sortRed(c1, c2) { return __valRGB(c2, 65536, 256, 1) - __valRGB(c1, 65536, 256, 1); } + function __sortGreen(c1, c2) { return __valRGB(c2, 1, 65536, 256) - __valRGB(c1, 1, 65536, 256); } + function __sortBlue(c1, c2) { return __valRGB(c2, 256, 1, 65536) - __valRGB(c1, 256, 1, 65536); } +#endregion \ No newline at end of file diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 2a207c4e4..eeff401f3 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -30,7 +30,7 @@ globalvar VERSION, SAVEFILE_VERSION, VERSION_STRING; VERSION = 1130; SAVEFILE_VERSION = 1300; - VERSION_STRING = "1.13"; + VERSION_STRING = "1.13.pr5"; globalvar NODES, NODE_MAP, APPEND_MAP, HOTKEYS, HOTKEY_CONTEXT; @@ -125,8 +125,8 @@ #macro RETURN_ON_REST if(!ANIMATOR.is_playing || !ANIMATOR.frame_progress) return; function print(str) { - show_debug_message(str); - noti_status(str); + show_debug_message(string_real(str)); + noti_status(string_real(str)); } function printIf(cond, log) { diff --git a/scripts/node_array_sort/node_array_sort.gml b/scripts/node_array_sort/node_array_sort.gml index 4780d9f5d..6b311f12d 100644 --- a/scripts/node_array_sort/node_array_sort.gml +++ b/scripts/node_array_sort/node_array_sort.gml @@ -11,7 +11,7 @@ function Node_Array_Sort(_x, _y, _group = -1) : Node(_x, _y, _group) constructor .setDisplay(VALUE_DISPLAY.enum_button, [ "Ascending", "Descending" ]) .rejectArray(); - outputs[| 0] = nodeValue("Shuffled array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, []); + outputs[| 0] = nodeValue("Sorted array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, []); static update = function(frame = ANIMATOR.current_frame) { var arr = inputs[| 0].getValue(); diff --git a/scripts/node_composite/node_composite.gml b/scripts/node_composite/node_composite.gml index 608bb9c13..1cd0760e5 100644 --- a/scripts/node_composite/node_composite.gml +++ b/scripts/node_composite/node_composite.gml @@ -42,7 +42,7 @@ function Node_Composite(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) co layer_remove = -1; layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { var amo = (ds_list_size(inputs) - input_fix_len) / data_length - 1; - if(array_length(current_data) != ds_list_size(inputs)) return; + if(array_length(current_data) != ds_list_size(inputs)) return 0; var lh = 32; var _h = 8 + max(1, amo) * (lh + 4) + 8; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 5b85abfa9..6253905c8 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -879,11 +879,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) constructor { var _type = instanceof(self); var _node = nodeBuild(_type, x, y, target); CLONING = false; + LOADING_VERSION = SAVEFILE_VERSION; if(!_node) return; var _nid = _node.node_id; - _node.deserialize(serialize()); _node.postDeserialize(); _node.applyDeserialize(); @@ -915,10 +915,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) constructor { ds_map_add_map(_map, "attri", attributeSerialize()); var _inputs = ds_list_create(); - for(var i = 0; i < ds_list_size(inputs); i++) { - ds_list_add(_inputs, inputs[| i].serialize(scale, preset)); - ds_list_mark_as_map(_inputs, i); - } + for(var i = 0; i < ds_list_size(inputs); i++) + ds_list_add_map(_inputs, inputs[| i].serialize(scale, preset)); ds_map_add_list(_map, "inputs", _inputs); doSerialize(_map); diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index a39aa4508..74d6ab6fe 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -185,7 +185,7 @@ function valueAnimator(_val, _prop) constructor { switch(prop.type) { case VALUE_TYPE.integer : case VALUE_TYPE.float : return toNumber(_val); - case VALUE_TYPE.text : return string(_val); + case VALUE_TYPE.text : return string_real(_val); case VALUE_TYPE.surface : if(is_string(_val)) return get_asset(_val); diff --git a/scripts/node_palette_sort/node_counter.yy b/scripts/node_palette_sort/node_counter.yy new file mode 100644 index 000000000..10832a0b0 --- /dev/null +++ b/scripts/node_palette_sort/node_counter.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "variable", + "path": "folders/nodes/data/variable.yy", + }, + "resourceVersion": "1.0", + "name": "node_counter", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_palette_sort/node_palette_sort.gml b/scripts/node_palette_sort/node_palette_sort.gml new file mode 100644 index 000000000..1d00a08f3 --- /dev/null +++ b/scripts/node_palette_sort/node_palette_sort.gml @@ -0,0 +1,54 @@ +function Node_Palette_Sort(_x, _y, _group = -1) : Node(_x, _y, _group) constructor { + name = "Sort Palette"; + previewable = false; + + w = 96; + + inputs[| 0] = nodeValue("Palette in", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, []) + .setDisplay(VALUE_DISPLAY.palette) + .setVisible(true, true); + + inputs[| 1] = nodeValue("Order", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.enum_button, [ "Brightness", "Hue (HSV)", "Saturation (SHV)", "Value (VHS)", "Red (RGB)", "Green (GBR)", "Blue (BRG)" ]) + .rejectArray(); + + inputs[| 2] = nodeValue("Reverse", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + outputs[| 0] = nodeValue("Sorted palette", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, []) + .setDisplay(VALUE_DISPLAY.palette); + + static update = function(frame = ANIMATOR.current_frame) { + var _arr = inputs[| 0].getValue(); + var _ord = inputs[| 1].getValue(); + var _rev = inputs[| 2].getValue(); + if(!is_array(_arr)) return; + + var _pal = array_clone(_arr); + + switch(_ord) { + case 0 : array_sort(_pal, __sortBright); break; + + case 1 : array_sort(_pal, __sortHue); break; + case 2 : array_sort(_pal, __sortSat); break; + case 3 : array_sort(_pal, __sortVal); break; + + case 4 : array_sort(_pal, __sortRed); break; + case 5 : array_sort(_pal, __sortGreen); break; + case 6 : array_sort(_pal, __sortBlue); break; + } + + if(_rev) _pal = array_reverse(_pal); + + outputs[| 0].setValue(_pal); + } + + static onDrawNode = function(xx, yy, _mx, _my, _s) { + var bbox = drawGetBbox(xx, yy, _s); + if(bbox.h < 1) return; + + var pal = outputs[| 0].getValue(); + if(array_length(pal) && is_array(pal[0])) return; + + drawPalette(pal, bbox.x0, bbox.y0, bbox.w, bbox.h); + } +} \ No newline at end of file diff --git a/scripts/node_palette_sort/node_palette_sort.yy b/scripts/node_palette_sort/node_palette_sort.yy new file mode 100644 index 000000000..6e72505a4 --- /dev/null +++ b/scripts/node_palette_sort/node_palette_sort.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_palette_sort", + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "color", + "path": "folders/nodes/data/value/color.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 2aed54aa6..a06774db4 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -413,6 +413,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { ds_list_add(color, "Palettes"); addNodeObject(color, "Palette", s_node_palette, "Node_Palette", [1, Node_Palette]); + addNodeObject(color, "Sort Palette", s_node_palette_sort, "Node_Palette_Sort", [1, Node_Palette_Sort]).set_version(1130); addNodeObject(color, "Palette Extract", s_node_palette_extract, "Node_Palette_Extract", [1, Node_Palette_Extract]).set_version(1100); addNodeObject(color, "Palette Replace", s_node_palette_replace, "Node_Palette_Replace", [1, Node_Palette_Replace]).set_version(1120); diff --git a/scripts/node_shadow_cast/node_shadow_cast.gml b/scripts/node_shadow_cast/node_shadow_cast.gml index 2a824eb99..472125403 100644 --- a/scripts/node_shadow_cast/node_shadow_cast.gml +++ b/scripts/node_shadow_cast/node_shadow_cast.gml @@ -63,7 +63,7 @@ function Node_Shadow_Cast(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) inputs[| 9] = nodeValue("Render solid", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); - inputs[| 10] = nodeValue("Use BG color", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, "If checked, BG color will be used as shadow caster."); + inputs[| 10] = nodeValue("Use BG color", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, "If checked, background color will be used as shadow caster."); inputs[| 11] = nodeValue("BG threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1) .setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]); @@ -99,6 +99,7 @@ function Node_Shadow_Cast(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + if(array_length(current_data) != ds_list_size(inputs)) return; var _type = current_data[5]; if(_type == 0) { diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 903ed73fa..fb44427b6 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -770,7 +770,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } if(type == VALUE_TYPE.text) - return string(value); + return string_real(value); if(typeFrom == VALUE_TYPE.integer && type == VALUE_TYPE.color) return make_color_hsv(0, 0, value); @@ -1057,7 +1057,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru static getShowString = function() { var val = showValue(); - return string(val); + return string_real(val); } static setString = function(str) { diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 97bfc9c5c..61862dd62 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -123,9 +123,9 @@ function Panel_Inspector() : PanelContent() constructor { } if(i == 0) { - var is_author = meta.author_steam_id == 0 || meta.author_steam_id == STEAM_USER_ID; - meta.displays[1][1].interactable = is_author; - meta.displays[2][1].interactable = is_author; + //var is_author = !meta.steam || (meta.author_steam_id == 0 || meta.author_steam_id == STEAM_USER_ID); + //meta.displays[1][1].interactable = is_author; + //meta.displays[2][1].interactable = is_author; current_meta = meta; for( var j = 0; j < array_length(meta.displays); j++ ) { diff --git a/scripts/string_function/string_function.gml b/scripts/string_function/string_function.gml index 0bec1b1a8..16367a38a 100644 --- a/scripts/string_function/string_function.gml +++ b/scripts/string_function/string_function.gml @@ -29,4 +29,22 @@ function string_partial_match(str, key) { } return -9999; +} + +function string_real(val) { + if(is_string(val)) return val; + if(is_array(val)) { + var s = "["; + for( var i = 0; i < array_length(val); i++ ) + s += (i? ", " : "") + string_real(val[i]); + return s + "]"; + } + + var pres; + for( pres = 0; pres < 5; pres++ ) { + if(frac(val * power(10, pres)) == 0) + break; + } + + return string_format(val, -1, pres); } \ No newline at end of file diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index 6907cc0de..01ffd5c9b 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -252,6 +252,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod } static display_text = function(_x, _y, _text, _w, _mx = -1, _my = -1) { + _text = string_real(_text); if(_w != _prev_width) { _prev_width = _w; cut_line(); @@ -341,6 +342,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod y = _y; w = _w; h = _h; + _text = string_real(_text); _current_text = _text; if(extras && instanceof(extras) == "buttonClass") { @@ -575,7 +577,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod draw_sprite_stretched(THEME.textbox, 0, _x, _y, _w, hh); } - display_text(tx, _y + ui(7), string(_text), _w - ui(4)); + display_text(tx, _y + ui(7), _text, _w - ui(4)); } resetFocus(); diff --git a/scripts/textArrayBox/textArrayBox.gml b/scripts/textArrayBox/textArrayBox.gml index bd2842a56..3668ff5b4 100644 --- a/scripts/textArrayBox/textArrayBox.gml +++ b/scripts/textArrayBox/textArrayBox.gml @@ -38,7 +38,7 @@ function textArrayBox(arraySet, data) : widget() constructor { draw_sprite_stretched(THEME.textbox, 2, _x, _y, _w, th); } else { if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + th)) { - draw_sprite_stretched(THEME.textbox, 1, _x, _y, _w, th); + draw_sprite_stretched_ext(THEME.textbox, 1, _x, _y, _w, th, c_white, 0.5 + !hide * 0.5); if(mouse_press(mb_left, active)) { with(dialogCall(o_dialog_arrayBox, _rx + _x, _ry + _y + th)) { arrayBox = other; diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index ba9bdec5e..067652046 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -86,7 +86,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi static getDisplayText = function(val) { if(input == TEXTBOX_INPUT.text) return val; - return string(val); + return string_real(val); } static editText = function() { @@ -193,6 +193,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi } static display_text = function(_x, _y, _text, _w, _format, _m = -1) { + _text = string_real(_text); BLEND_OVERRIDE; if(!interactable) draw_set_alpha(0.5); @@ -306,6 +307,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi y = _y; w = _w; h = _h; + _text = string_real(_text); _current_text = _text; if(extras && instanceof(extras) == "buttonClass") { @@ -340,7 +342,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi if(key_mod_press(CTRL)) spd *= 10; - _input_text = _input_text + spd; + _input_text = string_real(toNumber(_input_text) + spd); if(apply()) UNDO_HOLDING = true; @@ -424,9 +426,8 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi draw_set_alpha(1); if(mouse_press(mb_left, active)) { - var ktxt = _input_text; - if(key_mod_press(ALT)) _input_text = string(toNumber(ktxt) / 2); - else _input_text = string(toNumber(ktxt) * 2); + if(key_mod_press(ALT)) _input_text = string_real(toNumber(_input_text) / 2); + else _input_text = string_real(toNumber(_input_text) * 2); apply(); } } @@ -472,8 +473,6 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi disp_x_to += _w - ui(16); if(cursor_pos_to > _x + _w - ui(16)) disp_x_to -= _w - ui(16); - - //print("Cursor x : " + string(cursor_pos_to) + ", Display x : " + string(_x) + ", to x : " + string(disp_x_to) + ", max x : " + string(disp_x_max)); cursor_pos = cursor_pos == 0? cursor_pos_to : lerp_float(cursor_pos, cursor_pos_to, 4);