├── LossOfControl
├── Media
│ ├── Sound
│ │ └── 34468.ogg
│ └── Texture
│ │ └── Cooldown
│ │ ├── edge.blp
│ │ ├── ping4.blp
│ │ ├── star4.blp
│ │ ├── cooldown.blp
│ │ ├── cooldown2.blp
│ │ ├── edge-LoC.blp
│ │ ├── starburst.blp
│ │ ├── Loc-RedLine.blp
│ │ └── loc-shadowbg.blp
├── Libs
│ ├── AceDB-3.0
│ │ └── AceDB-3.0.xml
│ ├── AceAddon-3.0
│ │ └── AceAddon-3.0.xml
│ ├── AceEvent-3.0
│ │ ├── AceEvent-3.0.xml
│ │ └── AceEvent-3.0.lua
│ ├── AceTimer-3.0
│ │ └── AceTimer-3.0.xml
│ ├── CallbackHandler-1.0
│ │ ├── CallbackHandler-1.0.xml
│ │ └── CallbackHandler-1.0.lua
│ ├── AceConfig-3.0
│ │ ├── AceConfigCmd-3.0
│ │ │ └── AceConfigCmd-3.0.xml
│ │ ├── AceConfigDialog-3.0
│ │ │ └── AceConfigDialog-3.0.xml
│ │ ├── AceConfigRegistry-3.0
│ │ │ ├── AceConfigRegistry-3.0.xml
│ │ │ └── AceConfigRegistry-3.0.lua
│ │ ├── AceConfig-3.0.xml
│ │ └── AceConfig-3.0.lua
│ ├── LibStub
│ │ ├── LibStub.toc
│ │ ├── tests
│ │ │ ├── test3.lua
│ │ │ ├── test4.lua
│ │ │ ├── test2.lua
│ │ │ └── test.lua
│ │ └── LibStub.lua
│ └── AceGUI-3.0
│ │ ├── AceGUI-3.0.xml
│ │ └── widgets
│ │ ├── AceGUIWidget-Heading.lua
│ │ ├── AceGUIWidget-Button.lua
│ │ ├── AceGUIWidget-SimpleGroup.lua
│ │ ├── AceGUIWidget-Icon.lua
│ │ ├── AceGUIWidget-Label.lua
│ │ ├── AceGUIWidget-InlineGroup.lua
│ │ ├── AceGUIWidget-BlizOptionsGroup.lua
│ │ ├── AceGUIWidget-DropDownGroup.lua
│ │ ├── AceGUIWidget-ColorPicker.lua
│ │ ├── AceGUIWidget-InteractiveLabel.lua
│ │ ├── AceGUIWidget-EditBox.lua
│ │ ├── AceGUIWidget-Keybinding.lua
│ │ ├── AceGUIWidget-CheckBox.lua
│ │ ├── AceGUIWidget-Slider.lua
│ │ ├── AceGUIWidget-ScrollFrame.lua
│ │ ├── AceGUIWidget-Frame.lua
│ │ ├── AceGUIWidget-Window.lua
│ │ ├── AceGUIWidget-MultiLineEditBox.lua
│ │ ├── AceGUIWidget-TabGroup.lua
│ │ └── AceGUIWidget-DropDown-Items.lua
├── LossOfControl.toc
├── LossOfControl.xml
├── LossOfControlOptions.lua
├── LossOfControl.lua
└── LossOfControlMixin.lua
├── .vscode
└── settings.json
└── README.md
/LossOfControl/Media/Sound/34468.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Sound/34468.ogg
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Lua.diagnostics.disable": [
3 | "undefined-global",
4 | "undefined-field"
5 | ]
6 | }
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/edge.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/edge.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/ping4.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/ping4.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/star4.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/star4.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/cooldown.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/cooldown.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/cooldown2.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/cooldown2.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/edge-LoC.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/edge-LoC.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/starburst.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/starburst.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/Loc-RedLine.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/Loc-RedLine.blp
--------------------------------------------------------------------------------
/LossOfControl/Media/Texture/Cooldown/loc-shadowbg.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanSpector/LossOfControl/HEAD/LossOfControl/Media/Texture/Cooldown/loc-shadowbg.blp
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceDB-3.0/AceDB-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceAddon-3.0/AceAddon-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceEvent-3.0/AceEvent-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceTimer-3.0/AceTimer-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/LossOfControl/LossOfControl.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 30300
2 | ## Title: Loss of Control Alerts
3 | ## Version: 1.0
4 | ## Author: RomanSpector & Blizzard
5 | ## Notes: Backport LossOfControl from retail
6 | ## DefaultState: enabled
7 | ## SavedVariables: LossOfControlDB
8 |
9 | LossOfControl.xml
10 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LossOfControl
2 | ## Backport LossOfControl from retail for 3.3.5a
3 |
4 |
5 | ## Open -main folder in zip and copy LossOfControl folder to AddOns
6 |
7 | ## [Download](https://github.com/RomanSpector/LossOfControl/archive/refs/heads/main.zip)
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/LibStub.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 50001
2 | ## Title: Lib: LibStub
3 | ## Notes: Universal Library Stub
4 | ## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
5 | ## X-Website: http://www.wowace.com/addons/libstub/
6 | ## X-Category: Library
7 | ## X-License: Public Domain
8 | ## X-Curse-Packaged-Version: r97
9 | ## X-Curse-Project-Name: LibStub
10 | ## X-Curse-Project-ID: libstub
11 | ## X-Curse-Repository-ID: wow/libstub/mainline
12 |
13 | LibStub.lua
14 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfig-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/tests/test3.lua:
--------------------------------------------------------------------------------
1 | debugstack = debug.traceback
2 | strmatch = string.match
3 |
4 | loadfile("../LibStub.lua")()
5 |
6 | local proxy = newproxy() -- non-string
7 |
8 | assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
9 | local success, ret = pcall(LibStub.GetLibrary, proxy, true)
10 | assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
11 |
12 | assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
13 |
14 | assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/tests/test4.lua:
--------------------------------------------------------------------------------
1 | debugstack = debug.traceback
2 | strmatch = string.match
3 |
4 | loadfile("../LibStub.lua")()
5 |
6 |
7 | -- Pretend like loaded libstub is old and doesn't have :IterateLibraries
8 | assert(LibStub.minor)
9 | LibStub.minor = LibStub.minor - 0.0001
10 | LibStub.IterateLibraries = nil
11 |
12 | loadfile("../LibStub.lua")()
13 |
14 | assert(type(LibStub.IterateLibraries)=="function")
15 |
16 |
17 | -- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
18 | LibStub.IterateLibraries = 123
19 |
20 | loadfile("../LibStub.lua")()
21 |
22 | assert(LibStub.IterateLibraries == 123)
23 |
24 |
25 | -- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
26 | LibStub.minor = LibStub.minor + 0.0001
27 |
28 | loadfile("../LibStub.lua")()
29 |
30 | assert(LibStub.IterateLibraries == 123)
31 |
32 |
33 | -- Again with a huge number
34 | LibStub.minor = LibStub.minor + 1234567890
35 |
36 | loadfile("../LibStub.lua")()
37 |
38 | assert(LibStub.IterateLibraries == 123)
39 |
40 |
41 | print("OK")
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/tests/test2.lua:
--------------------------------------------------------------------------------
1 | debugstack = debug.traceback
2 | strmatch = string.match
3 |
4 | loadfile("../LibStub.lua")()
5 |
6 | for major, library in LibStub:IterateLibraries() do
7 | -- check that MyLib doesn't exist yet, by iterating through all the libraries
8 | assert(major ~= "MyLib")
9 | end
10 |
11 | assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
12 | assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
13 | local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
14 | assert(lib) -- check it exists
15 | assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
16 |
17 | assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
18 |
19 | local count=0
20 | for major, library in LibStub:IterateLibraries() do
21 | -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
22 | if major == "MyLib" then -- we found it!
23 | count = count +1
24 | assert(rawequal(library, lib)) -- verify that the references are equal
25 | end
26 | end
27 | assert(count == 1) -- verify that we actually found it, and only once
28 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/AceGUI-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Heading --
5 | --------------------------
6 | do
7 | local Type = "Heading"
8 | local Version = 5
9 |
10 | local function OnAcquire(self)
11 | self:SetText("")
12 | self:SetFullWidth()
13 | self:SetHeight(18)
14 | end
15 |
16 | local function OnRelease(self)
17 | self.frame:ClearAllPoints()
18 | self.frame:Hide()
19 | end
20 |
21 | local function SetText(self, text)
22 | self.label:SetText(text or "")
23 | if (text or "") == "" then
24 | self.left:SetPoint("RIGHT",self.frame,"RIGHT",-3,0)
25 | self.right:Hide()
26 | else
27 | self.left:SetPoint("RIGHT",self.label,"LEFT",-5,0)
28 | self.right:Show()
29 | end
30 | end
31 |
32 | local function Constructor()
33 | local frame = CreateFrame("Frame",nil,UIParent)
34 | local self = {}
35 | self.type = Type
36 |
37 | self.OnRelease = OnRelease
38 | self.OnAcquire = OnAcquire
39 | self.SetText = SetText
40 | self.frame = frame
41 | frame.obj = self
42 |
43 | frame:SetHeight(18)
44 |
45 | local label = frame:CreateFontString(nil,"BACKGROUND","GameFontNormal")
46 | label:SetPoint("TOP",frame,"TOP",0,0)
47 | label:SetPoint("BOTTOM",frame,"BOTTOM",0,0)
48 | label:SetJustifyH("CENTER")
49 | label:SetHeight(18)
50 | self.label = label
51 |
52 | local left = frame:CreateTexture(nil, "BACKGROUND")
53 | self.left = left
54 | left:SetHeight(8)
55 | left:SetPoint("LEFT",frame,"LEFT",3,0)
56 | left:SetPoint("RIGHT",label,"LEFT",-5,0)
57 | left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
58 | left:SetTexCoord(0.81, 0.94, 0.5, 1)
59 |
60 | local right = frame:CreateTexture(nil, "BACKGROUND")
61 | self.right = right
62 | right:SetHeight(8)
63 | right:SetPoint("RIGHT",frame,"RIGHT",-3,0)
64 | right:SetPoint("LEFT",label,"RIGHT",5,0)
65 | right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
66 | right:SetTexCoord(0.81, 0.94, 0.5, 1)
67 |
68 | AceGUI:RegisterAsWidget(self)
69 | return self
70 | end
71 |
72 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
73 | end
74 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/tests/test.lua:
--------------------------------------------------------------------------------
1 | debugstack = debug.traceback
2 | strmatch = string.match
3 |
4 | loadfile("../LibStub.lua")()
5 |
6 | local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
7 | assert(lib) -- should return the library table
8 | assert(not oldMinor) -- should not return the old minor, since it didn't exist
9 |
10 | -- the following is to create data and then be able to check if the same data exists after the fact
11 | function lib:MyMethod()
12 | end
13 | local MyMethod = lib.MyMethod
14 | lib.MyTable = {}
15 | local MyTable = lib.MyTable
16 |
17 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
18 | assert(not newLib) -- should not return since out of date
19 |
20 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
21 | assert(not newLib) -- should not return since out of date
22 |
23 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
24 | assert(newLib) -- library table
25 | assert(rawequal(newLib, lib)) -- should be the same reference as the previous
26 | assert(newOldMinor == 1) -- should return the minor version of the previous version
27 |
28 | assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
29 | assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
30 |
31 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
32 | assert(newLib) -- library table
33 | assert(newOldMinor == 2) -- previous version was 2
34 |
35 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
36 | assert(newLib)
37 | assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
38 |
39 | local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
40 | assert(newLib)
41 | assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
--------------------------------------------------------------------------------
/LossOfControl/Libs/LibStub/LibStub.lua:
--------------------------------------------------------------------------------
1 | -- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
2 | -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
3 | -- LibStub is hereby placed in the Public Domain
4 | -- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
5 | local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
6 | local LibStub = _G[LIBSTUB_MAJOR]
7 |
8 | -- Check to see is this version of the stub is obsolete
9 | if not LibStub or LibStub.minor < LIBSTUB_MINOR then
10 | LibStub = LibStub or {libs = {}, minors = {} }
11 | _G[LIBSTUB_MAJOR] = LibStub
12 | LibStub.minor = LIBSTUB_MINOR
13 |
14 | -- LibStub:NewLibrary(major, minor)
15 | -- major (string) - the major version of the library
16 | -- minor (string or number ) - the minor version of the library
17 | --
18 | -- returns nil if a newer or same version of the lib is already present
19 | -- returns empty library object or old library object if upgrade is needed
20 | function LibStub:NewLibrary(major, minor)
21 | assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
22 | minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
23 |
24 | local oldminor = self.minors[major]
25 | if oldminor and oldminor >= minor then return nil end
26 | self.minors[major], self.libs[major] = minor, self.libs[major] or {}
27 | return self.libs[major], oldminor
28 | end
29 |
30 | -- LibStub:GetLibrary(major, [silent])
31 | -- major (string) - the major version of the library
32 | -- silent (boolean) - if true, library is optional, silently return nil if its not found
33 | --
34 | -- throws an error if the library can not be found (except silent is set)
35 | -- returns the library object if found
36 | function LibStub:GetLibrary(major, silent)
37 | if not self.libs[major] and not silent then
38 | error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
39 | end
40 | return self.libs[major], self.minors[major]
41 | end
42 |
43 | -- LibStub:IterateLibraries()
44 | --
45 | -- Returns an iterator for the currently registered libraries
46 | function LibStub:IterateLibraries()
47 | return pairs(self.libs)
48 | end
49 |
50 | setmetatable(LibStub, { __call = LibStub.GetLibrary })
51 | end
52 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfig-3.0.lua:
--------------------------------------------------------------------------------
1 | --- AceConfig-3.0 wrapper library.
2 | -- Provides an API to register an options table with the config registry,
3 | -- as well as associate it with a slash command.
4 | -- @class file
5 | -- @name AceConfig-3.0
6 | -- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $
7 |
8 | --[[
9 | AceConfig-3.0
10 |
11 | Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
12 |
13 | ]]
14 |
15 | local MAJOR, MINOR = "AceConfig-3.0", 2
16 | local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
17 |
18 | if not AceConfig then return end
19 |
20 | local cfgreg = LibStub("AceConfigRegistry-3.0")
21 | local cfgcmd = LibStub("AceConfigCmd-3.0")
22 | --TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
23 | --TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
24 |
25 | -- Lua APIs
26 | local pcall, error, type, pairs = pcall, error, type, pairs
27 |
28 | -- -------------------------------------------------------------------
29 | -- :RegisterOptionsTable(appName, options, slashcmd, persist)
30 | --
31 | -- - appName - (string) application name
32 | -- - options - table or function ref, see AceConfigRegistry
33 | -- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
34 |
35 | --- Register a option table with the AceConfig registry.
36 | -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
37 | -- @paramsig appName, options [, slashcmd]
38 | -- @param appName The application name for the config table.
39 | -- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/
40 | -- @param slashcmd A slash command to register for the option table, or a table of slash commands.
41 | -- @usage
42 | -- local AceConfig = LibStub("AceConfig-3.0")
43 | -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
44 | function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
45 | local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
46 | if not ok then error(msg, 2) end
47 |
48 | if slashcmd then
49 | if type(slashcmd) == "table" then
50 | for _,cmd in pairs(slashcmd) do
51 | cfgcmd:CreateChatCommand(cmd, appName)
52 | end
53 | else
54 | cfgcmd:CreateChatCommand(slashcmd, appName)
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Button --
5 | --------------------------
6 | do
7 | local Type = "Button"
8 | local Version = 12
9 |
10 | local function OnAcquire(self)
11 | -- restore default values
12 | self:SetHeight(24)
13 | self:SetWidth(200)
14 | end
15 |
16 | local function OnRelease(self)
17 | self.frame:ClearAllPoints()
18 | self.frame:Hide()
19 | self:SetDisabled(false)
20 | end
21 |
22 | local function Button_OnClick(this, ...)
23 | this.obj:Fire("OnClick", ...)
24 | AceGUI:ClearFocus()
25 | end
26 |
27 | local function Button_OnEnter(this)
28 | this.obj:Fire("OnEnter")
29 | end
30 |
31 | local function Button_OnLeave(this)
32 | this.obj:Fire("OnLeave")
33 | end
34 |
35 | local function SetText(self, text)
36 | self.text:SetText(text or "")
37 | end
38 |
39 | local function SetDisabled(self, disabled)
40 | self.disabled = disabled
41 | if disabled then
42 | self.frame:Disable()
43 | else
44 | self.frame:Enable()
45 | end
46 | end
47 |
48 | local function Constructor()
49 | local num = AceGUI:GetNextWidgetNum(Type)
50 | local name = "AceGUI30Button"..num
51 | local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2")
52 | local self = {}
53 | self.num = num
54 | self.type = Type
55 | self.frame = frame
56 |
57 | local left = _G[name .. "Left"]
58 | local right = _G[name .. "Right"]
59 | local middle = _G[name .. "Middle"]
60 |
61 | left:SetPoint("TOP", frame, "TOP", 0, 0)
62 | left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
63 |
64 | right:SetPoint("TOP", frame, "TOP", 0, 0)
65 | right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
66 |
67 | middle:SetPoint("TOP", frame, "TOP", 0, 0)
68 | middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
69 |
70 | local text = frame:GetFontString()
71 | self.text = text
72 | text:ClearAllPoints()
73 | text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1)
74 | text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1)
75 | text:SetJustifyV("MIDDLE")
76 |
77 | frame:SetScript("OnClick",Button_OnClick)
78 | frame:SetScript("OnEnter",Button_OnEnter)
79 | frame:SetScript("OnLeave",Button_OnLeave)
80 |
81 | self.SetText = SetText
82 | self.SetDisabled = SetDisabled
83 |
84 | frame:EnableMouse(true)
85 |
86 | frame:SetHeight(24)
87 | frame:SetWidth(200)
88 |
89 | self.OnRelease = OnRelease
90 | self.OnAcquire = OnAcquire
91 |
92 | self.frame = frame
93 | frame.obj = self
94 |
95 | AceGUI:RegisterAsWidget(self)
96 | return self
97 | end
98 |
99 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
100 | end
101 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-SimpleGroup.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 |
4 | -------------
5 | -- Widgets --
6 | -------------
7 | --[[
8 | Widgets must provide the following functions
9 | Acquire() - Called when the object is aquired, should set everything to a default hidden state
10 | Release() - Called when the object is Released, should remove any anchors and hide the Widget
11 |
12 | And the following members
13 | frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
14 | type - the type of the object, same as the name given to :RegisterWidget()
15 |
16 | Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
17 | It will be cleared automatically when a widget is released
18 | Placing values directly into a widget object should be avoided
19 |
20 | If the Widget can act as a container for other Widgets the following
21 | content - frame or derivitive that children will be anchored to
22 |
23 | The Widget can supply the following Optional Members
24 |
25 |
26 | ]]
27 |
28 | --------------------------
29 | -- Simple Group --
30 | --------------------------
31 | --[[
32 | This is a simple grouping container, no selection, no borders
33 | It will resize automatically to the height of the controls added to it
34 | ]]
35 |
36 | do
37 | local Type = "SimpleGroup"
38 | local Version = 5
39 |
40 | local function OnAcquire(self)
41 | self:SetWidth(300)
42 | self:SetHeight(100)
43 | end
44 |
45 | local function OnRelease(self)
46 | self.frame:ClearAllPoints()
47 | self.frame:Hide()
48 | end
49 |
50 | local function LayoutFinished(self, width, height)
51 | if self.noAutoHeight then return end
52 | self:SetHeight(height or 0)
53 | end
54 |
55 | local function OnWidthSet(self, width)
56 | local content = self.content
57 | content:SetWidth(width)
58 | content.width = width
59 | end
60 |
61 | local function OnHeightSet(self, height)
62 | local content = self.content
63 | content:SetHeight(height)
64 | content.height = height
65 | end
66 |
67 | local function Constructor()
68 | local frame = CreateFrame("Frame",nil,UIParent)
69 | local self = {}
70 | self.type = Type
71 |
72 | self.OnRelease = OnRelease
73 | self.OnAcquire = OnAcquire
74 | self.frame = frame
75 | self.LayoutFinished = LayoutFinished
76 | self.OnWidthSet = OnWidthSet
77 | self.OnHeightSet = OnHeightSet
78 |
79 | frame.obj = self
80 |
81 | frame:SetHeight(100)
82 | frame:SetWidth(100)
83 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
84 |
85 | --Container Support
86 | local content = CreateFrame("Frame",nil,frame)
87 | self.content = content
88 | content.obj = self
89 | content:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
90 | content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
91 |
92 | AceGUI:RegisterAsContainer(self)
93 | return self
94 | end
95 |
96 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
97 | end
98 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Label --
5 | --------------------------
6 | do
7 | local Type = "Icon"
8 | local Version = 10
9 |
10 | local function OnAcquire(self)
11 | self:SetHeight(110)
12 | self:SetWidth(110)
13 | self:SetLabel("")
14 | self:SetImage(nil)
15 | self:SetImageSize(64, 64)
16 | end
17 |
18 | local function OnRelease(self)
19 | self.frame:ClearAllPoints()
20 | self.frame:Hide()
21 | self:SetDisabled(false)
22 | end
23 |
24 | local function SetLabel(self, text)
25 | if text and text ~= "" then
26 | self.label:Show()
27 | self.label:SetText(text)
28 | self.frame:SetHeight(self.image:GetHeight() + 25)
29 | else
30 | self.label:Hide()
31 | self.frame:SetHeight(self.image:GetHeight() + 10)
32 | end
33 | end
34 |
35 | local function SetImage(self, path, ...)
36 | local image = self.image
37 | image:SetTexture(path)
38 |
39 | if image:GetTexture() then
40 | self.imageshown = true
41 | local n = select('#', ...)
42 | if n == 4 or n == 8 then
43 | image:SetTexCoord(...)
44 | end
45 | else
46 | self.imageshown = nil
47 | end
48 | end
49 |
50 | local function SetImageSize(self, width, height)
51 | self.image:SetWidth(width)
52 | self.image:SetHeight(height)
53 | --self.frame:SetWidth(width + 30)
54 | if self.label:IsShown() then
55 | self.frame:SetHeight(height + 25)
56 | else
57 | self.frame:SetHeight(height + 10)
58 | end
59 | end
60 |
61 | local function SetDisabled(self, disabled)
62 | self.disabled = disabled
63 | if disabled then
64 | self.frame:Disable()
65 | self.label:SetTextColor(0.5,0.5,0.5)
66 | self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
67 | else
68 | self.frame:Enable()
69 | self.label:SetTextColor(1,1,1)
70 | self.image:SetVertexColor(1, 1, 1)
71 | end
72 | end
73 |
74 | local function OnClick(this, button)
75 | this.obj:Fire("OnClick", button)
76 | AceGUI:ClearFocus()
77 | end
78 |
79 | local function OnEnter(this)
80 | this.obj.highlight:Show()
81 | this.obj:Fire("OnEnter")
82 | end
83 |
84 | local function OnLeave(this)
85 | this.obj.highlight:Hide()
86 | this.obj:Fire("OnLeave")
87 | end
88 |
89 | local function Constructor()
90 | local frame = CreateFrame("Button",nil,UIParent)
91 | local self = {}
92 | self.type = Type
93 |
94 | self.OnRelease = OnRelease
95 | self.OnAcquire = OnAcquire
96 | self.SetLabel = SetLabel
97 | self.frame = frame
98 | self.SetImage = SetImage
99 | self.SetImageSize = SetImageSize
100 |
101 | -- SetText should be deprecated along the way
102 | self.SetText = SetLabel
103 | self.SetDisabled = SetDisabled
104 |
105 | frame.obj = self
106 |
107 | frame:SetHeight(110)
108 | frame:SetWidth(110)
109 | frame:EnableMouse(true)
110 | frame:SetScript("OnClick", OnClick)
111 | frame:SetScript("OnLeave", OnLeave)
112 | frame:SetScript("OnEnter", OnEnter)
113 | local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight")
114 | label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
115 | label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
116 | label:SetJustifyH("CENTER")
117 | label:SetJustifyV("TOP")
118 | label:SetHeight(18)
119 | self.label = label
120 |
121 | local image = frame:CreateTexture(nil,"BACKGROUND")
122 | self.image = image
123 | image:SetWidth(64)
124 | image:SetHeight(64)
125 | image:SetPoint("TOP",frame,"TOP",0,-5)
126 |
127 | local highlight = frame:CreateTexture(nil,"OVERLAY")
128 | self.highlight = highlight
129 | highlight:SetAllPoints(image)
130 | highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
131 | highlight:SetTexCoord(0,1,0.23,0.77)
132 | highlight:SetBlendMode("ADD")
133 | highlight:Hide()
134 |
135 | AceGUI:RegisterAsWidget(self)
136 | return self
137 | end
138 |
139 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
140 | end
141 |
142 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Label --
5 | --------------------------
6 | do
7 | local Type = "Label"
8 | local Version = 11
9 |
10 | local function OnAcquire(self)
11 | self:SetHeight(18)
12 | self:SetWidth(200)
13 | self:SetText("")
14 | self:SetImage(nil)
15 | self:SetColor()
16 | self:SetFontObject()
17 | end
18 |
19 | local function OnRelease(self)
20 | self.frame:ClearAllPoints()
21 | self.frame:Hide()
22 | end
23 |
24 | local function UpdateImageAnchor(self)
25 | local width = self.frame.width or self.frame:GetWidth() or 0
26 | local image = self.image
27 | local label = self.label
28 | local frame = self.frame
29 | local height
30 |
31 | label:ClearAllPoints()
32 | image:ClearAllPoints()
33 |
34 | if self.imageshown then
35 | local imagewidth = image:GetWidth()
36 | if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
37 | --image goes on top centered when less than 200 width for the text, or if there is no text
38 | image:SetPoint("TOP",frame,"TOP",0,0)
39 | label:SetPoint("TOP",image,"BOTTOM",0,0)
40 | label:SetPoint("LEFT",frame,"LEFT",0,0)
41 | label:SetWidth(width)
42 | height = image:GetHeight() + label:GetHeight()
43 | else
44 | --image on the left
45 | image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
46 | label:SetPoint("TOPLEFT",image,"TOPRIGHT",4,0)
47 | label:SetWidth(width - imagewidth)
48 | height = math.max(image:GetHeight(), label:GetHeight())
49 | end
50 | else
51 | --no image shown
52 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
53 | label:SetWidth(width)
54 | height = self.label:GetHeight()
55 | end
56 |
57 | self.resizing = true
58 | self.frame:SetHeight(height)
59 | self.frame.height = height
60 | self.resizing = nil
61 | end
62 |
63 | local function SetText(self, text)
64 | self.label:SetText(text or "")
65 | UpdateImageAnchor(self)
66 | end
67 |
68 | local function SetColor(self, r, g, b)
69 | if not (r and g and b) then
70 | r, g, b = 1, 1, 1
71 | end
72 | self.label:SetVertexColor(r, g, b)
73 | end
74 |
75 | local function OnWidthSet(self, width)
76 | if self.resizing then return end
77 | UpdateImageAnchor(self)
78 | end
79 |
80 | local function SetImage(self, path, ...)
81 | local image = self.image
82 | image:SetTexture(path)
83 |
84 | if image:GetTexture() then
85 | self.imageshown = true
86 | local n = select('#', ...)
87 | if n == 4 or n == 8 then
88 | image:SetTexCoord(...)
89 | end
90 | else
91 | self.imageshown = nil
92 | end
93 | UpdateImageAnchor(self)
94 | end
95 |
96 | local function SetFont(self, font, height, flags)
97 | self.label:SetFont(font, height, flags)
98 | end
99 |
100 | local function SetFontObject(self, font)
101 | self.label:SetFontObject(font or GameFontHighlightSmall)
102 | end
103 |
104 | local function SetImageSize(self, width, height)
105 | self.image:SetWidth(width)
106 | self.image:SetHeight(height)
107 | UpdateImageAnchor(self)
108 | end
109 |
110 | local function Constructor()
111 | local frame = CreateFrame("Frame",nil,UIParent)
112 | local self = {}
113 | self.type = Type
114 |
115 | self.OnRelease = OnRelease
116 | self.OnAcquire = OnAcquire
117 | self.SetText = SetText
118 | self.SetColor = SetColor
119 | self.frame = frame
120 | self.OnWidthSet = OnWidthSet
121 | self.SetImage = SetImage
122 | self.SetImageSize = SetImageSize
123 | self.SetFont = SetFont
124 | self.SetFontObject = SetFontObject
125 | frame.obj = self
126 |
127 | frame:SetHeight(18)
128 | frame:SetWidth(200)
129 | local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall")
130 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
131 | label:SetWidth(200)
132 | label:SetJustifyH("LEFT")
133 | label:SetJustifyV("TOP")
134 | self.label = label
135 |
136 | local image = frame:CreateTexture(nil,"BACKGROUND")
137 | self.image = image
138 |
139 | AceGUI:RegisterAsWidget(self)
140 | return self
141 | end
142 |
143 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
144 | end
145 |
146 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-InlineGroup.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 |
4 | -------------
5 | -- Widgets --
6 | -------------
7 | --[[
8 | Widgets must provide the following functions
9 | Acquire() - Called when the object is aquired, should set everything to a default hidden state
10 | Release() - Called when the object is Released, should remove any anchors and hide the Widget
11 |
12 | And the following members
13 | frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
14 | type - the type of the object, same as the name given to :RegisterWidget()
15 |
16 | Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
17 | It will be cleared automatically when a widget is released
18 | Placing values directly into a widget object should be avoided
19 |
20 | If the Widget can act as a container for other Widgets the following
21 | content - frame or derivitive that children will be anchored to
22 |
23 | The Widget can supply the following Optional Members
24 |
25 |
26 | ]]
27 |
28 | --------------------------
29 | -- Inline Group --
30 | --------------------------
31 | --[[
32 | This is a simple grouping container, no selection
33 | It will resize automatically to the height of the controls added to it
34 | ]]
35 |
36 | do
37 | local Type = "InlineGroup"
38 | local Version = 5
39 |
40 | local function OnAcquire(self)
41 | self:SetWidth(300)
42 | self:SetHeight(100)
43 | end
44 |
45 | local function OnRelease(self)
46 | self.frame:ClearAllPoints()
47 | self.frame:Hide()
48 | end
49 |
50 | local PaneBackdrop = {
51 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
52 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
53 | tile = true, tileSize = 16, edgeSize = 16,
54 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
55 | }
56 |
57 | local function SetTitle(self,title)
58 | self.titletext:SetText(title)
59 | end
60 |
61 |
62 | local function LayoutFinished(self, width, height)
63 | if self.noAutoHeight then return end
64 | self:SetHeight((height or 0) + 40)
65 | end
66 |
67 | local function OnWidthSet(self, width)
68 | local content = self.content
69 | local contentwidth = width - 20
70 | if contentwidth < 0 then
71 | contentwidth = 0
72 | end
73 | content:SetWidth(contentwidth)
74 | content.width = contentwidth
75 | end
76 |
77 |
78 | local function OnHeightSet(self, height)
79 | local content = self.content
80 | local contentheight = height - 20
81 | if contentheight < 0 then
82 | contentheight = 0
83 | end
84 | content:SetHeight(contentheight)
85 | content.height = contentheight
86 | end
87 |
88 | local function Constructor()
89 | local frame = CreateFrame("Frame",nil,UIParent)
90 | local self = {}
91 | self.type = Type
92 |
93 | self.OnRelease = OnRelease
94 | self.OnAcquire = OnAcquire
95 | self.SetTitle = SetTitle
96 | self.frame = frame
97 | self.LayoutFinished = LayoutFinished
98 | self.OnWidthSet = OnWidthSet
99 | self.OnHeightSet = OnHeightSet
100 |
101 | frame.obj = self
102 |
103 | frame:SetHeight(100)
104 | frame:SetWidth(100)
105 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
106 |
107 | local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
108 | titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
109 | titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
110 | titletext:SetJustifyH("LEFT")
111 | titletext:SetHeight(18)
112 |
113 | self.titletext = titletext
114 |
115 | local border = CreateFrame("Frame",nil,frame)
116 | self.border = border
117 | border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-17)
118 | border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
119 |
120 | border:SetBackdrop(PaneBackdrop)
121 | border:SetBackdropColor(0.1,0.1,0.1,0.5)
122 | border:SetBackdropBorderColor(0.4,0.4,0.4)
123 |
124 | --Container Support
125 | local content = CreateFrame("Frame",nil,border)
126 | self.content = content
127 | content.obj = self
128 | content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
129 | content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
130 |
131 | AceGUI:RegisterAsContainer(self)
132 | return self
133 | end
134 |
135 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
136 | end
137 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 |
4 | -------------
5 | -- Widgets --
6 | -------------
7 | --[[
8 | Widgets must provide the following functions
9 | Acquire() - Called when the object is aquired, should set everything to a default hidden state
10 | Release() - Called when the object is Released, should remove any anchors and hide the Widget
11 |
12 | And the following members
13 | frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
14 | type - the type of the object, same as the name given to :RegisterWidget()
15 |
16 | Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
17 | It will be cleared automatically when a widget is released
18 | Placing values directly into a widget object should be avoided
19 |
20 | If the Widget can act as a container for other Widgets the following
21 | content - frame or derivitive that children will be anchored to
22 |
23 | The Widget can supply the following Optional Members
24 |
25 |
26 | ]]
27 |
28 | ----------------------------------
29 | -- Blizzard Options Group --
30 | ----------------------------------
31 | --[[
32 | Group Designed to be added to the bliz interface options panel
33 | ]]
34 |
35 | do
36 | local Type = "BlizOptionsGroup"
37 | local Version = 7
38 |
39 | local function OnAcquire(self)
40 |
41 | end
42 |
43 | local function OnRelease(self)
44 | self.frame:ClearAllPoints()
45 | self.frame:Hide()
46 | self:SetName()
47 | end
48 |
49 | local function okay(this)
50 | this.obj:Fire("okay")
51 | end
52 |
53 | local function cancel(this)
54 | this.obj:Fire("cancel")
55 | end
56 |
57 | local function defaults(this)
58 | this.obj:Fire("defaults")
59 | end
60 |
61 | local function SetName(self, name, parent)
62 | self.frame.name = name
63 | self.frame.parent = parent
64 | end
65 |
66 | local function OnShow(this)
67 | this.obj:Fire("OnShow")
68 | end
69 |
70 | local function OnHide(this)
71 | this.obj:Fire("OnHide")
72 | end
73 |
74 | local function OnWidthSet(self, width)
75 | local content = self.content
76 | local contentwidth = width - 63
77 | if contentwidth < 0 then
78 | contentwidth = 0
79 | end
80 | content:SetWidth(contentwidth)
81 | content.width = contentwidth
82 | end
83 |
84 |
85 | local function OnHeightSet(self, height)
86 | local content = self.content
87 | local contentheight = height - 26
88 | if contentheight < 0 then
89 | contentheight = 0
90 | end
91 | content:SetHeight(contentheight)
92 | content.height = contentheight
93 | end
94 |
95 | local function SetTitle(self, title)
96 | local content = self.content
97 | content:ClearAllPoints()
98 | if not title or title == "" then
99 | content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-10)
100 | self.label:SetText("")
101 | else
102 | content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-40)
103 | self.label:SetText(title)
104 | end
105 | content:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-10,10)
106 | end
107 |
108 | local function Constructor()
109 | local frame = CreateFrame("Frame")
110 | local self = {}
111 | self.type = Type
112 |
113 | self.OnRelease = OnRelease
114 | self.OnAcquire = OnAcquire
115 | self.frame = frame
116 | self.SetName = SetName
117 |
118 | self.OnWidthSet = OnWidthSet
119 | self.OnHeightSet = OnHeightSet
120 | self.SetTitle = SetTitle
121 |
122 | frame.obj = self
123 | frame.okay = okay
124 | frame.cancel = cancel
125 | frame.defaults = defaults
126 |
127 | frame:Hide()
128 | frame:SetScript("OnHide",OnHide)
129 | frame:SetScript("OnShow",OnShow)
130 |
131 | local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
132 | self.label = label
133 | label:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -15)
134 | label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
135 | label:SetJustifyH("LEFT")
136 | label:SetJustifyV("TOP")
137 |
138 | --Container Support
139 | local content = CreateFrame("Frame",nil,frame)
140 | self.content = content
141 | content.obj = self
142 | content:SetPoint("TOPLEFT",frame,"TOPLEFT",15,-10)
143 | content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-10,10)
144 |
145 | AceGUI:RegisterAsContainer(self)
146 | return self
147 | end
148 |
149 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
150 | end
151 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDownGroup.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --[[
4 | Selection Group controls all have an interface to select a group for thier contents
5 | None of them will auto size to thier contents, and should usually be used with a scrollframe
6 | unless you know that the controls will fit inside
7 | ]]
8 |
9 | --------------------------
10 | -- Dropdown Group --
11 | --------------------------
12 | --[[
13 | Events :
14 | OnGroupSelected
15 |
16 | ]]
17 | do
18 | local Type = "DropdownGroup"
19 | local Version = 12
20 |
21 | local function OnAcquire(self)
22 | self.dropdown:SetText("")
23 | self:SetDropdownWidth(200)
24 | end
25 |
26 | local function OnRelease(self)
27 | self.frame:ClearAllPoints()
28 | self.frame:Hide()
29 | self.dropdown.list = nil
30 | self.status = nil
31 | for k in pairs(self.localstatus) do
32 | self.localstatus[k] = nil
33 | end
34 | end
35 |
36 | local PaneBackdrop = {
37 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
38 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
39 | tile = true, tileSize = 16, edgeSize = 16,
40 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
41 | }
42 |
43 | local function SetTitle(self,title)
44 | self.titletext:SetText(title)
45 | end
46 |
47 |
48 | local function SelectedGroup(self,event,value)
49 | local group = self.parentgroup
50 | local status = group.status or group.localstatus
51 | status.selected = value
52 | self.parentgroup:Fire("OnGroupSelected", value)
53 | end
54 |
55 | local function SetGroupList(self,list)
56 | self.dropdown:SetList(list)
57 | end
58 |
59 | -- called to set an external table to store status in
60 | local function SetStatusTable(self, status)
61 | assert(type(status) == "table")
62 | self.status = status
63 | end
64 |
65 | local function SetGroup(self,group)
66 | self.dropdown:SetValue(group)
67 | local status = self.status or self.localstatus
68 | status.selected = group
69 | self:Fire("OnGroupSelected", group)
70 | end
71 |
72 | local function OnWidthSet(self, width)
73 | local content = self.content
74 | local contentwidth = width - 26
75 | if contentwidth < 0 then
76 | contentwidth = 0
77 | end
78 | content:SetWidth(contentwidth)
79 | content.width = contentwidth
80 | end
81 |
82 |
83 | local function OnHeightSet(self, height)
84 | local content = self.content
85 | local contentheight = height - 63
86 | if contentheight < 0 then
87 | contentheight = 0
88 | end
89 | content:SetHeight(contentheight)
90 | content.height = contentheight
91 | end
92 |
93 | local function LayoutFinished(self, width, height)
94 | self:SetHeight((height or 0) + 63)
95 | end
96 |
97 | local function SetDropdownWidth(self, width)
98 | self.dropdown:SetWidth(width)
99 | end
100 |
101 | local function Constructor()
102 | local frame = CreateFrame("Frame")
103 | local self = {}
104 | self.type = Type
105 |
106 | self.OnRelease = OnRelease
107 | self.OnAcquire = OnAcquire
108 |
109 | self.SetTitle = SetTitle
110 | self.SetGroupList = SetGroupList
111 | self.SetGroup = SetGroup
112 | self.SetStatusTable = SetStatusTable
113 | self.SetDropdownWidth = SetDropdownWidth
114 | self.OnWidthSet = OnWidthSet
115 | self.OnHeightSet = OnHeightSet
116 | self.LayoutFinished = LayoutFinished
117 |
118 | self.localstatus = {}
119 |
120 | self.frame = frame
121 | frame.obj = self
122 |
123 |
124 | frame:SetHeight(100)
125 | frame:SetWidth(100)
126 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
127 |
128 | local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
129 | titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",4,0)
130 | titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-4,0)
131 | titletext:SetJustifyH("LEFT")
132 | titletext:SetHeight(18)
133 |
134 |
135 | self.titletext = titletext
136 |
137 | local dropdown = AceGUI:Create("Dropdown")
138 | self.dropdown = dropdown
139 | dropdown.frame:SetParent(frame)
140 | dropdown.parentgroup = self
141 | dropdown:SetCallback("OnValueChanged",SelectedGroup)
142 |
143 | dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-6,3)
144 | dropdown.frame:Show()
145 | dropdown:SetLabel("")
146 |
147 | local border = CreateFrame("Frame",nil,frame)
148 | self.border = border
149 | border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-40)
150 | border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,3)
151 |
152 | border:SetBackdrop(PaneBackdrop)
153 | border:SetBackdropColor(0.1,0.1,0.1,0.5)
154 | border:SetBackdropBorderColor(0.4,0.4,0.4)
155 |
156 | --Container Support
157 | local content = CreateFrame("Frame",nil,border)
158 | self.content = content
159 | content.obj = self
160 | content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
161 | content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
162 |
163 | AceGUI:RegisterAsContainer(self)
164 | return self
165 | end
166 |
167 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
168 | end
169 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceEvent-3.0/AceEvent-3.0.lua:
--------------------------------------------------------------------------------
1 | --- AceEvent-3.0 provides event registration and secure dispatching.
2 | -- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around
3 | -- CallbackHandler, and dispatches all game events or addon message to the registrees.
4 | --
5 | -- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by
6 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
7 | -- and can be accessed directly, without having to explicitly call AceEvent itself.\\
8 | -- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you
9 | -- make into AceEvent.
10 | -- @class file
11 | -- @name AceEvent-3.0
12 | -- @release $Id: AceEvent-3.0.lua 766 2009-04-04 08:26:05Z nevcairiel $
13 | local MAJOR, MINOR = "AceEvent-3.0", 3
14 | local AceEvent = LibStub:NewLibrary(MAJOR, MINOR)
15 |
16 | if not AceEvent then return end
17 |
18 | local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
19 |
20 |
21 | AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame
22 | AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib
23 |
24 |
25 | -- APIs and registry for blizzard events, using CallbackHandler lib
26 | if not AceEvent.events then
27 | AceEvent.events = CallbackHandler:New(AceEvent,
28 | "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents")
29 | end
30 |
31 | function AceEvent.events:OnUsed(target, eventname)
32 | AceEvent.frame:RegisterEvent(eventname)
33 | end
34 |
35 | function AceEvent.events:OnUnused(target, eventname)
36 | AceEvent.frame:UnregisterEvent(eventname)
37 | end
38 |
39 |
40 | -- APIs and registry for IPC messages, using CallbackHandler lib
41 | if not AceEvent.messages then
42 | AceEvent.messages = CallbackHandler:New(AceEvent,
43 | "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages"
44 | )
45 | AceEvent.SendMessage = AceEvent.messages.Fire
46 | end
47 |
48 | --- embedding and embed handling
49 | local mixins = {
50 | "RegisterEvent", "UnregisterEvent",
51 | "RegisterMessage", "UnregisterMessage",
52 | "SendMessage",
53 | "UnregisterAllEvents", "UnregisterAllMessages",
54 | }
55 |
56 | --- Register for a Blizzard Event.
57 | -- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument.
58 | -- Any arguments to the event will be passed on after that.
59 | -- @name AceEvent:RegisterEvent
60 | -- @class function
61 | -- @paramsig event[, callback [, arg]]
62 | -- @param event The event to register for
63 | -- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name)
64 | -- @param arg An optional argument to pass to the callback function
65 |
66 | --- Unregister an event.
67 | -- @name AceEvent:UnregisterEvent
68 | -- @class function
69 | -- @paramsig event
70 | -- @param event The event to unregister
71 |
72 | --- Register for a custom AceEvent-internal message.
73 | -- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument.
74 | -- Any arguments to the event will be passed on after that.
75 | -- @name AceEvent:RegisterMessage
76 | -- @class function
77 | -- @paramsig message[, callback [, arg]]
78 | -- @param message The message to register for
79 | -- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name)
80 | -- @param arg An optional argument to pass to the callback function
81 |
82 | --- Unregister a message
83 | -- @name AceEvent:UnregisterMessage
84 | -- @class function
85 | -- @paramsig message
86 | -- @param message The message to unregister
87 |
88 | --- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message.
89 | -- @name AceEvent:SendMessage
90 | -- @class function
91 | -- @paramsig message, ...
92 | -- @param message The message to send
93 | -- @param ... Any arguments to the message
94 |
95 |
96 | -- Embeds AceEvent into the target object making the functions from the mixins list available on target:..
97 | -- @param target target object to embed AceEvent in
98 | function AceEvent:Embed(target)
99 | for k, v in pairs(mixins) do
100 | target[v] = self[v]
101 | end
102 | self.embeds[target] = true
103 | return target
104 | end
105 |
106 | -- AceEvent:OnEmbedDisable( target )
107 | -- target (object) - target object that is being disabled
108 | --
109 | -- Unregister all events messages etc when the target disables.
110 | -- this method should be called by the target manually or by an addon framework
111 | function AceEvent:OnEmbedDisable(target)
112 | target:UnregisterAllEvents()
113 | target:UnregisterAllMessages()
114 | end
115 |
116 | -- Script to fire blizzard events into the event listeners
117 | local events = AceEvent.events
118 | AceEvent.frame:SetScript("OnEvent", function(this, event, ...)
119 | events:Fire(event, ...)
120 | end)
121 |
122 | --- Finally: upgrade our old embeds
123 | for target, v in pairs(AceEvent.embeds) do
124 | AceEvent:Embed(target)
125 | end
126 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- ColorPicker --
5 | --------------------------
6 | do
7 | local Type = "ColorPicker"
8 | local Version = 11
9 |
10 | local function OnAcquire(self)
11 | self.HasAlpha = false
12 | self:SetColor(0,0,0,1)
13 | self:SetHeight(24)
14 | self:SetWidth(200)
15 | end
16 |
17 | local function SetLabel(self, text)
18 | self.text:SetText(text)
19 | end
20 |
21 | local function SetColor(self,r,g,b,a)
22 | self.r = r
23 | self.g = g
24 | self.b = b
25 | self.a = a or 1
26 | self.colorSwatch:SetVertexColor(r,g,b,a)
27 | end
28 |
29 | local function Control_OnEnter(this)
30 | this.obj:Fire("OnEnter")
31 | end
32 |
33 | local function Control_OnLeave(this)
34 | this.obj:Fire("OnLeave")
35 | end
36 |
37 | local function SetHasAlpha(self, HasAlpha)
38 | self.HasAlpha = HasAlpha
39 | end
40 |
41 | local function ColorCallback(self,r,g,b,a,isAlpha)
42 | if not self.HasAlpha then
43 | a = 1
44 | end
45 | self:SetColor(r,g,b,a)
46 | if ColorPickerFrame:IsVisible() then
47 | --colorpicker is still open
48 |
49 | self:Fire("OnValueChanged",r,g,b,a)
50 | else
51 | --colorpicker is closed, color callback is first, ignore it,
52 | --alpha callback is the final call after it closes so confirm now
53 | if isAlpha then
54 | self:Fire("OnValueConfirmed",r,g,b,a)
55 | end
56 | end
57 | end
58 |
59 | local function ColorSwatch_OnClick(this)
60 | HideUIPanel(ColorPickerFrame)
61 | local self = this.obj
62 | if not self.disabled then
63 | ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
64 |
65 | ColorPickerFrame.func = function()
66 | local r,g,b = ColorPickerFrame:GetColorRGB()
67 | local a = 1 - OpacitySliderFrame:GetValue()
68 | ColorCallback(self,r,g,b,a)
69 | end
70 |
71 | ColorPickerFrame.hasOpacity = self.HasAlpha
72 | ColorPickerFrame.opacityFunc = function()
73 | local r,g,b = ColorPickerFrame:GetColorRGB()
74 | local a = 1 - OpacitySliderFrame:GetValue()
75 | ColorCallback(self,r,g,b,a,true)
76 | end
77 | local r, g, b, a = self.r, self.g, self.b, self.a
78 | if self.HasAlpha then
79 | ColorPickerFrame.opacity = 1 - (a or 0)
80 | end
81 | ColorPickerFrame:SetColorRGB(r, g, b)
82 |
83 | ColorPickerFrame.cancelFunc = function()
84 | ColorCallback(self,r,g,b,a,true)
85 | end
86 | ShowUIPanel(ColorPickerFrame)
87 | end
88 | AceGUI:ClearFocus()
89 | end
90 |
91 | local function OnRelease(self)
92 | self.frame:ClearAllPoints()
93 | self.frame:Hide()
94 | end
95 |
96 | local function SetDisabled(self, disabled)
97 | self.disabled = disabled
98 | if self.disabled then
99 | self.frame:Disable()
100 | self.text:SetTextColor(0.5,0.5,0.5)
101 | else
102 | self.frame:Enable()
103 | self.text:SetTextColor(1,1,1)
104 | end
105 | end
106 |
107 | local function Constructor()
108 | local frame = CreateFrame("Button",nil,UIParent)
109 | local self = {}
110 | self.type = Type
111 |
112 | self.OnRelease = OnRelease
113 | self.OnAcquire = OnAcquire
114 |
115 | self.SetLabel = SetLabel
116 | self.SetColor = SetColor
117 | self.SetDisabled = SetDisabled
118 | self.SetHasAlpha = SetHasAlpha
119 |
120 | self.frame = frame
121 | frame.obj = self
122 |
123 | local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
124 | self.text = text
125 | text:SetJustifyH("LEFT")
126 | text:SetTextColor(1,1,1)
127 | frame:SetHeight(24)
128 | frame:SetWidth(200)
129 | text:SetHeight(24)
130 | frame:SetScript("OnClick", ColorSwatch_OnClick)
131 | frame:SetScript("OnEnter",Control_OnEnter)
132 | frame:SetScript("OnLeave",Control_OnLeave)
133 |
134 | local colorSwatch = frame:CreateTexture(nil, "OVERLAY")
135 | self.colorSwatch = colorSwatch
136 | colorSwatch:SetWidth(19)
137 | colorSwatch:SetHeight(19)
138 | colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
139 | local texture = frame:CreateTexture(nil, "BACKGROUND")
140 | colorSwatch.texture = texture
141 | texture:SetWidth(16)
142 | texture:SetHeight(16)
143 | texture:SetTexture(1,1,1)
144 | texture:Show()
145 |
146 | local checkers = frame:CreateTexture(nil, "BACKGROUND")
147 | colorSwatch.checkers = checkers
148 | checkers:SetTexture("Tileset\\Generic\\Checkers")
149 | checkers:SetDesaturated(true)
150 | checkers:SetVertexColor(1,1,1,0.75)
151 | checkers:SetTexCoord(.25,0,0.5,.25)
152 | checkers:SetWidth(14)
153 | checkers:SetHeight(14)
154 | checkers:Show()
155 |
156 | local highlight = frame:CreateTexture(nil, "BACKGROUND")
157 | self.highlight = highlight
158 | highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
159 | highlight:SetBlendMode("ADD")
160 | highlight:SetAllPoints(frame)
161 | highlight:Hide()
162 |
163 | texture:SetPoint("CENTER", colorSwatch, "CENTER")
164 | checkers:SetPoint("CENTER", colorSwatch, "CENTER")
165 | colorSwatch:SetPoint("LEFT", frame, "LEFT", 0, 0)
166 | text:SetPoint("LEFT",colorSwatch,"RIGHT",2,0)
167 | text:SetPoint("RIGHT",frame,"RIGHT")
168 |
169 | AceGUI:RegisterAsWidget(self)
170 | return self
171 | end
172 |
173 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
174 | end
175 |
--------------------------------------------------------------------------------
/LossOfControl/LossOfControl.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | self:GetParent():GetParent().Cooldown:Show()
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | Mixin(self, TimeLeftMixin)
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | Mixin(self, LossOfContolrMixin)
138 | LossOfControlAnimGroupMixin:Mixin(self.RedLineTop.Anim, self.RedLineBottom.Anim, self.Icon.Anim)
139 | self:OnLoad()
140 | LossOfControlFrame_OnLoad(self)
141 |
142 |
143 |
144 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Label --
5 | --------------------------
6 | do
7 | local Type = "InteractiveLabel"
8 | local Version = 6
9 |
10 | local function OnAcquire(self)
11 | self:SetHeight(18)
12 | self:SetWidth(200)
13 | self:SetText("")
14 | self:SetImage(nil)
15 | self:SetColor()
16 | self:SetFontObject()
17 | self:SetHighlight()
18 | self:SetHighlightTexCoord()
19 | end
20 |
21 | local function OnRelease(self)
22 | self:SetDisabled(false)
23 | self.frame:ClearAllPoints()
24 | self.frame:Hide()
25 | end
26 |
27 | local function UpdateImageAnchor(self)
28 | local width = self.frame.width or self.frame:GetWidth() or 0
29 | local image = self.image
30 | local label = self.label
31 | local frame = self.frame
32 | local height
33 |
34 | label:ClearAllPoints()
35 | image:ClearAllPoints()
36 |
37 | if self.imageshown then
38 | local imagewidth = image:GetWidth()
39 | if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
40 | --image goes on top centered when less than 200 width for the text, or if there is no text
41 | image:SetPoint("TOP",frame,"TOP",0,0)
42 | label:SetPoint("TOP",image,"BOTTOM",0,0)
43 | label:SetPoint("LEFT",frame,"LEFT",0,0)
44 | label:SetWidth(width)
45 | height = image:GetHeight() + label:GetHeight()
46 | else
47 | --image on the left
48 | local imageheight = image:GetHeight()
49 | local labelheight = label:GetHeight()
50 | --center image with label
51 | if imageheight > labelheight then
52 | image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
53 | label:SetPoint("LEFT",image,"RIGHT",0,0)
54 | else
55 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",imagewidth,0)
56 | image:SetPoint("RIGHT",label,"LEFT",0,0)
57 | end
58 | label:SetWidth(width - imagewidth)
59 | height = math.max(imageheight, labelheight)
60 | end
61 | else
62 | --no image shown
63 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
64 | label:SetWidth(width)
65 | height = self.label:GetHeight()
66 | end
67 |
68 | self.resizing = true
69 | self.frame:SetHeight(height)
70 | self.frame.height = height
71 | self.resizing = nil
72 | end
73 |
74 | local function SetText(self, text)
75 | self.label:SetText(text or "")
76 | UpdateImageAnchor(self)
77 | end
78 |
79 | local function SetColor(self, r, g, b)
80 | if not (r and g and b) then
81 | r, g, b = 1, 1, 1
82 | end
83 | self.label:SetVertexColor(r, g, b)
84 | end
85 |
86 | local function OnWidthSet(self, width)
87 | if self.resizing then return end
88 | UpdateImageAnchor(self)
89 | end
90 |
91 | local function SetImage(self, path, ...)
92 | local image = self.image
93 | image:SetTexture(path)
94 |
95 | if image:GetTexture() then
96 | self.imageshown = true
97 | local n = select('#', ...)
98 | if n == 4 or n == 8 then
99 | image:SetTexCoord(...)
100 | end
101 | else
102 | self.imageshown = nil
103 | end
104 | UpdateImageAnchor(self)
105 | end
106 |
107 | local function SetFont(self, font, height, flags)
108 | self.label:SetFont(font, height, flags)
109 | end
110 |
111 | local function SetFontObject(self, font)
112 | self.label:SetFontObject(font or GameFontHighlightSmall)
113 | end
114 |
115 | local function SetImageSize(self, width, height)
116 | self.image:SetWidth(width)
117 | self.image:SetHeight(height)
118 | UpdateImageAnchor(self)
119 | end
120 |
121 | local function SetHighlight(self, ...)
122 | self.highlight:SetTexture(...)
123 | end
124 |
125 | local function SetHighlightTexCoord(self, ...)
126 | if select('#', ...) >= 1 then
127 | self.highlight:SetTexCoord(...)
128 | else
129 | self.highlight:SetTexCoord(0, 1, 0, 1)
130 | end
131 | end
132 |
133 | local function SetDisabled(self,disabled)
134 | self.disabled = disabled
135 | if disabled then
136 | self.frame:EnableMouse(false)
137 | self.label:SetTextColor(0.5, 0.5, 0.5)
138 | else
139 | self.frame:EnableMouse(true)
140 | self.label:SetTextColor(1, 1, 1)
141 | end
142 | end
143 |
144 | local function OnEnter(this)
145 | this.obj.highlight:Show()
146 | this.obj:Fire("OnEnter")
147 | end
148 |
149 | local function OnLeave(this)
150 | this.obj.highlight:Hide()
151 | this.obj:Fire("OnLeave")
152 | end
153 |
154 | local function OnClick(this, ...)
155 | this.obj:Fire("OnClick", ...)
156 | AceGUI:ClearFocus()
157 | end
158 |
159 | local function Constructor()
160 | local frame = CreateFrame("Frame",nil,UIParent)
161 | local self = {}
162 | self.type = Type
163 |
164 | frame:EnableMouse(true)
165 | frame:SetScript("OnEnter", OnEnter)
166 | frame:SetScript("OnLeave", OnLeave)
167 | frame:SetScript("OnMouseDown", OnClick)
168 |
169 | self.OnRelease = OnRelease
170 | self.OnAcquire = OnAcquire
171 | self.SetText = SetText
172 | self.SetColor = SetColor
173 | self.frame = frame
174 | self.OnWidthSet = OnWidthSet
175 | self.SetImage = SetImage
176 | self.SetImageSize = SetImageSize
177 | self.SetFont = SetFont
178 | self.SetFontObject = SetFontObject
179 | self.SetHighlight = SetHighlight
180 | self.SetHighlightTexCoord = SetHighlightTexCoord
181 | self.SetDisabled = SetDisabled
182 | frame.obj = self
183 |
184 | frame:SetHeight(18)
185 | frame:SetWidth(200)
186 | local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall")
187 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
188 | label:SetWidth(200)
189 | label:SetJustifyH("LEFT")
190 | label:SetJustifyV("TOP")
191 | self.label = label
192 |
193 | local highlight = frame:CreateTexture(nil, "OVERLAY")
194 | highlight:SetTexture(nil)
195 | highlight:SetAllPoints()
196 | highlight:SetBlendMode("ADD")
197 | highlight:Hide()
198 | self.highlight = highlight
199 |
200 | local image = frame:CreateTexture(nil,"BACKGROUND")
201 | self.image = image
202 |
203 | AceGUI:RegisterAsWidget(self)
204 | return self
205 | end
206 |
207 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
208 | end
209 |
210 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | local Type = "EditBox"
4 | local Version = 12
5 |
6 | local _G=_G
7 |
8 | if not AceGUIEditBoxInsertLink then
9 | -- upgradeable hook
10 | hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
11 | end
12 |
13 | function _G.AceGUIEditBoxInsertLink(text)
14 | for i = 1, AceGUI:GetNextWidgetNum(Type)-1 do
15 | local editbox = _G["AceGUI-3.0EditBox"..i]
16 | if editbox and editbox:IsVisible() and editbox:HasFocus() then
17 | editbox:Insert(text)
18 | return true
19 | end
20 | end
21 | end
22 |
23 |
24 | --------------------------
25 | -- Edit box --
26 | --------------------------
27 | --[[
28 | Events :
29 | OnTextChanged
30 | OnEnterPressed
31 |
32 | ]]
33 | do
34 | local function OnAcquire(self)
35 | self:SetHeight(26)
36 | self:SetWidth(200)
37 | self:SetDisabled(false)
38 | self:SetLabel()
39 | self.showbutton = true
40 | end
41 |
42 | local function OnRelease(self)
43 | self.frame:ClearAllPoints()
44 | self.frame:Hide()
45 | self:SetDisabled(false)
46 | end
47 |
48 | local function Control_OnEnter(this)
49 | this.obj:Fire("OnEnter")
50 | end
51 |
52 | local function Control_OnLeave(this)
53 | this.obj:Fire("OnLeave")
54 | end
55 |
56 | local function EditBox_OnEscapePressed(this)
57 | this:ClearFocus()
58 | end
59 |
60 | local function ShowButton(self)
61 | if self.showbutton then
62 | self.button:Show()
63 | self.editbox:SetTextInsets(0,20,3,3)
64 | end
65 | end
66 |
67 | local function HideButton(self)
68 | self.button:Hide()
69 | self.editbox:SetTextInsets(0,0,3,3)
70 | end
71 |
72 | local function EditBox_OnEnterPressed(this)
73 | local self = this.obj
74 | local value = this:GetText()
75 | local cancel = self:Fire("OnEnterPressed",value)
76 | if not cancel then
77 | HideButton(self)
78 | end
79 | end
80 |
81 | local function Button_OnClick(this)
82 | local editbox = this.obj.editbox
83 | editbox:ClearFocus()
84 | EditBox_OnEnterPressed(editbox)
85 | end
86 |
87 | local function EditBox_OnReceiveDrag(this)
88 | local self = this.obj
89 | local type, id, info = GetCursorInfo()
90 | if type == "item" then
91 | self:SetText(info)
92 | self:Fire("OnEnterPressed",info)
93 | ClearCursor()
94 | elseif type == "spell" then
95 | local name, rank = GetSpellName(id, info)
96 | if rank and rank:match("%d") then
97 | name = name.."("..rank..")"
98 | end
99 | self:SetText(name)
100 | self:Fire("OnEnterPressed",name)
101 | ClearCursor()
102 | end
103 | HideButton(self)
104 | AceGUI:ClearFocus()
105 | end
106 |
107 | local function EditBox_OnTextChanged(this)
108 | local self = this.obj
109 | local value = this:GetText()
110 | if tostring(value) ~= tostring(self.lasttext) then
111 | self:Fire("OnTextChanged",value)
112 | self.lasttext = value
113 | ShowButton(self)
114 | end
115 | end
116 |
117 | local function SetDisabled(self, disabled)
118 | self.disabled = disabled
119 | if disabled then
120 | self.editbox:EnableMouse(false)
121 | self.editbox:ClearFocus()
122 | self.editbox:SetTextColor(0.5,0.5,0.5)
123 | self.label:SetTextColor(0.5,0.5,0.5)
124 | else
125 | self.editbox:EnableMouse(true)
126 | self.editbox:SetTextColor(1,1,1)
127 | self.label:SetTextColor(1,.82,0)
128 | end
129 | end
130 |
131 | local function SetText(self, text)
132 | self.lasttext = text or ""
133 | self.editbox:SetText(text or "")
134 | self.editbox:SetCursorPosition(0)
135 | HideButton(self)
136 | end
137 |
138 | local function SetLabel(self, text)
139 | if text and text ~= "" then
140 | self.label:SetText(text)
141 | self.label:Show()
142 | self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
143 | self:SetHeight(44)
144 | self.alignoffset = 30
145 | else
146 | self.label:SetText("")
147 | self.label:Hide()
148 | self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
149 | self:SetHeight(26)
150 | self.alignoffset = 12
151 | end
152 | end
153 |
154 |
155 | local function Constructor()
156 | local num = AceGUI:GetNextWidgetNum(Type)
157 | local frame = CreateFrame("Frame",nil,UIParent)
158 | local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..num,frame,"InputBoxTemplate")
159 |
160 | local self = {}
161 | self.type = Type
162 | self.num = num
163 |
164 | self.OnRelease = OnRelease
165 | self.OnAcquire = OnAcquire
166 |
167 | self.SetDisabled = SetDisabled
168 | self.SetText = SetText
169 | self.SetLabel = SetLabel
170 |
171 | self.frame = frame
172 | frame.obj = self
173 | self.editbox = editbox
174 | editbox.obj = self
175 |
176 | self.alignoffset = 30
177 |
178 | frame:SetHeight(44)
179 | frame:SetWidth(200)
180 |
181 | editbox:SetScript("OnEnter",Control_OnEnter)
182 | editbox:SetScript("OnLeave",Control_OnLeave)
183 |
184 | editbox:SetAutoFocus(false)
185 | editbox:SetFontObject(ChatFontNormal)
186 | editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed)
187 | editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed)
188 | editbox:SetScript("OnTextChanged",EditBox_OnTextChanged)
189 | editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
190 | editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
191 |
192 | editbox:SetTextInsets(0,0,3,3)
193 | editbox:SetMaxLetters(256)
194 |
195 | editbox:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",6,0)
196 | editbox:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
197 | editbox:SetHeight(19)
198 |
199 | local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
200 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2)
201 | label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2)
202 | label:SetJustifyH("LEFT")
203 | label:SetHeight(18)
204 | self.label = label
205 |
206 | local button = CreateFrame("Button",nil,editbox,"UIPanelButtonTemplate")
207 | button:SetWidth(40)
208 | button:SetHeight(20)
209 | button:SetPoint("RIGHT",editbox,"RIGHT",-2,0)
210 | button:SetText(OKAY)
211 | button:SetScript("OnClick", Button_OnClick)
212 | button:Hide()
213 |
214 | self.button = button
215 | button.obj = self
216 |
217 | AceGUI:RegisterAsWidget(self)
218 | return self
219 | end
220 |
221 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
222 | end
223 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Keybinding --
5 | --------------------------
6 |
7 | do
8 | local Type = "Keybinding"
9 | local Version = 13
10 |
11 | local ControlBackdrop = {
12 | bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
13 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
14 | tile = true, tileSize = 16, edgeSize = 16,
15 | insets = { left = 3, right = 3, top = 3, bottom = 3 }
16 | }
17 |
18 | local function Control_OnEnter(this)
19 | this.obj:Fire("OnEnter")
20 | end
21 |
22 | local function Control_OnLeave(this)
23 | this.obj:Fire("OnLeave")
24 | end
25 |
26 | local function keybindingMsgFixWidth(this)
27 | this:SetWidth(this.msg:GetWidth()+10)
28 | this:SetScript("OnUpdate",nil)
29 | end
30 |
31 | local function Keybinding_OnClick(this, button)
32 | if button == "LeftButton" or button == "RightButton" then
33 | local self = this.obj
34 | if self.waitingForKey then
35 | this:EnableKeyboard(false)
36 | self.msgframe:Hide()
37 | this:UnlockHighlight()
38 | self.waitingForKey = nil
39 | else
40 | this:EnableKeyboard(true)
41 | self.msgframe:Show()
42 | this:LockHighlight()
43 | self.waitingForKey = true
44 | end
45 | end
46 | AceGUI:ClearFocus()
47 | end
48 |
49 | local ignoreKeys = nil
50 | local function Keybinding_OnKeyDown(this, key)
51 | local self = this.obj
52 | if self.waitingForKey then
53 | local keyPressed = key
54 | if keyPressed == "ESCAPE" then
55 | keyPressed = ""
56 | else
57 | if not ignoreKeys then
58 | ignoreKeys = {
59 | ["BUTTON1"] = true, ["BUTTON2"] = true,
60 | ["UNKNOWN"] = true,
61 | ["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
62 | ["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
63 | }
64 | end
65 | if ignoreKeys[keyPressed] then return end
66 | if IsShiftKeyDown() then
67 | keyPressed = "SHIFT-"..keyPressed
68 | end
69 | if IsControlKeyDown() then
70 | keyPressed = "CTRL-"..keyPressed
71 | end
72 | if IsAltKeyDown() then
73 | keyPressed = "ALT-"..keyPressed
74 | end
75 | end
76 |
77 | this:EnableKeyboard(false)
78 | self.msgframe:Hide()
79 | this:UnlockHighlight()
80 | self.waitingForKey = nil
81 |
82 | if not self.disabled then
83 | self:SetKey(keyPressed)
84 | self:Fire("OnKeyChanged",keyPressed)
85 | end
86 | end
87 | end
88 |
89 | local function Keybinding_OnMouseDown(this, button)
90 | if button == "LeftButton" or button == "RightButton" then
91 | return
92 | elseif button == "MiddleButton" then
93 | button = "BUTTON3"
94 | elseif button == "Button4" then
95 | button = "BUTTON4"
96 | elseif button == "Button5" then
97 | button = "BUTTON5"
98 | end
99 | Keybinding_OnKeyDown(this, button)
100 | end
101 |
102 | local function OnAcquire(self)
103 | self:SetWidth(200)
104 | self:SetHeight(44)
105 | self:SetLabel("")
106 | self:SetKey("")
107 | end
108 |
109 | local function OnRelease(self)
110 | self.frame:ClearAllPoints()
111 | self.frame:Hide()
112 | self.waitingForKey = nil
113 | self.msgframe:Hide()
114 | self:SetDisabled(false)
115 | end
116 |
117 | local function SetDisabled(self, disabled)
118 | self.disabled = disabled
119 | if disabled then
120 | self.button:Disable()
121 | self.label:SetTextColor(0.5,0.5,0.5)
122 | else
123 | self.button:Enable()
124 | self.label:SetTextColor(1,1,1)
125 | end
126 | end
127 |
128 | local function SetKey(self, key)
129 | if (key or "") == "" then
130 | self.button:SetText(NOT_BOUND)
131 | self.button:SetNormalFontObject("GameFontNormal")
132 | else
133 | self.button:SetText(key)
134 | self.button:SetNormalFontObject("GameFontHighlight")
135 | end
136 | end
137 |
138 | local function SetLabel(self, label)
139 | self.label:SetText(label or "")
140 | if (label or "") == "" then
141 | self.alignoffset = nil
142 | self:SetHeight(24)
143 | else
144 | self.alignoffset = 30
145 | self:SetHeight(44)
146 | end
147 | end
148 |
149 | local function Constructor()
150 | local num = AceGUI:GetNextWidgetNum(Type)
151 | local frame = CreateFrame("Frame",nil,UIParent)
152 |
153 | local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..num,frame,"UIPanelButtonTemplate2")
154 |
155 | local self = {}
156 | self.type = Type
157 | self.num = num
158 |
159 | local text = button:GetFontString()
160 | text:SetPoint("LEFT",button,"LEFT",7,0)
161 | text:SetPoint("RIGHT",button,"RIGHT",-7,0)
162 |
163 | button:SetScript("OnClick",Keybinding_OnClick)
164 | button:SetScript("OnKeyDown",Keybinding_OnKeyDown)
165 | button:SetScript("OnEnter",Control_OnEnter)
166 | button:SetScript("OnLeave",Control_OnLeave)
167 | button:SetScript("OnMouseDown",Keybinding_OnMouseDown)
168 | button:RegisterForClicks("AnyDown")
169 | button:EnableMouse()
170 |
171 | button:SetHeight(24)
172 | button:SetWidth(200)
173 | button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0)
174 | button:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
175 |
176 | frame:SetWidth(200)
177 | frame:SetHeight(44)
178 |
179 | self.alignoffset = 30
180 |
181 | self.button = button
182 |
183 | local label = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
184 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
185 | label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
186 | label:SetJustifyH("CENTER")
187 | label:SetHeight(18)
188 | self.label = label
189 |
190 | local msgframe = CreateFrame("Frame",nil,UIParent)
191 | msgframe:SetHeight(30)
192 | msgframe:SetBackdrop(ControlBackdrop)
193 | msgframe:SetBackdropColor(0,0,0)
194 | msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
195 | msgframe:SetFrameLevel(1000)
196 | self.msgframe = msgframe
197 | local msg = msgframe:CreateFontString(nil,"OVERLAY","GameFontNormal")
198 | msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel")
199 | msgframe.msg = msg
200 | msg:SetPoint("TOPLEFT",msgframe,"TOPLEFT",5,-5)
201 | msgframe:SetScript("OnUpdate", keybindingMsgFixWidth)
202 | msgframe:SetPoint("BOTTOM",button,"TOP",0,0)
203 | msgframe:Hide()
204 |
205 | self.OnRelease = OnRelease
206 | self.OnAcquire = OnAcquire
207 | self.SetLabel = SetLabel
208 | self.SetDisabled = SetDisabled
209 | self.SetKey = SetKey
210 |
211 | self.frame = frame
212 | frame.obj = self
213 | button.obj = self
214 |
215 | AceGUI:RegisterAsWidget(self)
216 | return self
217 | end
218 |
219 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
220 | end
221 |
--------------------------------------------------------------------------------
/LossOfControl/LossOfControlOptions.lua:
--------------------------------------------------------------------------------
1 | --######################################################################
2 | --###### Bakcport LossOfControl from retail #######
3 | ------------------------------------------------------------------------
4 | --######################################################################
5 |
6 | local LossOfControl = LibStub("AceAddon-3.0"):GetAddon("LossOfControl", "AceEvent-3.0");
7 |
8 | local AceDB = LibStub("AceDB-3.0");
9 | local AceConfig = LibStub("AceConfig-3.0");
10 | local AceConfigDialog = LibStub("AceConfigDialog-3.0");
11 | local lossOfControl = "Loss Of Control Alerts";
12 | local profileDB;
13 |
14 | local LOC_OPTION_VALUE = function()
15 | return {
16 | [0] = LOC_OPTION_OFF,
17 | [1] = LOC_OPTION_ALERT,
18 | [2] = LOC_OPTION_FULL,
19 | };
20 | end
21 |
22 | local function SetOptionValue(self, value)
23 | profileDB[self.option.name] = value;
24 | LossOfControl:SetDisplay();
25 | end
26 |
27 | local function GetOptionValue(self)
28 | return profileDB[self.option.name];
29 | end
30 |
31 | local function SetOptionEnable(self, value)
32 |
33 | for _, state in pairs(self.options.args) do
34 | if ( state.disabled ~= nil ) then
35 | state.disabled = not value;
36 | end
37 | end
38 |
39 | profileDB[self.option.name] = value;
40 | LoC_CVar.SetCVar("lossOfControl", value);
41 | LossOfControl:SendMessage("CVAR_UPDATE", LossOfControlFrame, "LOSS_OF_CONTROL", value and "1" or "0");
42 | end
43 |
44 | local function IsOptionEnable()
45 | return profileDB[lossOfControl];
46 | end
47 |
48 | LossOfControl.default = {
49 | locale = "enUS",
50 | [lossOfControl] = true,
51 | [LOC_TYPE_FULL] = 2,
52 | [LOC_TYPE_SILENCE] = 2,
53 | [LOC_TYPE_INTERRUPT] = 2,
54 | [LOC_TYPE_DISARM] = 2,
55 | [LOC_TYPE_ROOT] = 2;
56 | };
57 |
58 | LossOfControl.options = {
59 | name = "",
60 | handler = LossOfControl,
61 | type = "group",
62 | args = {
63 | lossOfControl = {
64 | order = 0,
65 | type = "toggle",
66 | name = lossOfControl,
67 | desc = OPTION_TOOLTIP_LOSS_OF_CONTROL,
68 | get = GetOptionValue,
69 | set = SetOptionEnable,
70 | width = "full"
71 | },
72 | full = {
73 | order = 1,
74 | type = "select",
75 | style = "dropdown",
76 | name = LOC_TYPE_FULL,
77 | desc = OPTION_LOSS_OF_CONTROL_FULL,
78 | get = GetOptionValue,
79 | set = SetOptionValue,
80 | values = LOC_OPTION_VALUE,
81 | disabled = not IsOptionEnable,
82 | },
83 | Silence = {
84 | order = 2,
85 | type = "select",
86 | style = "dropdown",
87 | name = LOC_TYPE_SILENCE,
88 | desc = OPTION_LOSS_OF_CONTROL_SILENCE,
89 | get = function()
90 | return profileDB[LOC_TYPE_SILENCE]
91 | end,
92 | set = SetOptionValue,
93 | values = LOC_OPTION_VALUE,
94 | disabled = not IsOptionEnable,
95 | },
96 | Interrupt = {
97 | order = 3,
98 | type = "select",
99 | style = "dropdown",
100 | name = LOC_TYPE_INTERRUPT,
101 | desc = OPTION_LOSS_OF_CONTROL_INTERRUPT,
102 | get = GetOptionValue,
103 | set = SetOptionValue,
104 | values = LOC_OPTION_VALUE,
105 | disabled = not IsOptionEnable,
106 | },
107 | Disarm = {
108 | order = 4,
109 | type = "select",
110 | style = "dropdown",
111 | name = LOC_TYPE_DISARM,
112 | desc = OPTION_LOSS_OF_CONTROL_DISARM,
113 | get = GetOptionValue,
114 | set = SetOptionValue,
115 | values = LOC_OPTION_VALUE,
116 | disabled = not IsOptionEnable,
117 | },
118 | Root = {
119 | order = 5,
120 | type = "select",
121 | style = "dropdown",
122 | name = LOC_TYPE_ROOT,
123 | desc = OPTION_LOSS_OF_CONTROL_ROOT,
124 | get = GetOptionValue,
125 | set = SetOptionValue,
126 | values = LOC_OPTION_VALUE,
127 | disabled = not IsOptionEnable,
128 | },
129 | },
130 | };
131 |
132 | function LossOfControl:SetupOptions()
133 | AceConfig:RegisterOptionsTable("LossOfControl", self.options, {SLASH_LossOfControl1});
134 |
135 | self.optionsFrames = {};
136 | self.optionsFrames.general = AceConfigDialog:AddToBlizOptions("LossOfControl", "LossOfControl");
137 | end
138 |
139 | function LossOfControl:OnInitialize()
140 | self.db = AceDB:New("LossOfControlDB");
141 |
142 | if self.db.char.myVal and self.db.char.myVal.locale and self.db.char.myVal.locale == GetLocale() then
143 | self.db.char.myVal = self.db.char.myVal
144 | else
145 | self.db.char.myVal = self.default
146 | self.db.char.myVal.locale = GetLocale()
147 | end
148 |
149 | profileDB = self.db.char.myVal;
150 |
151 | self:SetupOptions();
152 | self:SetDisplay();
153 | LoC_CVar.SetCVar("lossOfControl", self.db.char.myVal["Loss Of Control Alerts"]);
154 | self:SendMessage("VARIABLES_LOADED", LossOfControlFrame);
155 |
156 | SLASH_LossOfControl1 = "/loc";
157 | SlashCmdList["LossOfControl"] = function()
158 | InterfaceOptionsFrame_OpenToCategory(self.optionsFrames.general);
159 | end
160 |
161 | if ( not ROMANSPECTOR_DISCORD ) then
162 | ROMANSPECTOR_DISCORD = true;
163 | DEFAULT_CHAT_FRAME:AddMessage("|cffbaf5aeLossOfControl|r: See more |cff44d3e3https://discord.gg/4GTrkkaV9U|r");
164 | end
165 | end
166 |
167 | function LossOfControl:GetDisplayValue( controlType )
168 | return profileDB[controlType];
169 | end
170 |
171 | local displayType = {
172 | [LOSS_OF_CONTROL_DISPLAY_DISARM] = LOC_TYPE_DISARM,
173 | [LOSS_OF_CONTROL_DISPLAY_ROOT] = LOC_TYPE_ROOT,
174 | [LOSS_OF_CONTROL_DISPLAY_SILENCE] = LOC_TYPE_SILENCE,
175 | };
176 |
177 | function LossOfControl:SetDisplay()
178 | for _, spellData in pairs(LOSS_OF_CONTROL_STORAGE) do
179 | local controlType = spellData[1];
180 | spellData[3] = self:GetDisplayValue(displayType[controlType] or LOC_TYPE_FULL);
181 | end
182 | end
183 |
184 | LoC_CVar = LoC_CVar or {};
185 | LoC_CVar.Config = {};
186 |
187 | function LoC_CVar.GetCVarBool(name)
188 | return LoC_CVar.Config[name];
189 | end
190 |
191 | function LoC_CVar.SetCVar(eventName, value)
192 | if ( type(value) == "boolean" ) then
193 | LoC_CVar.Config[eventName] = value and "1" or "0";
194 | else
195 | LoC_CVar.Config[eventName] = value and tostring(value) or nil;
196 | end
197 | end
198 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Check Box --
5 | --------------------------
6 | --[[
7 | Events :
8 | OnValueChanged
9 |
10 | ]]
11 | do
12 | local Type = "CheckBox"
13 | local Version = 11
14 |
15 | local function OnAcquire(self)
16 | self:SetValue(false)
17 | self.tristate = nil
18 | self:SetHeight(24)
19 | self:SetWidth(200)
20 | end
21 |
22 | local function OnRelease(self)
23 | self.frame:ClearAllPoints()
24 | self.frame:Hide()
25 | self.check:Hide()
26 | self.highlight:Hide()
27 | self.down = nil
28 | self.checked = nil
29 | self:SetType()
30 | self:SetDisabled(false)
31 | self:SetDescription(nil)
32 | end
33 |
34 | local function CheckBox_OnEnter(this)
35 | local self = this.obj
36 | self.highlight:Show()
37 | self:Fire("OnEnter")
38 | end
39 |
40 | local function CheckBox_OnLeave(this)
41 | local self = this.obj
42 | self.highlight:Hide()
43 | self:Fire("OnLeave")
44 | end
45 |
46 | local function CheckBox_OnMouseUp(this)
47 | local self = this.obj
48 | if not self.disabled then
49 | self:ToggleChecked()
50 | self:Fire("OnValueChanged",self.checked)
51 | self.text:SetPoint("LEFT",self.check,"RIGHT",0,0)
52 | end
53 | self.down = nil
54 | end
55 |
56 | local function CheckBox_OnMouseDown(this)
57 | local self = this.obj
58 | if not self.disabled then
59 | self.text:SetPoint("LEFT",self.check,"RIGHT",1,-1)
60 | self.down = true
61 | end
62 | AceGUI:ClearFocus()
63 | end
64 |
65 | local function SetDisabled(self,disabled)
66 | self.disabled = disabled
67 | if disabled then
68 | self.frame:Disable()
69 | self.text:SetTextColor(0.5,0.5,0.5)
70 | SetDesaturation(self.check, true)
71 | else
72 | self.frame:Enable()
73 | self.text:SetTextColor(1,1,1)
74 | if self.tristate and self.checked == nil then
75 | SetDesaturation(self.check, true)
76 | else
77 | SetDesaturation(self.check, false)
78 | end
79 | end
80 | end
81 |
82 | local function SetValue(self,value)
83 | local check = self.check
84 | self.checked = value
85 | if value then
86 | SetDesaturation(self.check, false)
87 | check:SetWidth(24)
88 | check:SetHeight(24)
89 | self.check:Show()
90 | else
91 | --Nil is the unknown tristate value
92 | if self.tristate and value == nil then
93 | SetDesaturation(self.check, true)
94 | check:SetWidth(24)
95 | check:SetHeight(24)
96 | self.check:Show()
97 | else
98 | SetDesaturation(self.check, false)
99 | check:SetWidth(24)
100 | check:SetHeight(24)
101 | self.check:Hide()
102 | end
103 | end
104 | end
105 |
106 | local function SetTriState(self, enabled)
107 | self.tristate = enabled
108 | self:SetValue(self:GetValue())
109 | end
110 |
111 | local function GetValue(self)
112 | return self.checked
113 | end
114 |
115 | local function SetType(self, type)
116 | local checkbg = self.checkbg
117 | local check = self.check
118 | local highlight = self.highlight
119 |
120 | if type == "radio" then
121 | checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton")
122 | checkbg:SetTexCoord(0,0.25,0,1)
123 | check:SetTexture("Interface\\Buttons\\UI-RadioButton")
124 | check:SetTexCoord(0.5,0.75,0,1)
125 | check:SetBlendMode("ADD")
126 | highlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
127 | highlight:SetTexCoord(0.5,0.75,0,1)
128 | else
129 | checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
130 | checkbg:SetTexCoord(0,1,0,1)
131 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
132 | check:SetTexCoord(0,1,0,1)
133 | check:SetBlendMode("BLEND")
134 | highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
135 | highlight:SetTexCoord(0,1,0,1)
136 | end
137 | end
138 |
139 | local function ToggleChecked(self)
140 | local value = self:GetValue()
141 | if self.tristate then
142 | --cycle in true, nil, false order
143 | if value then
144 | self:SetValue(nil)
145 | elseif value == nil then
146 | self:SetValue(false)
147 | else
148 | self:SetValue(true)
149 | end
150 | else
151 | self:SetValue(not self:GetValue())
152 | end
153 | end
154 |
155 | local function SetLabel(self, label)
156 | self.text:SetText(label)
157 | end
158 |
159 | local function SetDescription(self, desc)
160 | if desc then
161 | if not self.desc then
162 | local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
163 | desc:ClearAllPoints()
164 | desc:SetPoint("TOPLEFT", self.check, "TOPRIGHT", 5, -20)
165 | desc:SetWidth(self.frame.width - 30)
166 | desc:SetJustifyH("LEFT")
167 | desc:SetJustifyV("TOP")
168 | self.desc = desc
169 | end
170 | self.desc:Show()
171 | --self.text:SetFontObject(GameFontNormal)
172 | self.desc:SetText(desc)
173 | self:SetHeight(24 + self.desc:GetHeight())
174 | else
175 | if self.desc then
176 | self.desc:SetText("")
177 | self.desc:Hide()
178 | end
179 | self.text:SetFontObject(GameFontHighlight)
180 | self:SetHeight(24)
181 | end
182 | end
183 |
184 | local function OnWidthSet(self, width)
185 | if self.desc and self.desc:GetText() ~= "" then
186 | self.desc:SetWidth(width - 30)
187 | self:SetHeight(24 + self.desc:GetHeight())
188 | end
189 | end
190 |
191 | local function Constructor()
192 | local frame = CreateFrame("Button",nil,UIParent)
193 | local self = {}
194 | self.type = Type
195 |
196 | self.OnRelease = OnRelease
197 | self.OnAcquire = OnAcquire
198 |
199 | self.SetValue = SetValue
200 | self.GetValue = GetValue
201 | self.SetDisabled = SetDisabled
202 | self.SetType = SetType
203 | self.ToggleChecked = ToggleChecked
204 | self.SetLabel = SetLabel
205 | self.SetTriState = SetTriState
206 | self.SetDescription = SetDescription
207 | self.OnWidthSet = OnWidthSet
208 |
209 | self.frame = frame
210 | frame.obj = self
211 |
212 | local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
213 | self.text = text
214 |
215 | frame:SetScript("OnEnter",CheckBox_OnEnter)
216 | frame:SetScript("OnLeave",CheckBox_OnLeave)
217 | frame:SetScript("OnMouseUp",CheckBox_OnMouseUp)
218 | frame:SetScript("OnMouseDown",CheckBox_OnMouseDown)
219 | frame:EnableMouse()
220 | local checkbg = frame:CreateTexture(nil,"ARTWORK")
221 | self.checkbg = checkbg
222 | checkbg:SetWidth(24)
223 | checkbg:SetHeight(24)
224 | checkbg:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
225 | checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
226 | local check = frame:CreateTexture(nil,"OVERLAY")
227 | self.check = check
228 | check:SetWidth(24)
229 | check:SetHeight(24)
230 | check:SetPoint("CENTER",checkbg,"CENTER",0,0)
231 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
232 |
233 | local highlight = frame:CreateTexture(nil, "OVERLAY")
234 | self.highlight = highlight
235 | highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
236 | highlight:SetBlendMode("ADD")
237 | highlight:SetAllPoints(checkbg)
238 | highlight:Hide()
239 |
240 | text:SetJustifyH("LEFT")
241 | frame:SetHeight(24)
242 | frame:SetWidth(200)
243 | text:SetHeight(18)
244 | text:SetPoint("LEFT",check,"RIGHT",0,0)
245 | text:SetPoint("RIGHT",frame,"RIGHT",0,0)
246 |
247 | AceGUI:RegisterAsWidget(self)
248 | return self
249 | end
250 |
251 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
252 | end
253 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | --------------------------
4 | -- Slider --
5 | --------------------------
6 | do
7 | local Type = "Slider"
8 | local Version = 8
9 |
10 | local function OnAcquire(self)
11 | self:SetWidth(200)
12 | self:SetHeight(44)
13 | self:SetDisabled(false)
14 | self:SetIsPercent(nil)
15 | self:SetSliderValues(0,100,1)
16 | self:SetValue(0)
17 | end
18 |
19 | local function OnRelease(self)
20 | self.frame:ClearAllPoints()
21 | self.frame:Hide()
22 | self.slider:EnableMouseWheel(false)
23 | self:SetDisabled(false)
24 | end
25 |
26 | local function Control_OnEnter(this)
27 | this.obj:Fire("OnEnter")
28 | end
29 |
30 | local function Control_OnLeave(this)
31 | this.obj:Fire("OnLeave")
32 | end
33 |
34 | local function UpdateText(self)
35 | local value = self.value or 0
36 | if self.ispercent then
37 | self.editbox:SetText(("%s%%"):format(math.floor(value*1000+0.5)/10))
38 | else
39 | self.editbox:SetText(math.floor(value*100+0.5)/100)
40 | end
41 | end
42 |
43 | local function UpdateLabels(self)
44 | local min, max = (self.min or 0), (self.max or 100)
45 | if self.ispercent then
46 | self.lowtext:SetFormattedText("%s%%",(min * 100))
47 | self.hightext:SetFormattedText("%s%%",(max * 100))
48 | else
49 | self.lowtext:SetText(min)
50 | self.hightext:SetText(max)
51 | end
52 | end
53 |
54 | local function Slider_OnValueChanged(this)
55 | local self = this.obj
56 | if not this.setup then
57 | local newvalue
58 | newvalue = this:GetValue()
59 | if newvalue ~= self.value and not self.disabled then
60 | self.value = newvalue
61 | self:Fire("OnValueChanged", newvalue)
62 | end
63 | if self.value then
64 | local value = self.value
65 | UpdateText(self)
66 | end
67 | end
68 | end
69 |
70 | local function Slider_OnMouseUp(this)
71 | local self = this.obj
72 | self:Fire("OnMouseUp",this:GetValue())
73 | end
74 |
75 | local function Slider_OnMouseWheel(this, v)
76 | local self = this.obj
77 | if not self.disabled then
78 | local value = self.value
79 | if v > 0 then
80 | value = math.min(value + (self.step or 1),self.max)
81 | else
82 | value = math.max(value - (self.step or 1), self.min)
83 | end
84 | self.slider:SetValue(value)
85 | end
86 | end
87 |
88 | local function SetDisabled(self, disabled)
89 | self.disabled = disabled
90 | if disabled then
91 | self.slider:EnableMouse(false)
92 | self.label:SetTextColor(.5,.5,.5)
93 | self.hightext:SetTextColor(.5,.5,.5)
94 | self.lowtext:SetTextColor(.5,.5,.5)
95 | --self.valuetext:SetTextColor(.5,.5,.5)
96 | self.editbox:SetTextColor(.5,.5,.5)
97 | self.editbox:EnableMouse(false)
98 | self.editbox:ClearFocus()
99 | else
100 | self.slider:EnableMouse(true)
101 | self.label:SetTextColor(1,.82,0)
102 | self.hightext:SetTextColor(1,1,1)
103 | self.lowtext:SetTextColor(1,1,1)
104 | --self.valuetext:SetTextColor(1,1,1)
105 | self.editbox:SetTextColor(1,1,1)
106 | self.editbox:EnableMouse(true)
107 | end
108 | end
109 |
110 | local function SetValue(self, value)
111 | self.slider.setup = true
112 | self.slider:SetValue(value)
113 | self.value = value
114 | UpdateText(self)
115 | self.slider.setup = nil
116 | end
117 |
118 | local function SetLabel(self, text)
119 | self.label:SetText(text)
120 | end
121 |
122 | local function SetSliderValues(self, min, max, step)
123 | local frame = self.slider
124 | frame.setup = true
125 | self.min = min
126 | self.max = max
127 | self.step = step
128 | frame:SetMinMaxValues(min or 0,max or 100)
129 | UpdateLabels(self)
130 | frame:SetValueStep(step or 1)
131 | if self.value then
132 | frame:SetValue(self.value)
133 | end
134 | frame.setup = nil
135 | end
136 |
137 | local function EditBox_OnEscapePressed(this)
138 | this:ClearFocus()
139 | end
140 |
141 | local function EditBox_OnEnterPressed(this)
142 | local self = this.obj
143 | local value = this:GetText()
144 | if self.ispercent then
145 | value = value:gsub('%%','')
146 | value = tonumber(value) / 100
147 | else
148 | value = tonumber(value)
149 | end
150 |
151 | if value then
152 | self:Fire("OnMouseUp",value)
153 | end
154 | end
155 |
156 | local function SetIsPercent(self, value)
157 | self.ispercent = value
158 | UpdateLabels(self)
159 | UpdateText(self)
160 | end
161 |
162 | local function FrameOnMouseDown(this)
163 | this.obj.slider:EnableMouseWheel(true)
164 | AceGUI:ClearFocus()
165 | end
166 |
167 | local SliderBackdrop = {
168 | bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
169 | edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
170 | tile = true, tileSize = 8, edgeSize = 8,
171 | insets = { left = 3, right = 3, top = 6, bottom = 6 }
172 | }
173 |
174 | local function Constructor()
175 | local frame = CreateFrame("Frame",nil,UIParent)
176 | local self = {}
177 | self.type = Type
178 |
179 | self.OnRelease = OnRelease
180 | self.OnAcquire = OnAcquire
181 |
182 | self.frame = frame
183 | frame.obj = self
184 |
185 | self.SetDisabled = SetDisabled
186 | self.SetValue = SetValue
187 | self.SetSliderValues = SetSliderValues
188 | self.SetLabel = SetLabel
189 | self.SetIsPercent = SetIsPercent
190 |
191 | self.alignoffset = 25
192 |
193 | frame:EnableMouse(true)
194 | frame:SetScript("OnMouseDown",FrameOnMouseDown)
195 | self.slider = CreateFrame("Slider",nil,frame)
196 | local slider = self.slider
197 | slider:SetScript("OnEnter",Control_OnEnter)
198 | slider:SetScript("OnLeave",Control_OnLeave)
199 | slider:SetScript("OnMouseUp", Slider_OnMouseUp)
200 | slider.obj = self
201 | slider:SetOrientation("HORIZONTAL")
202 | slider:SetHeight(15)
203 | slider:SetHitRectInsets(0,0,-10,0)
204 | slider:SetBackdrop(SliderBackdrop)
205 | --slider:EnableMouseWheel(true)
206 | slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
207 |
208 | local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
209 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
210 | label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
211 | label:SetJustifyH("CENTER")
212 | label:SetHeight(15)
213 | self.label = label
214 |
215 | self.lowtext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall")
216 | self.lowtext:SetPoint("TOPLEFT",slider,"BOTTOMLEFT",2,3)
217 |
218 | self.hightext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall")
219 | self.hightext:SetPoint("TOPRIGHT",slider,"BOTTOMRIGHT",-2,3)
220 |
221 |
222 | local editbox = CreateFrame("EditBox",nil,frame)
223 | editbox:SetAutoFocus(false)
224 | editbox:SetFontObject(GameFontHighlightSmall)
225 | editbox:SetPoint("TOP",slider,"BOTTOM",0,0)
226 | editbox:SetHeight(14)
227 | editbox:SetWidth(70)
228 | editbox:SetJustifyH("CENTER")
229 | editbox:EnableMouse(true)
230 | editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed)
231 | editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed)
232 | self.editbox = editbox
233 | editbox.obj = self
234 |
235 | local bg = editbox:CreateTexture(nil,"BACKGROUND")
236 | editbox.bg = bg
237 | bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
238 | bg:SetVertexColor(0,0,0,0.25)
239 | bg:SetAllPoints(editbox)
240 |
241 | slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
242 |
243 | frame:SetWidth(200)
244 | frame:SetHeight(44)
245 | slider:SetPoint("TOP",label,"BOTTOM",0,0)
246 | slider:SetPoint("LEFT",frame,"LEFT",3,0)
247 | slider:SetPoint("RIGHT",frame,"RIGHT",-3,0)
248 |
249 |
250 | slider:SetValue(self.value or 0)
251 | slider:SetScript("OnValueChanged",Slider_OnValueChanged)
252 |
253 | AceGUI:RegisterAsWidget(self)
254 | return self
255 | end
256 |
257 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
258 | end
259 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-ScrollFrame.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | -------------
4 | -- Widgets --
5 | -------------
6 | --[[
7 | Widgets must provide the following functions
8 | Acquire() - Called when the object is aquired, should set everything to a default hidden state
9 | Release() - Called when the object is Released, should remove any anchors and hide the Widget
10 |
11 | And the following members
12 | frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
13 | type - the type of the object, same as the name given to :RegisterWidget()
14 |
15 | Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
16 | It will be cleared automatically when a widget is released
17 | Placing values directly into a widget object should be avoided
18 |
19 | If the Widget can act as a container for other Widgets the following
20 | content - frame or derivitive that children will be anchored to
21 |
22 | The Widget can supply the following Optional Members
23 |
24 |
25 | ]]
26 |
27 | --------------------------
28 | -- Scroll Frame --
29 | --------------------------
30 | do
31 | local Type = "ScrollFrame"
32 | local Version = 6
33 |
34 | local function OnAcquire(self)
35 |
36 | end
37 |
38 | local function OnRelease(self)
39 | self.frame:ClearAllPoints()
40 | self.frame:Hide()
41 | self.status = nil
42 | for k in pairs(self.localstatus) do
43 | self.localstatus[k] = nil
44 | end
45 | self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
46 | self.scrollbar:Hide()
47 | self.scrollBarShown = nil
48 | self.content.height, self.content.width = nil, nil
49 | end
50 |
51 | local function SetScroll(self, value)
52 |
53 | local status = self.status or self.localstatus
54 |
55 | local frame, child = self.scrollframe, self.content
56 | local viewheight = frame:GetHeight()
57 | local height = child:GetHeight()
58 | local offset
59 | if viewheight > height then
60 | offset = 0
61 | else
62 | offset = floor((height - viewheight) / 1000.0 * value)
63 | end
64 | child:ClearAllPoints()
65 | child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset)
66 | child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset)
67 | status.offset = offset
68 | status.scrollvalue = value
69 | end
70 |
71 | local function MoveScroll(self, value)
72 | local status = self.status or self.localstatus
73 | local frame, child = self.scrollframe, self.content
74 | local height, viewheight = frame:GetHeight(), child:GetHeight()
75 | if height > viewheight then
76 | self.scrollbar:Hide()
77 | else
78 | self.scrollbar:Show()
79 | local diff = height - viewheight
80 | local delta = 1
81 | if value < 0 then
82 | delta = -1
83 | end
84 | self.scrollbar:SetValue(math.min(math.max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
85 | end
86 | end
87 |
88 |
89 | local function FixScroll(self)
90 | if self.updateLock then return end
91 | self.updateLock = true
92 | local status = self.status or self.localstatus
93 | local frame, child = self.scrollframe, self.content
94 | local height, viewheight = frame:GetHeight(), child:GetHeight()
95 | local offset = status.offset
96 | if not offset then
97 | offset = 0
98 | end
99 | local curvalue = self.scrollbar:GetValue()
100 | if viewheight < height then
101 | if self.scrollBarShown then
102 | self.scrollBarShown = nil
103 | self.scrollbar:Hide()
104 | self.scrollbar:SetValue(0)
105 | self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
106 | self:DoLayout()
107 | end
108 | else
109 | if not self.scrollBarShown then
110 | self.scrollBarShown = true
111 | self.scrollbar:Show()
112 | self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-20,0)
113 | self:DoLayout()
114 | end
115 | local value = (offset / (viewheight - height) * 1000)
116 | if value > 1000 then value = 1000 end
117 | self.scrollbar:SetValue(value)
118 | self:SetScroll(value)
119 | if value < 1000 then
120 | child:ClearAllPoints()
121 | child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset)
122 | child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset)
123 | status.offset = offset
124 | end
125 | end
126 | self.updateLock = nil
127 | end
128 |
129 | local function OnMouseWheel(this,value)
130 | this.obj:MoveScroll(value)
131 | end
132 |
133 | local function OnScrollValueChanged(this, value)
134 | this.obj:SetScroll(value)
135 | end
136 |
137 | local function FixScrollOnUpdate(this)
138 | this:SetScript("OnUpdate", nil)
139 | this.obj:FixScroll()
140 | end
141 | local function OnSizeChanged(this)
142 | this:SetScript("OnUpdate", FixScrollOnUpdate)
143 | --this.obj:FixScroll()
144 | end
145 |
146 | local function LayoutFinished(self,width,height)
147 | self.content:SetHeight(height or 20)
148 | self:FixScroll()
149 | end
150 |
151 | -- called to set an external table to store status in
152 | local function SetStatusTable(self, status)
153 | assert(type(status) == "table")
154 | self.status = status
155 | if not status.scrollvalue then
156 | status.scrollvalue = 0
157 | end
158 | end
159 |
160 |
161 | local createdcount = 0
162 |
163 | local function OnWidthSet(self, width)
164 | local content = self.content
165 | content.width = width
166 | end
167 |
168 |
169 | local function OnHeightSet(self, height)
170 | local content = self.content
171 | content.height = height
172 | end
173 |
174 | local function Constructor()
175 | local frame = CreateFrame("Frame",nil,UIParent)
176 | local self = {}
177 | self.type = Type
178 |
179 | self.OnRelease = OnRelease
180 | self.OnAcquire = OnAcquire
181 |
182 | self.MoveScroll = MoveScroll
183 | self.FixScroll = FixScroll
184 | self.SetScroll = SetScroll
185 | self.LayoutFinished = LayoutFinished
186 | self.SetStatusTable = SetStatusTable
187 | self.OnWidthSet = OnWidthSet
188 | self.OnHeightSet = OnHeightSet
189 |
190 | self.localstatus = {}
191 | self.frame = frame
192 | frame.obj = self
193 |
194 | --Container Support
195 | local scrollframe = CreateFrame("ScrollFrame",nil,frame)
196 | local content = CreateFrame("Frame",nil,scrollframe)
197 | createdcount = createdcount + 1
198 | local scrollbar = CreateFrame("Slider",("AceConfigDialogScrollFrame%dScrollBar"):format(createdcount),scrollframe,"UIPanelScrollBarTemplate")
199 | local scrollbg = scrollbar:CreateTexture(nil,"BACKGROUND")
200 | scrollbg:SetAllPoints(scrollbar)
201 | scrollbg:SetTexture(0,0,0,0.4)
202 | self.scrollframe = scrollframe
203 | self.content = content
204 | self.scrollbar = scrollbar
205 |
206 | scrollbar.obj = self
207 | scrollframe.obj = self
208 | content.obj = self
209 |
210 | scrollframe:SetScrollChild(content)
211 | scrollframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
212 | scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
213 | scrollframe:EnableMouseWheel(true)
214 | scrollframe:SetScript("OnMouseWheel", OnMouseWheel)
215 | scrollframe:SetScript("OnSizeChanged", OnSizeChanged)
216 |
217 |
218 | content:SetPoint("TOPLEFT",scrollframe,"TOPLEFT",0,0)
219 | content:SetPoint("TOPRIGHT",scrollframe,"TOPRIGHT",0,0)
220 | content:SetHeight(400)
221 |
222 | scrollbar:SetPoint("TOPLEFT",scrollframe,"TOPRIGHT",4,-16)
223 | scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",4,16)
224 | scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
225 | scrollbar:SetMinMaxValues(0,1000)
226 | scrollbar:SetValueStep(1)
227 | scrollbar:SetValue(0)
228 | scrollbar:SetWidth(16)
229 | scrollbar:Hide()
230 |
231 | self.localstatus.scrollvalue = 0
232 |
233 |
234 | --self:FixScroll()
235 | AceGUI:RegisterAsContainer(self)
236 | --AceGUI:RegisterAsWidget(self)
237 | return self
238 | end
239 |
240 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
241 | end
242 |
--------------------------------------------------------------------------------
/LossOfControl/LossOfControl.lua:
--------------------------------------------------------------------------------
1 | --######################################################################
2 | --###### Bakcport LossOfControl from retail #######
3 | ------------------------------------------------------------------------
4 | --######################################################################
5 |
6 | -- can't scale text with animations, use raid warning scaling
7 | local abilityNameTimings = {
8 | ["RAID_NOTICE_MIN_HEIGHT"] = 22.0,
9 | ["RAID_NOTICE_MAX_HEIGHT"] = 32.0,
10 | ["RAID_NOTICE_SCALE_UP_TIME"] = 0.1,
11 | ["RAID_NOTICE_SCALE_DOWN_TIME"] = 0.2,
12 | }
13 | local timeLeftTimings = {
14 | ["RAID_NOTICE_MIN_HEIGHT"] = 20.0,
15 | ["RAID_NOTICE_MAX_HEIGHT"] = 28.0,
16 | ["RAID_NOTICE_SCALE_UP_TIME"] = 0.1,
17 | ["RAID_NOTICE_SCALE_DOWN_TIME"] = 0.2,
18 | };
19 |
20 | local TEXT_OVERRIDE = {
21 | [33786] = LOSS_OF_CONTROL_DISPLAY_CYCLONE,
22 | };
23 |
24 | local TIME_LEFT_FRAME_WIDTH = 200;
25 | LOSS_OF_CONTROL_TIME_OFFSET = 6;
26 |
27 | local DISPLAY_TYPE_FULL = 2;
28 | local DISPLAY_TYPE_ALERT = 1;
29 | local DISPLAY_TYPE_NONE = 0;
30 |
31 | LOSS_OF_CONTROL_ACTIVE_INDEX = 1;
32 |
33 | function LossOfControlFrame_OnLoad(self)
34 | self:RegisterEvents("CVAR_UPDATE");
35 | self:RegisterEvents("VARIABLES_LOADED");
36 | -- figure out some string widths - our base width is for under 10 seconds which should be almost all loss of control durations
37 | self.TimeLeft.baseNumberWidth = self.TimeLeft.NumberText:GetStringWidth() + LOSS_OF_CONTROL_TIME_OFFSET;
38 | self.TimeLeft.secondsWidth = self.TimeLeft.SecondsText:GetStringWidth();
39 | end
40 |
41 | function LossOfControlFrame_OnEvent(event, self, ...)
42 | if ( event == "LOSS_OF_CONTROL_UPDATE" ) then
43 | LossOfControlFrame_UpdateDisplay(self, false); -- false? KEKW
44 | elseif ( event == "LOSS_OF_CONTROL_ADDED" and ... ) then
45 | local eventIndex = ...;
46 | local data = C_LossOfControl.GetActiveLossOfControlData(eventIndex);
47 | local timeRemaining = data.timeRemaining;
48 | local priority = data.priority;
49 |
50 | if ( data.displayType == DISPLAY_TYPE_ALERT ) then
51 | -- only display an alert type if there's nothing up or it has higher priority. If same priority, it needs to have longer time remaining
52 | if ( not self:IsShown() or priority > self.priority
53 | or ( priority == self.priority and timeRemaining
54 | and ( not self.TimeLeft.timeRemaining or timeRemaining > self.TimeLeft.timeRemaining ) ) ) then
55 | LossOfControlFrame_SetUpDisplay(self, true, data);
56 | end
57 | return;
58 | end
59 | if ( eventIndex == LOSS_OF_CONTROL_ACTIVE_INDEX ) then
60 | self.fadeTime = nil;
61 | LossOfControlFrame_SetUpDisplay(self, true);
62 | end
63 | elseif ( event == "CVAR_UPDATE" ) then
64 | local cvar, value = ...;
65 | if ( cvar == "LOSS_OF_CONTROL" ) then
66 | if ( value == "1" ) then
67 | self:RegisterEvents("LOSS_OF_CONTROL_UPDATE");
68 | self:RegisterEvents("LOSS_OF_CONTROL_ADDED");
69 | else
70 | self:UnRegisterEvents("LOSS_OF_CONTROL_UPDATE");
71 | self:UnRegisterEvents("LOSS_OF_CONTROL_ADDED");
72 | self:Hide();
73 | end
74 | end
75 | elseif ( event == "VARIABLES_LOADED" ) then
76 | if ( LoC_CVar.GetCVarBool("lossOfControl") ) then
77 | self:RegisterEvents("LOSS_OF_CONTROL_UPDATE");
78 | self:RegisterEvents("LOSS_OF_CONTROL_ADDED");
79 | end
80 | end
81 | end
82 |
83 | function LossOfControlFrame_OnUpdate(self, elapsed)
84 | RaidNotice_UpdateSlots(self.AbilityName, abilityNameTimings, elapsed);
85 | RaidNotice_UpdateSlots(self.TimeLeft.NumberText, timeLeftTimings, elapsed);
86 | RaidNotice_UpdateSlots(self.TimeLeft.SecondsText, timeLeftTimings, elapsed);
87 | -- handle alert type
88 | if (self.fadeTime) then
89 | self.fadeTime = self.fadeTime - elapsed;
90 | self:SetAlpha(max(self.fadeTime*2, 0.0));
91 | if (self.fadeTime < 0) then
92 | self:Hide();
93 | else
94 | -- no need to do any other work
95 | return;
96 | end
97 | else
98 | self:SetAlpha(1.0);
99 | end
100 | LossOfControlFrame_UpdateDisplay(self);
101 | end
102 |
103 | function LossOfControlFrame_OnHide(self)
104 | self.fadeTime = nil;
105 | self.priority = nil;
106 | end
107 |
108 | function LossOfControlFrame_SetUpDisplay(self, animate, data)
109 | if ( not data ) then
110 | data = C_LossOfControl.GetActiveLossOfControlData(LOSS_OF_CONTROL_ACTIVE_INDEX);
111 | end
112 |
113 | local locType = data.locType;
114 | local spellID = data.spellID;
115 | local text = data.displayText;
116 | local iconTexture = data.iconTexture;
117 | local startTime = data.startTime;
118 | local timeRemaining = data.timeRemaining;
119 | local duration = data.duration;
120 | local lockoutSchool = data.lockoutSchool;
121 | local priority = data.priority;
122 | local displayType = data.displayType;
123 |
124 | if ( text and displayType ~= DISPLAY_TYPE_NONE ) then
125 | -- ability name
126 | text = TEXT_OVERRIDE[spellID] or text;
127 | if ( locType == "SCHOOL_INTERRUPT" ) then
128 | -- Replace text with school-specific lockout text
129 | if(lockoutSchool and lockoutSchool ~= 0) then
130 | text = string.format(LOSS_OF_CONTROL_DISPLAY_INTERRUPT_SCHOOL, GetSchoolString(lockoutSchool));
131 | end
132 | end
133 |
134 | self.AbilityName:SetText(text);
135 | -- icon
136 | self.Icon:SetTexture(iconTexture);
137 | -- time
138 | local timeLeftFrame = self.TimeLeft;
139 | if ( displayType == DISPLAY_TYPE_ALERT ) then
140 | timeRemaining = duration;
141 | CooldownFrame_Clear(self.Cooldown);
142 | elseif ( not startTime ) then
143 | CooldownFrame_Clear(self.Cooldown);
144 | else
145 | CooldownFrame_SetTimer(self.Cooldown, startTime, duration, 1);
146 | end
147 | LossOfControlTimeLeftFrame_SetTime(timeLeftFrame, timeRemaining);
148 | -- align stuff
149 | local abilityWidth = self.AbilityName:GetWidth();
150 | local longestTextWidth = max(abilityWidth, (timeLeftFrame.numberWidth + timeLeftFrame.secondsWidth));
151 | local xOffset = (abilityWidth - longestTextWidth) / 2 + 27;
152 | self.AbilityName:SetPoint("CENTER", xOffset, 11);
153 | self.Icon:SetPoint("CENTER", -((6 + longestTextWidth) / 2), 0);
154 | -- left-align the TimeLeft frame with the ability name using a center anchor (will need center for "animating" via frame scaling - NYI)
155 | xOffset = xOffset + (TIME_LEFT_FRAME_WIDTH - abilityWidth) / 2;
156 | timeLeftFrame:SetPoint("CENTER", xOffset, -12);
157 | -- show
158 | if ( animate ) then
159 | if ( displayType == DISPLAY_TYPE_ALERT ) then
160 | self.fadeTime = 1.5;
161 | end
162 | self.Anim:Stop();
163 | self.AbilityName.scrollTime = 0;
164 | self.TimeLeft.NumberText.scrollTime = 0;
165 | self.TimeLeft.SecondsText.scrollTime = 0;
166 | self.Cooldown:Hide();
167 | self.Anim:Play();
168 | PlaySoundFile(SOUNDKIT.UI_LOSS_OF_CONTROL_START);
169 | end
170 | self.priority = priority;
171 | self.spellID = spellID;
172 | self.startTime = startTime;
173 | self:Show();
174 | end
175 | end
176 |
177 | function LossOfControlFrame_UpdateDisplay(self)
178 | -- if displaying an alert, wait for it to go away on its own
179 | if ( self.fadeTime ) then
180 | return;
181 | end
182 | local data = C_LossOfControl.GetActiveLossOfControlData(LOSS_OF_CONTROL_ACTIVE_INDEX);
183 | if ( data and data.displayText and data.displayType == DISPLAY_TYPE_FULL ) then
184 | if ( data.spellID ~= self.spellID or data.startTime ~= self.startTime ) then
185 | LossOfControlFrame_SetUpDisplay(self, false, data);
186 | end
187 | if ( not self.Anim:IsPlaying() and data.startTime ) then
188 | CooldownFrame_SetTimer(self.Cooldown, data.startTime, data.duration, 1);
189 | end
190 | LossOfControlTimeLeftFrame_SetTime(self.TimeLeft, data.timeRemaining);
191 | else
192 | self:Hide();
193 | end
194 | end
195 |
196 | function LossOfControlTimeLeftFrame_SetTime(self, timeRemaining)
197 | if ( timeRemaining ) then
198 | if ( timeRemaining >= 10 ) then
199 | self.NumberText:SetFormattedText("%d", timeRemaining);
200 | elseif (timeRemaining < 9.95) then -- From 9.95 to 9.99 it will print 10.0 instead of 9.9
201 | self.NumberText:SetFormattedText("%.1F", timeRemaining);
202 | end
203 | self:SetShown(timeRemaining > 0);
204 | self.timeRemaining = timeRemaining;
205 | self.numberWidth = self.NumberText:GetStringWidth() + LOSS_OF_CONTROL_TIME_OFFSET;
206 | else
207 | self:Hide();
208 | self.numberWidth = 0;
209 | end
210 | end
211 |
212 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua:
--------------------------------------------------------------------------------
1 | --[[ $Id: CallbackHandler-1.0.lua 846 2009-09-17 10:51:12Z ammo $ ]]
2 | local MAJOR, MINOR = "CallbackHandler-1.0", 5
3 | local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
4 |
5 | if not CallbackHandler then return end -- No upgrade needed
6 |
7 | local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
8 |
9 | local type = type
10 | local pcall = pcall
11 | local pairs = pairs
12 | local assert = assert
13 | local concat = table.concat
14 | local loadstring = loadstring
15 | local next = next
16 | local select = select
17 | local type = type
18 | local xpcall = xpcall
19 |
20 | local function errorhandler(err)
21 | return geterrorhandler()(err)
22 | end
23 |
24 | local function CreateDispatcher(argCount)
25 | local code = [[
26 | local next, xpcall, eh = ...
27 |
28 | local method, ARGS
29 | local function call() method(ARGS) end
30 |
31 | local function dispatch(handlers, ...)
32 | local index
33 | index, method = next(handlers)
34 | if not method then return end
35 | local OLD_ARGS = ARGS
36 | ARGS = ...
37 | repeat
38 | xpcall(call, eh)
39 | index, method = next(handlers, index)
40 | until not method
41 | ARGS = OLD_ARGS
42 | end
43 |
44 | return dispatch
45 | ]]
46 |
47 | local ARGS, OLD_ARGS = {}, {}
48 | for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
49 | code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", "))
50 | return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
51 | end
52 |
53 | local Dispatchers = setmetatable({}, {__index=function(self, argCount)
54 | local dispatcher = CreateDispatcher(argCount)
55 | rawset(self, argCount, dispatcher)
56 | return dispatcher
57 | end})
58 |
59 | --------------------------------------------------------------------------
60 | -- CallbackHandler:New
61 | --
62 | -- target - target object to embed public APIs in
63 | -- RegisterName - name of the callback registration API, default "RegisterCallback"
64 | -- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
65 | -- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
66 |
67 | function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused)
68 | -- TODO: Remove this after beta has gone out
69 | assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
70 |
71 | RegisterName = RegisterName or "RegisterCallback"
72 | UnregisterName = UnregisterName or "UnregisterCallback"
73 | if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
74 | UnregisterAllName = "UnregisterAllCallbacks"
75 | end
76 |
77 | -- we declare all objects and exported APIs inside this closure to quickly gain access
78 | -- to e.g. function names, the "target" parameter, etc
79 |
80 |
81 | -- Create the registry object
82 | local events = setmetatable({}, meta)
83 | local registry = { recurse=0, events=events }
84 |
85 | -- registry:Fire() - fires the given event/message into the registry
86 | function registry:Fire(eventname, ...)
87 | if not rawget(events, eventname) or not next(events[eventname]) then return end
88 | local oldrecurse = registry.recurse
89 | registry.recurse = oldrecurse + 1
90 |
91 | Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
92 |
93 | registry.recurse = oldrecurse
94 |
95 | if registry.insertQueue and oldrecurse==0 then
96 | -- Something in one of our callbacks wanted to register more callbacks; they got queued
97 | for eventname,callbacks in pairs(registry.insertQueue) do
98 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
99 | for self,func in pairs(callbacks) do
100 | events[eventname][self] = func
101 | -- fire OnUsed callback?
102 | if first and registry.OnUsed then
103 | registry.OnUsed(registry, target, eventname)
104 | first = nil
105 | end
106 | end
107 | end
108 | registry.insertQueue = nil
109 | end
110 | end
111 |
112 | -- Registration of a callback, handles:
113 | -- self["method"], leads to self["method"](self, ...)
114 | -- self with function ref, leads to functionref(...)
115 | -- "addonId" (instead of self) with function ref, leads to functionref(...)
116 | -- all with an optional arg, which, if present, gets passed as first argument (after self if present)
117 | target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
118 | if type(eventname) ~= "string" then
119 | error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
120 | end
121 |
122 | method = method or eventname
123 |
124 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
125 |
126 | if type(method) ~= "string" and type(method) ~= "function" then
127 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
128 | end
129 |
130 | local regfunc
131 |
132 | if type(method) == "string" then
133 | -- self["method"] calling style
134 | if type(self) ~= "table" then
135 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
136 | elseif self==target then
137 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
138 | elseif type(self[method]) ~= "function" then
139 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
140 | end
141 |
142 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
143 | local arg=select(1,...)
144 | regfunc = function(...) self[method](self,arg,...) end
145 | else
146 | regfunc = function(...) self[method](self,...) end
147 | end
148 | else
149 | -- function ref with self=object or self="addonId"
150 | if type(self)~="table" and type(self)~="string" then
151 | error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2)
152 | end
153 |
154 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
155 | local arg=select(1,...)
156 | regfunc = function(...) method(arg,...) end
157 | else
158 | regfunc = method
159 | end
160 | end
161 |
162 |
163 | if events[eventname][self] or registry.recurse<1 then
164 | -- if registry.recurse<1 then
165 | -- we're overwriting an existing entry, or not currently recursing. just set it.
166 | events[eventname][self] = regfunc
167 | -- fire OnUsed callback?
168 | if registry.OnUsed and first then
169 | registry.OnUsed(registry, target, eventname)
170 | end
171 | else
172 | -- we're currently processing a callback in this registry, so delay the registration of this new entry!
173 | -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
174 | registry.insertQueue = registry.insertQueue or setmetatable({},meta)
175 | registry.insertQueue[eventname][self] = regfunc
176 | end
177 | end
178 |
179 | -- Unregister a callback
180 | target[UnregisterName] = function(self, eventname)
181 | if not self or self==target then
182 | error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
183 | end
184 | if type(eventname) ~= "string" then
185 | error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
186 | end
187 | if rawget(events, eventname) and events[eventname][self] then
188 | events[eventname][self] = nil
189 | -- Fire OnUnused callback?
190 | if registry.OnUnused and not next(events[eventname]) then
191 | registry.OnUnused(registry, target, eventname)
192 | end
193 | end
194 | if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
195 | registry.insertQueue[eventname][self] = nil
196 | end
197 | end
198 |
199 | -- OPTIONAL: Unregister all callbacks for given selfs/addonIds
200 | if UnregisterAllName then
201 | target[UnregisterAllName] = function(...)
202 | if select("#",...)<1 then
203 | error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
204 | end
205 | if select("#",...)==1 and ...==target then
206 | error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
207 | end
208 |
209 |
210 | for i=1,select("#",...) do
211 | local self = select(i,...)
212 | if registry.insertQueue then
213 | for eventname, callbacks in pairs(registry.insertQueue) do
214 | if callbacks[self] then
215 | callbacks[self] = nil
216 | end
217 | end
218 | end
219 | for eventname, callbacks in pairs(events) do
220 | if callbacks[self] then
221 | callbacks[self] = nil
222 | -- Fire OnUnused callback?
223 | if registry.OnUnused and not next(callbacks) then
224 | registry.OnUnused(registry, target, eventname)
225 | end
226 | end
227 | end
228 | end
229 | end
230 | end
231 |
232 | return registry
233 | end
234 |
235 |
236 | -- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
237 | -- try to upgrade old implicit embeds since the system is selfcontained and
238 | -- relies on closures to work.
239 |
240 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Frame.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | ----------------
4 | -- Main Frame --
5 | ----------------
6 | --[[
7 | Events :
8 | OnClose
9 |
10 | ]]
11 | do
12 | local Type = "Frame"
13 | local Version = 8
14 |
15 | local FrameBackdrop = {
16 | bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
17 | edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
18 | tile = true, tileSize = 32, edgeSize = 32,
19 | insets = { left = 8, right = 8, top = 8, bottom = 8 }
20 | }
21 |
22 | local PaneBackdrop = {
23 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
24 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
25 | tile = true, tileSize = 16, edgeSize = 16,
26 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
27 | }
28 |
29 | local function frameOnClose(this)
30 | this.obj:Fire("OnClose")
31 | end
32 |
33 | local function closeOnClick(this)
34 | this.obj:Hide()
35 | end
36 |
37 | local function frameOnMouseDown(this)
38 | AceGUI:ClearFocus()
39 | end
40 |
41 | local function titleOnMouseDown(this)
42 | this:GetParent():StartMoving()
43 | AceGUI:ClearFocus()
44 | end
45 |
46 | local function frameOnMouseUp(this)
47 | local frame = this:GetParent()
48 | frame:StopMovingOrSizing()
49 | local self = frame.obj
50 | local status = self.status or self.localstatus
51 | status.width = frame:GetWidth()
52 | status.height = frame:GetHeight()
53 | status.top = frame:GetTop()
54 | status.left = frame:GetLeft()
55 | end
56 |
57 | local function sizerseOnMouseDown(this)
58 | this:GetParent():StartSizing("BOTTOMRIGHT")
59 | AceGUI:ClearFocus()
60 | end
61 |
62 | local function sizersOnMouseDown(this)
63 | this:GetParent():StartSizing("BOTTOM")
64 | AceGUI:ClearFocus()
65 | end
66 |
67 | local function sizereOnMouseDown(this)
68 | this:GetParent():StartSizing("RIGHT")
69 | AceGUI:ClearFocus()
70 | end
71 |
72 | local function sizerOnMouseUp(this)
73 | this:GetParent():StopMovingOrSizing()
74 | end
75 |
76 | local function SetTitle(self,title)
77 | self.titletext:SetText(title)
78 | end
79 |
80 | local function SetStatusText(self,text)
81 | self.statustext:SetText(text)
82 | end
83 |
84 | local function Hide(self)
85 | self.frame:Hide()
86 | end
87 |
88 | local function Show(self)
89 | self.frame:Show()
90 | end
91 |
92 | local function OnAcquire(self)
93 | self.frame:SetParent(UIParent)
94 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
95 | self:ApplyStatus()
96 | end
97 |
98 | local function OnRelease(self)
99 | self.status = nil
100 | for k in pairs(self.localstatus) do
101 | self.localstatus[k] = nil
102 | end
103 | end
104 |
105 | -- called to set an external table to store status in
106 | local function SetStatusTable(self, status)
107 | assert(type(status) == "table")
108 | self.status = status
109 | self:ApplyStatus()
110 | end
111 |
112 | local function ApplyStatus(self)
113 | local status = self.status or self.localstatus
114 | local frame = self.frame
115 | self:SetWidth(status.width or 700)
116 | self:SetHeight(status.height or 500)
117 | if status.top and status.left then
118 | frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
119 | frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
120 | else
121 | frame:SetPoint("CENTER",UIParent,"CENTER")
122 | end
123 | end
124 |
125 | local function OnWidthSet(self, width)
126 | local content = self.content
127 | local contentwidth = width - 34
128 | if contentwidth < 0 then
129 | contentwidth = 0
130 | end
131 | content:SetWidth(contentwidth)
132 | content.width = contentwidth
133 | end
134 |
135 |
136 | local function OnHeightSet(self, height)
137 | local content = self.content
138 | local contentheight = height - 57
139 | if contentheight < 0 then
140 | contentheight = 0
141 | end
142 | content:SetHeight(contentheight)
143 | content.height = contentheight
144 | end
145 |
146 | local function Constructor()
147 | local frame = CreateFrame("Frame",nil,UIParent)
148 | local self = {}
149 | self.type = "Frame"
150 |
151 | self.Hide = Hide
152 | self.Show = Show
153 | self.SetTitle = SetTitle
154 | self.OnRelease = OnRelease
155 | self.OnAcquire = OnAcquire
156 | self.SetStatusText = SetStatusText
157 | self.SetStatusTable = SetStatusTable
158 | self.ApplyStatus = ApplyStatus
159 | self.OnWidthSet = OnWidthSet
160 | self.OnHeightSet = OnHeightSet
161 |
162 | self.localstatus = {}
163 |
164 | self.frame = frame
165 | frame.obj = self
166 | frame:SetWidth(700)
167 | frame:SetHeight(500)
168 | frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
169 | frame:EnableMouse()
170 | frame:SetMovable(true)
171 | frame:SetResizable(true)
172 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
173 | frame:SetScript("OnMouseDown", frameOnMouseDown)
174 |
175 | frame:SetBackdrop(FrameBackdrop)
176 | frame:SetBackdropColor(0,0,0,1)
177 | frame:SetScript("OnHide",frameOnClose)
178 | frame:SetMinResize(400,200)
179 | frame:SetToplevel(true)
180 |
181 | local closebutton = CreateFrame("Button",nil,frame,"UIPanelButtonTemplate")
182 | closebutton:SetScript("OnClick", closeOnClick)
183 | closebutton:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-27,17)
184 | closebutton:SetHeight(20)
185 | closebutton:SetWidth(100)
186 | closebutton:SetText(CLOSE)
187 |
188 | self.closebutton = closebutton
189 | closebutton.obj = self
190 |
191 | local statusbg = CreateFrame("Frame",nil,frame)
192 | statusbg:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",15,15)
193 | statusbg:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-132,15)
194 | statusbg:SetHeight(24)
195 | statusbg:SetBackdrop(PaneBackdrop)
196 | statusbg:SetBackdropColor(0.1,0.1,0.1)
197 | statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
198 | self.statusbg = statusbg
199 |
200 | local statustext = statusbg:CreateFontString(nil,"OVERLAY","GameFontNormal")
201 | self.statustext = statustext
202 | statustext:SetPoint("TOPLEFT",statusbg,"TOPLEFT",7,-2)
203 | statustext:SetPoint("BOTTOMRIGHT",statusbg,"BOTTOMRIGHT",-7,2)
204 | statustext:SetHeight(20)
205 | statustext:SetJustifyH("LEFT")
206 | statustext:SetText("")
207 |
208 | local title = CreateFrame("Frame",nil,frame)
209 | self.title = title
210 | title:EnableMouse()
211 | title:SetScript("OnMouseDown",titleOnMouseDown)
212 | title:SetScript("OnMouseUp", frameOnMouseUp)
213 |
214 |
215 | local titlebg = frame:CreateTexture(nil,"OVERLAY")
216 | titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
217 | titlebg:SetTexCoord(0.31,0.67,0,0.63)
218 | titlebg:SetPoint("TOP",frame,"TOP",0,12)
219 | titlebg:SetWidth(100)
220 | titlebg:SetHeight(40)
221 |
222 | local titlebg_l = frame:CreateTexture(nil,"OVERLAY")
223 | titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
224 | titlebg_l:SetTexCoord(0.21,0.31,0,0.63)
225 | titlebg_l:SetPoint("RIGHT",titlebg,"LEFT",0,0)
226 | titlebg_l:SetWidth(30)
227 | titlebg_l:SetHeight(40)
228 |
229 | local titlebg_right = frame:CreateTexture(nil,"OVERLAY")
230 | titlebg_right:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
231 | titlebg_right:SetTexCoord(0.67,0.77,0,0.63)
232 | titlebg_right:SetPoint("LEFT",titlebg,"RIGHT",0,0)
233 | titlebg_right:SetWidth(30)
234 | titlebg_right:SetHeight(40)
235 |
236 | title:SetAllPoints(titlebg)
237 | local titletext = title:CreateFontString(nil,"OVERLAY","GameFontNormal")
238 | titletext:SetPoint("TOP",titlebg,"TOP",0,-14)
239 |
240 | self.titletext = titletext
241 |
242 | local sizer_se = CreateFrame("Frame",nil,frame)
243 | sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
244 | sizer_se:SetWidth(25)
245 | sizer_se:SetHeight(25)
246 | sizer_se:EnableMouse()
247 | sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
248 | sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
249 | self.sizer_se = sizer_se
250 |
251 | local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
252 | self.line1 = line1
253 | line1:SetWidth(14)
254 | line1:SetHeight(14)
255 | line1:SetPoint("BOTTOMRIGHT", -8, 8)
256 | line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
257 | local x = 0.1 * 14/17
258 | line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
259 |
260 | local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
261 | self.line2 = line2
262 | line2:SetWidth(8)
263 | line2:SetHeight(8)
264 | line2:SetPoint("BOTTOMRIGHT", -8, 8)
265 | line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
266 | local x = 0.1 * 8/17
267 | line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
268 |
269 | local sizer_s = CreateFrame("Frame",nil,frame)
270 | sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
271 | sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
272 | sizer_s:SetHeight(25)
273 | sizer_s:EnableMouse()
274 | sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
275 | sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
276 | self.sizer_s = sizer_s
277 |
278 | local sizer_e = CreateFrame("Frame",nil,frame)
279 | sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
280 | sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
281 | sizer_e:SetWidth(25)
282 | sizer_e:EnableMouse()
283 | sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
284 | sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
285 | self.sizer_e = sizer_e
286 |
287 | --Container Support
288 | local content = CreateFrame("Frame",nil,frame)
289 | self.content = content
290 | content.obj = self
291 | content:SetPoint("TOPLEFT",frame,"TOPLEFT",17,-27)
292 | content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-17,40)
293 |
294 | AceGUI:RegisterAsContainer(self)
295 | return self
296 | end
297 |
298 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
299 | end
300 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-Window.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | ----------------
4 | -- Main Frame --
5 | ----------------
6 | --[[
7 | Events :
8 | OnClose
9 |
10 | ]]
11 | do
12 | local Type = "Window"
13 | local Version = 1
14 |
15 | local function frameOnClose(this)
16 | this.obj:Fire("OnClose")
17 | end
18 |
19 | local function closeOnClick(this)
20 | this.obj:Hide()
21 | end
22 |
23 | local function frameOnMouseDown(this)
24 | AceGUI:ClearFocus()
25 | end
26 |
27 | local function titleOnMouseDown(this)
28 | this:GetParent():StartMoving()
29 | AceGUI:ClearFocus()
30 | end
31 |
32 | local function frameOnMouseUp(this)
33 | local frame = this:GetParent()
34 | frame:StopMovingOrSizing()
35 | local self = frame.obj
36 | local status = self.status or self.localstatus
37 | status.width = frame:GetWidth()
38 | status.height = frame:GetHeight()
39 | status.top = frame:GetTop()
40 | status.left = frame:GetLeft()
41 | end
42 |
43 | local function sizerseOnMouseDown(this)
44 | this:GetParent():StartSizing("BOTTOMRIGHT")
45 | AceGUI:ClearFocus()
46 | end
47 |
48 | local function sizersOnMouseDown(this)
49 | this:GetParent():StartSizing("BOTTOM")
50 | AceGUI:ClearFocus()
51 | end
52 |
53 | local function sizereOnMouseDown(this)
54 | this:GetParent():StartSizing("RIGHT")
55 | AceGUI:ClearFocus()
56 | end
57 |
58 | local function sizerOnMouseUp(this)
59 | this:GetParent():StopMovingOrSizing()
60 | end
61 |
62 | local function SetTitle(self,title)
63 | self.titletext:SetText(title)
64 | end
65 |
66 | local function SetStatusText(self,text)
67 | -- self.statustext:SetText(text)
68 | end
69 |
70 | local function Hide(self)
71 | self.frame:Hide()
72 | end
73 |
74 | local function Show(self)
75 | self.frame:Show()
76 | end
77 |
78 | local function OnAcquire(self)
79 | self.frame:SetParent(UIParent)
80 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
81 | self:ApplyStatus()
82 | end
83 |
84 | local function OnRelease(self)
85 | self.status = nil
86 | for k in pairs(self.localstatus) do
87 | self.localstatus[k] = nil
88 | end
89 | end
90 |
91 | -- called to set an external table to store status in
92 | local function SetStatusTable(self, status)
93 | assert(type(status) == "table")
94 | self.status = status
95 | self:ApplyStatus()
96 | end
97 |
98 | local function ApplyStatus(self)
99 | local status = self.status or self.localstatus
100 | local frame = self.frame
101 | self:SetWidth(status.width or 700)
102 | self:SetHeight(status.height or 500)
103 | if status.top and status.left then
104 | frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
105 | frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
106 | else
107 | frame:SetPoint("CENTER",UIParent,"CENTER")
108 | end
109 | end
110 |
111 | local function OnWidthSet(self, width)
112 | local content = self.content
113 | local contentwidth = width - 34
114 | if contentwidth < 0 then
115 | contentwidth = 0
116 | end
117 | content:SetWidth(contentwidth)
118 | content.width = contentwidth
119 | end
120 |
121 |
122 | local function OnHeightSet(self, height)
123 | local content = self.content
124 | local contentheight = height - 57
125 | if contentheight < 0 then
126 | contentheight = 0
127 | end
128 | content:SetHeight(contentheight)
129 | content.height = contentheight
130 | end
131 |
132 | local function Constructor()
133 | local frame = CreateFrame("Frame",nil,UIParent)
134 | local self = {}
135 | self.type = "Window"
136 |
137 | self.Hide = Hide
138 | self.Show = Show
139 | self.SetTitle = SetTitle
140 | self.OnRelease = OnRelease
141 | self.OnAcquire = OnAcquire
142 | self.SetStatusText = SetStatusText
143 | self.SetStatusTable = SetStatusTable
144 | self.ApplyStatus = ApplyStatus
145 | self.OnWidthSet = OnWidthSet
146 | self.OnHeightSet = OnHeightSet
147 |
148 | self.localstatus = {}
149 |
150 | self.frame = frame
151 | frame.obj = self
152 | frame:SetWidth(700)
153 | frame:SetHeight(500)
154 | frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
155 | frame:EnableMouse()
156 | frame:SetMovable(true)
157 | frame:SetResizable(true)
158 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
159 | frame:SetScript("OnMouseDown", frameOnMouseDown)
160 |
161 | frame:SetScript("OnHide",frameOnClose)
162 | frame:SetMinResize(240,240)
163 | frame:SetToplevel(true)
164 |
165 | local titlebg = frame:CreateTexture(nil, "BACKGROUND")
166 | titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
167 | titlebg:SetPoint("TOPLEFT", 9, -6)
168 | titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
169 |
170 | local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
171 | dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
172 | dialogbg:SetPoint("TOPLEFT", 8, -24)
173 | dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
174 | dialogbg:SetVertexColor(0, 0, 0, .75)
175 |
176 | local topleft = frame:CreateTexture(nil, "BORDER")
177 | topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
178 | topleft:SetWidth(64)
179 | topleft:SetHeight(64)
180 | topleft:SetPoint("TOPLEFT")
181 | topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
182 |
183 | local topright = frame:CreateTexture(nil, "BORDER")
184 | topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
185 | topright:SetWidth(64)
186 | topright:SetHeight(64)
187 | topright:SetPoint("TOPRIGHT")
188 | topright:SetTexCoord(0.625, 0.75, 0, 1)
189 |
190 | local top = frame:CreateTexture(nil, "BORDER")
191 | top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
192 | top:SetHeight(64)
193 | top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
194 | top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
195 | top:SetTexCoord(0.25, 0.369140625, 0, 1)
196 |
197 | local bottomleft = frame:CreateTexture(nil, "BORDER")
198 | bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
199 | bottomleft:SetWidth(64)
200 | bottomleft:SetHeight(64)
201 | bottomleft:SetPoint("BOTTOMLEFT")
202 | bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
203 |
204 | local bottomright = frame:CreateTexture(nil, "BORDER")
205 | bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
206 | bottomright:SetWidth(64)
207 | bottomright:SetHeight(64)
208 | bottomright:SetPoint("BOTTOMRIGHT")
209 | bottomright:SetTexCoord(0.875, 1, 0, 1)
210 |
211 | local bottom = frame:CreateTexture(nil, "BORDER")
212 | bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
213 | bottom:SetHeight(64)
214 | bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
215 | bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
216 | bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
217 |
218 | local left = frame:CreateTexture(nil, "BORDER")
219 | left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
220 | left:SetWidth(64)
221 | left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
222 | left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
223 | left:SetTexCoord(0.001953125, 0.125, 0, 1)
224 |
225 | local right = frame:CreateTexture(nil, "BORDER")
226 | right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
227 | right:SetWidth(64)
228 | right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
229 | right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
230 | right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
231 |
232 | local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
233 | close:SetPoint("TOPRIGHT", 2, 1)
234 | close:SetScript("OnClick", closeOnClick)
235 | self.closebutton = close
236 | close.obj = self
237 |
238 | local titletext = frame:CreateFontString(nil, "ARTWORK")
239 | titletext:SetFontObject(GameFontNormal)
240 | titletext:SetPoint("TOPLEFT", 12, -8)
241 | titletext:SetPoint("TOPRIGHT", -32, -8)
242 | self.titletext = titletext
243 |
244 | local title = CreateFrame("Button", nil, frame)
245 | title:SetPoint("TOPLEFT", titlebg)
246 | title:SetPoint("BOTTOMRIGHT", titlebg)
247 | title:EnableMouse()
248 | title:SetScript("OnMouseDown",titleOnMouseDown)
249 | title:SetScript("OnMouseUp", frameOnMouseUp)
250 | self.title = title
251 |
252 | local sizer_se = CreateFrame("Frame",nil,frame)
253 | sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
254 | sizer_se:SetWidth(25)
255 | sizer_se:SetHeight(25)
256 | sizer_se:EnableMouse()
257 | sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
258 | sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
259 | self.sizer_se = sizer_se
260 |
261 | local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
262 | self.line1 = line1
263 | line1:SetWidth(14)
264 | line1:SetHeight(14)
265 | line1:SetPoint("BOTTOMRIGHT", -8, 8)
266 | line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
267 | local x = 0.1 * 14/17
268 | line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
269 |
270 | local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
271 | self.line2 = line2
272 | line2:SetWidth(8)
273 | line2:SetHeight(8)
274 | line2:SetPoint("BOTTOMRIGHT", -8, 8)
275 | line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
276 | local x = 0.1 * 8/17
277 | line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
278 |
279 | local sizer_s = CreateFrame("Frame",nil,frame)
280 | sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
281 | sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
282 | sizer_s:SetHeight(25)
283 | sizer_s:EnableMouse()
284 | sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
285 | sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
286 | self.sizer_s = sizer_s
287 |
288 | local sizer_e = CreateFrame("Frame",nil,frame)
289 | sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
290 | sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
291 | sizer_e:SetWidth(25)
292 | sizer_e:EnableMouse()
293 | sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
294 | sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
295 | self.sizer_e = sizer_e
296 |
297 | --Container Support
298 | local content = CreateFrame("Frame",nil,frame)
299 | self.content = content
300 | content.obj = self
301 | content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
302 | content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
303 |
304 | AceGUI:RegisterAsContainer(self)
305 | return self
306 | end
307 |
308 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
309 | end
310 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua:
--------------------------------------------------------------------------------
1 |
2 | --[[
3 | --Multiline Editbox Widget, Originally by bam
4 |
5 | --]]
6 | local assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall =
7 | assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall
8 | local getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack =
9 | getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack
10 | local math, string, table = math, string, table
11 | local find, format, gmatch, gsub, tolower, match, toupper, join, split, trim =
12 | string.find, string.format, string.gmatch, string.gsub, string.lower, string.match, string.upper, string.join, string.split, string.trim
13 | local concat, insert, maxn, remove, sort = table.concat, table.insert, table.maxn, table.remove, table.sort
14 | local max, min, abs, ceil, floor = math.max, math.min, math.abs, math.ceil, math.floor
15 |
16 | local LibStub = assert(LibStub)
17 |
18 | local ChatFontNormal = ChatFontNormal
19 | local ClearCursor = ClearCursor
20 | local CreateFrame = CreateFrame
21 | local GetCursorInfo = GetCursorInfo
22 | local GetSpellName = GetSpellName
23 | local UIParent = UIParent
24 | local UISpecialFrames = UISpecialFrames
25 |
26 | -- No global variables after this!
27 |
28 | local _G = getfenv()
29 |
30 | local AceGUI = LibStub("AceGUI-3.0")
31 |
32 | local Version = 10
33 | ---------------------
34 | -- Common Elements --
35 | ---------------------
36 |
37 | local FrameBackdrop = {
38 | bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
39 | edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
40 | tile = true, tileSize = 32, edgeSize = 32,
41 | insets = { left = 8, right = 8, top = 8, bottom = 8 }
42 | }
43 |
44 | local PaneBackdrop = {
45 |
46 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
47 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
48 | tile = true, tileSize = 16, edgeSize = 16,
49 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
50 | }
51 |
52 | local ControlBackdrop = {
53 | bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
54 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
55 | tile = true, tileSize = 16, edgeSize = 16,
56 | insets = { left = 3, right = 3, top = 3, bottom = 3 }
57 | }
58 |
59 | --------------------------
60 | -- Edit box --
61 | --------------------------
62 | --[[
63 | Events :
64 | OnTextChanged
65 | OnEnterPressed
66 |
67 | ]]
68 | do
69 | local Type = "MultiLineEditBox"
70 |
71 | local MultiLineEditBox = {}
72 |
73 | local function EditBox_OnEnterPressed(this)
74 | local self = this.obj
75 | local value = this:GetText()
76 | local cancel = self:Fire("OnEnterPressed",value)
77 | if not cancel then
78 | self.button:Disable()
79 | end
80 | end
81 |
82 | local function Button_OnClick(this)
83 | local editbox = this.obj.editbox
84 | editbox:ClearFocus()
85 | EditBox_OnEnterPressed(editbox)
86 | end
87 |
88 | local function EditBox_OnReceiveDrag(this)
89 | local self = this.obj
90 | local type, id, info = GetCursorInfo()
91 | if type == "item" then
92 | self:SetText(info)
93 | self:Fire("OnEnterPressed",info)
94 | ClearCursor()
95 | elseif type == "spell" then
96 | local name, rank = GetSpellName(id, info)
97 | if rank and rank:match("%d") then
98 | name = name.."("..rank..")"
99 | end
100 | self:SetText(name)
101 | self:Fire("OnEnterPressed",name)
102 | ClearCursor()
103 | end
104 | --self.button:Disable()
105 | AceGUI:ClearFocus()
106 | end
107 |
108 | function MultiLineEditBox:OnAcquire()
109 | self:SetWidth(200)
110 | self:SetHeight(116)
111 | self:SetNumLines(4)
112 | self:SetDisabled(false)
113 | self:ShowButton(true)
114 | end
115 |
116 | function MultiLineEditBox:OnRelease()
117 | self.frame:ClearAllPoints()
118 | self.frame:Hide()
119 | self:SetDisabled(false)
120 | end
121 |
122 | function MultiLineEditBox:SetDisabled(disabled)
123 | self.disabled = disabled
124 | if disabled then
125 | self.editbox:EnableMouse(false)
126 | self.scrollframe:EnableMouse(false)
127 | self.editbox:ClearFocus()
128 | self.editbox:SetTextColor(0.5, 0.5, 0.5)
129 | self.label:SetTextColor(0.5,0.5,0.5)
130 | else
131 | self.editbox:EnableMouse(true)
132 | self.scrollframe:EnableMouse(true)
133 | self.editbox:SetTextColor(1, 1, 1)
134 | self.label:SetTextColor(1,.82,0)
135 | end
136 | end
137 |
138 | function MultiLineEditBox:SetText(text)
139 | text = text or ""
140 | local editbox = self.editbox
141 | local oldText = editbox:GetText()
142 | local dummy = format(" %s", text)
143 | self.lasttext = dummy -- prevents OnTextChanged from firing
144 | editbox:SetText(dummy)
145 | editbox:HighlightText(0, 1)
146 | self.lasttext = oldText
147 | editbox:Insert("")
148 | end
149 |
150 | function MultiLineEditBox:SetLabel(text)
151 | if (text or "") == "" then
152 | self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,0)
153 | self.label:Hide()
154 | self.label:SetText("")
155 | else
156 | self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-20)
157 | self.label:Show()
158 | self.label:SetText(text)
159 | end
160 | end
161 |
162 | function MultiLineEditBox:SetNumLines(number)
163 | number = number or 4
164 | self:SetHeight(60 + (14*number))
165 | end
166 |
167 | function MultiLineEditBox:GetText()
168 | return self.editbox:GetText()
169 | end
170 |
171 | function MultiLineEditBox:ShowButton(show)
172 | if show then
173 | self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,22)
174 | self.button:Show()
175 | else
176 | self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
177 | self.button:Hide()
178 | end
179 | end
180 |
181 | local function Constructor()
182 | local frame = CreateFrame("Frame", nil, UIParent)
183 | local backdrop = CreateFrame("Frame", nil, frame)
184 | local self = {}
185 | for k, v in pairs(MultiLineEditBox) do self[k] = v end
186 | self.type = Type
187 | self.frame = frame
188 | self.backdrop = backdrop
189 | frame.obj = self
190 |
191 | backdrop:SetBackdrop(ControlBackdrop)
192 | backdrop:SetBackdropColor(0, 0, 0)
193 | backdrop:SetBackdropBorderColor(0.4, 0.4, 0.4)
194 |
195 | backdrop:SetPoint("TOPLEFT",frame,"TOPLEFT",0, -20)
196 | backdrop:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,22)
197 |
198 | local scrollframe = CreateFrame("ScrollFrame", format("%s@%s@%s", Type, "ScrollFrame", tostring(self)), backdrop, "UIPanelScrollFrameTemplate")
199 | scrollframe:SetPoint("TOPLEFT", 5, -6)
200 | scrollframe:SetPoint("BOTTOMRIGHT", -28, 6)
201 | scrollframe.obj = self
202 | self.scrollframe = scrollframe
203 |
204 | --local scrollchild = CreateFrame("Frame", nil, scrollframe)
205 | --scrollframe:SetScrollChild(scrollchild)
206 | --scrollchild:SetHeight(2)
207 | --scrollchild:SetWidth(2)
208 |
209 | local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
210 | label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2)
211 | label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2)
212 | label:SetJustifyH("LEFT")
213 | label:SetHeight(18)
214 | self.label = label
215 |
216 | local editbox = CreateFrame("EditBox", nil, scrollframe)
217 | self.editbox = editbox
218 | editbox.obj = self
219 | editbox:SetPoint("TOPLEFT")
220 | editbox:SetPoint("BOTTOMLEFT")
221 | editbox:SetHeight(50)
222 | editbox:SetWidth(50)
223 | editbox:SetMultiLine(true)
224 | -- editbox:SetMaxLetters(7500)
225 | editbox:SetTextInsets(5, 5, 3, 3)
226 | editbox:EnableMouse(true)
227 | editbox:SetAutoFocus(false)
228 | editbox:SetFontObject(ChatFontNormal)
229 | scrollframe:SetScrollChild(editbox)
230 |
231 | local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate")
232 | button:SetWidth(80)
233 | button:SetHeight(20)
234 | button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2)
235 | button:SetText(ACCEPT)
236 | button:SetScript("OnClick", Button_OnClick)
237 | button:SetFrameLevel(editbox:GetFrameLevel() + 1)
238 | button:Disable()
239 | button:Hide()
240 | self.button = button
241 | button.obj = self
242 |
243 | scrollframe:EnableMouse(true)
244 | scrollframe:SetScript("OnMouseUp", function() editbox:SetFocus() end)
245 | scrollframe:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end)
246 | scrollframe:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end)
247 |
248 | editbox:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end)
249 | editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end)
250 |
251 | local function FixSize()
252 | --scrollchild:SetHeight(scrollframe:GetHeight())
253 | --scrollchild:SetWidth(scrollframe:GetWidth())
254 | editbox:SetWidth(scrollframe:GetWidth())
255 | end
256 | scrollframe:SetScript("OnShow", FixSize)
257 | scrollframe:SetScript("OnSizeChanged", FixSize)
258 |
259 | editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
260 | editbox:SetScript("OnTextChanged", function(_, ...)
261 | scrollframe:UpdateScrollChildRect()
262 | local value = editbox:GetText()
263 | if value ~= self.lasttext then
264 | self:Fire("OnTextChanged", value)
265 | self.lasttext = value
266 | self.button:Enable()
267 | end
268 | end)
269 |
270 | editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
271 | editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
272 |
273 | do
274 | local cursorOffset, cursorHeight
275 | local idleTime
276 | local function FixScroll(_, elapsed)
277 | if cursorOffset and cursorHeight then
278 | idleTime = 0
279 | local height = scrollframe:GetHeight()
280 | local range = scrollframe:GetVerticalScrollRange()
281 | local scroll = scrollframe:GetVerticalScroll()
282 | local size = height + range
283 | cursorOffset = -cursorOffset
284 | while cursorOffset < scroll do
285 | scroll = scroll - (height / 2)
286 | if scroll < 0 then scroll = 0 end
287 | scrollframe:SetVerticalScroll(scroll)
288 | end
289 | while cursorOffset + cursorHeight > scroll + height and scroll < range do
290 | scroll = scroll + (height / 2)
291 | if scroll > range then scroll = range end
292 | scrollframe:SetVerticalScroll(scroll)
293 | end
294 | elseif not idleTime or idleTime > 2 then
295 | frame:SetScript("OnUpdate", nil)
296 | idleTime = nil
297 | else
298 | idleTime = idleTime + elapsed
299 | end
300 | cursorOffset = nil
301 | end
302 | editbox:SetScript("OnCursorChanged", function(_, x, y, w, h)
303 | cursorOffset, cursorHeight = y, h
304 | if not idleTime then
305 | frame:SetScript("OnUpdate", FixScroll)
306 | end
307 | end)
308 | end
309 |
310 | AceGUI:RegisterAsWidget(self)
311 | return self
312 | end
313 |
314 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
315 | end
316 |
317 |
318 |
319 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-TabGroup.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | -------------
4 | -- Widgets --
5 | -------------
6 | --[[
7 | Widgets must provide the following functions
8 | Acquire() - Called when the object is aquired, should set everything to a default hidden state
9 | Release() - Called when the object is Released, should remove any anchors and hide the Widget
10 |
11 | And the following members
12 | frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
13 | type - the type of the object, same as the name given to :RegisterWidget()
14 |
15 | Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
16 | It will be cleared automatically when a widget is released
17 | Placing values directly into a widget object should be avoided
18 |
19 | If the Widget can act as a container for other Widgets the following
20 | content - frame or derivitive that children will be anchored to
21 |
22 | The Widget can supply the following Optional Members
23 |
24 |
25 | ]]
26 |
27 | --------------------------
28 | -- Tab Group --
29 | --------------------------
30 |
31 | do
32 | local Type = "TabGroup"
33 | local Version = 22
34 |
35 | local PaneBackdrop = {
36 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
37 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
38 | tile = true, tileSize = 16, edgeSize = 16,
39 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
40 | }
41 |
42 | local function OnAcquire(self)
43 |
44 | end
45 |
46 | local function OnRelease(self)
47 | self.frame:ClearAllPoints()
48 | self.frame:Hide()
49 | self.status = nil
50 | for k in pairs(self.localstatus) do
51 | self.localstatus[k] = nil
52 | end
53 | self.tablist = nil
54 | for _, tab in pairs(self.tabs) do
55 | tab:Hide()
56 | end
57 | self:SetTitle()
58 | end
59 |
60 | local function Tab_SetText(self, text)
61 | self:_SetText(text)
62 | local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0
63 | PanelTemplates_TabResize(self, 0, nil, width)
64 | end
65 |
66 | local function UpdateTabLook(self)
67 | if self.disabled then
68 | PanelTemplates_SetDisabledTabState(self)
69 | elseif self.selected then
70 | PanelTemplates_SelectTab(self)
71 | else
72 | PanelTemplates_DeselectTab(self)
73 | end
74 | end
75 |
76 | local function Tab_SetSelected(self, selected)
77 | self.selected = selected
78 | UpdateTabLook(self)
79 | end
80 |
81 | local function Tab_OnClick(self)
82 | if not (self.selected or self.disabled) then
83 | self.obj:SelectTab(self.value)
84 | end
85 | end
86 |
87 | local function Tab_SetDisabled(self, disabled)
88 | self.disabled = disabled
89 | UpdateTabLook(self)
90 | end
91 |
92 | local function Tab_OnEnter(this)
93 | local self = this.obj
94 | self:Fire("OnTabEnter", self.tabs[this.id].value, this)
95 | end
96 |
97 | local function Tab_OnLeave(this)
98 | local self = this.obj
99 | self:Fire("OnTabLeave", self.tabs[this.id].value, this)
100 | end
101 |
102 | local function Tab_OnShow(this)
103 | _G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
104 | end
105 |
106 | local function CreateTab(self, id)
107 | local tabname = "AceGUITabGroup"..self.num.."Tab"..id
108 | local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate")
109 | tab.obj = self
110 | tab.id = id
111 |
112 | tab.text = _G[tabname .. "Text"]
113 | tab.text:ClearAllPoints()
114 | tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3)
115 | tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3)
116 |
117 | tab:SetScript("OnClick",Tab_OnClick)
118 | tab:SetScript("OnEnter",Tab_OnEnter)
119 | tab:SetScript("OnLeave",Tab_OnLeave)
120 | tab:SetScript("OnShow", Tab_OnShow)
121 |
122 | tab._SetText = tab.SetText
123 | tab.SetText = Tab_SetText
124 | tab.SetSelected = Tab_SetSelected
125 | tab.SetDisabled = Tab_SetDisabled
126 |
127 | return tab
128 | end
129 |
130 | local function SetTitle(self, text)
131 | self.titletext:SetText(text or "")
132 | if text and text ~= "" then
133 | self.alignoffset = 25
134 | else
135 | self.alignoffset = 18
136 | end
137 | self:BuildTabs()
138 | end
139 |
140 | -- called to set an external table to store status in
141 | local function SetStatusTable(self, status)
142 | assert(type(status) == "table")
143 | self.status = status
144 | end
145 |
146 | local function SelectTab(self, value)
147 | local status = self.status or self.localstatus
148 |
149 | local found
150 | for i, v in ipairs(self.tabs) do
151 | if v.value == value then
152 | v:SetSelected(true)
153 | found = true
154 | else
155 | v:SetSelected(false)
156 | end
157 | end
158 | status.selected = value
159 | if found then
160 | self:Fire("OnGroupSelected",value)
161 | end
162 | end
163 |
164 | local function SetTabs(self, tabs)
165 | self.tablist = tabs
166 | self:BuildTabs()
167 | end
168 |
169 |
170 | local widths = {}
171 | local rowwidths = {}
172 | local rowends = {}
173 | local function BuildTabs(self)
174 | local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
175 | local status = self.status or self.localstatus
176 | local tablist = self.tablist
177 | local tabs = self.tabs
178 |
179 | if not tablist then return end
180 |
181 | local width = self.frame.width or self.frame:GetWidth() or 0
182 |
183 | for i = #widths, 1, -1 do
184 | widths[i] = nil
185 | end
186 | for i = #rowwidths, 1, -1 do
187 | rowwidths[i] = nil
188 | end
189 | for i = #rowends, 1, -1 do
190 | rowends[i] = nil
191 | end
192 |
193 | --Place Text into tabs and get thier initial width
194 | for i, v in ipairs(tablist) do
195 | local tab = tabs[i]
196 | if not tab then
197 | tab = self:CreateTab(i)
198 | tabs[i] = tab
199 | end
200 |
201 | tab:Show()
202 | tab:SetText(v.text)
203 | tab:SetDisabled(v.disabled)
204 | tab.value = v.value
205 |
206 | widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
207 | end
208 |
209 | for i = (#tablist)+1, #tabs, 1 do
210 | tabs[i]:Hide()
211 | end
212 |
213 | --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
214 | local numtabs = #tablist
215 | local numrows = 1
216 | local usedwidth = 0
217 |
218 | for i = 1, #tablist do
219 | --If this is not the first tab of a row and there isn't room for it
220 | if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
221 | rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
222 | rowends[numrows] = i - 1
223 | numrows = numrows + 1
224 | usedwidth = 0
225 | end
226 | usedwidth = usedwidth + widths[i]
227 | end
228 | rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
229 | rowends[numrows] = #tablist
230 |
231 | --Fix for single tabs being left on the last row, move a tab from the row above if applicable
232 | if numrows > 1 then
233 | --if the last row has only one tab
234 | if rowends[numrows-1] == numtabs-1 then
235 | --if there are more than 2 tabs in the 2nd last row
236 | if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
237 | --move 1 tab from the second last row to the last, if there is enough space
238 | if (rowwidths[numrows] + widths[numtabs-1]) <= width then
239 | rowends[numrows-1] = rowends[numrows-1] - 1
240 | rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
241 | rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
242 | end
243 | end
244 | end
245 | end
246 |
247 | --anchor the rows as defined and resize tabs to fill thier row
248 | local starttab = 1
249 | for row, endtab in ipairs(rowends) do
250 | local first = true
251 | for tabno = starttab, endtab do
252 | local tab = tabs[tabno]
253 | tab:ClearAllPoints()
254 | if first then
255 | tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
256 | first = false
257 | else
258 | tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
259 | end
260 | end
261 |
262 | -- equal padding for each tab to fill the available width,
263 | -- if the used space is above 75% already
264 | local padding = 0
265 | if not (numrows == 1 and rowwidths[1] < width*0.75) then
266 | padding = (width - rowwidths[row]) / (endtab - starttab+1)
267 | end
268 |
269 | for i = starttab, endtab do
270 | PanelTemplates_TabResize(tabs[i], padding + 4, nil, width)
271 | end
272 | starttab = endtab + 1
273 | end
274 |
275 | self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
276 | self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",3,-self.borderoffset)
277 | end
278 |
279 | local function BuildTabsOnUpdate(this)
280 | BuildTabs(this.obj)
281 | this:SetScript("OnUpdate", nil)
282 | end
283 |
284 | local function OnWidthSet(self, width)
285 | local content = self.content
286 | local contentwidth = width - 60
287 | if contentwidth < 0 then
288 | contentwidth = 0
289 | end
290 | content:SetWidth(contentwidth)
291 | content.width = contentwidth
292 | BuildTabs(self)
293 | self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
294 | end
295 |
296 |
297 | local function OnHeightSet(self, height)
298 | local content = self.content
299 | local contentheight = height - (self.borderoffset + 23)
300 | if contentheight < 0 then
301 | contentheight = 0
302 | end
303 | content:SetHeight(contentheight)
304 | content.height = contentheight
305 | end
306 |
307 | local function LayoutFinished(self, width, height)
308 | if self.noAutoHeight then return end
309 | self:SetHeight((height or 0) + (self.borderoffset + 23))
310 | end
311 |
312 | local function Constructor()
313 | local frame = CreateFrame("Frame",nil,UIParent)
314 | local self = {}
315 | self.type = Type
316 |
317 | self.num = AceGUI:GetNextWidgetNum(Type)
318 |
319 | self.localstatus = {}
320 |
321 | self.OnRelease = OnRelease
322 | self.OnAcquire = OnAcquire
323 | self.SetTitle = SetTitle
324 | self.CreateTab = CreateTab
325 | self.SelectTab = SelectTab
326 | self.BuildTabs = BuildTabs
327 | self.SetStatusTable = SetStatusTable
328 | self.SetTabs = SetTabs
329 | self.LayoutFinished = LayoutFinished
330 | self.frame = frame
331 |
332 | self.OnWidthSet = OnWidthSet
333 | self.OnHeightSet = OnHeightSet
334 |
335 | frame.obj = self
336 |
337 | frame:SetHeight(100)
338 | frame:SetWidth(100)
339 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
340 |
341 | self.alignoffset = 18
342 |
343 | local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
344 | titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
345 | titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
346 | titletext:SetJustifyH("LEFT")
347 | titletext:SetHeight(18)
348 | titletext:SetText("")
349 |
350 | self.titletext = titletext
351 |
352 | local border = CreateFrame("Frame",nil,frame)
353 | self.border = border
354 | self.borderoffset = 27
355 | border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27)
356 | border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
357 |
358 | border:SetBackdrop(PaneBackdrop)
359 | border:SetBackdropColor(0.1,0.1,0.1,0.5)
360 | border:SetBackdropBorderColor(0.4,0.4,0.4)
361 |
362 | self.tabs = {}
363 |
364 | --Container Support
365 | local content = CreateFrame("Frame",nil,border)
366 | self.content = content
367 | content.obj = self
368 | content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
369 | content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
370 |
371 | AceGUI:RegisterAsContainer(self)
372 | return self
373 | end
374 |
375 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
376 | end
377 |
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua:
--------------------------------------------------------------------------------
1 | --[[ $Id: AceGUIWidget-DropDown-Items.lua 808 2009-05-07 14:45:15Z ammo $ ]]--
2 |
3 | local AceGUI = LibStub("AceGUI-3.0")
4 |
5 | local function fixlevels(parent,...)
6 | local i = 1
7 | local child = select(i, ...)
8 | while child do
9 | child:SetFrameLevel(parent:GetFrameLevel()+1)
10 | fixlevels(child, child:GetChildren())
11 | i = i + 1
12 | child = select(i, ...)
13 | end
14 | end
15 |
16 | local function fixstrata(strata, parent, ...)
17 | local i = 1
18 | local child = select(i, ...)
19 | parent:SetFrameStrata(strata)
20 | while child do
21 | fixstrata(strata, child, child:GetChildren())
22 | i = i + 1
23 | child = select(i, ...)
24 | end
25 | end
26 |
27 | -- ItemBase is the base "class" for all dropdown items.
28 | -- Each item has to use ItemBase.Create(widgetType) to
29 | -- create an initial 'self' value.
30 | -- ItemBase will add common functions and ui event handlers.
31 | -- Be sure to keep basic usage when you override functions.
32 |
33 | local ItemBase = {
34 | -- NOTE: The ItemBase version is added to each item's version number
35 | -- to ensure proper updates on ItemBase changes.
36 | -- Use at least 1000er steps.
37 | version = 1000,
38 | counter = 0,
39 | }
40 |
41 | function ItemBase.Frame_OnEnter(this)
42 | local self = this.obj
43 |
44 | if self.useHighlight then
45 | self.highlight:Show()
46 | end
47 | self:Fire("OnEnter")
48 |
49 | if self.specialOnEnter then
50 | self.specialOnEnter(self)
51 | end
52 | end
53 |
54 | function ItemBase.Frame_OnLeave(this)
55 | local self = this.obj
56 |
57 | self.highlight:Hide()
58 | self:Fire("OnLeave")
59 |
60 | if self.specialOnLeave then
61 | self.specialOnLeave(self)
62 | end
63 | end
64 |
65 | -- exported, AceGUI callback
66 | function ItemBase.OnAcquire(self)
67 | self.frame:SetToplevel(true)
68 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
69 | end
70 |
71 | -- exported, AceGUI callback
72 | function ItemBase.OnRelease(self)
73 | self:SetDisabled(false)
74 | self.pullout = nil
75 | self.frame:SetParent(nil)
76 | self.frame:ClearAllPoints()
77 | self.frame:Hide()
78 | end
79 |
80 | -- exported
81 | -- NOTE: this is called by a Dropdown-Pullout.
82 | -- Do not call this method directly
83 | function ItemBase.SetPullout(self, pullout)
84 | self.pullout = pullout
85 |
86 | self.frame:SetParent(nil)
87 | self.frame:SetParent(pullout.itemFrame)
88 | self.parent = pullout.itemFrame
89 | fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
90 | end
91 |
92 | -- exported
93 | function ItemBase.SetText(self, text)
94 | self.text:SetText(text or "")
95 | end
96 |
97 | -- exported
98 | function ItemBase.GetText(self)
99 | return self.text:GetText()
100 | end
101 |
102 | -- exported
103 | function ItemBase.SetPoint(self, ...)
104 | self.frame:SetPoint(...)
105 | end
106 |
107 | -- exported
108 | function ItemBase.Show(self)
109 | self.frame:Show()
110 | end
111 |
112 | -- exported
113 | function ItemBase.Hide(self)
114 | self.frame:Hide()
115 | end
116 |
117 | -- exported
118 | function ItemBase.SetDisabled(self, disabled)
119 | self.disabled = disabled
120 | if disabled then
121 | self.useHighlight = false
122 | self.text:SetTextColor(.5, .5, .5)
123 | else
124 | self.useHighlight = true
125 | self.text:SetTextColor(1, 1, 1)
126 | end
127 | end
128 |
129 | -- exported
130 | -- NOTE: this is called by a Dropdown-Pullout.
131 | -- Do not call this method directly
132 | function ItemBase.SetOnLeave(self, func)
133 | self.specialOnLeave = func
134 | end
135 |
136 | -- exported
137 | -- NOTE: this is called by a Dropdown-Pullout.
138 | -- Do not call this method directly
139 | function ItemBase.SetOnEnter(self, func)
140 | self.specialOnEnter = func
141 | end
142 |
143 | function ItemBase.Create(type)
144 | -- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget
145 | local count = AceGUI:GetNextWidgetNum(type)
146 | local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count)
147 | local self = {}
148 | self.frame = frame
149 | frame.obj = self
150 | self.type = type
151 |
152 | self.useHighlight = true
153 |
154 | frame:SetHeight(17)
155 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
156 |
157 | local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
158 | text:SetTextColor(1,1,1)
159 | text:SetJustifyH("LEFT")
160 | text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
161 | text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
162 | self.text = text
163 |
164 | local highlight = frame:CreateTexture(nil, "OVERLAY")
165 | highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
166 | highlight:SetBlendMode("ADD")
167 | highlight:SetHeight(14)
168 | highlight:ClearAllPoints()
169 | highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
170 | highlight:SetPoint("LEFT",frame,"LEFT",5,0)
171 | highlight:Hide()
172 | self.highlight = highlight
173 |
174 | local check = frame:CreateTexture("OVERLAY")
175 | check:SetWidth(16)
176 | check:SetHeight(16)
177 | check:SetPoint("LEFT",frame,"LEFT",3,-1)
178 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
179 | check:Hide()
180 | self.check = check
181 |
182 | local sub = frame:CreateTexture("OVERLAY")
183 | sub:SetWidth(16)
184 | sub:SetHeight(16)
185 | sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
186 | sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
187 | sub:Hide()
188 | self.sub = sub
189 |
190 | frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
191 | frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
192 |
193 | self.OnAcquire = ItemBase.OnAcquire
194 | self.OnRelease = ItemBase.OnRelease
195 |
196 | self.SetPullout = ItemBase.SetPullout
197 | self.GetText = ItemBase.GetText
198 | self.SetText = ItemBase.SetText
199 | self.SetDisabled = ItemBase.SetDisabled
200 |
201 | self.SetPoint = ItemBase.SetPoint
202 | self.Show = ItemBase.Show
203 | self.Hide = ItemBase.Hide
204 |
205 | self.SetOnLeave = ItemBase.SetOnLeave
206 | self.SetOnEnter = ItemBase.SetOnEnter
207 |
208 | return self
209 | end
210 |
211 | --[[
212 | Template for items:
213 |
214 | -- Item:
215 | --
216 | do
217 | local widgetType = "Dropdown-Item-"
218 | local widgetVersion = 1
219 |
220 | local function Constructor()
221 | local self = ItemBase.Create(widgetType)
222 |
223 | AceGUI:RegisterAsWidget(self)
224 | return self
225 | end
226 |
227 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
228 | end
229 | --]]
230 |
231 | -- Item: Header
232 | -- A single text entry.
233 | -- Special: Different text color and no highlight
234 | do
235 | local widgetType = "Dropdown-Item-Header"
236 | local widgetVersion = 1
237 |
238 | local function OnEnter(this)
239 | local self = this.obj
240 | self:Fire("OnEnter")
241 |
242 | if self.specialOnEnter then
243 | self.specialOnEnter(self)
244 | end
245 | end
246 |
247 | local function OnLeave(this)
248 | local self = this.obj
249 | self:Fire("OnLeave")
250 |
251 | if self.specialOnLeave then
252 | self.specialOnLeave(self)
253 | end
254 | end
255 |
256 | -- exported, override
257 | local function SetDisabled(self, disabled)
258 | ItemBase.SetDisabled(self, disabled)
259 | if not disabled then
260 | self.text:SetTextColor(1, 1, 0)
261 | end
262 | end
263 |
264 | local function Constructor()
265 | local self = ItemBase.Create(widgetType)
266 |
267 | self.SetDisabled = SetDisabled
268 |
269 | self.frame:SetScript("OnEnter", OnEnter)
270 | self.frame:SetScript("OnLeave", OnLeave)
271 |
272 | self.text:SetTextColor(1, 1, 0)
273 |
274 | AceGUI:RegisterAsWidget(self)
275 | return self
276 | end
277 |
278 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
279 | end
280 |
281 | -- Item: Execute
282 | -- A simple button
283 | do
284 | local widgetType = "Dropdown-Item-Execute"
285 | local widgetVersion = 1
286 |
287 | local function Frame_OnClick(this, button)
288 | local self = this.obj
289 | if self.disabled then return end
290 | self:Fire("OnClick")
291 | if self.pullout then
292 | self.pullout:Close()
293 | end
294 | end
295 |
296 | local function Constructor()
297 | local self = ItemBase.Create(widgetType)
298 |
299 | self.frame:SetScript("OnClick", Frame_OnClick)
300 |
301 | AceGUI:RegisterAsWidget(self)
302 | return self
303 | end
304 |
305 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
306 | end
307 |
308 | -- Item: Toggle
309 | -- Some sort of checkbox for dropdown menus.
310 | -- Does not close the pullout on click.
311 | do
312 | local widgetType = "Dropdown-Item-Toggle"
313 | local widgetVersion = 2
314 |
315 | local function UpdateToggle(self)
316 | if self.value then
317 | self.check:Show()
318 | else
319 | self.check:Hide()
320 | end
321 | end
322 |
323 | local function OnRelease(self)
324 | ItemBase.OnRelease(self)
325 | self:SetValue(nil)
326 | end
327 |
328 | local function Frame_OnClick(this, button)
329 | local self = this.obj
330 | if self.disabled then return end
331 | self.value = not self.value
332 | UpdateToggle(self)
333 | self:Fire("OnValueChanged", self.value)
334 | end
335 |
336 | -- exported
337 | local function SetValue(self, value)
338 | self.value = value
339 | UpdateToggle(self)
340 | end
341 |
342 | -- exported
343 | local function GetValue(self)
344 | return self.value
345 | end
346 |
347 | local function Constructor()
348 | local self = ItemBase.Create(widgetType)
349 |
350 | self.frame:SetScript("OnClick", Frame_OnClick)
351 |
352 | self.SetValue = SetValue
353 | self.GetValue = GetValue
354 | self.OnRelease = OnRelease
355 |
356 | AceGUI:RegisterAsWidget(self)
357 | return self
358 | end
359 |
360 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
361 | end
362 |
363 | -- Item: Menu
364 | -- Shows a submenu on mouse over
365 | -- Does not close the pullout on click
366 | do
367 | local widgetType = "Dropdown-Item-Menu"
368 | local widgetVersion = 2
369 |
370 | local function OnEnter(this)
371 | local self = this.obj
372 | self:Fire("OnEnter")
373 |
374 | if self.specialOnEnter then
375 | self.specialOnEnter(self)
376 | end
377 |
378 | self.highlight:Show()
379 |
380 | if not self.disabled and self.submenu then
381 | self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
382 | end
383 | end
384 |
385 | local function OnHide(this)
386 | local self = this.obj
387 | if self.submenu then
388 | self.submenu:Close()
389 | end
390 | end
391 |
392 | -- exported
393 | local function SetMenu(self, menu)
394 | assert(menu.type == "Dropdown-Pullout")
395 | self.submenu = menu
396 | end
397 |
398 | -- exported
399 | local function CloseMenu(self)
400 | self.submenu:Close()
401 | end
402 |
403 | local function Constructor()
404 | local self = ItemBase.Create(widgetType)
405 |
406 | self.sub:Show()
407 |
408 | self.frame:SetScript("OnEnter", OnEnter)
409 | self.frame:SetScript("OnHide", OnHide)
410 |
411 | self.SetMenu = SetMenu
412 | self.CloseMenu = CloseMenu
413 |
414 | AceGUI:RegisterAsWidget(self)
415 | return self
416 | end
417 |
418 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
419 | end
420 |
421 | -- Item: Separator
422 | -- A single line to separate items
423 | do
424 | local widgetType = "Dropdown-Item-Separator"
425 | local widgetVersion = 1
426 |
427 | -- exported, override
428 | local function SetDisabled(self, disabled)
429 | ItemBase.SetDisabled(self, disabled)
430 | self.useHighlight = false
431 | end
432 |
433 | local function Constructor()
434 | local self = ItemBase.Create(widgetType)
435 |
436 | self.SetDisabled = SetDisabled
437 |
438 | local line = self.frame:CreateTexture(nil, "OVERLAY")
439 | line:SetHeight(1)
440 | line:SetTexture(.5, .5, .5)
441 | line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
442 | line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
443 |
444 | self.text:Hide()
445 |
446 | self.useHighlight = false
447 |
448 | AceGUI:RegisterAsWidget(self)
449 | return self
450 | end
451 |
452 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
453 | end
454 |
--------------------------------------------------------------------------------
/LossOfControl/LossOfControlMixin.lua:
--------------------------------------------------------------------------------
1 | --######################################################################
2 | --###### Bakcport LossOfControl from retail #######
3 | ------------------------------------------------------------------------
4 | --######################################################################
5 |
6 | local LossOfControl = LibStub("AceAddon-3.0"):NewAddon("LossOfControl", "AceEvent-3.0");
7 | _G.LossOfControl = LossOfControl;
8 | LossOfControl.timer = LibStub("AceTimer-3.0");
9 | local LossOfControl_AddControlOrUpdate, LossOfControl_AddInterruptControl, LossOfControl_Hide;
10 |
11 | SOUNDKIT = SOUNDKIT or {};
12 | SOUNDKIT.UI_LOSS_OF_CONTROL_START = "Interface\\AddOns\\LossOfControl\\Media\\Sound\\34468.ogg";
13 |
14 | local blacklist = {
15 | [72120] = true,
16 | [70106] = true,
17 | [72121] = true,
18 | [24134] = true,
19 | [71151] = true,
20 | [23262] = true,
21 | [38064] = true,
22 | [49010] = true,
23 | [72426] = true,
24 | -- [spellID] = true,
25 | };
26 |
27 | local SpellSchoolString = {
28 | [0x1] = STRING_SCHOOL_PHYSICAL,
29 | [0x2] = STRING_SCHOOL_HOLY,
30 | [0x4] = STRING_SCHOOL_FIRE,
31 | [0x8] = STRING_SCHOOL_NATURE,
32 | [0x10] = STRING_SCHOOL_FROST,
33 | [0x20] = STRING_SCHOOL_SHADOW,
34 | [0x40] = STRING_SCHOOL_ARCANE,
35 | -- double
36 | [0x3] = STRING_SCHOOL_HOLYSTRIKE,
37 | [0x5] = STRING_SCHOOL_FLAMESTRIKE,
38 | [0x6] = STRING_SCHOOL_HOLYFIRE,
39 | [0x9] = STRING_SCHOOL_STORMSTRIKE,
40 | [0xA] = STRING_SCHOOL_HOLYSTORM,
41 | [0xC] = STRING_SCHOOL_FIRESTORM,
42 | [0x11] = STRING_SCHOOL_FROSTSTRIKE,
43 | [0x12] = STRING_SCHOOL_HOLYFROST,
44 | [0x14] = STRING_SCHOOL_FROSTFIRE,
45 | [0x18] = STRING_SCHOOL_FROSTSTORM,
46 | [0x21] = STRING_SCHOOL_SHADOWSTRIKE,
47 | [0x22] = STRING_SCHOOL_SHADOWLIGHT,
48 | [0x24] = STRING_SCHOOL_SHADOWFLAME,
49 | [0x28] = STRING_SCHOOL_SHADOWSTORM,
50 | [0x30] = STRING_SCHOOL_SHADOWFROST,
51 | [0x41] = STRING_SCHOOL_SPELLSTRIKE,
52 | [0x42] = STRING_SCHOOL_DIVINE,
53 | [0x44] = STRING_SCHOOL_SPELLFIRE,
54 | [0x48] = STRING_SCHOOL_SPELLSTORM,
55 | [0x50] = STRING_SCHOOL_SPELLFROST,
56 | [0x60] = STRING_SCHOOL_SPELLSHADOW,
57 | [0x1C] = STRING_SCHOOL_ELEMENTAL,
58 | -- triple and more
59 | [0x7C] = STRING_SCHOOL_CHROMATIC,
60 | [0x7E] = STRING_SCHOOL_MAGIC,
61 | [0x7F] = STRING_SCHOOL_CHAOS,
62 | };
63 |
64 | function GetSchoolString(lockoutSchool)
65 | if ( SpellSchoolString[lockoutSchool] ) then
66 | return SpellSchoolString[lockoutSchool];
67 | end
68 | end
69 |
70 | local lockoutChannel = {
71 | --
72 | [GetSpellInfo(12051)] = GetSpellInfo(42897),
73 | --
74 | [GetSpellInfo(53007)] = GetSpellInfo(32375),
75 | --
76 | [GetSpellInfo(64901)] = GetSpellInfo(48071),
77 | [GetSpellInfo(64843)] = GetSpellInfo(48071),
78 | --
79 | [GetSpellInfo(48447)] = GetSpellInfo(50763),
80 | };
81 |
82 | function RaidNotice_UpdateSlots( slotFrame, timings, elapsedTime, hasFading )
83 | if ( slotFrame.scrollTime ) then
84 | slotFrame.scrollTime = slotFrame.scrollTime + elapsedTime;
85 | if ( slotFrame.scrollTime <= timings["RAID_NOTICE_SCALE_UP_TIME"] ) then
86 | slotFrame:SetTextHeight(floor(timings["RAID_NOTICE_MIN_HEIGHT"]+
87 | ((timings["RAID_NOTICE_MAX_HEIGHT"]-timings["RAID_NOTICE_MIN_HEIGHT"])*slotFrame.scrollTime/timings["RAID_NOTICE_SCALE_UP_TIME"])));
88 | elseif ( slotFrame.scrollTime <= timings["RAID_NOTICE_SCALE_DOWN_TIME"] ) then
89 | slotFrame:SetTextHeight(floor(timings["RAID_NOTICE_MAX_HEIGHT"] -
90 | ((timings["RAID_NOTICE_MAX_HEIGHT"]-timings["RAID_NOTICE_MIN_HEIGHT"])*(slotFrame.scrollTime -
91 | timings["RAID_NOTICE_SCALE_UP_TIME"])/(timings["RAID_NOTICE_SCALE_DOWN_TIME"] -
92 | timings["RAID_NOTICE_SCALE_UP_TIME"]))));
93 | else
94 | slotFrame:SetTextHeight(timings["RAID_NOTICE_MIN_HEIGHT"]);
95 | slotFrame.scrollTime = nil;
96 | end
97 | end
98 | if ( hasFading ) then
99 | FadingFrame_OnUpdate(slotFrame);
100 | end
101 | end
102 |
103 | function CooldownFrame_Clear(self)
104 | self:Hide();
105 | end
106 |
107 | -------------------------------------------------------------
108 |
109 | -------------------------------------------------------------
110 | LossOfControlAnimGroupMixin = {};
111 | LossOfControlAnimGroupMixin.AnimationGroup = {};
112 |
113 | function LossOfControlAnimGroupMixin:Mixin(...)
114 | for i = 1, select("#", ...) do
115 | local mixin = select(i, ...);
116 | self.AnimationGroup[i] = mixin;
117 | end
118 | end
119 |
120 | function LossOfControlAnimGroupMixin:Play()
121 | for _, childKey in pairs(self.AnimationGroup) do
122 | childKey:Play();
123 | end
124 | end
125 |
126 | function LossOfControlAnimGroupMixin:Stop()
127 | for _, childKey in pairs(self.AnimationGroup) do
128 | childKey:Stop();
129 | end
130 | end
131 |
132 | function LossOfControlAnimGroupMixin:IsPlaying()
133 | for _, childKey in pairs(self.AnimationGroup) do
134 | return childKey:IsPlaying();
135 | end
136 | end
137 |
138 | LossOfContolrMixin = LossOfControl;
139 | LossOfContolrMixin.ActiveControl = {};
140 |
141 | function LossOfContolrMixin:OnLoad()
142 | self:RegisterEvent("UNIT_AURA", LossOfControl_AddControlOrUpdate);
143 | self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", LossOfControl_AddInterruptControl);
144 | self:RegisterEvent("PLAYER_ENTERING_WORLD", LossOfControl_Hide);
145 |
146 | self.Anim = LossOfControlAnimGroupMixin;
147 | end
148 |
149 | function LossOfContolrMixin:SetShown(value)
150 | if value then
151 | self:Show();
152 | else
153 | self:Hide();
154 | end
155 | end
156 |
157 | function LossOfContolrMixin:Added()
158 | local update = false;
159 |
160 | for i = 1, 255 do
161 | local name, _, iconTexture, _, locType, duration, expirationTime, _, _, _, spellID = UnitAura("player", i, "HARMFUL");
162 | if ( not name or blacklist[spellID] ) then
163 | break;
164 | end
165 |
166 | local spellInfo = LOSS_OF_CONTROL_STORAGE[spellID];
167 |
168 | if spellInfo then
169 |
170 | local Fields = {
171 | locType = locType,
172 | spellID = spellID,
173 | displayText = spellInfo[1],
174 | iconTexture = iconTexture,
175 | startTime = GetTime(),
176 | expirationTime = expirationTime,
177 | timeRemaining = expirationTime - GetTime(),
178 | duration = duration,
179 | lockoutSchool = nil,
180 | priority = spellInfo[2],
181 | displayType = spellInfo[3],
182 | };
183 |
184 | if not self.ActiveControl[spellID] or self.ActiveControl[spellID] < expirationTime then
185 | self.ActiveControl[spellID] = expirationTime;
186 | self:ScanEvents(Fields);
187 | update = true;
188 | end
189 | end
190 | end
191 |
192 | return update;
193 | end
194 |
195 | function LossOfContolrMixin:Update()
196 | local update = false;
197 |
198 | for index, controlData in pairs(C_LossOfControl.ControlData) do
199 | if not self:GetControlID(controlData.spellID)
200 | and not controlData.lockoutSchool then
201 | self.ActiveControl[controlData.spellID] = nil;
202 | C_LossOfControl.ControlData[index] = nil;
203 | C_LossOfControl.ControlData = self:SetControlDataPriority(C_LossOfControl.ControlData);
204 | self:SendMessage("LOSS_OF_CONTROL_UPDATE", LossOfControlFrame);
205 | update = true;
206 | end
207 | end
208 |
209 | return update;
210 | end
211 |
212 | function LossOfContolrMixin:AddInterruptControl(event, ...)
213 | local _, subEvent, _, _, _, _, destName, _, spellID, _, _, _, spellName, lockoutSchool = ...;
214 |
215 | if ( subEvent == "SPELL_INTERRUPT" and destName == UnitName("player") ) then
216 | if lockoutSchool then
217 | local _, _, iconTexture = GetSpellInfo(spellID);
218 | local duration;
219 |
220 | if lockoutChannel[spellName] then
221 | _, duration = GetSpellCooldown(lockoutChannel[spellName]);
222 | else
223 | _, duration = GetSpellCooldown(spellName);
224 | end
225 |
226 | local Fields = {
227 | locType = "SCHOOL_INTERRUPT",
228 | spellID = spellID,
229 | displayText = LOSS_OF_CONTROL_DISPLAY_INTERRUPT_SCHOOL,
230 | iconTexture = iconTexture,
231 | startTime = GetTime(),
232 | expirationTime = duration + GetTime(),
233 | timeRemaining = duration,
234 | duration = duration,
235 | lockoutSchool = lockoutSchool,
236 | priority = 5,
237 | displayType = LossOfControl:GetDisplayValue(LOC_TYPE_INTERRUPT),
238 | }
239 |
240 | self:ScanEvents(Fields);
241 | self.ActiveControl[spellID] = true;
242 | LossOfControl.timer:ScheduleTimer( function() self:InterruptUpdate() end, duration );
243 | end
244 | end
245 |
246 | end
247 |
248 | function LossOfContolrMixin:InterruptUpdate()
249 | for k, v in pairs(C_LossOfControl.ControlData) do
250 | if ( v.lockoutSchool and math.floor(v.expirationTime - GetTime()) <= 0 ) then
251 | C_LossOfControl.ControlData[k] = nil;
252 | C_LossOfControl.ControlData = self:SetControlDataPriority(C_LossOfControl.ControlData);
253 | end
254 | end
255 | self:SendMessage("LOSS_OF_CONTROL_UPDATE", LossOfControlFrame);
256 | end
257 |
258 | function LossOfContolrMixin:SetControlDataPriority(ControlData)
259 | local t = {}
260 | for _, data in pairs(ControlData) do
261 | if data and data.priority then
262 | t[#t + 1] = data;
263 | end
264 | end
265 |
266 | table.sort(t, function (a,b)
267 | if a.priority == b.priority then
268 | return a.expirationTime > b.expirationTime;
269 | else
270 | return (a.priority > b.priority);
271 | end
272 | end)
273 |
274 | return t
275 | end
276 |
277 | function LossOfContolrMixin:GetControlID(spellID)
278 | for i = 1, 255 do
279 | local debuffID = select(11, UnitAura("player", i, "HARMFUL"));
280 | if ( not debuffID ) then
281 | return;
282 | end
283 |
284 | if ( spellID == debuffID ) then
285 | return true;
286 | end
287 | end
288 | end
289 |
290 | function LossOfContolrMixin:ScanEvents(Fields)
291 | tinsert(C_LossOfControl.ControlData, Fields);
292 | C_LossOfControl.ControlData = self:SetControlDataPriority(C_LossOfControl.ControlData); -- сразу сортируем, т.к. от индекса толку никакого
293 | local index = C_LossOfControl.GetActiveLossOfControlDataCount();
294 | self:SendMessage("LOSS_OF_CONTROL_ADDED", LossOfControlFrame, index);
295 | end
296 |
297 | function LossOfContolrMixin:RegisterEvents(event)
298 | self:RegisterMessage(event, LossOfControlFrame_OnEvent);
299 | end
300 |
301 | function LossOfContolrMixin:UnRegisterEvents(event)
302 | self:UnregisterMessage(event, LossOfControlFrame_OnEvent);
303 | end
304 |
305 | function LossOfControl_AddInterruptControl(event, ...)
306 | if ( event and ... ) then
307 | LossOfContolrMixin:AddInterruptControl(event, ...);
308 | end
309 | end
310 |
311 | function LossOfControl_AddControlOrUpdate(event, unit)
312 | if not ( unit == "player" ) then
313 | return;
314 | end
315 |
316 | return LossOfContolrMixin:Update() or LossOfContolrMixin:Added();
317 | end
318 |
319 | function LossOfControl_Hide()
320 | if LossOfControlFrame and LossOfControlFrame:IsShown() then
321 | LossOfControlFrame:Hide();
322 | LossOfContolrMixin.ActiveControl = {};
323 | C_LossOfControl.ControlData = {};
324 | end
325 | end
326 |
327 | TimeLeftMixin = {};
328 |
329 | function TimeLeftMixin:SetShown(value)
330 | if ( value ) then
331 | self:Show();
332 | else
333 | self:Hide();
334 | end
335 | end
336 |
337 | function Mixin(object, ...)
338 | for i = 1, select("#", ...) do
339 | local mixin = select(i, ...);
340 | for k, v in pairs(mixin) do
341 | object[k] = v;
342 | end
343 | end
344 | return object;
345 | end
346 | -- where ... are the mixins to mixin
347 | function CreateFromMixins(...)
348 | return Mixin({}, ...);
349 | end
350 |
351 | function CreateAndInitFromMixin(mixin, ...)
352 | local object = CreateFromMixins(mixin);
353 | object:Init(...);
354 | return object;
355 | end
--------------------------------------------------------------------------------
/LossOfControl/Libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua:
--------------------------------------------------------------------------------
1 | --- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\
2 | -- Options tables can be registered as raw tables, OR as function refs that return a table.\\
3 | -- Such functions receive three arguments: "uiType", "uiName", "appName". \\
4 | -- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\
5 | -- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\
6 | -- * The **appName** field is the options table name as given at registration time \\
7 | --
8 | -- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
9 | -- @class file
10 | -- @name AceConfigRegistry-3.0
11 | -- @release $Id: AceConfigRegistry-3.0.lua 1045 2011-12-09 17:58:40Z nevcairiel $
12 | local MAJOR, MINOR = "AceConfigRegistry-3.0", 14
13 | local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
14 |
15 | if not AceConfigRegistry then return end
16 |
17 | AceConfigRegistry.tables = AceConfigRegistry.tables or {}
18 |
19 | local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
20 |
21 | if not AceConfigRegistry.callbacks then
22 | AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
23 | end
24 |
25 | -- Lua APIs
26 | local tinsert, tconcat = table.insert, table.concat
27 | local strfind, strmatch = string.find, string.match
28 | local type, tostring, select, pairs = type, tostring, select, pairs
29 | local error, assert = error, assert
30 |
31 | -----------------------------------------------------------------------
32 | -- Validating options table consistency:
33 |
34 |
35 | AceConfigRegistry.validated = {
36 | -- list of options table names ran through :ValidateOptionsTable automatically.
37 | -- CLEARED ON PURPOSE, since newer versions may have newer validators
38 | cmd = {},
39 | dropdown = {},
40 | dialog = {},
41 | }
42 |
43 |
44 |
45 | local function err(msg, errlvl, ...)
46 | local t = {}
47 | for i=select("#",...),1,-1 do
48 | tinsert(t, (select(i, ...)))
49 | end
50 | error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
51 | end
52 |
53 |
54 | local isstring={["string"]=true, _="string"}
55 | local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
56 | local istable={["table"]=true, _="table"}
57 | local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
58 | local optstring={["nil"]=true,["string"]=true, _="string"}
59 | local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
60 | local optnumber={["nil"]=true,["number"]=true, _="number"}
61 | local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"}
62 | local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"}
63 | local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"}
64 | local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
65 | local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"}
66 | local opttable={["nil"]=true,["table"]=true, _="table"}
67 | local optbool={["nil"]=true,["boolean"]=true, _="boolean"}
68 | local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"}
69 |
70 | local basekeys={
71 | type=isstring,
72 | name=isstringfunc,
73 | desc=optstringfunc,
74 | descStyle=optstring,
75 | order=optmethodnumber,
76 | validate=optmethodfalse,
77 | confirm=optmethodbool,
78 | confirmText=optstring,
79 | disabled=optmethodbool,
80 | hidden=optmethodbool,
81 | guiHidden=optmethodbool,
82 | dialogHidden=optmethodbool,
83 | dropdownHidden=optmethodbool,
84 | cmdHidden=optmethodbool,
85 | icon=optstringfunc,
86 | iconCoords=optmethodtable,
87 | handler=opttable,
88 | get=optmethodfalse,
89 | set=optmethodfalse,
90 | func=optmethodfalse,
91 | arg={["*"]=true},
92 | width=optstring,
93 | }
94 |
95 | local typedkeys={
96 | header={},
97 | description={
98 | image=optstringfunc,
99 | imageCoords=optmethodtable,
100 | imageHeight=optnumber,
101 | imageWidth=optnumber,
102 | fontSize=optstringfunc,
103 | },
104 | group={
105 | args=istable,
106 | plugins=opttable,
107 | inline=optbool,
108 | cmdInline=optbool,
109 | guiInline=optbool,
110 | dropdownInline=optbool,
111 | dialogInline=optbool,
112 | childGroups=optstring,
113 | },
114 | execute={
115 | image=optstringfunc,
116 | imageCoords=optmethodtable,
117 | imageHeight=optnumber,
118 | imageWidth=optnumber,
119 | },
120 | input={
121 | pattern=optstring,
122 | usage=optstring,
123 | control=optstring,
124 | dialogControl=optstring,
125 | dropdownControl=optstring,
126 | multiline=optboolnumber,
127 | },
128 | toggle={
129 | tristate=optbool,
130 | image=optstringfunc,
131 | imageCoords=optmethodtable,
132 | },
133 | tristate={
134 | },
135 | range={
136 | min=optnumber,
137 | softMin=optnumber,
138 | max=optnumber,
139 | softMax=optnumber,
140 | step=optnumber,
141 | bigStep=optnumber,
142 | isPercent=optbool,
143 | },
144 | select={
145 | values=ismethodtable,
146 | style={
147 | ["nil"]=true,
148 | ["string"]={dropdown=true,radio=true},
149 | _="string: 'dropdown' or 'radio'"
150 | },
151 | control=optstring,
152 | dialogControl=optstring,
153 | dropdownControl=optstring,
154 | itemControl=optstring,
155 | },
156 | multiselect={
157 | values=ismethodtable,
158 | style=optstring,
159 | tristate=optbool,
160 | control=optstring,
161 | dialogControl=optstring,
162 | dropdownControl=optstring,
163 | },
164 | color={
165 | hasAlpha=optmethodbool,
166 | },
167 | keybinding={
168 | -- TODO
169 | },
170 | }
171 |
172 | local function validateKey(k,errlvl,...)
173 | errlvl=(errlvl or 0)+1
174 | if type(k)~="string" then
175 | err("["..tostring(k).."] - key is not a string", errlvl,...)
176 | end
177 | if strfind(k, "[%c\127]") then
178 | err("["..tostring(k).."] - key name contained control characters", errlvl,...)
179 | end
180 | end
181 |
182 | local function validateVal(v, oktypes, errlvl,...)
183 | errlvl=(errlvl or 0)+1
184 | local isok=oktypes[type(v)] or oktypes["*"]
185 |
186 | if not isok then
187 | err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...)
188 | end
189 | if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
190 | if not isok[v] then
191 | err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...)
192 | end
193 | end
194 | end
195 |
196 | local function validate(options,errlvl,...)
197 | errlvl=(errlvl or 0)+1
198 | -- basic consistency
199 | if type(options)~="table" then
200 | err(": expected a table, got a "..type(options), errlvl,...)
201 | end
202 | if type(options.type)~="string" then
203 | err(".type: expected a string, got a "..type(options.type), errlvl,...)
204 | end
205 |
206 | -- get type and 'typedkeys' member
207 | local tk = typedkeys[options.type]
208 | if not tk then
209 | err(".type: unknown type '"..options.type.."'", errlvl,...)
210 | end
211 |
212 | -- make sure that all options[] are known parameters
213 | for k,v in pairs(options) do
214 | if not (tk[k] or basekeys[k]) then
215 | err(": unknown parameter", errlvl,tostring(k),...)
216 | end
217 | end
218 |
219 | -- verify that required params are there, and that everything is the right type
220 | for k,oktypes in pairs(basekeys) do
221 | validateVal(options[k], oktypes, errlvl,k,...)
222 | end
223 | for k,oktypes in pairs(tk) do
224 | validateVal(options[k], oktypes, errlvl,k,...)
225 | end
226 |
227 | -- extra logic for groups
228 | if options.type=="group" then
229 | for k,v in pairs(options.args) do
230 | validateKey(k,errlvl,"args",...)
231 | validate(v, errlvl,k,"args",...)
232 | end
233 | if options.plugins then
234 | for plugname,plugin in pairs(options.plugins) do
235 | if type(plugin)~="table" then
236 | err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...)
237 | end
238 | for k,v in pairs(plugin) do
239 | validateKey(k,errlvl,tostring(plugname),"plugins",...)
240 | validate(v, errlvl,k,tostring(plugname),"plugins",...)
241 | end
242 | end
243 | end
244 | end
245 | end
246 |
247 |
248 | --- Validates basic structure and integrity of an options table \\
249 | -- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
250 | -- @param options The table to be validated
251 | -- @param name The name of the table to be validated (shown in any error message)
252 | -- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
253 | function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl)
254 | errlvl=(errlvl or 0)+1
255 | name = name or "Optionstable"
256 | if not options.name then
257 | options.name=name -- bit of a hack, the root level doesn't really need a .name :-/
258 | end
259 | validate(options,errlvl,name)
260 | end
261 |
262 | --- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh.
263 | -- You should call this function if your options table changed from any outside event, like a game event
264 | -- or a timer.
265 | -- @param appName The application name as given to `:RegisterOptionsTable()`
266 | function AceConfigRegistry:NotifyChange(appName)
267 | if not AceConfigRegistry.tables[appName] then return end
268 | AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
269 | end
270 |
271 | -- -------------------------------------------------------------------
272 | -- Registering and retreiving options tables:
273 |
274 |
275 | -- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it)
276 |
277 | local function validateGetterArgs(uiType, uiName, errlvl)
278 | errlvl=(errlvl or 0)+2
279 | if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
280 | error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
281 | end
282 | if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
283 | error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
284 | end
285 | end
286 |
287 | --- Register an options table with the config registry.
288 | -- @param appName The application name as given to `:RegisterOptionsTable()`
289 | -- @param options The options table, OR a function reference that generates it on demand. \\
290 | -- See the top of the page for info on arguments passed to such functions.
291 | function AceConfigRegistry:RegisterOptionsTable(appName, options)
292 | if type(options)=="table" then
293 | if options.type~="group" then -- quick sanity checker
294 | error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
295 | end
296 | AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
297 | errlvl=(errlvl or 0)+1
298 | validateGetterArgs(uiType, uiName, errlvl)
299 | if not AceConfigRegistry.validated[uiType][appName] then
300 | AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
301 | AceConfigRegistry.validated[uiType][appName] = true
302 | end
303 | return options
304 | end
305 | elseif type(options)=="function" then
306 | AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
307 | errlvl=(errlvl or 0)+1
308 | validateGetterArgs(uiType, uiName, errlvl)
309 | local tab = assert(options(uiType, uiName, appName))
310 | if not AceConfigRegistry.validated[uiType][appName] then
311 | AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
312 | AceConfigRegistry.validated[uiType][appName] = true
313 | end
314 | return tab
315 | end
316 | else
317 | error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2)
318 | end
319 | end
320 |
321 | --- Returns an iterator of ["appName"]=funcref pairs
322 | function AceConfigRegistry:IterateOptionsTables()
323 | return pairs(AceConfigRegistry.tables)
324 | end
325 |
326 |
327 |
328 |
329 | --- Query the registry for a specific options table.
330 | -- If only appName is given, a function is returned which you
331 | -- can call with (uiType,uiName) to get the table.\\
332 | -- If uiType&uiName are given, the table is returned.
333 | -- @param appName The application name as given to `:RegisterOptionsTable()`
334 | -- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog"
335 | -- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0"
336 | function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
337 | local f = AceConfigRegistry.tables[appName]
338 | if not f then
339 | return nil
340 | end
341 |
342 | if uiType then
343 | return f(uiType,uiName,1) -- get the table for us
344 | else
345 | return f -- return the function
346 | end
347 | end
348 |
--------------------------------------------------------------------------------