From bf1f270d8199d41c582a3e7c75d13e4ec5a4d175 Mon Sep 17 00:00:00 2001 From: dem0nd Date: Mon, 18 May 2026 09:45:33 +0300 Subject: [PATCH 1/3] refactor(filter): restore actionscripts from decompiled to source version --- .../Common/skyui/filter/IFiIlter.as | 5 + .../Common/skyui/filter/ItemTypeFilter.as | 161 +++++++++++------- .../Common/skyui/filter/SortFilter.as | 109 +++++++----- 3 files changed, 164 insertions(+), 111 deletions(-) create mode 100644 source/actionscript/Common/skyui/filter/IFiIlter.as diff --git a/source/actionscript/Common/skyui/filter/IFiIlter.as b/source/actionscript/Common/skyui/filter/IFiIlter.as new file mode 100644 index 00000000..22907db5 --- /dev/null +++ b/source/actionscript/Common/skyui/filter/IFiIlter.as @@ -0,0 +1,5 @@ +interface skyui.filter.IFilter +{ + // Apply filter on the given array + // public function applyFilter(filteredList: Array); +} \ No newline at end of file diff --git a/source/actionscript/Common/skyui/filter/ItemTypeFilter.as b/source/actionscript/Common/skyui/filter/ItemTypeFilter.as index c8c78e30..82dd0c73 100644 --- a/source/actionscript/Common/skyui/filter/ItemTypeFilter.as +++ b/source/actionscript/Common/skyui/filter/ItemTypeFilter.as @@ -1,69 +1,98 @@ class skyui.filter.ItemTypeFilter implements skyui.filter.IFilter { - var _matcherFunc; - var dispatchEvent; - var _itemFilter = 4294967295; - function ItemTypeFilter() - { - gfx.events.EventDispatcher.initialize(this); - this._matcherFunc = skyui.filter.ItemTypeFilter.entryMatchesFilter; - } - function get itemFilter() - { - return this._itemFilter; - } - function changeFilterFlag(a_newFilter, a_bDoNotUpdate) - { - if(a_bDoNotUpdate == undefined) - { - a_bDoNotUpdate = false; - } - this._itemFilter = a_newFilter; - if(!a_bDoNotUpdate) - { - this.dispatchEvent({type:"filterChange"}); - } - } - function setPartitionedFilterMode(a_bPartition) - { - this._matcherFunc = !a_bPartition ? skyui.filter.ItemTypeFilter.entryMatchesFilter : skyui.filter.ItemTypeFilter.entryMatchesPartitionedFilter; - } - function applyFilter(a_filteredList) - { - var _loc2_ = 0; - while(_loc2_ < a_filteredList.length) - { - if(!this._matcherFunc(a_filteredList[_loc2_],this._itemFilter)) - { - a_filteredList.splice(_loc2_,1); - _loc2_ = _loc2_ - 1; - } - _loc2_ = _loc2_ + 1; - } - } - function isMatch(a_entry, a_flag) - { - return this._matcherFunc(a_entry,a_flag); - } - static function entryMatchesFilter(a_entry, a_flag) - { - return a_entry != undefined && (a_entry.filterFlag == undefined || (a_entry.filterFlag & a_flag) != 0); - } - static function entryMatchesPartitionedFilter(a_entry, a_flag) - { - if(a_entry == undefined) - { - return false; - } - if(a_flag == 4294967295) - { - return true; - } - var _loc1_ = a_entry.filterFlag; - var _loc4_ = _loc1_ & 0xFF; - var _loc3_ = (_loc1_ & 0xFF00) >>> 8; - var _loc6_ = (_loc1_ & 0xFF0000) >>> 16; - var _loc5_ = (_loc1_ & 0xFF000000) >>> 24; - return _loc4_ == a_flag || _loc3_ == a_flag || _loc6_ == a_flag || _loc5_ == a_flag; - } + /* PRIVATE VARIABLES */ + + private var _matcherFunc: Function; + + + /* PROPERTIES */ + + private var _itemFilter: Number = 0xFFFFFFFF; + + function get itemFilter() + { + return this._itemFilter; + } + + + /* INITIALIZATION */ + + public function ItemTypeFilter() + { + gfx.events.EventDispatcher.initialize(this); + + this._matcherFunc = skyui.filter.ItemTypeFilter.entryMatchesFilter; + } + + + /* PUBLIC FUNCTIONS */ + + // @mixin by gfx.events.EventDispatcher + public var dispatchEvent: Function; + public var dispatchQueue: Function; + public var hasEventListener: Function; + public var addEventListener: Function; + public var removeEventListener: Function; + public var removeAllEventListeners: Function; + public var cleanUpEvents: Function; + + public function changeFilterFlag(a_newFilter: Number, a_bDoNotUpdate: Boolean) + { + if (a_bDoNotUpdate == undefined) + a_bDoNotUpdate = false; + + this._itemFilter = a_newFilter; + + if (!a_bDoNotUpdate) + this.dispatchEvent({type:"filterChange"}); + } + + public function setPartitionedFilterMode(a_bPartition: Boolean) + { + this._matcherFunc = a_bPartition + ? skyui.filter.ItemTypeFilter.entryMatchesPartitionedFilter + : skyui.filter.ItemTypeFilter.entryMatchesFilter; + } + + // @override skyui.IFilter + public function applyFilter(a_filteredList: Array) + { + for (var i = 0; i < a_filteredList.length; i++) { + if (!this._matcherFunc(a_filteredList[i], this._itemFilter)) { + a_filteredList.splice(i,1); + i--; + } + } + } + + public function isMatch(a_entry: Object, a_flag) + { + return this._matcherFunc(a_entry, a_flag); + } + + + /* PRIVATE FUNCTIONS */ + + public static function entryMatchesFilter(a_entry: Object, a_flag: Boolean) + { + return a_entry != undefined && + (a_entry.filterFlag == undefined || (a_entry.filterFlag & a_flag) != 0); + } + + private static function entryMatchesPartitionedFilter(a_entry: Object, a_flag: Boolean) + { + if (a_entry == undefined) + return false; + + if (a_flag == 0xFFFFFFFF) + return true; + + var flag: Number = a_entry.filterFlag; + var byte0: Number = (flag & 0x000000FF); + var byte1: Number = (flag & 0x0000FF00) >>> 8; + var byte2: Number = (flag & 0x00FF0000) >>> 16; + var byte3: Number = (flag & 0xFF000000) >>> 24; + + return byte0 == a_flag || byte1 == a_flag || byte2 == a_flag || byte3 == a_flag; + } } diff --git a/source/actionscript/Common/skyui/filter/SortFilter.as b/source/actionscript/Common/skyui/filter/SortFilter.as index 6863d6d9..f6d6f73c 100644 --- a/source/actionscript/Common/skyui/filter/SortFilter.as +++ b/source/actionscript/Common/skyui/filter/SortFilter.as @@ -1,48 +1,67 @@ class skyui.filter.SortFilter implements skyui.filter.IFilter { - var _sortAttributes; - var _sortOptions; - var dispatchEvent; - function SortFilter() - { - gfx.events.EventDispatcher.initialize(this); - } - function setSortBy(a_sortAttributes, a_sortOptions) - { - if(this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions) - { - return undefined; - } - this._sortAttributes = a_sortAttributes; - this._sortOptions = a_sortOptions; - this.dispatchEvent({type:"filterChange"}); - } - function applyFilter(a_filteredList) - { - var _loc5_ = this._sortAttributes[0]; - var _loc2_ = 0; - var _loc4_; - while(_loc2_ < a_filteredList.length) - { - _loc4_ = a_filteredList[_loc2_][_loc5_]; - if(_loc4_ == null) - { - a_filteredList[_loc2_]._sortFlag = 1; - } - else - { - a_filteredList[_loc2_]._sortFlag = 0; - } - _loc2_ = _loc2_ + 1; - } - this._sortAttributes.unshift("enabled"); - this._sortOptions.unshift(Array.NUMERIC | Array.DESCENDING); - this._sortAttributes.unshift("_sortFlag"); - this._sortOptions.unshift(Array.NUMERIC); - a_filteredList.sortOn(this._sortAttributes,this._sortOptions); - this._sortAttributes.shift(); - this._sortOptions.shift(); - this._sortAttributes.shift(); - this._sortOptions.shift(); - } + /* PRIVATE VARIABLES */ + + private var _sortAttributes: Array; + private var _sortOptions: Array; + + + /* INITIALIZATION */ + + public function SortFilter() + { + gfx.events.EventDispatcher.initialize(this); + } + + + /* PUBLIC FUNCTIONS */ + + // @mixin by gfx.events.EventDispatcher + public var dispatchEvent: Function; + public var dispatchQueue: Function; + public var hasEventListener: Function; + public var addEventListener: Function; + public var removeEventListener: Function; + public var removeAllEventListeners: Function; + public var cleanUpEvents: Function; + + // Change the filter attributes and options and trigger an update if necessary. + public function setSortBy(a_sortAttributes: Array, a_sortOptions: Array) + { + if (this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions) + return; + + this._sortAttributes = a_sortAttributes; + this._sortOptions = a_sortOptions; + + this.dispatchEvent({type: "filterChange"}); + } + + // @override skyui.filter.IFilter + public function applyFilter(a_filteredList: Array) + { + var primaryAttribute = this._sortAttributes[0]; + + for (var i = 0; i < a_filteredList.length; i++) { + var t = a_filteredList[i][primaryAttribute]; + if (t == null) + a_filteredList[i]._sortFlag = 1; + else + a_filteredList[i]._sortFlag = 0; + } + + this._sortAttributes.unshift("enabled"); + this._sortOptions.unshift(Array.NUMERIC | Array.DESCENDING); + + this._sortAttributes.unshift("_sortFlag"); + this._sortOptions.unshift(Array.NUMERIC); + + a_filteredList.sortOn(this._sortAttributes, this._sortOptions); + + this._sortAttributes.shift(); + this._sortOptions.shift(); + + this._sortAttributes.shift(); + this._sortOptions.shift(); + } } From ab6229bd397660e9a6a6cb0875249dbed17fb011 Mon Sep 17 00:00:00 2001 From: dem0nd Date: Mon, 18 May 2026 09:54:25 +0300 Subject: [PATCH 2/3] fix: rename script --- .../actionscript/Common/skyui/filter/{IFiIlter.as => IFilter.as} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename source/actionscript/Common/skyui/filter/{IFiIlter.as => IFilter.as} (100%) diff --git a/source/actionscript/Common/skyui/filter/IFiIlter.as b/source/actionscript/Common/skyui/filter/IFilter.as similarity index 100% rename from source/actionscript/Common/skyui/filter/IFiIlter.as rename to source/actionscript/Common/skyui/filter/IFilter.as From 1260639f4cd59e7535e49fd562bfe61f5a3f2cf8 Mon Sep 17 00:00:00 2001 From: dem0nd Date: Mon, 18 May 2026 10:52:57 +0300 Subject: [PATCH 3/3] chore: add missing typization arg --- source/actionscript/Common/skyui/filter/ItemTypeFilter.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/actionscript/Common/skyui/filter/ItemTypeFilter.as b/source/actionscript/Common/skyui/filter/ItemTypeFilter.as index 82dd0c73..a6e465c0 100644 --- a/source/actionscript/Common/skyui/filter/ItemTypeFilter.as +++ b/source/actionscript/Common/skyui/filter/ItemTypeFilter.as @@ -65,7 +65,7 @@ class skyui.filter.ItemTypeFilter implements skyui.filter.IFilter } } - public function isMatch(a_entry: Object, a_flag) + public function isMatch(a_entry: Object, a_flag: Boolean) { return this._matcherFunc(a_entry, a_flag); }