From 388a4ccf9362a22730941ed879cd09c6e32bc0b2 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 18 Aug 2024 09:51:54 +0700 Subject: [PATCH] p2 --- .../byte_read_function/byte_read_function.gml | 48 +++++++++---------- scripts/globals/globals.gml | 6 +-- scripts/textArea/textArea.gml | 4 ++ scripts/textBox/textBox.gml | 5 ++ scripts/textInput/textInput.gml | 11 ----- scripts/widget/widget.gml | 7 ++- 6 files changed, 38 insertions(+), 43 deletions(-) diff --git a/scripts/byte_read_function/byte_read_function.gml b/scripts/byte_read_function/byte_read_function.gml index 45cd9b231..917f30f34 100644 --- a/scripts/byte_read_function/byte_read_function.gml +++ b/scripts/byte_read_function/byte_read_function.gml @@ -1,4 +1,3 @@ - function bin_read_byte(_bin) { return file_bin_read_byte(_bin); } @@ -13,10 +12,10 @@ function bin_read_short(_bin) { var b0 = file_bin_read_byte(_bin); var b1 = file_bin_read_byte(_bin); - var short = b0 + (b1 << 8); - var sig = short >> 15; - short = short & ~(1 << 15); - return sig? -power(2, 15) + short : short; + var sht = b0 + (b1 << 8); + var sig = sht >> 15; + sht = sht & ~(1 << 15); + return sig? sht - power(2, 15) : sht; } function bin_read_dword(_bin) { @@ -24,8 +23,8 @@ function bin_read_dword(_bin) { var b1 = file_bin_read_byte(_bin); var b2 = file_bin_read_byte(_bin); var b3 = file_bin_read_byte(_bin); - var dword = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - return dword; + var dw = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + return dw; } function bin_read_long(_bin) { @@ -33,11 +32,11 @@ function bin_read_long(_bin) { var b1 = file_bin_read_byte(_bin); var b2 = file_bin_read_byte(_bin); var b3 = file_bin_read_byte(_bin); - var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + var lng = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - var sig = long >> 31; - long = long & ~(1 << 31); - return sig? -power(2, 31) : long; + var sig = lng >> 31; + lng = lng & ~(1 << 31); + return sig? lng - power(2, 31) : lng; } function bin_read_fixed(_bin) { @@ -56,11 +55,11 @@ function bin_read_float(_bin) { var b1 = file_bin_read_byte(_bin); var b2 = file_bin_read_byte(_bin); var b3 = file_bin_read_byte(_bin); - var float = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + var flt = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - var sig = float >> 31; - var expo = (float & ~(1 << 31)) >> 23; - var mant = float & 0b00000000_01111111_11111111_11111111; + var sig = flt >> 31; + var expo = (flt & ~(1 << 31)) >> 23; + var mant = flt & 0b00000000_01111111_11111111_11111111; var val = (1 + mant) * power(2, expo - 127); return sig? -val : val; @@ -75,11 +74,11 @@ function bin_read_double(_bin) { var b5 = file_bin_read_byte(_bin); var b6 = file_bin_read_byte(_bin); var b7 = file_bin_read_byte(_bin); - var double = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); + var dub = int64(b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56)); - var sig = double >> 63; - var expo = (double & ~(1 << 63)) >> 52; - var mant = double & 0b00000000_00001111_11111111_11111111_11111111_11111111_11111111_11111111; + var sig = dub >> 63; + var expo = (dub & ~(1 << 63)) >> 52; + var mant = dub & 0b00000000_00001111_11111111_11111111_11111111_11111111_11111111_11111111; var val = (1 + mant) * power(2, expo - 1023); return sig? -val : val; @@ -94,7 +93,7 @@ function bin_read_qword(_bin) { var b5 = file_bin_read_byte(_bin); var b6 = file_bin_read_byte(_bin); var b7 = file_bin_read_byte(_bin); - return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); + return int64(b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56)); } function bin_read_long64(_bin) { @@ -106,13 +105,12 @@ function bin_read_long64(_bin) { var b5 = file_bin_read_byte(_bin); var b6 = file_bin_read_byte(_bin); var b7 = file_bin_read_byte(_bin); - var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); - var sig = long >> 63; - long = long & ~(1 << 63); - return sig? -long : long; + var lng = int64(b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56)); + var sig = lng >> 63; + lng = lng & ~(1 << 63); + return sig? -lng : lng; } -// function bin_read_string(_bin) { var len = bin_read_word(_bin); var ss = ""; diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 718727353..796a30edb 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -37,10 +37,10 @@ globalvar HOTKEYS, HOTKEY_CONTEXT; LATEST_VERSION = 1_16_00_0; - VERSION = 1_17_10_1; + VERSION = 1_17_10_2; SAVE_VERSION = 1_17_10_0; - VERSION_STRING = "1.17.10.001"; - BUILD_NUMBER = 1_17_10_1; + VERSION_STRING = "1.17.10.2"; + BUILD_NUMBER = 1_17_10_2; HOTKEYS = ds_map_create(); HOTKEY_CONTEXT = ds_list_create(); diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index fa0da62fb..2675979e5 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -1030,4 +1030,8 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor return hh; } #endregion + static clone = function() { + var cln = new textArea(input, onModify); + return cln; + } } \ No newline at end of file diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index 637cddd58..2b64dad94 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -819,4 +819,9 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { sprite_index = -1; return _h; } #endregion + + static clone = function() { + var cln = new textBox(input, onModify); + return cln; + } } \ No newline at end of file diff --git a/scripts/textInput/textInput.gml b/scripts/textInput/textInput.gml index 6056223e1..f86c9c540 100644 --- a/scripts/textInput/textInput.gml +++ b/scripts/textInput/textInput.gml @@ -26,15 +26,4 @@ function textInput(_input, _onModify) : widget() constructor { static setSideButton = function(_button) /*=>*/ { self.side_button = _button; return self; } static breakCharacter = function(ch) /*=>*/ { return ch == " " || ch == "\n"; } - - static clone = function() { - var _onModify = onModify; - onModify = noone; - - var cln = variable_clone(self); - cln.onModify = _onModify; - onModify = _onModify; - - return cln; - } } \ No newline at end of file diff --git a/scripts/widget/widget.gml b/scripts/widget/widget.gml index b0ce85458..51aad32f8 100644 --- a/scripts/widget/widget.gml +++ b/scripts/widget/widget.gml @@ -100,12 +100,11 @@ function widget() constructor { hover = false; } - static inBBOX = function(_m) { return point_in_rectangle(_m[0], _m[1], x, y, x + w, y + h); } - - static clone = function() { return variable_clone(self); } + static inBBOX = function(_m) { return point_in_rectangle(_m[0], _m[1], x, y, x + w, y + h); } + static clone = function() { return struct_clone(self); } static drawParam = function(params) {} - static draw = function() {} + static draw = function() {} } function widgetParam(x, y, w, h, data, display_data = {}, m = mouse_ui, rx = 0, ry = 0) constructor {