update Ace3

This commit is contained in:
Pinya
2018-07-24 18:46:37 +03:00
parent ec1ad46dd3
commit 11ea55b1a5
11 changed files with 59 additions and 82 deletions
@@ -114,7 +114,6 @@ function AceConsole:UnregisterChatCommand( command )
if name then if name then
SlashCmdList[name] = nil SlashCmdList[name] = nil
_G["SLASH_" .. name .. "1"] = nil _G["SLASH_" .. name .. "1"] = nil
hash_SlashCmdList["/" .. upper(command)] = nil
AceConsole.commands[command] = nil AceConsole.commands[command] = nil
end end
end end
@@ -561,7 +561,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
--parse for =on =off =default in the process --parse for =on =off =default in the process
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set --table will be key = true for options that should toggle, key = [on|off|default] for options to be set
local sels = {} local sels = {}
for v in strgfind(str, "[^ ]+") do for v in strgmatch(str, "[^ ]+") do
--parse option=on etc --parse option=on etc
local _, _, opt, val = strfind(v, '(.+)=(.+)') local _, _, opt, val = strfind(v, '(.+)=(.+)')
--get option if toggling --get option if toggling
@@ -377,7 +377,7 @@ do
end end
WidgetBase.SetPoint = function(self, ...) WidgetBase.SetPoint = function(self, ...)
return self.frame:SetPoint(unpack(arg)) return self.frame:SetPoint(arg[1], arg[2], arg[3], arg[4], arg[5])
end end
WidgetBase.ClearAllPoints = function(self) WidgetBase.ClearAllPoints = function(self)
@@ -389,7 +389,7 @@ do
end end
WidgetBase.GetPoint = function(self, ...) WidgetBase.GetPoint = function(self, ...)
return self.frame:GetPoint(unpack(arg)) return self.frame:GetPoint(arg[1])
end end
WidgetBase.GetUserDataTable = function(self) WidgetBase.GetUserDataTable = function(self)
@@ -81,11 +81,11 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local line = button.line local line = button.line
button.level = level button.level = level
if ( level == 1 ) then if ( level == 1 ) then
button.text:SetFontObject("GameFontNormal") button:SetTextFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight") button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2) button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else else
button.text:SetFontObject("GameFontHighlightSmall") button:SetTextFontObject("GameFontHighlightSmall")
button:SetHighlightFontObject("GameFontHighlightSmall") button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2) button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
end end
@@ -24,29 +24,29 @@ local function lockTooltip()
GameTooltip:SetText(" ") GameTooltip:SetText(" ")
GameTooltip:Show() GameTooltip:Show()
end end
local function dragdrop_OnMouseDown(...) local function dragdrop_OnMouseDown()
if this.obj.dragOnMouseDown then if this.obj.dragOnMouseDown then
dragdropButton.mouseDownFrame = this dragdropButton.mouseDownFrame = this
dragdropButton:SetText(this.obj.value or "Unknown") dragdropButton:SetText(this.obj.value or "Unknown")
dragdropButton:SetWidth(this:GetWidth()) dragdropButton:SetWidth(this:GetWidth())
dragdropButton:SetHeight(this:SetHeight()) dragdropButton:SetHeight(this:SetHeight())
this.obj.dragOnMouseDown(this, unpack(arg)) this.obj.dragOnMouseDown(this, arg1)
end end
end end
local function dragdrop_OnMouseUp(...) local function dragdrop_OnMouseUp()
if this.obj.dragOnMouseUp then if this.obj.dragOnMouseUp then
this:SetAlpha(1) this:SetAlpha(1)
GameTooltip:Hide() GameTooltip:Hide()
dragdropButton:Hide() dragdropButton:Hide()
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then
this.obj.dragOnMouseUp(this, unpack(arg)) this.obj.dragOnMouseUp(this, arg1)
this.obj.ActivateMultiControl(this.obj, unpack(arg)) this.obj.ActivateMultiControl(this.obj, arg1)
end end
dragdropButton.enteredFrame = nil dragdropButton.enteredFrame = nil
dragdropButton.mouseDownFrame = nil dragdropButton.mouseDownFrame = nil
end end
end end
local function dragdrop_OnLeave(...) local function dragdrop_OnLeave()
if this.obj.dragOnLeave then if this.obj.dragOnLeave then
if dragdropButton.mouseDownFrame then if dragdropButton.mouseDownFrame then
lockTooltip() lockTooltip()
@@ -54,15 +54,15 @@ local function dragdrop_OnLeave(...)
if this == dragdropButton.mouseDownFrame then if this == dragdropButton.mouseDownFrame then
this:SetAlpha(0) this:SetAlpha(0)
dragdropButton:Show() dragdropButton:Show()
this.obj.dragOnLeave(this, unpack(arg)) this.obj.dragOnLeave(this)
end end
end end
end end
local function dragdrop_OnEnter(...) local function dragdrop_OnEnter()
if this.obj.dragOnEnter and dragdropButton:IsShown() then if this.obj.dragOnEnter and dragdropButton:IsShown() then
dragdropButton.enteredFrame = this dragdropButton.enteredFrame = this
lockTooltip() lockTooltip()
this.obj.dragOnEnter(this, unpack(arg)) this.obj.dragOnEnter(this)
end end
end end
local function dragdrop_OnClick() local function dragdrop_OnClick()
@@ -228,7 +228,9 @@ local methods = {
if image:GetTexture() then if image:GetTexture() then
local n = arg.n local n = arg.n
if n == 4 or n == 8 then if n == 4 then
image:SetTexCoord(arg[1], arg[2], arg[3], arg[4])
elseif n == 8 then
image:SetTexCoord(unpack(arg)) image:SetTexCoord(unpack(arg))
else else
image:SetTexCoord(0, 1, 0, 1) image:SetTexCoord(0, 1, 0, 1)
@@ -3,7 +3,7 @@
local AceGUI = LibStub("AceGUI-3.0") local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs -- Lua APIs
local assert, unpack = assert, unpack local assert = assert
-- WoW APIs -- WoW APIs
local PlaySound = PlaySound local PlaySound = PlaySound
@@ -107,7 +107,7 @@ end
-- exported -- exported
function ItemBase.SetPoint(self, ...) function ItemBase.SetPoint(self, ...)
self.frame:SetPoint(unpack(arg)) self.frame:SetPoint(arg[1], arg[2], arg[3], arg[4], arg[5])
end end
-- exported -- exported
@@ -59,7 +59,9 @@ local methods = {
if image:GetTexture() then if image:GetTexture() then
local n = arg.n local n = arg.n
if n == 4 or n == 8 then if n == 4 then
image:SetTexCoord(arg[1], arg[2], arg[3], arg[4])
elseif n == 8 then
image:SetTexCoord(unpack(arg)) image:SetTexCoord(unpack(arg))
else else
image:SetTexCoord(0, 1, 0, 1) image:SetTexCoord(0, 1, 0, 1)
@@ -45,12 +45,14 @@ local methods = {
-- ["OnRelease"] = nil, -- ["OnRelease"] = nil,
["SetHighlight"] = function(self, ...) ["SetHighlight"] = function(self, ...)
self.highlight:SetTexture(unpack(arg)) self.highlight:SetTexture(arg[1], arg[2], arg[3], arg[4])
end, end,
["SetHighlightTexCoord"] = function(self, ...) ["SetHighlightTexCoord"] = function(self, ...)
local c = arg.n local c = arg.n
if c == 4 or c == 8 then if c == 4 then
self.highlight:SetTexCoord(arg[1], arg[2], arg[3], arg[4])
elseif c == 8 then
self.highlight:SetTexCoord(unpack(arg)) self.highlight:SetTexCoord(unpack(arg))
else else
self.highlight:SetTexCoord(0, 1, 0, 1) self.highlight:SetTexCoord(0, 1, 0, 1)
@@ -12,6 +12,7 @@ local pairs = pairs
-- WoW APIs -- WoW APIs
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
local CreateFrame, UIParent = CreateFrame, UIParent local CreateFrame, UIParent = CreateFrame, UIParent
local MouseIsOver = MouseIsOver
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script -- List them here for Mikk's FindGlobals script
@@ -29,17 +30,8 @@ local function Control_OnLeave()
this.obj:Fire("OnLeave") this.obj:Fire("OnLeave")
end end
local function Keybinding_OnHide() local function Keybinding_OnMouseUp()
local self = this.obj if (arg1 == "LeftButton" or arg1 == "RightButton") and MouseIsOver(this) and not this.disabled then
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
this:UnlockHighlight()
self.waitingForKey = nil
end
local function Keybinding_OnClick()
if arg1 == "LeftButton" or arg1 == "RightButton" then
local self = this.obj local self = this.obj
if self.waitingForKey then if self.waitingForKey then
this:EnableKeyboard(false) this:EnableKeyboard(false)
@@ -61,13 +53,15 @@ end
local ignoreKeys = { local ignoreKeys = {
["BUTTON1"] = true, ["BUTTON2"] = true, ["BUTTON1"] = true, ["BUTTON2"] = true,
["UNKNOWN"] = true, ["UNKNOWN"] = true,
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, ["SHIFT"] = true, ["CTRL"] = true, ["ALT"] = true,
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
} }
local function Keybinding_OnKeyDown() local function Keybinding_OnKeyDown(frame, key)
local self = this.obj local frame = this or frame
local key = key or arg1
local self = frame.obj
if self.waitingForKey then if self.waitingForKey then
local keyPressed = arg1 local keyPressed = key
if keyPressed == "ESCAPE" then if keyPressed == "ESCAPE" then
keyPressed = "" keyPressed = ""
else else
@@ -83,62 +77,41 @@ local function Keybinding_OnKeyDown()
end end
end end
this:EnableKeyboard(false) frame:EnableKeyboard(false)
this:EnableMouseWheel(false) frame:EnableMouseWheel(false)
self.msgframe:Hide() self.msgframe:Hide()
this:UnlockHighlight() frame:UnlockHighlight()
self.waitingForKey = nil self.waitingForKey = nil
if not self.disabled then if not frame.disabled then
self:SetKey(keyPressed) self:SetKey(keyPressed)
self:Fire("OnKeyChanged", keyPressed) self:Fire("OnKeyChanged", keyPressed)
end end
end end
end end
local function Keybinding_OnMouseUp()
if MouseIsOver(this) and not self.disabled then
local self = this.obj
if self.waitingForKey then
if arg1 ~= "LeftButton" and arg1 ~= "RightButton" then
Keybinding_OnKeyDown()
end
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
this:UnlockHighlight()
self.waitingForKey = nil
else
this:EnableKeyboard(true)
this:EnableMouseWheel(true)
self.msgframe:Show()
this:LockHighlight()
self.waitingForKey = true
end
end
AceGUI:ClearFocus()
end
local function Keybinding_OnMouseDown() local function Keybinding_OnMouseDown()
if arg1 == "LeftButton" or arg1 == "RightButton" then local button = arg1
if button == "LeftButton" or button == "RightButton" then
return return
elseif arg1 == "MiddleButton" then elseif button == "MiddleButton" then
arg1 = "BUTTON3" button = "BUTTON3"
elseif arg1 == "Button4" then elseif button == "Button4" then
arg1 = "BUTTON4" button = "BUTTON4"
elseif arg1 == "Button5" then elseif button == "Button5" then
arg1 = "BUTTON5" button = "BUTTON5"
end end
Keybinding_OnKeyDown() Keybinding_OnKeyDown(this, button)
end end
local function Keybinding_OnMouseWheel() local function Keybinding_OnMouseWheel()
local button
if arg1 >= 0 then if arg1 >= 0 then
arg1 = "MOUSEWHEELUP" button = "MOUSEWHEELUP"
else else
arg1 = "MOUSEWHEELDOWN" button = "MOUSEWHEELDOWN"
end end
Keybinding_OnKeyDown() Keybinding_OnKeyDown(this, button)
end end
--[[----------------------------------------------------------------------------- --[[-----------------------------------------------------------------------------
@@ -172,10 +145,10 @@ local methods = {
["SetKey"] = function(self, key) ["SetKey"] = function(self, key)
if (key or "") == "" then if (key or "") == "" then
self.button:SetText(NOT_BOUND) self.button:SetText(NOT_BOUND)
self.text:SetFontObject("GameFontNormal") self.button:SetTextFontObject("GameFontNormal")
else else
self.button:SetText(key) self.button:SetText(key)
self.text:SetFontObject("GameFontHighlight") self.button:SetTextFontObject("GameFontHighlight")
end end
end, end,
@@ -226,12 +199,10 @@ local function Constructor()
button:RegisterForClicks("AnyDown") button:RegisterForClicks("AnyDown")
button:SetScript("OnEnter", Control_OnEnter) button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave) button:SetScript("OnLeave", Control_OnLeave)
-- button:SetScript("OnClick", Keybinding_OnClick)
button:SetScript("OnMouseUp", Keybinding_OnMouseUp) button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
button:SetScript("OnKeyDown", Keybinding_OnKeyDown) button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
button:SetScript("OnMouseDown", Keybinding_OnMouseDown) button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel) button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
button:SetScript("OnHide", Keybinding_OnHide)
button:SetPoint("BOTTOMLEFT", 0, 0) button:SetPoint("BOTTOMLEFT", 0, 0)
button:SetPoint("BOTTOMRIGHT", 0, 0) button:SetPoint("BOTTOMRIGHT", 0, 0)
button:SetHeight(24) button:SetHeight(24)
@@ -269,8 +240,7 @@ local function Constructor()
msgframe = msgframe, msgframe = msgframe,
frame = frame, frame = frame,
alignoffset = 30, alignoffset = 30,
type = Type, type = Type
text = text
} }
for method, func in pairs(methods) do for method, func in pairs(methods) do
widget[method] = func widget[method] = func
@@ -112,7 +112,9 @@ local methods = {
if image:GetTexture() then if image:GetTexture() then
self.imageshown = true self.imageshown = true
local n = arg.n local n = arg.n
if n == 4 or n == 8 then if n == 4 then
image:SetTexCoord(arg[1], arg[2], arg[3], arg[4])
elseif n == 8 then
image:SetTexCoord(unpack(arg)) image:SetTexCoord(unpack(arg))
else else
image:SetTexCoord(0, 1, 0, 1) image:SetTexCoord(0, 1, 0, 1)