From 36bd03c00da88f7c32cf5d75293343339210a4e4 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 2 Mar 2025 08:26:16 +0700 Subject: [PATCH] [Palette Editor] Fix adding color not select the added color. --- objects/o_dialog_palette/Create_0.gml | 11 ++--------- objects/o_dialog_palette/Draw_64.gml | 2 +- scripts/globals/globals.gml | 4 ++-- scripts/string_hexadecimal/string_hexadecimal.gml | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/objects/o_dialog_palette/Create_0.gml b/objects/o_dialog_palette/Create_0.gml index 02e1421ea..5d9314d2b 100644 --- a/objects/o_dialog_palette/Create_0.gml +++ b/objects/o_dialog_palette/Create_0.gml @@ -62,15 +62,8 @@ function __PaletteColor(_color = c_black) constructor { var dia = dialogCall(o_dialog_file_name, mouse_mx + ui(8), mouse_my + ui(8)); dia.onModify = function(txt) /*=>*/ { var file = file_text_open_write(txt + ".hex"); - for(var i = 0; i < array_length(palette); i++) { - var cc = palette[i]; - var r = number_to_hex(color_get_red(cc)); - var g = number_to_hex(color_get_green(cc)); - var b = number_to_hex(color_get_blue(cc)); - var a = number_to_hex(color_get_alpha(cc)); - - file_text_write_string(file, $"{r}{g}{b}{a}\n"); - } + for(var i = 0; i < array_length(palette); i++) + file_text_write_string(file, $"{color_get_hex(palette[i])}\n"); file_text_close(file); __initPalette(); }; diff --git a/objects/o_dialog_palette/Draw_64.gml b/objects/o_dialog_palette/Draw_64.gml index 28d529b59..d85324b03 100644 --- a/objects/o_dialog_palette/Draw_64.gml +++ b/objects/o_dialog_palette/Draw_64.gml @@ -368,8 +368,8 @@ draggable = true; bx -= ui(32); if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, _foc, "", THEME.add_16) == 2) { - palette[array_length(palette)] = cola(c_black); index_selecting = [ array_length(palette), 1 ]; + palette[array_length(palette)] = cola(c_black); refreshPaletteObject(); onApply(palette); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 0ea8708ac..f35e7e296 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -43,8 +43,8 @@ LATEST_VERSION = 1_18_00_0; VERSION = 1_18_09_0; SAVE_VERSION = 1_18_09_1; - VERSION_STRING = MAC? "1.18.003m" : "1.18.10.003"; - BUILD_NUMBER = 118101.003; + VERSION_STRING = MAC? "1.18.003m" : "1.18.10.004"; + BUILD_NUMBER = 118101.004; PREF_VERSION = 1_17_1; var _vsp = string_split(VERSION_STRING, "."); diff --git a/scripts/string_hexadecimal/string_hexadecimal.gml b/scripts/string_hexadecimal/string_hexadecimal.gml index 6a77c5cae..994cc1887 100644 --- a/scripts/string_hexadecimal/string_hexadecimal.gml +++ b/scripts/string_hexadecimal/string_hexadecimal.gml @@ -39,7 +39,7 @@ function color_get_hex(color, alpha = true) { var b = arr? round(color[2] * 256) : color_get_blue(color); var a = arr? round(color[3] * 256) : color_get_alpha(color); - return number_to_hex(r) + number_to_hex(g) + number_to_hex(b) + (alpha && is_int64(color)? number_to_hex(a) : ""); + return $"{number_to_hex(r)}{number_to_hex(g)}{number_to_hex(b)}{alpha && is_int64(color)? number_to_hex(a) : ""}"; } function color_from_rgb(str) {