-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
841 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
---@meta | ||
|
||
--- An object that acts as the owning handle of a callback registration. | ||
---@alias TRP3.CallbackOwner string|table|thread | ||
|
||
--- Interface for objects that allow untyped callback event registrations, | ||
--- mirroring the interface exposed by CallbackHandler-1.0. | ||
--- | ||
---@class TRP3.CallbackRegistry | ||
local CallbackRegistry = {}; | ||
|
||
---@generic T: string | ||
---@param owner TRP3.CallbackOwner | ||
---@param event T | ||
---@param callback fun(event: T, ...)|string? | ||
function CallbackRegistry.RegisterCallback(owner, event, callback) end | ||
|
||
---@generic T: string, V | ||
---@param owner TRP3.CallbackOwner | ||
---@param event T | ||
---@param callback fun(arg1: V, event: T, ...)|string? | ||
---@param arg1 V | ||
function CallbackRegistry.RegisterCallback(owner, event, callback, arg1) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event string | ||
function CallbackRegistry.UnregisterCallback(owner, event) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
function CallbackRegistry.UnregisterAllCallbacks(owner) end | ||
|
||
--- Interface for objects that allow dispatching of untyped callback events, | ||
--- mirroring the interface exposed by CallbackHandler-1.0. | ||
---@class TRP3.CallbackDispatcher | ||
local CallbackDispatcher = {}; | ||
|
||
---@param event string | ||
---@param ... any | ||
function CallbackDispatcher:Fire(event, ...) end | ||
|
||
---@param object table | ||
---@return TRP3.CallbackDispatcher callbacks | ||
function TRP3_API.InitCallbackRegistry(object) end | ||
|
||
---@param object table | ||
---@param events string[] | { [string]: string } | ||
---@return TRP3.CallbackDispatcher callbacks | ||
function TRP3_API.InitCallbackRegistryWithEvents(object, events) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
---@meta | ||
|
||
---@class TRP3_API | ||
TRP3_API = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
---@meta | ||
|
||
---@alias TRP3.ClassToken "DEATHKNIGHT" | "DEMONHUNTER" | "DRUID" | "EVOKER" | "HUNTER" | "MAGE" | "MONK" | "PALADIN" | "PRIEST" | "ROGUE" | "SHAMAN" | "WARLOCK" | "WARRIOR" | ||
---@alias TRP3.FileID integer | ||
---@alias TRP3.AtlasElementID integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
---@meta | ||
|
||
---@class TRP3.IconBrowserModel | ||
local IconBrowserModel = {}; | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnModelUpdated" | ||
---@param callback fun(event: "OnModelUpdated")|string? | ||
function IconBrowserModel.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnModelUpdated" | ||
function IconBrowserModel.UnregisterCallback(owner, event) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
function IconBrowserModel.UnregisterAllCallbacks(owner) end | ||
|
||
---@class TRP3.IconBrowserFilterModel : TRP3.IconBrowserModel | ||
local IconBrowserFilterModel = {}; | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnModelUpdated" | ||
---@param callback fun(event: "OnModelUpdated")|string? | ||
function IconBrowserFilterModel.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnSearchProgressChanged" | ||
---@param callback fun(event: "OnSearchProgressChanged", progress: TRP3.IconBrowserSearchProgress)|string? | ||
function IconBrowserFilterModel.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnSearchStateChanged" | ||
---@param callback fun(event: "OnSearchStateChanged", state: "running" | "finished")|string? | ||
function IconBrowserFilterModel.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnSearchProgressChanged" | ||
function IconBrowserFilterModel.UnregisterCallback(owner, event) end | ||
|
||
---@class TRP3.IconBrowserFilterTask | ||
local IconBrowserSearchTask = {}; | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnProgressChanged" | ||
---@param callback fun(event: "OnProgressChanged", progress: TRP3.IconBrowserSearchProgress)|string? | ||
function IconBrowserSearchTask.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnResultsChanged" | ||
---@param callback fun(event: "OnResultsChanged", results: integer[])|string? | ||
function IconBrowserSearchTask.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnStateChanged" | ||
---@param callback fun(event: "OnStateChanged", state: "running" | "finished")|string? | ||
function IconBrowserSearchTask.RegisterCallback(owner, event, callback) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
---@param event "OnStateChanged" | "OnProgressChanged" | "OnResultsChanged" | ||
function IconBrowserSearchTask.UnregisterCallback(owner, event) end | ||
|
||
---@param owner TRP3.CallbackOwner | ||
function IconBrowserSearchTask.UnregisterAllCallbacks(owner) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- Copyright The Total RP 3 Authors | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
TRP3_FunctionUtil = {}; | ||
|
||
--- Returns a closure that when first invoked will start a timer of duration | ||
--- `timeout`. When this timer has elapsed, the supplied callback will be | ||
--- invoked. | ||
--- | ||
--- Repeated calls to the closure will reset the timeout back to zero, in | ||
--- effect delaying execution of the callback. | ||
--- | ||
--- @param timeout number | ||
--- @param callback function | ||
function TRP3_FunctionUtil.Debounce(timeout, callback) | ||
local calls = 0; | ||
|
||
local function Decrement() | ||
calls = calls - 1; | ||
|
||
if calls == 0 then | ||
callback(); | ||
end | ||
end | ||
|
||
return function() | ||
C_Timer.After(timeout, Decrement); | ||
calls = calls + 1; | ||
end | ||
end | ||
|
||
--- Returns a closure that when first invoked will immediately execute the | ||
--- supplied callback, and starts a timer of duration `timeout`. Until the | ||
--- timer has elapsed, future invocations will do nothing. | ||
--- | ||
--- @param timeout number | ||
--- @param callback function | ||
function TRP3_FunctionUtil.Throttle(timeout, callback) | ||
local callable = true; | ||
|
||
local function Reset() | ||
callable = true; | ||
end | ||
|
||
return function() | ||
if callable then | ||
C_Timer.After(timeout, Reset); | ||
callable = false; | ||
callback(); | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.