From afc89ef797a1310f23ef853b0426914324b30438 Mon Sep 17 00:00:00 2001 From: crautou Date: Thu, 26 Jul 2018 16:26:12 +0200 Subject: [PATCH] Items can now send multiple callbacks on onDownloaded/onInstalled events --- steam/ugc/Item.hx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/steam/ugc/Item.hx b/steam/ugc/Item.hx index f199524..ee1719a 100644 --- a/steam/ugc/Item.hx +++ b/steam/ugc/Item.hx @@ -14,6 +14,8 @@ enum ItemState { class Item { public var id : UID; + public static var downloadedCallbacks = new ArrayVoid>(); + public static var installedCallbacks = new ArrayVoid>(); public static function fromInt( i : Int ){ var b = haxe.io.Bytes.alloc(8); @@ -22,11 +24,19 @@ class Item { } public static function init( onDownloaded : Item -> Void, onInstalled : Item -> Void ){ + downloadedCallbacks.push(onDownloaded); + installedCallbacks.push(onInstalled); Api.registerGlobalEvent(3400 + 6, function(data:{file:UID}){ - onDownloaded(new Item(data.file)); + var item = new Item(data.file); + for( callback in downloadedCallbacks ){ + callback(item); + } }); Api.registerGlobalEvent(3400 + 5, function(data:{file:UID}){ - onInstalled(new Item(data.file)); + var item = new Item(data.file); + for( callback in installedCallbacks ){ + callback(item); + } }); }