diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f4d4ea0..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Bartłomiej Bukowiecki - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.lua deleted file mode 100644 index 6a41f2d..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.lua +++ /dev/null @@ -1,150 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - - -------------- --- Widgets -- -------------- ---[[ - Widgets must provide the following functions - Acquire() - Called when the object is aquired, should set everything to a default hidden state - Release() - Called when the object is Released, should remove any anchors and hide the Widget - - And the following members - frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes - type - the type of the object, same as the name given to :RegisterWidget() - - Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet - It will be cleared automatically when a widget is released - Placing values directly into a widget object should be avoided - - If the Widget can act as a container for other Widgets the following - content - frame or derivitive that children will be anchored to - - The Widget can supply the following Optional Members - - -]] - ----------------------------------- --- Blizzard Options Group -- ----------------------------------- ---[[ - Group Designed to be added to the bliz interface options panel -]] - -do - local Type = "BlizOptionsGroup" - local Version = 6 - - local function OnAcquire(self) - - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self:SetName() - end - - local function okay(this) - this.obj:Fire("okay") - end - - local function cancel(this) - this.obj:Fire("cancel") - end - - local function defaults(this) - this.obj:Fire("defaults") - end - - local function SetName(self, name, parent) - self.frame.name = name - self.frame.parent = parent - end - - local function OnShow(this) - this.obj:Fire("OnShow") - end - - local function OnHide(this) - this.obj:Fire("OnHide") - end - - local function OnWidthSet(self, width) - local content = self.content - local contentwidth = width - 63 - if contentwidth < 0 then - contentwidth = 0 - end - content:SetWidth(contentwidth) - content.width = contentwidth - end - - - local function OnHeightSet(self, height) - local content = self.content - local contentheight = height - 26 - if contentheight < 0 then - contentheight = 0 - end - content:SetHeight(contentheight) - content.height = contentheight - end - - local function SetTitle(self, title) - local content = self.content - content:ClearAllPoints() - if not title or title == "" then - content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",15,-10) - self.label:SetText("") - else - content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",15,-40) - self.label:SetText(title) - end - content:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-10,10) - end - - local function Constructor() - local frame = CreateFrame("Frame") - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.frame = frame - self.SetName = SetName - - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - self.SetTitle = SetTitle - - frame.obj = self - frame.okay = okay - frame.cancel = cancel - frame.defaults = defaults - - frame:Hide() - frame:SetScript("OnHide",OnHide) - frame:SetScript("OnShow",OnShow) - - local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") - self.label = label - label:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -15) - label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45) - label:SetJustifyH("LEFT") - label:SetJustifyV("TOP") - - --Container Support - local content = CreateFrame("Frame",nil,frame) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",frame,"TOPLEFT",15,-10) - content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-10,10) - - AceGUI:RegisterAsContainer(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua deleted file mode 100644 index 82f6ec2..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua +++ /dev/null @@ -1,100 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Button -- --------------------------- -do - local Type = "Button" - local Version = 11 - - local function OnAcquire(self) - -- restore default values - self:SetHeight(24) - self:SetWidth(200) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self:SetDisabled(false) - end - - local function Button_OnClick(this) - this.obj:Fire("OnClick") - AceGUI:ClearFocus() - end - - local function Button_OnEnter(this) - this.obj:Fire("OnEnter") - end - - local function Button_OnLeave(this) - this.obj:Fire("OnLeave") - end - - local function SetText(self, text) - self.text:SetText(text or "") - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if disabled then - self.frame:Disable() - else - self.frame:Enable() - end - end - - local function Constructor() - local num = AceGUI:GetNextWidgetNum(Type) - local name = "AceGUI30Button"..num - local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2") - local self = {} - self.num = num - self.type = Type - self.frame = frame - - local left = _G[name .. "Left"] - local right = _G[name .. "Right"] - local middle = _G[name .. "Middle"] - - left:SetPoint("TOP", frame, "TOP", 0, 0) - left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) - - right:SetPoint("TOP", frame, "TOP", 0, 0) - right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) - - middle:SetPoint("TOP", frame, "TOP", 0, 0) - middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) - - local text = frame:GetFontString() - self.text = text - text:ClearAllPoints() - text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1) - text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1) - text:SetJustifyV("MIDDLE") - - frame:SetScript("OnClick",Button_OnClick) - frame:SetScript("OnEnter",Button_OnEnter) - frame:SetScript("OnLeave",Button_OnLeave) - - self.SetText = SetText - self.SetDisabled = SetDisabled - - frame:EnableMouse(true) - - frame:SetHeight(24) - frame:SetWidth(200) - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.frame = frame - frame.obj = self - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end \ No newline at end of file diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua deleted file mode 100644 index 26065ad..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua +++ /dev/null @@ -1,217 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Check Box -- --------------------------- ---[[ - Events : - OnValueChanged - -]] -do - local Type = "CheckBox" - local Version = 7 - - local function OnAcquire(self) - self:SetValue(false) - self.tristate = nil - self:SetHeight(24) - self:SetWidth(200) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.check:Hide() - self.highlight:Hide() - self.down = nil - self.checked = nil - self:SetType() - self:SetDisabled(false) - end - - local function CheckBox_OnEnter(this) - local self = this.obj - self.highlight:Show() - self:Fire("OnEnter") - end - - local function CheckBox_OnLeave(this) - local self = this.obj - self.highlight:Hide() - self:Fire("OnLeave") - end - - local function CheckBox_OnMouseUp(this) - local self = this.obj - if not self.disabled then - self:ToggleChecked() - self:Fire("OnValueChanged",self.checked) - self.text:SetPoint("LEFT",self.check,"RIGHT",0,0) - end - self.down = nil - end - - local function CheckBox_OnMouseDown(this) - local self = this.obj - if not self.disabled then - self.text:SetPoint("LEFT",self.check,"RIGHT",1,-1) - self.down = true - end - AceGUI:ClearFocus() - end - - local function SetDisabled(self,disabled) - self.disabled = disabled - if disabled then - self.frame:Disable() - self.text:SetTextColor(0.5,0.5,0.5) - SetDesaturation(self.check, true) - else - self.frame:Enable() - self.text:SetTextColor(1,1,1) - if self.tristate and self.checked == nil then - SetDesaturation(self.check, true) - else - SetDesaturation(self.check, false) - end - end - end - - local function SetValue(self,value) - local check = self.check - self.checked = value - if value then - SetDesaturation(self.check, false) - check:SetWidth(24) - check:SetHeight(24) - self.check:Show() - else - --Nil is the unknown tristate value - if self.tristate and value == nil then - SetDesaturation(self.check, true) - check:SetWidth(24) - check:SetHeight(24) - self.check:Show() - else - SetDesaturation(self.check, false) - check:SetWidth(24) - check:SetHeight(24) - self.check:Hide() - end - end - end - - local function SetTriState(self, enabled) - self.tristate = enabled - self:SetValue(self:GetValue()) - end - - local function GetValue(self) - return self.checked - end - - local function SetType(self, type) - local checkbg = self.checkbg - local check = self.check - local highlight = self.highlight - - if type == "radio" then - checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton") - checkbg:SetTexCoord(0,0.25,0,1) - check:SetTexture("Interface\\Buttons\\UI-RadioButton") - check:SetTexCoord(0.5,0.75,0,1) - check:SetBlendMode("ADD") - highlight:SetTexture("Interface\\Buttons\\UI-RadioButton") - highlight:SetTexCoord(0.5,0.75,0,1) - else - checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") - checkbg:SetTexCoord(0,1,0,1) - check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") - check:SetTexCoord(0,1,0,1) - check:SetBlendMode("BLEND") - highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") - highlight:SetTexCoord(0,1,0,1) - end - end - - local function ToggleChecked(self) - local value = self:GetValue() - if self.tristate then - --cycle in true, nil, false order - if value then - self:SetValue(nil) - elseif value == nil then - self:SetValue(false) - else - self:SetValue(true) - end - else - self:SetValue(not self:GetValue()) - end - end - - local function SetLabel(self, label) - self.text:SetText(label) - end - - local function Constructor() - local frame = CreateFrame("Button",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.SetValue = SetValue - self.GetValue = GetValue - self.SetDisabled = SetDisabled - self.SetType = SetType - self.ToggleChecked = ToggleChecked - self.SetLabel = SetLabel - self.SetTriState = SetTriState - - self.frame = frame - frame.obj = self - - local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") - self.text = text - - frame:SetScript("OnEnter",CheckBox_OnEnter) - frame:SetScript("OnLeave",CheckBox_OnLeave) - frame:SetScript("OnMouseUp",CheckBox_OnMouseUp) - frame:SetScript("OnMouseDown",CheckBox_OnMouseDown) - frame:EnableMouse() - local checkbg = frame:CreateTexture(nil,"ARTWORK") - self.checkbg = checkbg - checkbg:SetWidth(24) - checkbg:SetHeight(24) - checkbg:SetPoint("LEFT",frame,"LEFT",0,0) - checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") - local check = frame:CreateTexture(nil,"OVERLAY") - self.check = check - check:SetWidth(24) - check:SetHeight(24) - check:SetPoint("CENTER",checkbg,"CENTER",0,0) - check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") - - local highlight = frame:CreateTexture(nil, "BACKGROUND") - self.highlight = highlight - highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") - highlight:SetBlendMode("ADD") - highlight:SetAllPoints(checkbg) - highlight:Hide() - - text:SetJustifyH("LEFT") - frame:SetHeight(24) - frame:SetWidth(200) - text:SetHeight(18) - text:SetPoint("LEFT",check,"RIGHT",0,0) - text:SetPoint("RIGHT",frame,"RIGHT",0,0) - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua deleted file mode 100644 index d5399a1..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua +++ /dev/null @@ -1,174 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- ColorPicker -- --------------------------- -do - local Type = "ColorPicker" - local Version = 11 - - local function OnAcquire(self) - self.HasAlpha = false - self:SetColor(0,0,0,1) - self:SetHeight(24) - self:SetWidth(200) - end - - local function SetLabel(self, text) - self.text:SetText(text) - end - - local function SetColor(self,r,g,b,a) - self.r = r - self.g = g - self.b = b - self.a = a or 1 - self.colorSwatch:SetVertexColor(r,g,b,a) - end - - local function Control_OnEnter(this) - this.obj:Fire("OnEnter") - end - - local function Control_OnLeave(this) - this.obj:Fire("OnLeave") - end - - local function SetHasAlpha(self, HasAlpha) - self.HasAlpha = HasAlpha - end - - local function ColorCallback(self,r,g,b,a,isAlpha) - if not self.HasAlpha then - a = 1 - end - self:SetColor(r,g,b,a) - if ColorPickerFrame:IsVisible() then - --colorpicker is still open - - self:Fire("OnValueChanged",r,g,b,a) - else - --colorpicker is closed, color callback is first, ignore it, - --alpha callback is the final call after it closes so confirm now - if isAlpha then - self:Fire("OnValueConfirmed",r,g,b,a) - end - end - end - - local function ColorSwatch_OnClick(this) - HideUIPanel(ColorPickerFrame) - local self = this.obj - if not self.disabled then - ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG") - - ColorPickerFrame.func = function() - local r,g,b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self,r,g,b,a) - end - - ColorPickerFrame.hasOpacity = self.HasAlpha - ColorPickerFrame.opacityFunc = function() - local r,g,b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self,r,g,b,a,true) - end - local r, g, b, a = self.r, self.g, self.b, self.a - if self.HasAlpha then - ColorPickerFrame.opacity = 1 - (a or 0) - end - ColorPickerFrame:SetColorRGB(r, g, b) - - ColorPickerFrame.cancelFunc = function() - ColorCallback(self,r,g,b,a,true) - end - ShowUIPanel(ColorPickerFrame) - end - AceGUI:ClearFocus() - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if self.disabled then - self.frame:Disable() - self.text:SetTextColor(0.5,0.5,0.5) - else - self.frame:Enable() - self.text:SetTextColor(1,1,1) - end - end - - local function Constructor() - local frame = CreateFrame("Button",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.SetLabel = SetLabel - self.SetColor = SetColor - self.SetDisabled = SetDisabled - self.SetHasAlpha = SetHasAlpha - - self.frame = frame - frame.obj = self - - local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") - self.text = text - text:SetJustifyH("LEFT") - text:SetTextColor(1,1,1) - frame:SetHeight(24) - frame:SetWidth(200) - text:SetHeight(24) - frame:SetScript("OnClick", ColorSwatch_OnClick) - frame:SetScript("OnEnter",Control_OnEnter) - frame:SetScript("OnLeave",Control_OnLeave) - - local colorSwatch = frame:CreateTexture(nil, "OVERLAY") - self.colorSwatch = colorSwatch - colorSwatch:SetWidth(19) - colorSwatch:SetHeight(19) - colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") - local texture = frame:CreateTexture(nil, "BACKGROUND") - colorSwatch.texture = texture - texture:SetWidth(16) - texture:SetHeight(16) - texture:SetTexture(1,1,1) - texture:Show() - - local checkers = frame:CreateTexture(nil, "BACKGROUND") - colorSwatch.checkers = checkers - checkers:SetTexture("Tileset\\Generic\\Checkers") - checkers:SetDesaturated(true) - checkers:SetVertexColor(1,1,1,0.75) - checkers:SetTexCoord(.25,0,0.5,.25) - checkers:SetWidth(14) - checkers:SetHeight(14) - checkers:Show() - - local highlight = frame:CreateTexture(nil, "BACKGROUND") - self.highlight = highlight - highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - highlight:SetBlendMode("ADD") - highlight:SetAllPoints(frame) - highlight:Hide() - - texture:SetPoint("CENTER", colorSwatch, "CENTER") - checkers:SetPoint("CENTER", colorSwatch, "CENTER") - colorSwatch:SetPoint("LEFT", frame, "LEFT", 0, 0) - text:SetPoint("LEFT",colorSwatch,"RIGHT",2,0) - text:SetPoint("RIGHT",frame,"RIGHT") - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDownGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDownGroup.lua deleted file mode 100644 index bb9f2bd..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDownGroup.lua +++ /dev/null @@ -1,168 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - ---[[ - Selection Group controls all have an interface to select a group for thier contents - None of them will auto size to thier contents, and should usually be used with a scrollframe - unless you know that the controls will fit inside -]] - --------------------------- --- Dropdown Group -- --------------------------- ---[[ - Events : - OnGroupSelected - -]] -do - local Type = "DropdownGroup" - local Version = 11 - - local function OnAcquire(self) - self.dropdown:SetText("") - self:SetDropdownWidth(200) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.dropdown.list = nil - self.status = nil - for k in pairs(self.localstatus) do - self.localstatus[k] = nil - end - end - - local PaneBackdrop = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 5, bottom = 3 } - } - - local function SetTitle(self,title) - self.titletext:SetText(title) - end - - - local function SelectedGroup(self,event,value) - local group = self.parentgroup - local status = group.status or group.localstatus - status.selected = value - self.parentgroup:Fire("OnGroupSelected", value) - end - - local function SetGroupList(self,list) - self.dropdown:SetList(list) - end - - -- called to set an external table to store status in - local function SetStatusTable(self, status) - assert(type(status) == "table") - self.status = status - end - - local function SetGroup(self,group) - self.dropdown:SetValue(group) - local status = self.status or self.localstatus - status.selected = group - self:Fire("OnGroupSelected", group) - end - - local function OnWidthSet(self, width) - local content = self.content - local contentwidth = width - 26 - if contentwidth < 0 then - contentwidth = 0 - end - content:SetWidth(contentwidth) - content.width = contentwidth - end - - - local function OnHeightSet(self, height) - local content = self.content - local contentheight = height - 63 - if contentheight < 0 then - contentheight = 0 - end - content:SetHeight(contentheight) - content.height = contentheight - end - - local function LayoutFinished(self, width, height) - self:SetHeight((height or 0) + 63) - end - - local function SetDropdownWidth(self, width) - self.dropdown:SetWidth(width) - end - - local function Constructor() - local frame = CreateFrame("Frame") - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.SetTitle = SetTitle - self.SetGroupList = SetGroupList - self.SetGroup = SetGroup - self.SetStatusTable = SetStatusTable - self.SetDropdownWidth = SetDropdownWidth - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - self.LayoutFinished = LayoutFinished - - self.localstatus = {} - - self.frame = frame - frame.obj = self - - - frame:SetHeight(100) - frame:SetWidth(100) - frame:SetFrameStrata("FULLSCREEN_DIALOG") - - local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") - titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",4,0) - titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-4,0) - titletext:SetJustifyH("LEFT") - titletext:SetHeight(18) - - - self.titletext = titletext - - local dropdown = AceGUI:Create("Dropdown") - self.dropdown = dropdown - dropdown.frame:SetParent(frame) - dropdown.parentgroup = self - dropdown:SetCallback("OnValueChanged",SelectedGroup) - - dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-3,3) - dropdown.frame:Show() - dropdown:SetLabel("") - - local border = CreateFrame("Frame",nil,frame) - self.border = border - border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-40) - border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3) - - border:SetBackdrop(PaneBackdrop) - border:SetBackdropColor(0.1,0.1,0.1,0.5) - border:SetBackdropBorderColor(0.4,0.4,0.4) - - --Container Support - local content = CreateFrame("Frame",nil,border) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) - content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) - - AceGUI:RegisterAsContainer(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua deleted file mode 100644 index 2bc6b22..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua +++ /dev/null @@ -1,204 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Edit box -- --------------------------- ---[[ - Events : - OnTextChanged - OnEnterPressed - -]] -do - local Type = "EditBox" - local Version = 11 - - local function OnAcquire(self) - self:SetHeight(26) - self:SetWidth(200) - self:SetDisabled(false) - self:SetLabel() - self.showbutton = true - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self:SetDisabled(false) - end - - local function Control_OnEnter(this) - this.obj:Fire("OnEnter") - end - - local function Control_OnLeave(this) - this.obj:Fire("OnLeave") - end - - local function EditBox_OnEscapePressed(this) - this:ClearFocus() - end - - local function ShowButton(self) - if self.showbutton then - self.button:Show() - self.editbox:SetTextInsets(0,20,3,3) - end - end - - local function HideButton(self) - self.button:Hide() - self.editbox:SetTextInsets(0,0,3,3) - end - - local function EditBox_OnEnterPressed(this) - local self = this.obj - local value = this:GetText() - local cancel = self:Fire("OnEnterPressed",value) - if not cancel then - HideButton(self) - end - end - - local function Button_OnClick(this) - local editbox = this.obj.editbox - editbox:ClearFocus() - EditBox_OnEnterPressed(editbox) - end - - local function EditBox_OnReceiveDrag(this) - local self = this.obj - local type, id, info = GetCursorInfo() - if type == "item" then - self:SetText(info) - self:Fire("OnEnterPressed",info) - ClearCursor() - elseif type == "spell" then - local name, rank = GetSpellName(id, info) - if rank and rank:match("%d") then - name = name.."("..rank..")" - end - self:SetText(name) - self:Fire("OnEnterPressed",name) - ClearCursor() - end - HideButton(self) - AceGUI:ClearFocus() - end - - local function EditBox_OnTextChanged(this) - local self = this.obj - local value = this:GetText() - if value ~= self.lasttext then - self:Fire("OnTextChanged",value) - self.lasttext = value - ShowButton(self) - end - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if disabled then - self.editbox:EnableMouse(false) - self.editbox:ClearFocus() - self.editbox:SetTextColor(0.5,0.5,0.5) - self.label:SetTextColor(0.5,0.5,0.5) - else - self.editbox:EnableMouse(true) - self.editbox:SetTextColor(1,1,1) - self.label:SetTextColor(1,.82,0) - end - end - - local function SetText(self, text) - self.lasttext = text or "" - self.editbox:SetText(text or "") - self.editbox:SetCursorPosition(0) - HideButton(self) - end - - local function SetLabel(self, text) - if text and text ~= "" then - self.label:SetText(text) - self.label:Show() - self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18) - self:SetHeight(44) - self.alignoffset = 30 - else - self.label:SetText("") - self.label:Hide() - self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0) - self:SetHeight(26) - self.alignoffset = 12 - end - end - - - local function Constructor() - local num = AceGUI:GetNextWidgetNum(Type) - local frame = CreateFrame("Frame",nil,UIParent) - local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..num,frame,"InputBoxTemplate") - - local self = {} - self.type = Type - self.num = num - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.SetDisabled = SetDisabled - self.SetText = SetText - self.SetLabel = SetLabel - - self.frame = frame - frame.obj = self - self.editbox = editbox - editbox.obj = self - - self.alignoffset = 30 - - frame:SetHeight(44) - frame:SetWidth(200) - - editbox:SetScript("OnEnter",Control_OnEnter) - editbox:SetScript("OnLeave",Control_OnLeave) - - editbox:SetAutoFocus(false) - editbox:SetFontObject(ChatFontNormal) - editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed) - editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed) - editbox:SetScript("OnTextChanged",EditBox_OnTextChanged) - editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) - editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) - - editbox:SetTextInsets(0,0,3,3) - editbox:SetMaxLetters(256) - - editbox:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",6,0) - editbox:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) - editbox:SetHeight(19) - - local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2) - label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2) - label:SetJustifyH("LEFT") - label:SetHeight(18) - self.label = label - - local button = CreateFrame("Button",nil,editbox,"UIPanelButtonTemplate") - button:SetWidth(40) - button:SetHeight(20) - button:SetPoint("RIGHT",editbox,"RIGHT",-2,0) - button:SetText(OKAY) - button:SetScript("OnClick", Button_OnClick) - button:Hide() - - self.button = button - button.obj = self - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua deleted file mode 100644 index 86d8a87..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua +++ /dev/null @@ -1,73 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Heading -- --------------------------- -do - local Type = "Heading" - local Version = 5 - - local function OnAcquire(self) - self:SetText("") - self:SetFullWidth() - self:SetHeight(18) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local function SetText(self, text) - self.label:SetText(text or "") - if (text or "") == "" then - self.left:SetPoint("RIGHT",self.frame,"RIGHT",-3,0) - self.right:Hide() - else - self.left:SetPoint("RIGHT",self.label,"LEFT",-5,0) - self.right:Show() - end - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetText = SetText - self.frame = frame - frame.obj = self - - frame:SetHeight(18) - - local label = frame:CreateFontString(nil,"BACKGROUND","GameFontNormal") - label:SetPoint("TOP",frame,"TOP",0,0) - label:SetPoint("BOTTOM",frame,"BOTTOM",0,0) - label:SetJustifyH("CENTER") - label:SetHeight(18) - self.label = label - - local left = frame:CreateTexture(nil, "BACKGROUND") - self.left = left - left:SetHeight(8) - left:SetPoint("LEFT",frame,"LEFT",3,0) - left:SetPoint("RIGHT",label,"LEFT",-5,0) - left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") - left:SetTexCoord(0.81, 0.94, 0.5, 1) - - local right = frame:CreateTexture(nil, "BACKGROUND") - self.right = right - right:SetHeight(8) - right:SetPoint("RIGHT",frame,"RIGHT",-3,0) - right:SetPoint("LEFT",label,"RIGHT",5,0) - right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") - right:SetTexCoord(0.81, 0.94, 0.5, 1) - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua deleted file mode 100644 index 626a6a2..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua +++ /dev/null @@ -1,141 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Label -- --------------------------- -do - local Type = "Icon" - local Version = 10 - - local function OnAcquire(self) - self:SetHeight(110) - self:SetWidth(110) - self:SetLabel("") - self:SetImage(nil) - self:SetImageSize(64, 64) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self:SetDisabled(false) - end - - local function SetLabel(self, text) - if text and text ~= "" then - self.label:Show() - self.label:SetText(text) - self.frame:SetHeight(self.image:GetHeight() + 25) - else - self.label:Hide() - self.frame:SetHeight(self.image:GetHeight() + 10) - end - end - - local function SetImage(self, path, ...) - local image = self.image - image:SetTexture(path) - - if image:GetTexture() then - self.imageshown = true - local n = select('#', ...) - if n == 4 or n == 8 then - image:SetTexCoord(...) - end - else - self.imageshown = nil - end - end - - local function SetImageSize(self, width, height) - self.image:SetWidth(width) - self.image:SetHeight(height) - --self.frame:SetWidth(width + 30) - if self.label:IsShown() then - self.frame:SetHeight(height + 25) - else - self.frame:SetHeight(height + 10) - end - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if disabled then - self.frame:Disable() - self.label:SetTextColor(0.5,0.5,0.5) - self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5) - else - self.frame:Enable() - self.label:SetTextColor(1,1,1) - self.image:SetVertexColor(1, 1, 1) - end - end - - local function OnClick(this, button) - this.obj:Fire("OnClick", button) - AceGUI:ClearFocus() - end - - local function OnEnter(this) - this.obj.highlight:Show() - this.obj:Fire("OnEnter") - end - - local function OnLeave(this) - this.obj.highlight:Hide() - this.obj:Fire("OnLeave") - end - - local function Constructor() - local frame = CreateFrame("Button",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetLabel = SetLabel - self.frame = frame - self.SetImage = SetImage - self.SetImageSize = SetImageSize - - -- SetText should be deprecated along the way - self.SetText = SetLabel - self.SetDisabled = SetDisabled - - frame.obj = self - - frame:SetHeight(110) - frame:SetWidth(110) - frame:EnableMouse(true) - frame:SetScript("OnClick", OnClick) - frame:SetScript("OnLeave", OnLeave) - frame:SetScript("OnEnter", OnEnter) - local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight") - label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) - label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) - label:SetJustifyH("CENTER") - label:SetJustifyV("TOP") - label:SetHeight(18) - self.label = label - - local image = frame:CreateTexture(nil,"BACKGROUND") - self.image = image - image:SetWidth(64) - image:SetHeight(64) - image:SetPoint("TOP",frame,"TOP",0,-5) - - local highlight = frame:CreateTexture(nil,"OVERLAY") - self.highlight = highlight - highlight:SetAllPoints(image) - highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") - highlight:SetTexCoord(0,1,0.23,0.77) - highlight:SetBlendMode("ADD") - highlight:Hide() - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end - diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-InlineGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-InlineGroup.lua deleted file mode 100644 index 2eb258d..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-InlineGroup.lua +++ /dev/null @@ -1,136 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - - -------------- --- Widgets -- -------------- ---[[ - Widgets must provide the following functions - Acquire() - Called when the object is aquired, should set everything to a default hidden state - Release() - Called when the object is Released, should remove any anchors and hide the Widget - - And the following members - frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes - type - the type of the object, same as the name given to :RegisterWidget() - - Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet - It will be cleared automatically when a widget is released - Placing values directly into a widget object should be avoided - - If the Widget can act as a container for other Widgets the following - content - frame or derivitive that children will be anchored to - - The Widget can supply the following Optional Members - - -]] - --------------------------- --- Inline Group -- --------------------------- ---[[ - This is a simple grouping container, no selection - It will resize automatically to the height of the controls added to it -]] - -do - local Type = "InlineGroup" - local Version = 5 - - local function OnAcquire(self) - self:SetWidth(300) - self:SetHeight(100) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local PaneBackdrop = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 5, bottom = 3 } - } - - local function SetTitle(self,title) - self.titletext:SetText(title) - end - - - local function LayoutFinished(self, width, height) - if self.noAutoHeight then return end - self:SetHeight((height or 0) + 40) - end - - local function OnWidthSet(self, width) - local content = self.content - local contentwidth = width - 20 - if contentwidth < 0 then - contentwidth = 0 - end - content:SetWidth(contentwidth) - content.width = contentwidth - end - - - local function OnHeightSet(self, height) - local content = self.content - local contentheight = height - 20 - if contentheight < 0 then - contentheight = 0 - end - content:SetHeight(contentheight) - content.height = contentheight - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetTitle = SetTitle - self.frame = frame - self.LayoutFinished = LayoutFinished - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - - frame.obj = self - - frame:SetHeight(100) - frame:SetWidth(100) - frame:SetFrameStrata("FULLSCREEN_DIALOG") - - local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") - titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0) - titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0) - titletext:SetJustifyH("LEFT") - titletext:SetHeight(18) - - self.titletext = titletext - - local border = CreateFrame("Frame",nil,frame) - self.border = border - border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-17) - border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3) - - border:SetBackdrop(PaneBackdrop) - border:SetBackdropColor(0.1,0.1,0.1,0.5) - border:SetBackdropBorderColor(0.4,0.4,0.4) - - --Container Support - local content = CreateFrame("Frame",nil,border) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) - content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) - - AceGUI:RegisterAsContainer(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua deleted file mode 100644 index 0b10ee0..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua +++ /dev/null @@ -1,201 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Label -- --------------------------- -do - local Type = "InteractiveLabel" - local Version = 5 - - local function OnAcquire(self) - self:SetHeight(18) - self:SetWidth(200) - self:SetText("") - self:SetImage(nil) - self:SetColor() - self:SetFontObject() - self:SetHighlight() - self:SetHighlightTexCoord() - end - - local function OnRelease(self) - self:SetDisabled(false) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local function UpdateImageAnchor(self) - local width = self.frame.width or self.frame:GetWidth() or 0 - local image = self.image - local label = self.label - local frame = self.frame - local height - - label:ClearAllPoints() - image:ClearAllPoints() - - if self.imageshown then - local imagewidth = image:GetWidth() - if (width - imagewidth) < 200 or (label:GetText() or "") == "" then - --image goes on top centered when less than 200 width for the text, or if there is no text - image:SetPoint("TOP",frame,"TOP",0,0) - label:SetPoint("TOP",image,"BOTTOM",0,0) - label:SetPoint("LEFT",frame,"LEFT",0,0) - label:SetWidth(width) - height = image:GetHeight() + label:GetHeight() - else - --image on the left - image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetPoint("TOPLEFT",image,"TOPRIGHT",0,0) - label:SetWidth(width - imagewidth) - height = math.max(image:GetHeight(), label:GetHeight()) - end - else - --no image shown - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetWidth(width) - height = self.label:GetHeight() - end - - self.resizing = true - self.frame:SetHeight(height) - self.frame.height = height - self.resizing = nil - end - - local function SetText(self, text) - self.label:SetText(text or "") - UpdateImageAnchor(self) - end - - local function SetColor(self, r, g, b) - if not (r and g and b) then - r, g, b = 1, 1, 1 - end - self.label:SetVertexColor(r, g, b) - end - - local function OnWidthSet(self, width) - if self.resizing then return end - UpdateImageAnchor(self) - end - - local function SetImage(self, path, ...) - local image = self.image - image:SetTexture(path) - - if image:GetTexture() then - self.imageshown = true - local n = select('#', ...) - if n == 4 or n == 8 then - image:SetTexCoord(...) - end - else - self.imageshown = nil - end - UpdateImageAnchor(self) - end - - local function SetFont(self, font, height, flags) - self.label:SetFont(font, height, flags) - end - - local function SetFontObject(self, font) - self.label:SetFontObject(font or GameFontHighlightSmall) - end - - local function SetImageSize(self, width, height) - self.image:SetWidth(width) - self.image:SetHeight(height) - UpdateImageAnchor(self) - end - - local function SetHighlight(self, ...) - self.highlight:SetTexture(...) - end - - local function SetHighlightTexCoord(self, ...) - if select('#', ...) >= 1 then - self.highlight:SetTexCoord(...) - else - self.highlight:SetTexCoord(0, 1, 0, 1) - end - end - - local function SetDisabled(self,disabled) - self.disabled = disabled - if disabled then - self.frame:EnableMouse(false) - self.label:SetTextColor(0.5, 0.5, 0.5) - else - self.frame:EnableMouse(true) - self.label:SetTextColor(1, 1, 1) - end - end - - local function OnEnter(this) - this.obj.highlight:Show() - this.obj:Fire("OnEnter") - end - - local function OnLeave(this) - this.obj.highlight:Hide() - this.obj:Fire("OnLeave") - end - - local function OnClick(this, ...) - this.obj:Fire("OnClick", ...) - AceGUI:ClearFocus() - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - frame:EnableMouse(true) - frame:SetScript("OnEnter", OnEnter) - frame:SetScript("OnLeave", OnLeave) - frame:SetScript("OnMouseDown", OnClick) - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetText = SetText - self.SetColor = SetColor - self.frame = frame - self.OnWidthSet = OnWidthSet - self.SetImage = SetImage - self.SetImageSize = SetImageSize - self.SetFont = SetFont - self.SetFontObject = SetFontObject - self.SetHighlight = SetHighlight - self.SetHighlightTexCoord = SetHighlightTexCoord - self.SetDisabled = SetDisabled - frame.obj = self - - frame:SetHeight(18) - frame:SetWidth(200) - local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetWidth(200) - label:SetJustifyH("LEFT") - label:SetJustifyV("TOP") - self.label = label - - local highlight = frame:CreateTexture(nil, "OVERLAY") - highlight:SetTexture(nil) - highlight:SetAllPoints() - highlight:SetBlendMode("ADD") - highlight:Hide() - self.highlight = highlight - - local image = frame:CreateTexture(nil,"BACKGROUND") - self.image = image - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end - diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua deleted file mode 100644 index 87d834c..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua +++ /dev/null @@ -1,220 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Keybinding -- --------------------------- - -do - local Type = "Keybinding" - local Version = 13 - - local ControlBackdrop = { - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 3, bottom = 3 } - } - - local function Control_OnEnter(this) - this.obj:Fire("OnEnter") - end - - local function Control_OnLeave(this) - this.obj:Fire("OnLeave") - end - - local function keybindingMsgFixWidth(this) - this:SetWidth(this.msg:GetWidth()+10) - this:SetScript("OnUpdate",nil) - end - - local function Keybinding_OnClick(this, button) - if button == "LeftButton" or button == "RightButton" then - local self = this.obj - if self.waitingForKey then - this:EnableKeyboard(false) - self.msgframe:Hide() - this:UnlockHighlight() - self.waitingForKey = nil - else - this:EnableKeyboard(true) - self.msgframe:Show() - this:LockHighlight() - self.waitingForKey = true - end - end - AceGUI:ClearFocus() - end - - local ignoreKeys = nil - local function Keybinding_OnKeyDown(this, key) - local self = this.obj - if self.waitingForKey then - local keyPressed = key - if keyPressed == "ESCAPE" then - keyPressed = "" - else - if not ignoreKeys then - ignoreKeys = { - ["BUTTON1"] = true, ["BUTTON2"] = true, - ["UNKNOWN"] = true, - ["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, - ["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true, - } - end - if ignoreKeys[keyPressed] then return end - if IsShiftKeyDown() then - keyPressed = "SHIFT-"..keyPressed - end - if IsControlKeyDown() then - keyPressed = "CTRL-"..keyPressed - end - if IsAltKeyDown() then - keyPressed = "ALT-"..keyPressed - end - end - - this:EnableKeyboard(false) - self.msgframe:Hide() - this:UnlockHighlight() - self.waitingForKey = nil - - if not self.disabled then - self:SetKey(keyPressed) - self:Fire("OnKeyChanged",keyPressed) - end - end - end - - local function Keybinding_OnMouseDown(this, button) - if button == "LeftButton" or button == "RightButton" then - return - elseif button == "MiddleButton" then - button = "BUTTON3" - elseif button == "Button4" then - button = "BUTTON4" - elseif button == "Button5" then - button = "BUTTON5" - end - Keybinding_OnKeyDown(this, button) - end - - local function OnAcquire(self) - self:SetWidth(200) - self:SetHeight(44) - self:SetLabel("") - self:SetKey("") - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.waitingForKey = nil - self.msgframe:Hide() - self:SetDisabled(false) - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if disabled then - self.button:Disable() - self.label:SetTextColor(0.5,0.5,0.5) - else - self.button:Enable() - self.label:SetTextColor(1,1,1) - end - end - - local function SetKey(self, key) - if (key or "") == "" then - self.button:SetText(NOT_BOUND) - self.button:SetNormalFontObject("GameFontNormal") - else - self.button:SetText(key) - self.button:SetNormalFontObject("GameFontHighlight") - end - end - - local function SetLabel(self, label) - self.label:SetText(label or "") - if (label or "") == "" then - self.alignoffset = nil - self:SetHeight(24) - else - self.alignoffset = 30 - self:SetHeight(44) - end - end - - local function Constructor() - local num = AceGUI:GetNextWidgetNum(Type) - local frame = CreateFrame("Frame",nil,UIParent) - - local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..num,frame,"UIPanelButtonTemplate2") - - local self = {} - self.type = Type - self.num = num - - local text = button:GetFontString() - text:SetPoint("LEFT",button,"LEFT",7,0) - text:SetPoint("RIGHT",button,"RIGHT",-7,0) - - button:SetScript("OnClick",Keybinding_OnClick) - button:SetScript("OnKeyDown",Keybinding_OnKeyDown) - button:SetScript("OnEnter",Control_OnEnter) - button:SetScript("OnLeave",Control_OnLeave) - button:SetScript("OnMouseDown",Keybinding_OnMouseDown) - button:RegisterForClicks("AnyDown") - button:EnableMouse() - - button:SetHeight(24) - button:SetWidth(200) - button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0) - button:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) - - frame:SetWidth(200) - frame:SetHeight(44) - - self.alignoffset = 30 - - self.button = button - - local label = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) - label:SetJustifyH("CENTER") - label:SetHeight(18) - self.label = label - - local msgframe = CreateFrame("Frame",nil,UIParent) - msgframe:SetHeight(30) - msgframe:SetBackdrop(ControlBackdrop) - msgframe:SetBackdropColor(0,0,0) - msgframe:SetFrameStrata("FULLSCREEN_DIALOG") - msgframe:SetFrameLevel(1000) - self.msgframe = msgframe - local msg = msgframe:CreateFontString(nil,"OVERLAY","GameFontNormal") - msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel") - msgframe.msg = msg - msg:SetPoint("TOPLEFT",msgframe,"TOPLEFT",5,-5) - msgframe:SetScript("OnUpdate", keybindingMsgFixWidth) - msgframe:SetPoint("BOTTOM",button,"TOP",0,0) - msgframe:Hide() - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetLabel = SetLabel - self.SetDisabled = SetDisabled - self.SetKey = SetKey - - self.frame = frame - frame.obj = self - button.obj = self - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua deleted file mode 100644 index 2f4c5bd..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua +++ /dev/null @@ -1,145 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Label -- --------------------------- -do - local Type = "Label" - local Version = 10 - - local function OnAcquire(self) - self:SetHeight(18) - self:SetWidth(200) - self:SetText("") - self:SetImage(nil) - self:SetColor() - self:SetFontObject() - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local function UpdateImageAnchor(self) - local width = self.frame.width or self.frame:GetWidth() or 0 - local image = self.image - local label = self.label - local frame = self.frame - local height - - label:ClearAllPoints() - image:ClearAllPoints() - - if self.imageshown then - local imagewidth = image:GetWidth() - if (width - imagewidth) < 200 or (label:GetText() or "") == "" then - --image goes on top centered when less than 200 width for the text, or if there is no text - image:SetPoint("TOP",frame,"TOP",0,0) - label:SetPoint("TOP",image,"BOTTOM",0,0) - label:SetPoint("LEFT",frame,"LEFT",0,0) - label:SetWidth(width) - height = image:GetHeight() + label:GetHeight() - else - --image on the left - image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetPoint("TOPLEFT",image,"TOPRIGHT",0,0) - label:SetWidth(width - imagewidth) - height = math.max(image:GetHeight(), label:GetHeight()) - end - else - --no image shown - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetWidth(width) - height = self.label:GetHeight() - end - - self.resizing = true - self.frame:SetHeight(height) - self.frame.height = height - self.resizing = nil - end - - local function SetText(self, text) - self.label:SetText(text or "") - UpdateImageAnchor(self) - end - - local function SetColor(self, r, g, b) - if not (r and g and b) then - r, g, b = 1, 1, 1 - end - self.label:SetVertexColor(r, g, b) - end - - local function OnWidthSet(self, width) - if self.resizing then return end - UpdateImageAnchor(self) - end - - local function SetImage(self, path, ...) - local image = self.image - image:SetTexture(path) - - if image:GetTexture() then - self.imageshown = true - local n = select('#', ...) - if n == 4 or n == 8 then - image:SetTexCoord(...) - end - else - self.imageshown = nil - end - UpdateImageAnchor(self) - end - - local function SetFont(self, font, height, flags) - self.label:SetFont(font, height, flags) - end - - local function SetFontObject(self, font) - self.label:SetFontObject(font or GameFontHighlightSmall) - end - - local function SetImageSize(self, width, height) - self.image:SetWidth(width) - self.image:SetHeight(height) - UpdateImageAnchor(self) - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetText = SetText - self.SetColor = SetColor - self.frame = frame - self.OnWidthSet = OnWidthSet - self.SetImage = SetImage - self.SetImageSize = SetImageSize - self.SetFont = SetFont - self.SetFontObject = SetFontObject - frame.obj = self - - frame:SetHeight(18) - frame:SetWidth(200) - local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetWidth(200) - label:SetJustifyH("LEFT") - label:SetJustifyV("TOP") - self.label = label - - local image = frame:CreateTexture(nil,"BACKGROUND") - self.image = image - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end - diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua deleted file mode 100644 index 0700680..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua +++ /dev/null @@ -1,318 +0,0 @@ - ---[[ ---Multiline Editbox Widget, Originally by bam - ---]] -local assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall = - assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall -local getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack = - getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack -local math, string, table = math, string, table -local find, format, gmatch, gsub, tolower, match, toupper, join, split, trim = - string.find, string.format, string.gmatch, string.gsub, string.lower, string.match, string.upper, string.join, string.split, string.trim -local concat, insert, maxn, remove, sort = table.concat, table.insert, table.maxn, table.remove, table.sort -local max, min, abs, ceil, floor = math.max, math.min, math.abs, math.ceil, math.floor - -local LibStub = assert(LibStub) - -local ChatFontNormal = ChatFontNormal -local ClearCursor = ClearCursor -local CreateFrame = CreateFrame -local GetCursorInfo = GetCursorInfo -local GetSpellName = GetSpellName -local UIParent = UIParent -local UISpecialFrames = UISpecialFrames - --- No global variables after this! - -local _G = getfenv() - -local AceGUI = LibStub("AceGUI-3.0") - -local Version = 10 ---------------------- --- Common Elements -- ---------------------- - -local FrameBackdrop = { - bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", - edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", - tile = true, tileSize = 32, edgeSize = 32, - insets = { left = 8, right = 8, top = 8, bottom = 8 } -} - -local PaneBackdrop = { - - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 5, bottom = 3 } -} - -local ControlBackdrop = { - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 3, bottom = 3 } -} - --------------------------- --- Edit box -- --------------------------- ---[[ - Events : - OnTextChanged - OnEnterPressed - -]] -do - local Type = "MultiLineEditBox" - - local MultiLineEditBox = {} - - local function EditBox_OnEnterPressed(this) - local self = this.obj - local value = this:GetText() - local cancel = self:Fire("OnEnterPressed",value) - if not cancel then - self.button:Disable() - end - end - - local function Button_OnClick(this) - local editbox = this.obj.editbox - editbox:ClearFocus() - EditBox_OnEnterPressed(editbox) - end - - local function EditBox_OnReceiveDrag(this) - local self = this.obj - local type, id, info = GetCursorInfo() - if type == "item" then - self:SetText(info) - self:Fire("OnEnterPressed",info) - ClearCursor() - elseif type == "spell" then - local name, rank = GetSpellName(id, info) - if rank and rank:match("%d") then - name = name.."("..rank..")" - end - self:SetText(name) - self:Fire("OnEnterPressed",name) - ClearCursor() - end - --self.button:Disable() - AceGUI:ClearFocus() - end - - function MultiLineEditBox:OnAcquire() - self:SetWidth(200) - self:SetHeight(116) - self:SetNumLines(4) - self:SetDisabled(false) - self:ShowButton(true) - end - - function MultiLineEditBox:OnRelease() - self.frame:ClearAllPoints() - self.frame:Hide() - self:SetDisabled(false) - end - - function MultiLineEditBox:SetDisabled(disabled) - self.disabled = disabled - if disabled then - self.editbox:EnableMouse(false) - self.scrollframe:EnableMouse(false) - self.editbox:ClearFocus() - self.editbox:SetTextColor(0.5, 0.5, 0.5) - self.label:SetTextColor(0.5,0.5,0.5) - else - self.editbox:EnableMouse(true) - self.scrollframe:EnableMouse(true) - self.editbox:SetTextColor(1, 1, 1) - self.label:SetTextColor(1,.82,0) - end - end - - function MultiLineEditBox:SetText(text) - text = text or "" - local editbox = self.editbox - local oldText = editbox:GetText() - local dummy = format(" %s", text) - self.lasttext = dummy -- prevents OnTextChanged from firing - editbox:SetText(dummy) - editbox:HighlightText(0, 1) - self.lasttext = oldText - editbox:Insert("") - end - - function MultiLineEditBox:SetLabel(text) - if (text or "") == "" then - self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,0) - self.label:Hide() - self.label:SetText("") - else - self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-20) - self.label:Show() - self.label:SetText(text) - end - end - - function MultiLineEditBox:SetNumLines(number) - number = number or 4 - self:SetHeight(60 + (14*number)) - end - - function MultiLineEditBox:GetText() - return self.editbox:GetText() - end - - function MultiLineEditBox:ShowButton(show) - if show then - self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,22) - self.button:Show() - else - self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) - self.button:Hide() - end - end - - local function Constructor() - local frame = CreateFrame("Frame", nil, UIParent) - local backdrop = CreateFrame("Frame", nil, frame) - local self = {} - for k, v in pairs(MultiLineEditBox) do self[k] = v end - self.type = Type - self.frame = frame - self.backdrop = backdrop - frame.obj = self - - backdrop:SetBackdrop(ControlBackdrop) - backdrop:SetBackdropColor(0, 0, 0) - backdrop:SetBackdropBorderColor(0.4, 0.4, 0.4) - - backdrop:SetPoint("TOPLEFT",frame,"TOPLEFT",0, -20) - backdrop:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,22) - - local scrollframe = CreateFrame("ScrollFrame", format("%s@%s@%s", Type, "ScrollFrame", tostring(self)), backdrop, "UIPanelScrollFrameTemplate") - scrollframe:SetPoint("TOPLEFT", 5, -6) - scrollframe:SetPoint("BOTTOMRIGHT", -28, 6) - scrollframe.obj = self - self.scrollframe = scrollframe - - --local scrollchild = CreateFrame("Frame", nil, scrollframe) - --scrollframe:SetScrollChild(scrollchild) - --scrollchild:SetHeight(2) - --scrollchild:SetWidth(2) - - local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2) - label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2) - label:SetJustifyH("LEFT") - label:SetHeight(18) - self.label = label - - local editbox = CreateFrame("EditBox", nil, scrollframe) - self.editbox = editbox - editbox.obj = self - editbox:SetPoint("TOPLEFT") - editbox:SetPoint("BOTTOMLEFT") - editbox:SetHeight(50) - editbox:SetWidth(50) - editbox:SetMultiLine(true) - -- editbox:SetMaxLetters(7500) - editbox:SetTextInsets(5, 5, 3, 3) - editbox:EnableMouse(true) - editbox:SetAutoFocus(false) - editbox:SetFontObject(ChatFontNormal) - scrollframe:SetScrollChild(editbox) - - local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate") - button:SetWidth(80) - button:SetHeight(20) - button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2) - button:SetText(ACCEPT) - button:SetScript("OnClick", Button_OnClick) - button:SetFrameLevel(editbox:GetFrameLevel() + 1) - button:Disable() - button:Hide() - self.button = button - button.obj = self - - scrollframe:EnableMouse(true) - scrollframe:SetScript("OnMouseUp", function() editbox:SetFocus() end) - scrollframe:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) - scrollframe:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) - - editbox:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) - editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) - - local function FixSize() - --scrollchild:SetHeight(scrollframe:GetHeight()) - --scrollchild:SetWidth(scrollframe:GetWidth()) - editbox:SetWidth(scrollframe:GetWidth()) - end - scrollframe:SetScript("OnShow", FixSize) - scrollframe:SetScript("OnSizeChanged", FixSize) - - editbox:SetScript("OnEscapePressed", editbox.ClearFocus) - editbox:SetScript("OnTextChanged", function(_, ...) - scrollframe:UpdateScrollChildRect() - local value = editbox:GetText() - if value ~= self.lasttext then - self:Fire("OnTextChanged", value) - self.lasttext = value - self.button:Enable() - end - end) - - editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) - editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) - - do - local cursorOffset, cursorHeight - local idleTime - local function FixScroll(_, elapsed) - if cursorOffset and cursorHeight then - idleTime = 0 - local height = scrollframe:GetHeight() - local range = scrollframe:GetVerticalScrollRange() - local scroll = scrollframe:GetVerticalScroll() - local size = height + range - cursorOffset = -cursorOffset - while cursorOffset < scroll do - scroll = scroll - (height / 2) - if scroll < 0 then scroll = 0 end - scrollframe:SetVerticalScroll(scroll) - end - while cursorOffset + cursorHeight > scroll + height and scroll < range do - scroll = scroll + (height / 2) - if scroll > range then scroll = range end - scrollframe:SetVerticalScroll(scroll) - end - elseif not idleTime or idleTime > 2 then - frame:SetScript("OnUpdate", nil) - idleTime = nil - else - idleTime = idleTime + elapsed - end - cursorOffset = nil - end - editbox:SetScript("OnCursorChanged", function(_, x, y, w, h) - cursorOffset, cursorHeight = y, h - if not idleTime then - frame:SetScript("OnUpdate", FixScroll) - end - end) - end - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type, Constructor, Version) -end - - - diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-ScrollFrame.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-ScrollFrame.lua deleted file mode 100644 index b09c83b..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-ScrollFrame.lua +++ /dev/null @@ -1,225 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - -------------- --- Widgets -- -------------- ---[[ - Widgets must provide the following functions - Acquire() - Called when the object is aquired, should set everything to a default hidden state - Release() - Called when the object is Released, should remove any anchors and hide the Widget - - And the following members - frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes - type - the type of the object, same as the name given to :RegisterWidget() - - Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet - It will be cleared automatically when a widget is released - Placing values directly into a widget object should be avoided - - If the Widget can act as a container for other Widgets the following - content - frame or derivitive that children will be anchored to - - The Widget can supply the following Optional Members - - -]] - --------------------------- --- Scroll Frame -- --------------------------- -do - local Type = "ScrollFrame" - local Version = 4 - - local function OnAcquire(self) - - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.status = nil - for k in pairs(self.localstatus) do - self.localstatus[k] = nil - end - end - - local function SetScroll(self, value) - - local status = self.status or self.localstatus - - local frame, child = self.scrollframe, self.content - local viewheight = frame:GetHeight() - local height = child:GetHeight() - local offset - if viewheight > height then - offset = 0 - else - offset = floor((height - viewheight) / 1000.0 * value) - end - child:ClearAllPoints() - child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset) - child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset) - status.offset = offset - status.scrollvalue = value - end - - local function MoveScroll(self, value) - local status = self.status or self.localstatus - local frame, child = self.scrollframe, self.content - local height, viewheight = frame:GetHeight(), child:GetHeight() - if height > viewheight then - self.scrollbar:Hide() - else - self.scrollbar:Show() - local diff = height - viewheight - local delta = 1 - if value < 0 then - delta = -1 - end - self.scrollbar:SetValue(math.min(math.max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000)) - end - end - - - local function FixScroll(self) - local status = self.status or self.localstatus - local frame, child = self.scrollframe, self.content - local height, viewheight = frame:GetHeight(), child:GetHeight() - local offset = status.offset - if not offset then - offset = 0 - end - local curvalue = self.scrollbar:GetValue() - if viewheight < height then - self.scrollbar:Hide() - self.scrollbar:SetValue(0) - --self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) - else - self.scrollbar:Show() - --self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-16,0) - local value = (offset / (viewheight - height) * 1000) - if value > 1000 then value = 1000 end - self.scrollbar:SetValue(value) - self:SetScroll(value) - if value < 1000 then - child:ClearAllPoints() - child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset) - child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset) - status.offset = offset - end - end - end - - local function OnMouseWheel(this,value) - this.obj:MoveScroll(value) - end - - local function OnScrollValueChanged(this, value) - this.obj:SetScroll(value) - end - - local function FixScrollOnUpdate(this) - this:SetScript("OnUpdate", nil) - this.obj:FixScroll() - end - local function OnSizeChanged(this) - --this:SetScript("OnUpdate", FixScrollOnUpdate) - this.obj:FixScroll() - end - - local function LayoutFinished(self,width,height) - self.content:SetHeight(height or 0 + 20) - self:FixScroll() - end - - -- called to set an external table to store status in - local function SetStatusTable(self, status) - assert(type(status) == "table") - self.status = status - if not status.scrollvalue then - status.scrollvalue = 0 - end - end - - - local createdcount = 0 - - local function OnWidthSet(self, width) - local content = self.content - content.width = width - end - - - local function OnHeightSet(self, height) - local content = self.content - content.height = height - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.MoveScroll = MoveScroll - self.FixScroll = FixScroll - self.SetScroll = SetScroll - self.LayoutFinished = LayoutFinished - self.SetStatusTable = SetStatusTable - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - - self.localstatus = {} - self.frame = frame - frame.obj = self - - --Container Support - local scrollframe = CreateFrame("ScrollFrame",nil,frame) - local content = CreateFrame("Frame",nil,scrollframe) - createdcount = createdcount + 1 - local scrollbar = CreateFrame("Slider",("AceConfigDialogScrollFrame%dScrollBar"):format(createdcount),scrollframe,"UIPanelScrollBarTemplate") - local scrollbg = scrollbar:CreateTexture(nil,"BACKGROUND") - scrollbg:SetAllPoints(scrollbar) - scrollbg:SetTexture(0,0,0,0.4) - self.scrollframe = scrollframe - self.content = content - self.scrollbar = scrollbar - - scrollbar.obj = self - scrollframe.obj = self - content.obj = self - - scrollframe:SetScrollChild(content) - scrollframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-20,0) - scrollframe:EnableMouseWheel(true) - scrollframe:SetScript("OnMouseWheel", OnMouseWheel) - scrollframe:SetScript("OnSizeChanged", OnSizeChanged) - - - content:SetPoint("TOPLEFT",scrollframe,"TOPLEFT",0,0) - content:SetPoint("TOPRIGHT",scrollframe,"TOPRIGHT",0,0) - content:SetHeight(400) - - scrollbar:SetPoint("TOPLEFT",scrollframe,"TOPRIGHT",4,-16) - scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",4,16) - scrollbar:SetScript("OnValueChanged", OnScrollValueChanged) - scrollbar:SetMinMaxValues(0,1000) - scrollbar:SetValueStep(1) - scrollbar:SetValue(0) - scrollbar:SetWidth(16) - - self.localstatus.scrollvalue = 0 - - - self:FixScroll() - AceGUI:RegisterAsContainer(self) - --AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-SimpleGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-SimpleGroup.lua deleted file mode 100644 index d21461e..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-SimpleGroup.lua +++ /dev/null @@ -1,97 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - - -------------- --- Widgets -- -------------- ---[[ - Widgets must provide the following functions - Acquire() - Called when the object is aquired, should set everything to a default hidden state - Release() - Called when the object is Released, should remove any anchors and hide the Widget - - And the following members - frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes - type - the type of the object, same as the name given to :RegisterWidget() - - Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet - It will be cleared automatically when a widget is released - Placing values directly into a widget object should be avoided - - If the Widget can act as a container for other Widgets the following - content - frame or derivitive that children will be anchored to - - The Widget can supply the following Optional Members - - -]] - --------------------------- --- Simple Group -- --------------------------- ---[[ - This is a simple grouping container, no selection, no borders - It will resize automatically to the height of the controls added to it -]] - -do - local Type = "SimpleGroup" - local Version = 5 - - local function OnAcquire(self) - self:SetWidth(300) - self:SetHeight(100) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - end - - local function LayoutFinished(self, width, height) - if self.noAutoHeight then return end - self:SetHeight(height or 0) - end - - local function OnWidthSet(self, width) - local content = self.content - content:SetWidth(width) - content.width = width - end - - local function OnHeightSet(self, height) - local content = self.content - content:SetHeight(height) - content.height = height - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.frame = frame - self.LayoutFinished = LayoutFinished - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - - frame.obj = self - - frame:SetHeight(100) - frame:SetWidth(100) - frame:SetFrameStrata("FULLSCREEN_DIALOG") - - --Container Support - local content = CreateFrame("Frame",nil,frame) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) - - AceGUI:RegisterAsContainer(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua deleted file mode 100644 index 81e0918..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua +++ /dev/null @@ -1,255 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --------------------------- --- Slider -- --------------------------- -do - local Type = "Slider" - local Version = 7 - - local function OnAcquire(self) - self:SetWidth(200) - self:SetHeight(44) - self:SetDisabled(false) - self:SetIsPercent(nil) - self:SetSliderValues(0,100,1) - self:SetValue(0) - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.slider:EnableMouseWheel(false) - self:SetDisabled(false) - end - - local function Control_OnEnter(this) - this.obj:Fire("OnEnter") - end - - local function Control_OnLeave(this) - this.obj:Fire("OnLeave") - end - - local function UpdateText(self) - local value = self.value or 0 - if self.ispercent then - self.editbox:SetText(("%s%%"):format(math.floor(value*1000+0.5)/10)) - else - self.editbox:SetText(math.floor(value*100+0.5)/100) - end - end - - local function UpdateLabels(self) - local min, max = (self.min or 0), (self.max or 100) - if self.ispercent then - self.lowtext:SetFormattedText("%s%%",(min * 100)) - self.hightext:SetFormattedText("%s%%",(max * 100)) - else - self.lowtext:SetText(min) - self.hightext:SetText(max) - end - end - - local function Slider_OnValueChanged(this) - local self = this.obj - if not this.setup then - local newvalue - newvalue = this:GetValue() - if newvalue ~= self.value and not self.disabled then - self.value = newvalue - self:Fire("OnValueChanged", newvalue) - end - if self.value then - local value = self.value - UpdateText(self) - end - end - end - - local function Slider_OnMouseUp(this) - local self = this.obj - self:Fire("OnMouseUp",this:GetValue()) - end - - local function Slider_OnMouseWheel(this, v) - local self = this.obj - if not self.disabled then - local value = self.value - if v > 0 then - value = math.min(value + (self.step or 1),self.max) - else - value = math.max(value - (self.step or 1), self.min) - end - self.slider:SetValue(value) - end - end - - local function SetDisabled(self, disabled) - self.disabled = disabled - if disabled then - self.slider:EnableMouse(false) - self.label:SetTextColor(.5,.5,.5) - self.hightext:SetTextColor(.5,.5,.5) - self.lowtext:SetTextColor(.5,.5,.5) - --self.valuetext:SetTextColor(.5,.5,.5) - self.editbox:SetTextColor(.5,.5,.5) - self.editbox:EnableMouse(false) - self.editbox:ClearFocus() - else - self.slider:EnableMouse(true) - self.label:SetTextColor(1,.82,0) - self.hightext:SetTextColor(1,1,1) - self.lowtext:SetTextColor(1,1,1) - --self.valuetext:SetTextColor(1,1,1) - self.editbox:SetTextColor(1,1,1) - self.editbox:EnableMouse(true) - end - end - - local function SetValue(self, value) - self.slider.setup = true - self.slider:SetValue(value) - self.value = value - UpdateText(self) - self.slider.setup = nil - end - - local function SetLabel(self, text) - self.label:SetText(text) - end - - local function SetSliderValues(self, min, max, step) - local frame = self.slider - frame.setup = true - self.min = min - self.max = max - self.step = step - frame:SetMinMaxValues(min or 0,max or 100) - UpdateLabels(self) - frame:SetValueStep(step or 1) - frame.setup = nil - end - - local function EditBox_OnEscapePressed(this) - this:ClearFocus() - end - - local function EditBox_OnEnterPressed(this) - local self = this.obj - local value = this:GetText() - if self.ispercent then - value = value:gsub('%%','') - value = tonumber(value) / 100 - else - value = tonumber(value) - end - - if value then - self:Fire("OnMouseUp",value) - end - end - - local function SetIsPercent(self, value) - self.ispercent = value - UpdateLabels(self) - UpdateText(self) - end - - local function FrameOnMouseDown(this) - this.obj.slider:EnableMouseWheel(true) - AceGUI:ClearFocus() - end - - local SliderBackdrop = { - bgFile = "Interface\\Buttons\\UI-SliderBar-Background", - edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", - tile = true, tileSize = 8, edgeSize = 8, - insets = { left = 3, right = 3, top = 6, bottom = 6 } - } - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.frame = frame - frame.obj = self - - self.SetDisabled = SetDisabled - self.SetValue = SetValue - self.SetSliderValues = SetSliderValues - self.SetLabel = SetLabel - self.SetIsPercent = SetIsPercent - - self.alignoffset = 25 - - frame:EnableMouse(true) - frame:SetScript("OnMouseDown",FrameOnMouseDown) - self.slider = CreateFrame("Slider",nil,frame) - local slider = self.slider - slider:SetScript("OnEnter",Control_OnEnter) - slider:SetScript("OnLeave",Control_OnLeave) - slider:SetScript("OnMouseUp", Slider_OnMouseUp) - slider.obj = self - slider:SetOrientation("HORIZONTAL") - slider:SetHeight(15) - slider:SetHitRectInsets(0,0,-10,0) - slider:SetBackdrop(SliderBackdrop) - --slider:EnableMouseWheel(true) - slider:SetScript("OnMouseWheel", Slider_OnMouseWheel) - - local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") - label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) - label:SetJustifyH("CENTER") - label:SetHeight(15) - self.label = label - - self.lowtext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall") - self.lowtext:SetPoint("TOPLEFT",slider,"BOTTOMLEFT",2,3) - - self.hightext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall") - self.hightext:SetPoint("TOPRIGHT",slider,"BOTTOMRIGHT",-2,3) - - - local editbox = CreateFrame("EditBox",nil,frame) - editbox:SetAutoFocus(false) - editbox:SetFontObject(GameFontHighlightSmall) - editbox:SetPoint("TOP",slider,"BOTTOM",0,0) - editbox:SetHeight(14) - editbox:SetWidth(70) - editbox:SetJustifyH("CENTER") - editbox:EnableMouse(true) - editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed) - editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed) - self.editbox = editbox - editbox.obj = self - - local bg = editbox:CreateTexture(nil,"BACKGROUND") - editbox.bg = bg - bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") - bg:SetVertexColor(0,0,0,0.25) - bg:SetAllPoints(editbox) - - slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") - - frame:SetWidth(200) - frame:SetHeight(44) - slider:SetPoint("TOP",label,"BOTTOM",0,0) - slider:SetPoint("LEFT",frame,"LEFT",3,0) - slider:SetPoint("RIGHT",frame,"RIGHT",-3,0) - - - slider:SetValue(self.value or 0) - slider:SetScript("OnValueChanged",Slider_OnValueChanged) - - AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-TabGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-TabGroup.lua deleted file mode 100644 index ead8479..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-TabGroup.lua +++ /dev/null @@ -1,365 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - -------------- --- Widgets -- -------------- ---[[ - Widgets must provide the following functions - Acquire() - Called when the object is aquired, should set everything to a default hidden state - Release() - Called when the object is Released, should remove any anchors and hide the Widget - - And the following members - frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes - type - the type of the object, same as the name given to :RegisterWidget() - - Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet - It will be cleared automatically when a widget is released - Placing values directly into a widget object should be avoided - - If the Widget can act as a container for other Widgets the following - content - frame or derivitive that children will be anchored to - - The Widget can supply the following Optional Members - - -]] - --------------------------- --- Tab Group -- --------------------------- - -do - local Type = "TabGroup" - local Version = 20 - - local PaneBackdrop = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 5, bottom = 3 } - } - - local function OnAcquire(self) - - end - - local function OnRelease(self) - self.frame:ClearAllPoints() - self.frame:Hide() - self.status = nil - for k in pairs(self.localstatus) do - self.localstatus[k] = nil - end - self.tablist = nil - for _, tab in pairs(self.tabs) do - tab:Hide() - end - end - - local function Tab_SetText(self, text) - self:_SetText(text) - local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0 - PanelTemplates_TabResize(self, 0, nil, width) - end - - local function UpdateTabLook(self) - if self.disabled then - PanelTemplates_SetDisabledTabState(self) - elseif self.selected then - PanelTemplates_SelectTab(self) - else - PanelTemplates_DeselectTab(self) - end - end - - local function Tab_SetSelected(self, selected) - self.selected = selected - UpdateTabLook(self) - end - - local function Tab_OnClick(self) - if not (self.selected or self.disabled) then - self.obj:SelectTab(self.value) - end - end - - local function Tab_SetDisabled(self, disabled) - self.disabled = disabled - UpdateTabLook(self) - end - - local function Tab_OnEnter(this) - local self = this.obj - self:Fire("OnTabEnter", self.tabs[this.id].value, this) - end - - local function Tab_OnLeave(this) - local self = this.obj - self:Fire("OnTabLeave", self.tabs[this.id].value, this) - end - - local function Tab_OnShow(this) - _G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30) - end - - local function CreateTab(self, id) - local tabname = "AceGUITabGroup"..self.num.."Tab"..id - local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate") - tab.obj = self - tab.id = id - - tab.text = _G[tabname .. "Text"] - tab.text:ClearAllPoints() - tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3) - tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3) - - tab:SetScript("OnClick",Tab_OnClick) - tab:SetScript("OnEnter",Tab_OnEnter) - tab:SetScript("OnLeave",Tab_OnLeave) - tab:SetScript("OnShow", Tab_OnShow) - - tab._SetText = tab.SetText - tab.SetText = Tab_SetText - tab.SetSelected = Tab_SetSelected - tab.SetDisabled = Tab_SetDisabled - - return tab - end - - local function SetTitle(self, text) - self.titletext:SetText(text or "") - end - - -- called to set an external table to store status in - local function SetStatusTable(self, status) - assert(type(status) == "table") - self.status = status - end - - local function SelectTab(self, value) - local status = self.status or self.localstatus - - local found - for i, v in ipairs(self.tabs) do - if v.value == value then - v:SetSelected(true) - found = true - else - v:SetSelected(false) - end - end - status.selected = value - if found then - self:Fire("OnGroupSelected",value) - end - end - - local function SetTabs(self, tabs) - self.tablist = tabs - self:BuildTabs() - end - - - local widths = {} - local rowwidths = {} - local rowends = {} - local function BuildTabs(self) - local status = self.status or self.localstatus - local tablist = self.tablist - local tabs = self.tabs - - if not tablist then return end - - local width = self.frame.width or self.frame:GetWidth() or 0 - - for i = #widths, 1, -1 do - widths[i] = nil - end - for i = #rowwidths, 1, -1 do - rowwidths[i] = nil - end - for i = #rowends, 1, -1 do - rowends[i] = nil - end - - --Place Text into tabs and get thier initial width - for i, v in ipairs(tablist) do - local tab = tabs[i] - if not tab then - tab = self:CreateTab(i) - tabs[i] = tab - end - - tab:Show() - tab:SetText(v.text) - tab:SetDisabled(v.disabled) - tab.value = v.value - - 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 - end - - for i = (#tablist)+1, #tabs, 1 do - tabs[i]:Hide() - end - - --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout - local numtabs = #tablist - local numrows = 1 - local usedwidth = 0 - - for i = 1, #tablist do - --If this is not the first tab of a row and there isn't room for it - if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then - rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px - rowends[numrows] = i - 1 - numrows = numrows + 1 - usedwidth = 0 - end - usedwidth = usedwidth + widths[i] - end - rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px - rowends[numrows] = #tablist - - --Fix for single tabs being left on the last row, move a tab from the row above if applicable - if numrows > 1 then - --if the last row has only one tab - if rowends[numrows-1] == numtabs-1 then - --if there are more than 2 tabs in the 2nd last row - if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then - --move 1 tab from the second last row to the last, if there is enough space - if (rowwidths[numrows] + widths[numtabs-1]) <= width then - rowends[numrows-1] = rowends[numrows-1] - 1 - rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1] - rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1] - end - end - end - end - - --anchor the rows as defined and resize tabs to fill thier row - local starttab = 1 - for row, endtab in ipairs(rowends) do - local first = true - for tabno = starttab, endtab do - local tab = tabs[tabno] - tab:ClearAllPoints() - if first then - tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -7-(row-1)*20 ) - first = false - else - tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0) - end - end - - -- equal padding for each tab to fill the available width, - -- if the used space is above 75% already - local padding = 0 - if not (numrows == 1 and rowwidths[1] < width*0.75) then - padding = (width - rowwidths[row]) / (endtab - starttab+1) - end - - for i = starttab, endtab do - PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) - end - starttab = endtab + 1 - end - - self.borderoffset = 10+((numrows)*20) - self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",3,-self.borderoffset) - end - - local function BuildTabsOnUpdate(this) - BuildTabs(this.obj) - this:SetScript("OnUpdate", nil) - end - - local function OnWidthSet(self, width) - local content = self.content - local contentwidth = width - 60 - if contentwidth < 0 then - contentwidth = 0 - end - content:SetWidth(contentwidth) - content.width = contentwidth - BuildTabs(self) - self.frame:SetScript("OnUpdate", BuildTabsOnUpdate) - end - - - local function OnHeightSet(self, height) - local content = self.content - local contentheight = height - (self.borderoffset + 23) - if contentheight < 0 then - contentheight = 0 - end - content:SetHeight(contentheight) - content.height = contentheight - end - - local function LayoutFinished(self, width, height) - if self.noAutoHeight then return end - self:SetHeight((height or 0) + (self.borderoffset + 23)) - end - - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - - self.num = AceGUI:GetNextWidgetNum(Type) - - self.localstatus = {} - - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - self.SetTitle = SetTitle - self.CreateTab = CreateTab - self.SelectTab = SelectTab - self.BuildTabs = BuildTabs - self.SetStatusTable = SetStatusTable - self.SetTabs = SetTabs - self.LayoutFinished = LayoutFinished - self.frame = frame - - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - - frame.obj = self - - frame:SetHeight(100) - frame:SetWidth(100) - frame:SetFrameStrata("FULLSCREEN_DIALOG") - - local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") - titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0) - titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0) - titletext:SetJustifyH("LEFT") - titletext:SetHeight(18) - - self.titletext = titletext - - local border = CreateFrame("Frame",nil,frame) - self.border = border - self.borderoffset = 27 - border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27) - border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3) - - border:SetBackdrop(PaneBackdrop) - border:SetBackdropColor(0.1,0.1,0.1,0.5) - border:SetBackdropBorderColor(0.4,0.4,0.4) - - self.tabs = {} - - --Container Support - local content = CreateFrame("Frame",nil,border) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) - content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) - - AceGUI:RegisterAsContainer(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceGUI-3.0/widgets/AceGUIWidget-TreeGroup.lua b/Libs/AceGUI-3.0/widgets/AceGUIWidget-TreeGroup.lua deleted file mode 100644 index 81b3eec..0000000 --- a/Libs/AceGUI-3.0/widgets/AceGUIWidget-TreeGroup.lua +++ /dev/null @@ -1,715 +0,0 @@ -local AceGUI = LibStub("AceGUI-3.0") - --- Recycling functions -local new, del -do - local pool = setmetatable({},{__mode='k'}) - function new() - local t = next(pool) - if t then - pool[t] = nil - return t - else - return {} - end - end - function del(t) - for k in pairs(t) do - t[k] = nil - end - pool[t] = true - end -end - --------------- --- TreeView -- --------------- - -do - local Type = "TreeGroup" - local Version = 20 - - local DEFAULT_TREE_WIDTH = 175 - local DEFAULT_TREE_SIZABLE = true - - local PaneBackdrop = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 3, right = 3, top = 5, bottom = 3 } - } - - local DraggerBackdrop = { - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = nil, - tile = true, tileSize = 16, edgeSize = 0, - insets = { left = 3, right = 3, top = 7, bottom = 7 } - } - - local function OnAcquire(self) - self:SetTreeWidth(DEFAULT_TREE_WIDTH,DEFAULT_TREE_SIZABLE) - self:EnableButtonTooltips(true) - end - - local function OnRelease(self) - - self.frame:ClearAllPoints() - self.frame:Hide() - self.status = nil - for k, v in pairs(self.localstatus) do - if k == "groups" then - for k2 in pairs(v) do - v[k2] = nil - end - else - self.localstatus[k] = nil - end - end - self.localstatus.scrollvalue = 0 - self.localstatus.treewidth = DEFAULT_TREE_WIDTH - self.localstatus.treesizable = DEFAULT_TREE_SIZABLE - end - - local function GetButtonParents(line) - local parent = line.parent - if parent and parent.value then - return parent.value, GetButtonParents(parent) - end - end - - local function GetButtonUniqueValue(line) - local parent = line.parent - if parent and parent.value then - return GetButtonUniqueValue(parent).."\001"..line.value - else - return line.value - end - end - - local function ButtonOnClick(this) - local self = this.obj - self:Fire("OnClick",this.uniquevalue, this.selected) - if not this.selected then - self:SetSelected(this.uniquevalue) - this.selected = true - this:LockHighlight() - self:RefreshTree() - end - AceGUI:ClearFocus() - end - - local function ExpandOnClick(this) - local button = this.button - local self = button.obj - local status = (self.status or self.localstatus).groups - status[button.uniquevalue] = not status[button.uniquevalue] - self:RefreshTree() - end - - local function ButtonOnDoubleClick(button) - local self = button.obj - local status = self.status or self.localstatus - local status = (self.status or self.localstatus).groups - status[button.uniquevalue] = not status[button.uniquevalue] - self:RefreshTree() - end - - local function EnableButtonTooltips(self, enable) - self.enabletooltips = enable - end - - local function Button_OnEnter(this) - local self = this.obj - self:Fire("OnButtonEnter", this.uniquevalue, this) - - if self.enabletooltips then - GameTooltip:SetOwner(this, "ANCHOR_NONE") - GameTooltip:SetPoint("LEFT",this,"RIGHT") - GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, 1) - - GameTooltip:Show() - end - end - - local function Button_OnLeave(this) - local self = this.obj - self:Fire("OnButtonLeave", this.uniquevalue, this) - - if self.enabletooltips then - GameTooltip:Hide() - end - end - - - local buttoncount = 1 - local function CreateButton(self) - local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "OptionsListButtonTemplate") - buttoncount = buttoncount + 1 - button.obj = self - - local icon = button:CreateTexture(nil, "OVERLAY") - icon:SetWidth(14) - icon:SetHeight(14) - button.icon = icon - - button:SetScript("OnClick",ButtonOnClick) - button:SetScript("OnDoubleClick", ButtonOnDoubleClick) - button:SetScript("OnEnter",Button_OnEnter) - button:SetScript("OnLeave",Button_OnLeave) - - button.toggle.button = button - button.toggle:SetScript("OnClick",ExpandOnClick) - - return button - end - - local function UpdateButton(button, treeline, selected, canExpand, isExpanded) - local self = button.obj - local toggle = button.toggle - local frame = self.frame - local text = treeline.text or "" - local icon = treeline.icon - local level = treeline.level - local value = treeline.value - local uniquevalue = treeline.uniquevalue - local disabled = treeline.disabled - - button.treeline = treeline - button.value = value - button.uniquevalue = uniquevalue - if selected then - button:LockHighlight() - button.selected = true - else - button:UnlockHighlight() - button.selected = false - end - local normalTexture = button:GetNormalTexture() - local line = button.line - button.level = level - if ( level == 1 ) then - button:SetNormalFontObject("GameFontNormal") - button:SetHighlightFontObject("GameFontHighlight") - button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2) - else - button:SetNormalFontObject("GameFontHighlightSmall") - button:SetHighlightFontObject("GameFontHighlightSmall") - button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2) - end - - if disabled then - button:EnableMouse(false) - button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE) - else - button.text:SetText(text) - button:EnableMouse(true) - end - - if icon then - button.icon:SetTexture(icon) - button.icon:SetPoint("LEFT", button, "LEFT", 8 * level, (level == 1) and 0 or 1) - else - button.icon:SetTexture(nil) - end - - if canExpand then - if not isExpanded then - toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP") - toggle:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN") - else - toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP") - toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN") - end - toggle:Show() - else - toggle:Hide() - end - end - - - local function OnScrollValueChanged(this, value) - if this.obj.noupdate then return end - local self = this.obj - local status = self.status or self.localstatus - status.scrollvalue = value - self:RefreshTree() - AceGUI:ClearFocus() - end - - -- called to set an external table to store status in - local function SetStatusTable(self, status) - assert(type(status) == "table") - self.status = status - if not status.groups then - status.groups = {} - end - if not status.scrollvalue then - status.scrollvalue = 0 - end - if not status.treewidth then - status.treewidth = DEFAULT_TREE_WIDTH - end - if not status.treesizable then - status.treesizable = DEFAULT_TREE_SIZABLE - end - self:SetTreeWidth(status.treewidth,status.treesizable) - self:RefreshTree() - end - - --sets the tree to be displayed - --[[ - example tree - - Alpha - Bravo - -Charlie - -Delta - -Echo - Foxtrot - - tree = { - { - value = "A", - text = "Alpha" - }, - { - value = "B", - text = "Bravo", - children = { - { - value = "C", - text = "Charlie" - }, - { - value = "D", - text = "Delta" - children = { - { - value = "E", - text = "Echo" - } - } - } - } - }, - { - value = "F", - text = "Foxtrot" - }, - } - ]] - local function SetTree(self, tree, filter) - self.filter = filter - if tree then - assert(type(tree) == "table") - end - self.tree = tree - self:RefreshTree() - end - - local function ShouldDisplayLevel(tree) - local result = false - for k, v in ipairs(tree) do - if v.children == nil and v.visible ~= false then - result = true - elseif v.children then - result = result or ShouldDisplayLevel(v.children) - end - if result then return result end - end - return false - end - - local function addLine(self, v, tree, level, parent) - local line = new() - line.value = v.value - line.text = v.text - line.icon = v.icon - line.disabled = v.disabled - line.tree = tree - line.level = level - line.parent = parent - line.visible = v.visible - line.uniquevalue = GetButtonUniqueValue(line) - if v.children then - line.hasChildren = true - else - line.hasChildren = nil - end - self.lines[#self.lines+1] = line - return line - end - - local function BuildLevel(self, tree, level, parent) - local groups = (self.status or self.localstatus).groups - local hasChildren = self.hasChildren - - for i, v in ipairs(tree) do - if v.children then - if not self.filter or ShouldDisplayLevel(v.children) then - local line = addLine(self, v, tree, level, parent) - if groups[line.uniquevalue] then - self:BuildLevel(v.children, level+1, line) - end - end - elseif v.visible ~= false or not self.filter then - addLine(self, v, tree, level, parent) - end - end - end - - --fire an update after one frame to catch the treeframes height - local function FirstFrameUpdate(this) - local self = this.obj - this:SetScript("OnUpdate",nil) - self:RefreshTree() - end - - local function ResizeUpdate(this) - this.obj:RefreshTree() - end - - local function RefreshTree(self) - local buttons = self.buttons - local lines = self.lines - - for i, v in ipairs(buttons) do - v:Hide() - end - while lines[1] do - local t = tremove(lines) - for k in pairs(t) do - t[k] = nil - end - del(t) - end - - if not self.tree then return end - --Build the list of visible entries from the tree and status tables - local status = self.status or self.localstatus - local groupstatus = status.groups - local tree = self.tree - - local treeframe = self.treeframe - - self:BuildLevel(tree, 1) - - local numlines = #lines - - local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) - - local first, last - - if numlines <= maxlines then - --the whole tree fits in the frame - status.scrollvalue = 0 - self:ShowScroll(false) - first, last = 1, numlines - else - self:ShowScroll(true) - --scrolling will be needed - self.noupdate = true - self.scrollbar:SetMinMaxValues(0, numlines - maxlines) - --check if we are scrolled down too far - if numlines - status.scrollvalue < maxlines then - status.scrollvalue = numlines - maxlines - self.scrollbar:SetValue(status.scrollvalue) - end - self.noupdate = nil - first, last = status.scrollvalue+1, status.scrollvalue + maxlines - end - - local buttonnum = 1 - for i = first, last do - local line = lines[i] - local button = buttons[buttonnum] - if not button then - button = self:CreateButton() - - buttons[buttonnum] = button - button:SetParent(treeframe) - button:SetFrameLevel(treeframe:GetFrameLevel()+1) - button:ClearAllPoints() - if i == 1 then - if self.showscroll then - button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10) - button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) - else - button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10) - button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) - end - else - button:SetPoint("TOPRIGHT", buttons[buttonnum-1], "BOTTOMRIGHT",0,0) - button:SetPoint("TOPLEFT", buttons[buttonnum-1], "BOTTOMLEFT",0,0) - end - end - - UpdateButton(button, line, status.selected == line.uniquevalue, line.hasChildren, groupstatus[line.uniquevalue] ) - button:Show() - buttonnum = buttonnum + 1 - end - - end - - local function SetSelected(self, value) - local status = self.status or self.localstatus - if status.selected ~= value then - status.selected = value - self:Fire("OnGroupSelected", value) - end - end - - local function BuildUniqueValue(...) - local n = select('#', ...) - if n == 1 then - return ... - else - return (...).."\001"..BuildUniqueValue(select(2,...)) - end - end - - local function Select(self, uniquevalue, ...) - self.filter = false - local status = self.status or self.localstatus - local groups = status.groups - for i = 1, select('#', ...) do - groups[BuildUniqueValue(select(i, ...))] = true - end - status.selected = uniquevalue - self:RefreshTree() - self:Fire("OnGroupSelected", uniquevalue) - end - - local function SelectByPath(self, ...) - self:Select(BuildUniqueValue(...), ...) - end - - --Selects a tree node by UniqueValue - local function SelectByValue(self, uniquevalue) - self:Select(uniquevalue,string.split("\001", uniquevalue)) - end - - - local function ShowScroll(self, show) - self.showscroll = show - if show then - self.scrollbar:Show() - if self.buttons[1] then - self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10) - end - else - self.scrollbar:Hide() - if self.buttons[1] then - self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10) - end - end - end - - local function OnWidthSet(self, width) - local content = self.content - local treeframe = self.treeframe - local status = self.status or self.localstatus - - local contentwidth = width - status.treewidth - 20 - if contentwidth < 0 then - contentwidth = 0 - end - content:SetWidth(contentwidth) - content.width = contentwidth - - local maxtreewidth = math.min(400, width - 50) - - if maxtreewidth > 100 and status.treewidth > maxtreewidth then - self:SetTreeWidth(maxtreewidth, status.treesizable) - end - treeframe:SetMaxResize(maxtreewidth,1600) - end - - - local function OnHeightSet(self, height) - local content = self.content - local contentheight = height - 20 - if contentheight < 0 then - contentheight = 0 - end - content:SetHeight(contentheight) - content.height = contentheight - end - - - local function TreeOnMouseWheel(this, delta) - local self = this.obj - if self.showscroll then - local scrollbar = self.scrollbar - local min, max = scrollbar:GetMinMaxValues() - local value = scrollbar:GetValue() - local newvalue = math.min(max,math.max(min,value - delta)) - if value ~= newvalue then - scrollbar:SetValue(newvalue) - end - end - end - - local function SetTreeWidth(self, treewidth, resizable) - if not resizable then - if type(treewidth) == 'number' then - resizable = false - elseif type(treewidth) == 'boolean' then - resizable = treewidth - treewidth = DEFAULT_TREE_WIDTH - else - resizable = false - treewidth = DEFAULT_TREE_WIDTH - end - end - self.treeframe:SetWidth(treewidth) - self.dragger:EnableMouse(resizable) - - local status = self.status or self.localstatus - status.treewidth = treewidth - status.treesizable = resizable - end - - local function draggerLeave(this) - this:SetBackdropColor(1, 1, 1, 0) - end - - local function draggerEnter(this) - this:SetBackdropColor(1, 1, 1, 0.8) - end - - local function draggerDown(this) - local treeframe = this:GetParent() - treeframe:StartSizing("RIGHT") - end - - local function draggerUp(this) - local treeframe = this:GetParent() - local self = treeframe.obj - local frame = treeframe:GetParent() - treeframe:StopMovingOrSizing() - --treeframe:SetScript("OnUpdate", nil) - treeframe:SetUserPlaced(false) - --Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize - treeframe:SetHeight(0) - treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) - treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth()) - - local status = self.status or self.localstatus - status.treewidth = treeframe:GetWidth() - end - - local function LayoutFinished(self, width, height) - if self.noAutoHeight then return end - self:SetHeight((height or 0) + 20) - end - - local createdcount = 0 - local function Constructor() - local frame = CreateFrame("Frame",nil,UIParent) - local self = {} - self.type = Type - self.lines = {} - self.levels = {} - self.buttons = {} - self.hasChildren = {} - self.localstatus = {} - self.localstatus.groups = {} - self.filter = false - - local treeframe = CreateFrame("Frame",nil,frame) - treeframe.obj = self - treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) - treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) - treeframe:SetWidth(DEFAULT_TREE_WIDTH) - treeframe:SetScript("OnUpdate",FirstFrameUpdate) - treeframe:SetScript("OnSizeChanged",ResizeUpdate) - - treeframe:EnableMouseWheel(true) - treeframe:SetScript("OnMouseWheel", TreeOnMouseWheel) - treeframe:SetBackdrop(PaneBackdrop) - treeframe:SetBackdropColor(0.1,0.1,0.1,0.5) - treeframe:SetBackdropBorderColor(0.4,0.4,0.4) - - treeframe:SetResizable(true) - treeframe:SetMinResize(100, 1) - treeframe:SetMaxResize(400,1600) - local dragger = CreateFrame("Frame", nil, treeframe) - dragger:SetWidth(8) - dragger:SetPoint("TOP", treeframe, "TOPRIGHT") - dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT") - dragger:SetBackdrop(DraggerBackdrop) - dragger:SetBackdropColor(1, 1, 1, 0) - dragger:SetScript("OnMouseDown", draggerDown) - dragger:SetScript("OnMouseUp", draggerUp) - dragger:SetScript("OnEnter", draggerEnter) - dragger:SetScript("OnLeave", draggerLeave) - - self.dragger = dragger - self.treeframe = treeframe - self.OnRelease = OnRelease - self.OnAcquire = OnAcquire - - self.SetTree = SetTree - self.SetTreeWidth = SetTreeWidth - self.RefreshTree = RefreshTree - self.SetStatusTable = SetStatusTable - self.BuildLevel = BuildLevel - self.CreateButton = CreateButton - self.SetSelected = SetSelected - self.ShowScroll = ShowScroll - self.SetStatusTable = SetStatusTable - self.Select = Select - self.SelectByValue = SelectByValue - self.SelectByPath = SelectByPath - self.OnWidthSet = OnWidthSet - self.OnHeightSet = OnHeightSet - self.EnableButtonTooltips = EnableButtonTooltips - self.Filter = Filter - self.LayoutFinished = LayoutFinished - - self.frame = frame - frame.obj = self - - createdcount = createdcount + 1 - local scrollbar = CreateFrame("Slider",("AceConfigDialogTreeGroup%dScrollBar"):format(createdcount),treeframe,"UIPanelScrollBarTemplate") - self.scrollbar = scrollbar - local scrollbg = scrollbar:CreateTexture(nil,"BACKGROUND") - scrollbg:SetAllPoints(scrollbar) - scrollbg:SetTexture(0,0,0,0.4) - scrollbar.obj = self - self.noupdate = true - scrollbar:SetPoint("TOPRIGHT",treeframe,"TOPRIGHT",-10,-26) - scrollbar:SetPoint("BOTTOMRIGHT",treeframe,"BOTTOMRIGHT",-10,26) - scrollbar:SetScript("OnValueChanged", OnScrollValueChanged) - scrollbar:SetMinMaxValues(0,0) - self.localstatus.scrollvalue = 0 - scrollbar:SetValueStep(1) - scrollbar:SetValue(0) - scrollbar:SetWidth(16) - self.noupdate = nil - - local border = CreateFrame("Frame",nil,frame) - self.border = border - border:SetPoint("TOPLEFT",treeframe,"TOPRIGHT", 0,0) - border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) - - border:SetBackdrop(PaneBackdrop) - border:SetBackdropColor(0.1,0.1,0.1,0.5) - border:SetBackdropBorderColor(0.4,0.4,0.4) - - --Container Support - local content = CreateFrame("Frame",nil,border) - self.content = content - content.obj = self - content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) - content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) - - AceGUI:RegisterAsContainer(self) - --AceGUI:RegisterAsWidget(self) - return self - end - - AceGUI:RegisterWidgetType(Type,Constructor,Version) -end diff --git a/Libs/AceTab-3.0/AceTab-3.0.lua b/Libs/AceTab-3.0/AceTab-3.0.lua deleted file mode 100644 index a6ab192..0000000 --- a/Libs/AceTab-3.0/AceTab-3.0.lua +++ /dev/null @@ -1,452 +0,0 @@ ---- AceTab-3.0 provides support for tab-completion. --- Note: This library is not yet finalized. --- @class file --- @name AceTab-3.0 --- @release $Id: AceTab-3.0.lua 1031 2011-06-29 15:04:34Z nevcairiel $ - -local ACETAB_MAJOR, ACETAB_MINOR = 'AceTab-3.0', 9 -local AceTab, oldminor = LibStub:NewLibrary(ACETAB_MAJOR, ACETAB_MINOR) - -if not AceTab then return end -- No upgrade needed - -local is335 = GetBuildInfo() >= "3.3.5" - -AceTab.registry = AceTab.registry or {} - --- local upvalues -local _G = _G -local pairs = pairs -local ipairs = ipairs -local type = type -local registry = AceTab.registry - -local strfind = string.find -local strsub = string.sub -local strlower = string.lower -local strformat = string.format -local strmatch = string.match - -local function printf(...) - DEFAULT_CHAT_FRAME:AddMessage(strformat(...)) -end - -local function getTextBeforeCursor(this, start) - return strsub(this:GetText(), start or 1, this:GetCursorPosition()) -end - --- Hook OnTabPressed and OnTextChanged for the frame, give it an empty matches table, and set its curMatch to 0, if we haven't done so already. -local function hookFrame(f) - if f.hookedByAceTab3 then return end - f.hookedByAceTab3 = true - if f == (is335 and ChatEdit_GetActiveWindow() or ChatFrameEditBox) then - local origCTP = ChatEdit_CustomTabPressed - function ChatEdit_CustomTabPressed(...) - if AceTab:OnTabPressed(f) then - return origCTP(...) - else - return true - end - end - else - local origOTP = f:GetScript('OnTabPressed') - if type(origOTP) ~= 'function' then - origOTP = function() end - end - f:SetScript('OnTabPressed', function(...) - if AceTab:OnTabPressed(f) then - return origOTP(...) - end - end) - end - f.at3curMatch = 0 - f.at3matches = {} -end - -local firstPMLength - -local fallbacks, notfallbacks = {}, {} -- classifies completions into those which have preconditions and those which do not. Those without preconditions are only considered if no other completions have matches. -local pmolengths = {} -- holds the number of characters to overwrite according to pmoverwrite and the current prematch --- ------------------------------------------------------------------------------ --- RegisterTabCompletion( descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite ) --- See http://www.wowace.com/wiki/AceTab-2.0 for detailed API documentation --- --- descriptor string Unique identifier for this tab completion set --- --- prematches string|table|nil String match(es) AFTER which this tab completion will apply. --- AceTab will ignore tabs NOT preceded by the string(s). --- If no value is passed, will check all tabs pressed in the specified editframe(s) UNLESS a more-specific tab complete applies. --- --- wordlist function|table Function that will be passed a table into which it will insert strings corresponding to all possible completions, or an equivalent table. --- The text in the editbox, the position of the start of the word to be completed, and the uncompleted partial word --- are passed as second, third, and fourth arguments, to facilitate pre-filtering or conditional formatting, if desired. --- --- usagefunc function|boolean|nil Usage statement function. Defaults to the wordlist, one per line. A boolean true squelches usage output. --- --- listenframes string|table|nil EditFrames to monitor. Defaults to ChatFrameEditBox. --- --- postfunc function|nil Post-processing function. If supplied, matches will be passed through this function after they've been identified as a match. --- --- pmoverwrite boolean|number|nil Offset the beginning of the completion string in the editbox when making a completion. Passing a boolean true indicates that we want to overwrite --- the entire prematch string, and passing a number will overwrite that many characters prior to the cursor. --- This is useful when you want to use the prematch as an indicator character, but ultimately do not want it as part of the text, itself. --- --- no return --- ------------------------------------------------------------------------------ -function AceTab:RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite) - -- Arg checks - if type(descriptor) ~= 'string' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'descriptor' - string expected.", 3) end - if prematches and type(prematches) ~= 'string' and type(prematches) ~= 'table' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'prematches' - string, table, or nil expected.", 3) end - if type(wordlist) ~= 'function' and type(wordlist) ~= 'table' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'wordlist' - function or table expected.", 3) end - if usagefunc and type(usagefunc) ~= 'function' and type(usagefunc) ~= 'boolean' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'usagefunc' - function or boolean expected.", 3) end - if listenframes and type(listenframes) ~= 'string' and type(listenframes) ~= 'table' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'listenframes' - string or table expected.", 3) end - if postfunc and type(postfunc) ~= 'function' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'postfunc' - function expected.", 3) end - if pmoverwrite and type(pmoverwrite) ~= 'boolean' and type(pmoverwrite) ~= 'number' then error("Usage: RegisterTabCompletion(descriptor, prematches, wordlist, usagefunc, listenframes, postfunc, pmoverwrite): 'pmoverwrite' - boolean or number expected.", 3) end - - local pmtable - - if type(prematches) == 'table' then - pmtable = prematches - notfallbacks[descriptor] = true - else - pmtable = {} - -- Mark this group as a fallback group if no value was passed. - if not prematches then - pmtable[1] = "" - fallbacks[descriptor] = true - -- Make prematches into a one-element table if it was passed as a string. - elseif type(prematches) == 'string' then - pmtable[1] = prematches - if prematches == "" then - fallbacks[descriptor] = true - else - notfallbacks[descriptor] = true - end - end - end - - -- Make listenframes into a one-element table if it was not passed a table of frames. - if not listenframes then -- default - if is335 then - listenframes = {} - for i = 1, NUM_CHAT_WINDOWS do - listenframes[i] = _G["ChatFrame"..i.."EditBox"] - end - else - listenframes = { ChatFrameEditBox } - end - elseif type(listenframes) ~= 'table' or type(listenframes[0]) == 'userdata' and type(listenframes.IsObjectType) == 'function' then -- single frame or framename - listenframes = { listenframes } - end - - -- Hook each registered listenframe and give it a matches table. - for _, f in pairs(listenframes) do - if type(f) == 'string' then - f = _G[f] - end - if type(f) ~= 'table' or type(f[0]) ~= 'userdata' or type(f.IsObjectType) ~= 'function' then - error(format(ACETAB_MAJOR..": Cannot register frame %q; it does not exist", f:GetName())) - end - if f then - if f:GetObjectType() ~= 'EditBox' then - error(format(ACETAB_MAJOR..": Cannot register frame %q; it is not an EditBox", f:GetName())) - else - hookFrame(f) - end - end - end - - -- Everything checks out; register this completion. - if not registry[descriptor] then - registry[descriptor] = { prematches = pmtable, wordlist = wordlist, usagefunc = usagefunc, listenframes = listenframes, postfunc = postfunc, pmoverwrite = pmoverwrite } - end -end - -function AceTab:IsTabCompletionRegistered(descriptor) - return registry and registry[descriptor] -end - -function AceTab:UnregisterTabCompletion(descriptor) - registry[descriptor] = nil - pmolengths[descriptor] = nil - fallbacks[descriptor] = nil - notfallbacks[descriptor] = nil -end - --- ------------------------------------------------------------------------------ --- gcbs( s1, s2 ) --- --- s1 string First string to be compared --- --- s2 string Second string to be compared --- --- returns the greatest common substring beginning s1 and s2 --- ------------------------------------------------------------------------------ -local function gcbs(s1, s2) - if not s1 and not s2 then return end - if not s1 then s1 = s2 end - if not s2 then s2 = s1 end - if #s2 < #s1 then - s1, s2 = s2, s1 - end - if strfind(strlower(s2), "^"..strlower(s1)) then - return s1 - else - return gcbs(strsub(s1, 1, -2), s2) - end -end - -local cursor -- Holds cursor position. Set in :OnTabPressed(). --- ------------------------------------------------------------------------------ --- cycleTab() --- For when a tab press has multiple possible completions, we need to allow the user to press tab repeatedly to cycle through them. --- If we have multiple possible completions, all tab presses after the first will call this function to cycle through and insert the different possible matches. --- This function will stop being called after OnTextChanged() is triggered by something other than AceTab (i.e. the user inputs a character). --- ------------------------------------------------------------------------------ -local previousLength, cMatch, matched, postmatch -local function cycleTab(this) - cMatch = 0 -- Counter across all sets. The pseudo-index relevant to this value and corresponding to the current match is held in this.at3curMatch - matched = false - - -- Check each completion group registered to this frame. - for desc, compgrp in pairs(this.at3matches) do - - -- Loop through the valid completions for this set. - for m, pm in pairs(compgrp) do - cMatch = cMatch + 1 - if cMatch == this.at3curMatch then -- we're back to where we left off last time through the combined list - this.at3lastMatch = m - this.at3lastWord = pm - this.at3curMatch = cMatch + 1 -- save the new cMatch index - matched = true - break - end - end - if matched then break end - end - - -- If our index is beyond the end of the list, reset the original uncompleted substring and let the cycle start over next time tab is pressed. - if not matched then - this.at3lastMatch = this.at3origMatch - this.at3lastWord = this.at3origWord - this.at3curMatch = 1 - end - - -- Insert the completion. - this:HighlightText(this.at3matchStart-1, cursor) - this:Insert(this.at3lastWord or '') - this.at3_last_precursor = getTextBeforeCursor(this) or '' -end - -local IsSecureCmd = IsSecureCmd - -local cands, candUsage = {}, {} -local numMatches = 0 -local firstMatch, hasNonFallback, allGCBS, setGCBS, usage -local text_precursor, text_all, text_pmendToCursor -local matches, usagefunc -- convenience locals - --- Fill the this.at3matches[descriptor] tables with matching completion pairs for each entry, based on --- the partial string preceding the cursor position and using the corresponding registered wordlist. --- --- The entries of the matches tables are of the format raw_match = formatted_match, where raw_match is the plaintext completion and --- formatted_match is the match after being formatted/altered/processed by the registered postfunc. --- If no postfunc exists, then the formatted and raw matches are the same. -local pms, pme, pmt, prematchStart, prematchEnd, text_prematch, entry -local function fillMatches(this, desc, fallback) - entry = registry[desc] - -- See what frames are registered for this completion group. If the frame in which we pressed tab is one of them, then we start building matches. - for _, f in ipairs(entry.listenframes) do - if f == this then - - -- Try each precondition string registered for this completion group. - for _, prematch in ipairs(entry.prematches) do - - -- Test if our prematch string is satisfied. - -- If it is, then we find its last occurence prior to the cursor, calculate and store its pmoverwrite value (if applicable), and start considering completions. - if fallback then prematch = "%s" end - - -- Find the last occurence of the prematch before the cursor. - pms, pme, pmt = nil, 1, '' - text_prematch, prematchEnd, prematchStart = nil, nil, nil - while true do - pms, pme, pmt = strfind(text_precursor, "("..prematch..")", pme) - if pms then - prematchStart, prematchEnd, text_prematch = pms, pme, pmt - pme = pme + 1 - else - break - end - end - - if not prematchStart and fallback then - prematchStart, prematchEnd, text_prematch = 0, 0, '' - end - if prematchStart then - -- text_pmendToCursor should be the sub-word/phrase to be completed. - text_pmendToCursor = strsub(text_precursor, prematchEnd + 1) - - -- How many characters should we eliminate before the completion before writing it in. - pmolengths[desc] = entry.pmoverwrite == true and #text_prematch or entry.pmoverwrite or 0 - - -- This is where we will insert completions, taking the prematch overwrite into account. - this.at3matchStart = prematchEnd + 1 - (pmolengths[desc] or 0) - - -- We're either a non-fallback set or all completions thus far have been fallback sets, and the precondition matches. - -- Create cands from the registered wordlist, filling it with all potential (unfiltered) completion strings. - local wordlist = entry.wordlist - local cands = type(wordlist) == 'table' and wordlist or {} - if type(wordlist) == 'function' then - wordlist(cands, text_all, prematchEnd + 1, text_pmendToCursor) - end - if cands ~= false then - matches = this.at3matches[desc] or {} - for i in pairs(matches) do matches[i] = nil end - - -- Check each of the entries in cands to see if it completes the word before the cursor. - -- Finally, increment our match count and set firstMatch, if appropriate. - for _, m in ipairs(cands) do - if strfind(strlower(m), strlower(text_pmendToCursor), 1, 1) == 1 then -- we have a matching completion! - hasNonFallback = hasNonFallback or (not fallback) - matches[m] = entry.postfunc and entry.postfunc(m, prematchEnd + 1, text_all) or m - numMatches = numMatches + 1 - if numMatches == 1 then - firstMatch = matches[m] - firstPMLength = pmolengths[desc] or 0 - end - end - end - this.at3matches[desc] = numMatches > 0 and matches or nil - end - end - end - end - end -end - -function AceTab:OnTabPressed(this) - if this:GetText() == '' then return true end - - -- allow Blizzard to handle slash commands, themselves - if this == (is335 and ChatEdit_GetActiveWindow() or ChatFrameEditBox) then - local command = this:GetText() - if strfind(command, "^/[%a%d_]+$") then - return true - end - local cmd = strmatch(command, "^/[%a%d_]+") - if cmd and IsSecureCmd(cmd) then - return true - end - end - - cursor = this:GetCursorPosition() - - text_all = this:GetText() - text_precursor = getTextBeforeCursor(this) or '' - - -- If we've already found some matches and haven't done anything since the last tab press, then (continue) cycling matches. - -- Otherwise, reset this frame's matches and proceed to creating our list of possible completions. - this.at3lastMatch = this.at3curMatch > 0 and (this.at3lastMatch or this.at3origWord) - -- Detects if we've made any edits since the last tab press. If not, continue cycling completions. - if text_precursor == this.at3_last_precursor then - return cycleTab(this) - else - for i in pairs(this.at3matches) do this.at3matches[i] = nil end - this.at3curMatch = 0 - this.at3origWord = nil - this.at3origMatch = nil - this.at3lastWord = nil - this.at3lastMatch = nil - this.at3_last_precursor = text_precursor - end - - numMatches = 0 - firstMatch = nil - firstPMLength = 0 - hasNonFallback = false - for i in pairs(pmolengths) do pmolengths[i] = nil end - - for desc in pairs(notfallbacks) do - fillMatches(this, desc) - end - if not hasNonFallback then - for desc in pairs(fallbacks) do - fillMatches(this, desc, true) - end - end - - if not firstMatch then - this.at3_last_precursor = "\0" - return true - end - - -- We want to replace the entire word with our completion, so highlight it up to the cursor. - -- If only one match exists, then stick it in there and append a space. - if numMatches == 1 then - -- HighlightText takes the value AFTER which the highlighting starts, so we have to subtract 1 to have it start before the first character. - this:HighlightText(this.at3matchStart-1, cursor) - - this:Insert(firstMatch) - this:Insert(" ") - else - -- Otherwise, we want to begin cycling through the valid completions. - -- Beginning a cycle also causes the usage statement to be printed, if one exists. - - -- Print usage statements for each possible completion (and gather up the GCBS of all matches while we're walking the tables). - allGCBS = nil - for desc, matches in pairs(this.at3matches) do - -- Don't print usage statements for fallback completion groups if we have 'real' completion groups with matches. - if hasNonFallback and fallbacks[desc] then break end - - -- Use the group's description as a heading for its usage statements. - DEFAULT_CHAT_FRAME:AddMessage(desc..":") - - usagefunc = registry[desc].usagefunc - if not usagefunc then - -- No special usage processing; just print a list of the (formatted) matches. - for m, fm in pairs(matches) do - DEFAULT_CHAT_FRAME:AddMessage(fm) - allGCBS = gcbs(allGCBS, m) - end - else - -- Print a usage statement based on the corresponding registered usagefunc. - -- candUsage is the table passed to usagefunc to be filled with candidate = usage_statement pairs. - if type(usagefunc) == 'function' then - for i in pairs(candUsage) do candUsage[i] = nil end - - -- usagefunc takes the greatest common substring of valid matches as one of its args, so let's find that now. - -- TODO: Make the GCBS function accept a vararg or table, after which we can just pass in the list of matches. - setGCBS = nil - for m in pairs(matches) do - setGCBS = gcbs(setGCBS, m) - end - allGCBS = gcbs(allGCBS, setGCBS) - usage = usagefunc(candUsage, matches, setGCBS, strsub(text_precursor, 1, prematchEnd)) - - -- If the usagefunc returns a string, then the entire usage statement has been taken care of by usagefunc, and we need only to print it... - if type(usage) == 'string' then - DEFAULT_CHAT_FRAME:AddMessage(usage) - - -- ...otherwise, it should have filled candUsage with candidate-usage statement pairs, and we need to print the matching ones. - elseif next(candUsage) and numMatches > 0 then - for m, fm in pairs(matches) do - if candUsage[m] then DEFAULT_CHAT_FRAME:AddMessage(strformat("%s - %s", fm, candUsage[m])) end - end - end - end - end - - if next(matches) then - -- Replace the original string with the greatest common substring of all valid completions. - this.at3curMatch = 1 - this.at3origWord = strsub(text_precursor, this.at3matchStart, this.at3matchStart + pmolengths[desc] - 1) .. allGCBS or "" - this.at3origMatch = allGCBS or "" - this.at3lastWord = this.at3origWord - this.at3lastMatch = this.at3origMatch - - this:HighlightText(this.at3matchStart-1, cursor) - this:Insert(this.at3origWord) - this.at3_last_precursor = getTextBeforeCursor(this) or '' - end - end - end -end diff --git a/Libs/AceTimer-3.0/AceTimer-3.0.lua b/Libs/AceTimer-3.0/AceTimer-3.0.lua deleted file mode 100644 index afd6c4b..0000000 --- a/Libs/AceTimer-3.0/AceTimer-3.0.lua +++ /dev/null @@ -1,467 +0,0 @@ ---- **AceTimer-3.0** provides a central facility for registering timers. --- AceTimer supports one-shot timers and repeating timers. All timers are stored in an efficient --- data structure that allows easy dispatching and fast rescheduling. Timers can be registered, rescheduled --- or canceled at any time, even from within a running timer, without conflict or large overhead.\\ --- AceTimer is currently limited to firing timers at a frequency of 0.1s. This constant may change --- in the future, but for now it seemed like a good compromise in efficiency and accuracy. --- --- All `:Schedule` functions will return a handle to the current timer, which you will need to store if you --- need to cancel or reschedule the timer you just registered. --- --- **AceTimer-3.0** can be embeded into your addon, either explicitly by calling AceTimer:Embed(MyAddon) or by --- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object --- and can be accessed directly, without having to explicitly call AceTimer itself.\\ --- It is recommended to embed AceTimer, otherwise you'll have to specify a custom `self` on all calls you --- make into AceTimer. --- @class file --- @name AceTimer-3.0 --- @release $Id: AceTimer-3.0.lua 769 2009-04-04 11:05:08Z nevcairiel $ - ---[[ - Basic assumptions: - * In a typical system, we do more re-scheduling per second than there are timer pulses per second - * Regardless of timer implementation, we cannot guarantee timely delivery due to FPS restriction (may be as low as 10) - - This implementation: - CON: The smallest timer interval is constrained by HZ (currently 1/10s). - PRO: It will still correctly fire any timer slower than HZ over a length of time, e.g. 0.11s interval -> 90 times over 10 seconds - PRO: In lag bursts, the system simly skips missed timer intervals to decrease load - CON: Algorithms depending on a timer firing "N times per minute" will fail - PRO: (Re-)scheduling is O(1) with a VERY small constant. It's a simple linked list insertion in a hash bucket. - CAUTION: The BUCKETS constant constrains how many timers can be efficiently handled. With too many hash collisions, performance will decrease. - - Major assumptions upheld: - - ALLOWS scheduling multiple timers with the same funcref/method - - ALLOWS scheduling more timers during OnUpdate processing - - ALLOWS unscheduling ANY timer (including the current running one) at any time, including during OnUpdate processing -]] - -local MAJOR, MINOR = "AceTimer-3.0", 5 -local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR) - -if not AceTimer then return end -- No upgrade needed - -AceTimer.hash = AceTimer.hash or {} -- Array of [0..BUCKET-1] = linked list of timers (using .next member) - -- Linked list gets around ACE-88 and ACE-90. -AceTimer.selfs = AceTimer.selfs or {} -- Array of [self]={[handle]=timerobj, [handle2]=timerobj2, ...} -AceTimer.frame = AceTimer.frame or CreateFrame("Frame", "AceTimer30Frame") - -local type = type -local next = next -local pairs = pairs -local select = select -local tostring = tostring -local floor = floor -local max = max - --- Simple ONE-SHOT timer cache. Much more efficient than a full compost for our purposes. -local timerCache = nil - ---[[ - Timers will not be fired more often than HZ-1 times per second. - Keep at intended speed PLUS ONE or we get bitten by floating point rounding errors (n.5 + 0.1 can be n.599999) - If this is ever LOWERED, all existing timers need to be enforced to have a delay >= 1/HZ on lib upgrade. - If this number is ever changed, all entries need to be rehashed on lib upgrade. - ]] -local HZ = 11 - ---[[ - Prime for good distribution - If this number is ever changed, all entries need to be rehashed on lib upgrade. -]] -local BUCKETS = 131 - -local hash = AceTimer.hash -for i=1,BUCKETS do - hash[i] = hash[i] or false -- make it an integer-indexed array; it's faster than hashes -end - ---[[ - xpcall safecall implementation -]] -local xpcall = xpcall - -local function errorhandler(err) - return geterrorhandler()(err) -end - -local function CreateDispatcher(argCount) - local code = [[ - local xpcall, eh = ... -- our arguments are received as unnamed values in "..." since we don't have a proper function declaration - local method, ARGS - local function call() return method(ARGS) end - - local function dispatch(func, ...) - method = func - if not method then return end - ARGS = ... - return xpcall(call, eh) - end - - return dispatch - ]] - - local ARGS = {} - for i = 1, argCount do ARGS[i] = "arg"..i end - code = code:gsub("ARGS", table.concat(ARGS, ", ")) - return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) -end - -local Dispatchers = setmetatable({}, { - __index=function(self, argCount) - local dispatcher = CreateDispatcher(argCount) - rawset(self, argCount, dispatcher) - return dispatcher - end -}) -Dispatchers[0] = function(func) - return xpcall(func, errorhandler) -end - -local function safecall(func, ...) - return Dispatchers[select('#', ...)](func, ...) -end - -local lastint = floor(GetTime() * HZ) - --- -------------------------------------------------------------------- --- OnUpdate handler --- --- traverse buckets, always chasing "now", and fire timers that have expired - -local function OnUpdate() - local now = GetTime() - local nowint = floor(now * HZ) - - -- Have we passed into a new hash bucket? - if nowint == lastint then return end - - local soon = now + 1 -- +1 is safe as long as 1 < HZ < BUCKETS/2 - - -- Pass through each bucket at most once - -- Happens on e.g. instance loads, but COULD happen on high local load situations also - for curint = (max(lastint, nowint - BUCKETS) + 1), nowint do -- loop until we catch up with "now", usually only 1 iteration - local curbucket = (curint % BUCKETS)+1 - -- Yank the list of timers out of the bucket and empty it. This allows reinsertion in the currently-processed bucket from callbacks. - local nexttimer = hash[curbucket] - hash[curbucket] = false -- false rather than nil to prevent the array from becoming a hash - - while nexttimer do - local timer = nexttimer - nexttimer = timer.next - local when = timer.when - - if when < soon then - -- Call the timer func, either as a method on given object, or a straight function ref - local callback = timer.callback - if type(callback) == "string" then - safecall(timer.object[callback], timer.object, timer.arg) - elseif callback then - safecall(callback, timer.arg) - else - -- probably nilled out by CancelTimer - timer.delay = nil -- don't reschedule it - end - - local delay = timer.delay -- NOW make a local copy, can't do it earlier in case the timer cancelled itself in the callback - - if not delay then - -- single-shot timer (or cancelled) - AceTimer.selfs[timer.object][tostring(timer)] = nil - timerCache = timer - else - -- repeating timer - local newtime = when + delay - if newtime < now then -- Keep lag from making us firing a timer unnecessarily. (Note that this still won't catch too-short-delay timers though.) - newtime = now + delay - end - timer.when = newtime - - -- add next timer execution to the correct bucket - local bucket = (floor(newtime * HZ) % BUCKETS) + 1 - timer.next = hash[bucket] - hash[bucket] = timer - end - else -- if when>=soon - -- reinsert (yeah, somewhat expensive, but shouldn't be happening too often either due to hash distribution) - timer.next = hash[curbucket] - hash[curbucket] = timer - end -- if whenhandle->timer registry - local handle = tostring(timer) - - local selftimers = AceTimer.selfs[self] - if not selftimers then - selftimers = {} - AceTimer.selfs[self] = selftimers - end - selftimers[handle] = timer - selftimers.__ops = (selftimers.__ops or 0) + 1 - - return handle -end - ---- Schedule a new one-shot timer. --- The timer will fire once in `delay` seconds, unless canceled before. --- @param callback Callback function for the timer pulse (funcref or method name). --- @param delay Delay for the timer, in seconds. --- @param arg An optional argument to be passed to the callback function. --- @usage --- MyAddon = LibStub("AceAddon-3.0"):NewAddon("TimerTest", "AceTimer-3.0") --- --- function MyAddon:OnEnable() --- self:ScheduleTimer("TimerFeedback", 5) --- end --- --- function MyAddon:TimerFeedback() --- print("5 seconds passed") --- end -function AceTimer:ScheduleTimer(callback, delay, arg) - return Reg(self, callback, delay, arg) -end - ---- Schedule a repeating timer. --- The timer will fire every `delay` seconds, until canceled. --- @param callback Callback function for the timer pulse (funcref or method name). --- @param delay Delay for the timer, in seconds. --- @param arg An optional argument to be passed to the callback function. --- @usage --- MyAddon = LibStub("AceAddon-3.0"):NewAddon("TimerTest", "AceTimer-3.0") --- --- function MyAddon:OnEnable() --- self.timerCount = 0 --- self.testTimer = self:ScheduleRepeatingTimer("TimerFeedback", 5) --- end --- --- function MyAddon:TimerFeedback() --- self.timerCount = self.timerCount + 1 --- print(("%d seconds passed"):format(5 * self.timerCount)) --- -- run 30 seconds in total --- if self.timerCount == 6 then --- self:CancelTimer(self.testTimer) --- end --- end -function AceTimer:ScheduleRepeatingTimer(callback, delay, arg) - return Reg(self, callback, delay, arg, true) -end - ---- Cancels a timer with the given handle, registered by the same addon object as used for `:ScheduleTimer` --- Both one-shot and repeating timers can be canceled with this function, as long as the `handle` is valid --- and the timer has not fired yet or was canceled before. --- @param handle The handle of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer` --- @param silent If true, no error is raised if the timer handle is invalid (expired or already canceled) --- @return True if the timer was successfully cancelled. -function AceTimer:CancelTimer(handle, silent) - if not handle then return end -- nil handle -> bail out without erroring - if type(handle) ~= "string" then - error(MAJOR..": CancelTimer(handle): 'handle' - expected a string", 2) -- for now, anyway - end - local selftimers = AceTimer.selfs[self] - local timer = selftimers and selftimers[handle] - if silent then - if timer then - timer.callback = nil -- don't run it again - timer.delay = nil -- if this is the currently-executing one: don't even reschedule - -- The timer object is removed in the OnUpdate loop - end - return not not timer -- might return "true" even if we double-cancel. we'll live. - else - if not timer then - geterrorhandler()(MAJOR..": CancelTimer(handle[, silent]): '"..tostring(handle).."' - no such timer registered") - return false - end - if not timer.callback then - geterrorhandler()(MAJOR..": CancelTimer(handle[, silent]): '"..tostring(handle).."' - timer already cancelled or expired") - return false - end - timer.callback = nil -- don't run it again - timer.delay = nil -- if this is the currently-executing one: don't even reschedule - return true - end -end - ---- Cancels all timers registered to the current addon object ('self') -function AceTimer:CancelAllTimers() - if not(type(self) == "string" or type(self) == "table") then - error(MAJOR..": CancelAllTimers(): 'self' - must be a string or a table",2) - end - if self == AceTimer then - error(MAJOR..": CancelAllTimers(): supply a meaningful 'self'", 2) - end - - local selftimers = AceTimer.selfs[self] - if selftimers then - for handle,v in pairs(selftimers) do - if type(v) == "table" then -- avoid __ops, etc - AceTimer.CancelTimer(self, handle, true) - end - end - end -end - ---- Returns the time left for a timer with the given handle, registered by the current addon object ('self'). --- This function will raise a warning when the handle is invalid, but not stop execution. --- @param handle The handle of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer` --- @return The time left on the timer, or false if the handle is invalid. -function AceTimer:TimeLeft(handle) - if not handle then return end - if type(handle) ~= "string" then - error(MAJOR..": TimeLeft(handle): 'handle' - expected a string", 2) -- for now, anyway - end - local selftimers = AceTimer.selfs[self] - local timer = selftimers and selftimers[handle] - if not timer then - geterrorhandler()(MAJOR..": TimeLeft(handle): '"..tostring(handle).."' - no such timer registered") - return false - end - return timer.when - GetTime() -end - - --- --------------------------------------------------------------------- --- PLAYER_REGEN_ENABLED: Run through our .selfs[] array step by step --- and clean it out - otherwise the table indices can grow indefinitely --- if an addon starts and stops a lot of timers. AceBucket does this! --- --- See ACE-94 and tests/AceTimer-3.0-ACE-94.lua - -local lastCleaned = nil - -local function OnEvent(this, event) - if event~="PLAYER_REGEN_ENABLED" then - return - end - - -- Get the next 'self' to process - local selfs = AceTimer.selfs - local self = next(selfs, lastCleaned) - if not self then - self = next(selfs) - end - lastCleaned = self - if not self then -- should only happen if .selfs[] is empty - return - end - - -- Time to clean it out? - local list = selfs[self] - if (list.__ops or 0) < 250 then -- 250 slosh indices = ~10KB wasted (max!). For one 'self'. - return - end - - -- Create a new table and copy all members over - local newlist = {} - local n=0 - for k,v in pairs(list) do - newlist[k] = v - n=n+1 - end - newlist.__ops = 0 -- Reset operation count - - -- And since we now have a count of the number of live timers, check that it's reasonable. Emit a warning if not. - if n>BUCKETS then - DEFAULT_CHAT_FRAME:AddMessage(MAJOR..": Warning: The addon/module '"..tostring(self).."' has "..n.." live timers. Surely that's not intended?") - end - - selfs[self] = newlist -end - --- --------------------------------------------------------------------- --- Embed handling - -AceTimer.embeds = AceTimer.embeds or {} - -local mixins = { - "ScheduleTimer", "ScheduleRepeatingTimer", - "CancelTimer", "CancelAllTimers", - "TimeLeft" -} - -function AceTimer:Embed(target) - AceTimer.embeds[target] = true - for _,v in pairs(mixins) do - target[v] = AceTimer[v] - end - return target -end - --- AceTimer:OnEmbedDisable( target ) --- target (object) - target object that AceTimer is embedded in. --- --- cancel all timers registered for the object -function AceTimer:OnEmbedDisable( target ) - target:CancelAllTimers() -end - - -for addon in pairs(AceTimer.embeds) do - AceTimer:Embed(addon) -end - --- --------------------------------------------------------------------- --- Debug tools (expose copies of internals to test suites) -AceTimer.debug = AceTimer.debug or {} -AceTimer.debug.HZ = HZ -AceTimer.debug.BUCKETS = BUCKETS - --- --------------------------------------------------------------------- --- Finishing touchups - -AceTimer.frame:SetScript("OnUpdate", OnUpdate) -AceTimer.frame:SetScript("OnEvent", OnEvent) -AceTimer.frame:RegisterEvent("PLAYER_REGEN_ENABLED") - --- In theory, we should hide&show the frame based on there being timers or not. --- However, this job is fairly expensive, and the chance that there will --- actually be zero timers running is diminuitive to say the lest. diff --git a/Mainframe.lua b/Mainframe.lua deleted file mode 100644 index 2b85bdf..0000000 --- a/Mainframe.lua +++ /dev/null @@ -1,2763 +0,0 @@ --- Author : Potdisc --- Create Date : 3/21/2012 3:46:51 PM --- Mainframe.lua Handles all the masterloot interaction and host/client comms - ---_______________________________. --- TODO: --- Test if PARTY_LOOT_METHOD_CHANGED can handle the GetML() and GetCouncil() --- Random award between equal votes. --- Implement autopass. - --- --- Alt-Clicking skal tilføje items seperat i v2.0 --- Alle calls (council, mlDB osv) skal gøres af clienten. ---_______________________________. ---[[ CHANGELOG - ==== 1.6.3 Release - - *"/rc test #" now picks random items from a small list of T16 items. - - Bugfixes: - //*Council members are no longer spammed with loot roll windows.// - //*Fixed bugs with realm name stripping for realms with spaces.// - //*Fixed council voting problems caused by patch 5.4.7 API changes.// - //*Alt-click looting multiple items will now restart the looting session for any items not already awarded.// -]] - - -RCLootCouncil = LibStub("AceAddon-3.0"):NewAddon("RCLootCouncil", "AceConsole-3.0", "AceEvent-3.0", "AceComm-3.0", "AceSerializer-3.0", "AceHook-3.0"); -RCLootCouncil:SetDefaultModuleLibraries("AceEvent-3.0") -RCLootCouncil:SetDefaultModuleState(false) - -RCLootCouncil_Mainframe = {} -RCLootCouncil_LootFrame = {} -RCLootCouncil_RankFrame = {} - -local debug = false -- enable printing of debugging messages -local nnp = false -local superDebug = false -- extra debugging (very spammy) -local version = GetAddOnMetadata("RCLootCouncil", "Version") - -local isMasterLooter = false; -- is the player master looter? -local isCouncil = false; -- is the player in the council? -local isRunning = false; -- should we use the addon? -local isTesting = false; -- are we testing? -local masterLooter = ""; -- name of master looter -local currentCouncil = {} -- The current council of the session -local itemRunning = nil; -- the item in the current session -local guildRank = ""; -- Player's rank in guild -local selection = {}; -- The current selection -local lootNum = 0; -- the number of GetNumLootItems we've reached e.g. which item we're at -local itemsToLootIndex = {}; -- table containing the GetLootSlotLink() indexes that needs to be looted -local lootTable = {} -- table containing the actual items -local hasVerCheck = false; -- used to prevent "please upgrade" spamming -local bossName = "" -- used to get the boss name -local lootFramesCreated = false; -- used to get item info for loot frames -local votersNames = {}; -- contains the names of people that has voted -local currentSession = 1; -- the session the user is currently viewing -local itemsLoaded = true; -- used to test if any item is awaiting info -local hasItemInfo = false -- prevent spamming loot frames from GET_ITEM_INFO_RECEIVED -local channel = "RAID" -- the channel to use for comms, "RAID" normally, "PARTY" for debugging with starter accounts - -local MAX_DISPLAY = 11 -- max people to display in council voting window -local MAX_ITEMS = 20 -- max items allowed to be rolled at once (TODO make dynamic) - -local entryTable = {} -for i=1, MAX_ITEMS do - entryTable[i] = {} -end --- entryTable[i] order: (playerName, rank, role, totalIlvl, response, gear1, gear2, votes, class, color[], haveVoted, voters[], note) - -local offset = 0; -- scrollframe offset -local db, buttonsDB, lootDB; -- shortening of self.db.profile(.buttons/.lootDB) -local mlDB; -- the master looter's db -local debugLog; - -local sortMethod = 'desc'; -local currSortIndex = 0; -local self = RCLootCouncil; -local guildEventUnregister = false; -- used to unregister the guild_roster_update event -local _; -local menuFrame; -- rightclick menu frame - --- Create the defaults -local defaults = { - factionrealm = { -- the loot awarded db should be the same for all characters in the same faction on the same realm - lootDB = { - --[[ Format: - "playerName" = { - [#] = {"lootWon", "date (d/m/y)", "time (h:m:s)", "instance", "boss", "votes", "itemReplaced1", "itemReplaced2", "response", "responseID"} - }, - ]] - }, - }, - global = { -- debug log - logMaxEntries = 300, - log = {}, - }, - profile = { - council = {}, - awardAnnouncement = true, - awardMessageChat1 = "RAID", - awardMessageText1 = "&p was awarded with &i!", - awardMessageChat2 = "NONE", - awardMessageText2 = "", - announceConsideration = false, - announceText = "The council is currently considering &i!", - announceChannel = "RAID", - autoLooting = true, - altClickLooting = true, - lootEverything = true, - acceptWhispers = true, - acceptRaidChat = false, - trackAwards = false, - sendHistory = true, - advancedOptions = false, - autolootBoE = true, - minRank = -1, - filterPasses = false, - otherAwardReasons = { -- Used in "Award for ..." @ the rightclick menu - { text = "Disenchating", log = true}, --1 - { text = "Banking", log = true}, --2 - { text = "Free", log = false}, --3 - }, - autoAward = false, - autoAwardQualityLower = 2, - autoAwardQualityUpper = 3, - autoAwardTo = "None", - autoAwardReason = 1, - autoPass = "NONE", - -- below is the part of the db that's send to others. Separate section to avoid sending unnecessary data. - dbToSend = { - selfVote = true, - multiVote = true, - anonymousVoting = false, - masterLooterOnly = false, - allowNotes = true, - numButtons = 4, - maxButtons = 8, - passButton = 4, - buttons = { - { --1 - text = "Mainspec/Need", - color = {0, 1, 0,1}, -- Green - response = "Mainspec/Need", - whisperKey = "need, mainspec, ms, 1", - }, - { --2 - text = "Offspec/greed", - color = {1, 0.5, 0,1}, -- Orange - response = "Offspec/Greed", - whisperKey = "greed, offspec, os, 2", - }, - { --3 - text = "Minor Upgrade", - color = {0, 0.75, 0.75,1}, -- LightBlue - response = "Minor Upgrade", - whisperKey = "minorupgrade, minor, 3", - }, - { --4 - text = "Pass", - color = {0.75, 0.75,0.75,1}, -- Gray - response = "Pass", - whisperKey = "pass, 4", - }, - }, - }, - }, -} --- create the other buttons -for i = 5, defaults.profile.dbToSend.maxButtons do - defaults.profile.dbToSend.buttons[i] = { - text = "Button "..i, - color = {0.75, 0.75,0.75,1}, - response = "Button "..i.." response", - whisperKey = ""..i, - } -end - ------------------------------------------------------------------------------------ ---- Manualy implemented functions due to differences between MoP and Wotlk APIs --- ------------------------------------------------------------------------------------ -function IsInRaid() - local num = GetNumRaidMembers() - if num > 0 then - return true - end - return false -end - -function GetNumGroupMembers() - local raidNum = GetNumRaidMembers() - -- first check number of players in raid - if raidNum > 0 then - return raidNum - end - - -- if there is no raid then just return number of players in party as it returns 0 if there is no party present - return GetNumPartyMembers() -end - -function GetAverageItemLevel() - -- TODO: Implement some way to calculate iLvL for player as client doesn't support it - return 0 -end - -------------------------------------------------------------------------------------- - -function RCLootCouncil:OnInitialize() - self:RegisterChatCommand("rc", "ChatCommand") - self:RegisterChatCommand("rclc", "ChatCommand") - self:RegisterComm("RCLootCouncil") - self.db = LibStub("AceDB-3.0"):New("RCLootCouncilDB", defaults, true) - self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig") - self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig") - self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig") - db = self.db.profile - lootDB = self.db.factionrealm.lootDB - debugLog = self.db.global.log - - self.options = self:OptionsTable() - -- register the optionstable - self.options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) - LibStub("AceConfig-3.0"):RegisterOptionsTable("RCLootCouncil", self.options) - - -- add it to blizz options - self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("RCLootCouncil", "RCLootCouncil") - buttonsDB = db.dbToSend.buttons -end - -function RCLootCouncil:OnEnable() - self:debugS(" ") - self:debugS("Logged in") - MainFrame:RegisterEvent("LOOT_OPENED"); - MainFrame:RegisterEvent("LOOT_CLOSED"); - MainFrame:RegisterEvent("GROUP_ROSTER_UPDATE"); -- redundant with PARTY_LOOT_METHOD_CHANGED - MainFrame:RegisterEvent("PARTY_LOOT_METHOD_CHANGED"); - MainFrame:RegisterEvent("GUILD_ROSTER_UPDATE"); - MainFrame:RegisterEvent("CHAT_MSG_WHISPER"); - MainFrame:RegisterEvent("CHAT_MSG_RAID"); - MainFrame:RegisterEvent("GET_ITEM_INFO_RECEIVED"); - MainFrame:RegisterEvent("RAID_INSTANCE_WELCOME"); - MainFrame:SetScript("OnEvent", RCLootCouncil.EventHandler); - - if IsInGuild() then - self:SendCommMessage("RCLootCouncil", "verTest "..version, "GUILD") -- send out a version check - end - self.db.global.version = version; - - GuildRoster(); - - local filterFunc = function(_, event, msg, player, ...) - return strfind(msg, "[[RCLootCouncil]]:") - end - - ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM", filterFunc) -end - -function RCLootCouncil:OnDisable() - self:UnregisterAllEvents() - MainFrame:UnregisterAllEvents() -end - -function RCLootCouncil:RefreshConfig() - db = self.db.profile -end - -------------- MainFrame_OnLoad ----------- --- Loads the MainFrame ------------------------------------------- -function RCLootCouncil:MainFrame_OnLoad() - MainFrame:Hide() - ------ Create content entries -------- - local entry = CreateFrame("Button", "$parentEntry1", ContentFrame, "RCLootCouncil_Entry"); -- Creates the first row - entry:SetID(1); -- Set the ID - entry:SetPoint("TOPLEFT", 4, -4) -- Set anchor - for i = 2, MAX_DISPLAY do -- Create the rest of the rows - local entry = CreateFrame("Button", "$parentEntry"..i, ContentFrame, "RCLootCouncil_Entry"); - entry:SetID(i); - entry:SetPoint("TOP", "$parentEntry"..(i-1), "BOTTOM") -- Set the anchor to the row above - end - - ------ Create session switches ------- - for i = 1, MAX_ITEMS do - local button = CreateFrame("Button", "RCLootCouncil_SessionButton"..i, MainFrame, "RCLootCouncil_SessionToggleButton"); - if i == 1 then - button:SetPoint("TOPLEFT", MainFrame, "TOPRIGHT", 2, 0) - elseif mod(i,10) == 1 then - button:SetPoint("TOPLEFT", "RCLootCouncil_SessionButton"..i-10, "TOPRIGHT", 2, 0) - else - button:SetPoint("TOP", "RCLootCouncil_SessionButton"..i-1, "BOTTOM", 0, -2) - end - button:SetID(i) - end - - ------ rightclick menu -------------- - menuFrame = CreateFrame("Frame", "RCLootCouncil_RightClickMenu", MainFrame, "UIDropDownMenuTemplate") - UIDropDownMenu_Initialize(menuFrame, RCLootCouncil_Mainframe_RightClickMenu, "MENU") - - ----------PopUp setups -------------- - ------------------------------------- - StaticPopupDialogs["RCLOOTCOUNCIL_CONFIRM_ABORT"] = { - text = "Are you sure you want to abort?", - button1 = "Yes", - button2 = "No", - OnAccept = function() - RCLootCouncil_Mainframe.abortLooting() - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to abort as well - RCLootCouncil_Mainframe.stopLooting() - CloseButton_OnClick() -- close the frame - CloseLoot() -- close the lootlist - end, - timeout = 0, - enterClicksFirstButton = true, - whileDead = true, - hideOnEscape = true, - preferredIndex = 3, - } - - StaticPopupDialogs["RCLOOTCOUNCIL_CONFIRM_AWARD"] = { - text = "Are you sure you want to give %s to %s?", - button1 = "Yes", - button2 = "No", - OnAccept = function() - RCLootCouncil_Mainframe.award() - end, - timeout = 0, - enterClicksFirstButton = true, - whileDead = true, - hideOnEscape = true, - preferredIndex = 3, - } - - StaticPopupDialogs["RCLOOTCOUNCIL_CONFIRM_USAGE"] = { - text = "Do you want to use RCLootCouncil for this raid?", - button1 = "Yes", - button2 = "No", - OnAccept = function() - RCLootCouncil:debugS("CONFIRM_USAGE = true") - isRunning = true; - masterLooter = RCLootCouncil_Mainframe.getML() - if db.autoAward and GetLootThreshold() > db.autoAwardQualityLower then - RCLootCouncil:Print("Changing loot threshold to enable Auto Awarding.") - SetLootThreshold(db.autoAwardQualityLower) - end - self:Print("is active in this raid. You can turn it off in the options menu if you regret.") - if #db.council < 1 then -- if there's no council - self:Print("You haven't set a council") - RCLootCouncil_RankFrame.show() -- show the rankframe - end - end, - OnCancel = function () - RCLootCouncil:debugS("CONFIRM_USAGE = false") - isRunning = false; - self:Print("is not active in this raid. You can turn it on in the options menu if you regret.") - end, - timeout = 0, - enterClicksFirstButton = true, - whileDead = true, - hideOnEscape = true, - preferredIndex = 3, - } -end - ----------- EventHandler ----------------- --- Handles events ------------------------------------------ -function RCLootCouncil.EventHandler(self2, event, ...) - if event == "LOOT_OPENED" then - if isMasterLooter and isRunning and (IsInRaid() or nnp) then -- if we're masterlooter and addon is enabled or debug is on - self:debugS("event = "..event) - if GetNumLootItems() >= 1 then -- if there's something to loot - if not InCombatLockdown() then - bossName = GetUnitName("target", false) -- extract the boss name before the player can switch targets - if not bossName then bossName = "Unknown/Chest" end -- check if we really got a boss name, or we just looted a chest - for i = 1, GetNumLootItems() do -- run through the number of items in the loot window - if db.altClickLooting then -- hook loot buttons if we use altClickLooting - local lootButton = getglobal("LootButton"..i) - if lootButton ~= nil then - self:HookScript(lootButton, "OnClick", "LootOnClick") -- hook if we use it - end - if XLoot then -- hook XLoot - lootButton = getglobal("XLootButton"..i) - if lootButton ~= nil then - self:HookScript(lootButton, "OnClick", "LootOnClick") - end - end if XLootFrame then -- if XLoot 1.0 - lootButton = getglobal("XLootFrameButton"..i) - if lootButton ~= nil then - self:HookScript(lootButton, "OnClick", "LootOnClick") - end - end if getglobal("ElvLootSlot"..i) then -- if ElvUI - lootButton = getglobal("ElvLootSlot"..i) - if lootButton ~= nil then - self:HookScript(lootButton, "OnClick", "LootOnClick") - end - end - end - local _, _, lootQuantity, lootRarity = GetLootSlotInfo(i) - -- check if we should autoAward it, otherwise check if we should loot it - if db.autoAward and (LootSlotIsItem(i) == 1) and lootQuantity > 0 and (lootRarity >= db.autoAwardQualityLower and lootRarity <= db.autoAwardQualityUpper) then - RCLootCouncil:AutoAward(i, db.autoAwardTo, GetLootSlotLink(i)) - - elseif db.autoLooting then - if ((LootSlotIsItem(i) == 1) or db.lootEverything) and lootQuantity > 0 and lootRarity >= GetLootThreshold() then -- Check wether we want to loot the item or not - -- now that we know it's an lootable item, lets also check if we should loot BoE's - if RCLootCouncil:LootBoE(GetLootSlotLink(i)) then - tinsert(lootTable, GetLootSlotLink(i)) -- add the item link to the table - tinsert(itemsToLootIndex, i) -- add its index to the lootTable - end - elseif lootQuantity == 0 then -- if its coin - LootSlot(i) -- loot the coin - end - end - - end - else -- don't do anything if we're in combat - self:Print("Couldn't start the loot session because you're in combat.") - return; - end - if #itemsToLootIndex > 0 then -- if there's anything in the table - lootNum = 1; - RCLootCouncil_initiateLoot(lootTable[lootNum]); -- initiate the loot - end - end - end - elseif event == "LOOT_CLOSED" then - if isMasterLooter then - self:debugS("event = "..event) - self:UnhookAll() - if itemRunning then -- the loot window closed too early - DEFAULT_CHAT_FRAME:AddMessage("RCLootCouncil cannot loot anything without the loot window being open!", 1, 0.5, 0, 1, 10) - DEFAULT_CHAT_FRAME:AddMessage("Please restart the looting session.", 1, 0.5, 0, 1, 10) - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - CloseButton_OnClick() -- close the frame - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to abort as well - end - end - elseif event == "GROUP_ROSTER_UPDATE" and (IsInRaid() or nnp) then - masterLooter = RCLootCouncil_Mainframe.getML() - isCouncil = RCLootCouncil_Mainframe.isCouncil() - - elseif event == "RAID_INSTANCE_WELCOME" then - self:debugS("event = "..event) - if isRunning then return; end -- don't do shit - if IsInRaid() or nnp then -- if the player is in a raid - local lootMethod = GetLootMethod() - if lootMethod == 'master' then -- if master looter is turned on - -- just make the call to getML and it'll do the prompting - masterLooter = RCLootCouncil_Mainframe.getML() - elseif (IsRealRaidLeader() == 1) and not isRunning then -- otherwise ask the raid leader - StaticPopup_Show("RCLOOTCOUNCIL_CONFIRM_USAGE") - end - end - elseif event == "GUILD_ROSTER_UPDATE" then -- delay the getting of guildRank till it's available - guildRank = RCLootCouncil:GetGuildRank(); - if guildEventUnregister then - MainFrame:UnregisterEvent("GUILD_ROSTER_UPDATE"); -- we don't need it any more - RCLootCouncil:GetGuildOptions() -- get the guild data to the options table now that it's ready - end - elseif event == "CHAT_MSG_WHISPER" and isMasterLooter and db.acceptWhispers then - local msg, sender = ... - if msg == "rchelp" then - RCLootCouncil:SendWhisperHelp(sender) - elseif itemRunning then - RCLootCouncil:GetItemsFromMessage(msg, sender) - end - elseif event == "CHAT_MSG_RAID" and itemRunning and isMasterLooter and db.acceptRaidChat then - local msg, sender = ... - RCLootCouncil:GetItemsFromMessage(msg, sender) - - elseif event == "PARTY_LOOT_METHOD_CHANGED" then - self:debug("PARTY_LOOT_METHOD_CHANGED") - -- TODO Test this shit - - elseif event == "GET_ITEM_INFO_RECEIVED" then - if not lootFramesCreated and #lootTable > 0 then - itemsLoaded = true - for i = 1, #lootTable do - local name = GetItemInfo(lootTable[i]) - if name == nil then - itemsLoaded = false; - hasItemInfo = false - end - end - if itemsLoaded then - if not hasItemInfo then - self:debugS("RCLootCouncil_LootFrame:Update() - "..event) - hasItemInfo = true - lootFramesCreated = true - RCLootCouncil_LootFrame:Update(lootTable) - if itemRunning then - RCLootCouncil_Mainframe.prepareLootFrame(itemRunning); - end - end - end - end - end -end - - --------- OnCommReceived ------------------- --- Handles communications -------------------------------------------- -function RCLootCouncil:OnCommReceived(prefix, msg, distri, sender) ---[[List of commands: - start (i) - ML initiates new looting (number from lootTable we're at) - lootTable (table) - ML sends the loot table - stop - ML stops looting - council (table) - ML sends the council - mlDB (table) - ML sends his options database - vote (string) - anyone sends a vote - add (table) - anyone sends an response on the "roll" - remove (name) - ML removes an entry - change (table) - ML changes a response - verTest (string) - anyone sends a version test - verTestReply (table) - anyone sends a verTest reply - award(name, table) - ML sends an award history entrance - reRoll(table) - ML says to reroll - msg - Message to display ---]] - if prefix == "RCLootCouncil" then - -- no need to diff it for pservers - -- sender = Ambiguate(sender, "none") - local cmd, object = strsplit(" ", msg, 2) -- split the command from the object - if cmd and object then - self:debugS("Comm received, cmd: "..cmd..", object: "..object..", sender: "..sender) - else - self:debugS("Comm received, cmd: "..cmd..", sender: "..sender) - end - if sender == GetUnitName("player", false) and distri ~= "WHISPER" then return end; -- don't do anything if we send the message, unless it was a whisper - if cmd == 'start' and (isCouncil or isMasterLooter) then - if not isMasterLooter or nnp then - RCLootCouncil_Mainframe.abortLooting() -- start with aborting, just in case the masterlooter disconnects during looting - lootNum = tonumber(object); - self:debug("Added item (council): "..lootTable[lootNum]) - itemRunning = lootTable[lootNum]; - RCLootCouncil_Mainframe:ChangeSession(lootNum) -- just call ChangeSession as it's basicly the same - else - self:debug("A non ML called for a start!") - end - elseif cmd == "lootTable" then - if not isMasterLooter or nnp then - local test, c = self:Deserialize(object) - if test then - for i = 1, #c do - GetItemInfo(c[i]) -- queue the item info - end - lootTable = c - itemsLoaded = true -- test if the item info is queued - for i = 1, #lootTable do - local name = GetItemInfo(lootTable[i]) - if name == nil then - itemsLoaded = false - hasItemInfo = false - end - end - if itemsLoaded then -- and only call .setupLoot if it is, otherwise wait for it to arrive (Event) - self:debugS("RCLootCouncil_LootFrame:Update() - "..cmd) - lootFramesCreated = true - hasItemInfo = true - RCLootCouncil_LootFrame:Update(lootTable) - end - else - self:debug("Deserialization on lootTable failed!") - end - else - self:debug("A non ML send a lootTable!") - end - elseif cmd == "stop" then - if not isMasterLooter then - isRunning = false; -- the ML said stop, so better stop the addon just in case - self:debug("isRunning = false") - self:Print("The Master Looter stopped the voting") - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - else - self:debug("A non ML called for a stop!") - end - elseif cmd == 'council' then - if not isMasterLooter then - local test, c = self:Deserialize(object) - if test then - currentCouncil = c - isCouncil = RCLootCouncil_Mainframe.isCouncil() - masterLooter = RCLootCouncil_Mainframe.getML() - else - --TODO: perhaps add a callback for another send - self:debug("Deserialization on counciltable failed!") - end - else - self:debug("A non ML send a councillist!") - end - - elseif cmd == 'mlDB' then - if not isMasterLooter then - local test, c = self:Deserialize(object) - if test then - mlDB = c - else - --TODO: perhaps add a callback for another send - self:debug("Deserialization on mlDB failed!") - end - else - self:debug("A non ML send a mlDB!") - end - elseif cmd == 'vote' and (isCouncil or isMasterLooter) then - for i = 1, #currentCouncil +1 do -- make sure we only accept votes from council members (+1 to force it to at least try ML once) - if currentCouncil[i] == sender or masterLooter == sender then - local session, name, devote = strsplit(" ", object, 3) - session = tonumber(session) - if type(session) ~= "number" or session > MAX_ITEMS then -- incompatible version check - self:Print(sender.." uses an incompatible version and cannot vote.") - return; - end - RCLootCouncil_Mainframe.voteOther(session, name, devote, sender) - if isMasterLooter then -- insert the voter's name to the table - if not tContains(votersNames, sender) then - tinsert(votersNames, sender) - end - end - return; - end - end - self:Print("Rejected a vote from a non councilmember ("..sender..")") - - elseif cmd == 'add' and (isCouncil or isMasterLooter) then - local test, c = self:Deserialize(object) - if test then - tinsert(entryTable[c["i"]], c[1]) - if c["i"] == currentSession then -- only sort incoming rolls on our current page - RCLootCouncil_Mainframe.sortTable(4, true) -- sort passes away, and let that function call the update - end - else - --TODO: Add a callback for another send - self:debug("Deserialization on add failed!") - end - elseif cmd == 'remove' and (isCouncil or isMasterLooter) then - if not isMasterLooter then - local session, name = strsplit(" ", object, 2) - RCLootCouncil_Mainframe.removeEntry(session, name) - else - self:debug("A non ML ("..sender..") send a remove cmd") - end - - elseif cmd == "change" and isCouncil then - local test, c = self:Deserialize(object) - if test then - entryTable[c[1]][c[2]][5] = c[3] - RCLootCouncil_Mainframe.Update(true); - else - -- new send - self:debug("Deserialization on change failed!") - end - elseif cmd == 'verTest' then - if version < object and not hasVerCheck then -- if we're outdated and haven't already showed it to the user - self:Print("Your version: "..version.." is outdated, newer version is: "..object) - hasVerCheck = true; - end - local _, class = UnitClass("player") - self:SendCommMessage("RCLootCouncil", "verTestReply "..self:Serialize({class, guildRank, version}) , "WHISPER", sender) - - elseif cmd == 'verTestReply' then - local test, c = self:Deserialize(object) - if test then - if version < c[3] and not hasVerCheck then -- if we're outdated - self:Print("Your version: "..version.." is outdated, newest version is: "..c[3]) - hasVerCheck = true; - end - tinsert(c, 2, sender) -- insert sender to the table - RCLootCouncil_VersionFrame:AddPlayer(c) -- and add the data to the versionFrame - else -- if old version - RCLootCouncil_VersionFrame:AddPlayer({nil, sender, "Unknown", object}) - end - - elseif cmd == "award" and db.trackAwards then - local name, table = string.split(" ", object,2) - if name and table then -- just to be sure - local test, c = self:Deserialize(table) - if test then - if lootDB[name] then -- if the name is already registered in the table - tinsert(lootDB[name], c) - else -- if it isn't - lootDB[name] = {c}; - end - else - self:debug("Deserialization on award failed!") - end - else - self:debug("Couldn't get name or table in award cmd") - end - - elseif cmd == "reRoll" then - -- object = item, session - local test, c = self:Deserialize(object) - if test then - RCLootCouncil_LootFrame:Update(nil, {item = c[1], position = c[2]}) - self:Print(sender.." requested a reroll on "..c[1]) - else - -- new send - end - - elseif cmd == "msg" then - self:Print(tostring(object)) --- else --- self:debug("Bad command: "..tostring(object)) --- disabled for spamming when (not (isCouncil or isMasterLooter)) - end - end -end - - ---------------- debug --------------------- --- Prints debug messages if turned on -------------------------------------------- -function RCLootCouncil:debug(msg) - if debug then - self:Print("debug: "..msg) - end - RCLootCouncil:DebugLogAdd(msg) -end - --------------- superDebug ----------------- --- Prints superDebug messages -------------------------------------------- -function RCLootCouncil:debugS(msg) - if superDebug then - self:Print("debugS: "..msg) - end - RCLootCouncil:DebugLogAdd(msg) -end - --------------- showMainFrame -------------- --- Shows the Main Frame -------------------------------------------- -function RCLootCouncil_Mainframe.showMainFrame() - self:debugS("Mainframe.showMainFrame()") - if itemRunning then -- would hide the entries if a councilmember closes and trys to re open it - RCLootCouncil_Mainframe.Update(true) - else -- no items, so we want to hide it - RCLootCouncil_Mainframe.Update(false) - end - MainFrame:Show() -end - --------------- hideMainFrame -------------- --- Hides the Main Frame -------------------------------------------- -function RCLootCouncil_Mainframe.hideMainFrame() - self:debugS("Mainframe.hideMainFrame()") - MainFrame:Hide() -end - - ---------- CloseButton_OnClick ------------- --- When close button is clicked -------------------------------------------- -function CloseButton_OnClick() - self:debugS("CloseButtion_OnClick()") - if not isMasterLooter and not isTesting then -- hide if we're not the masterlooter - RCLootCouncil_Mainframe.hideMainFrame() - elseif not itemRunning then -- if we are, only hide when nothings running - RCLootCouncil_Mainframe.hideMainFrame() - else -- else show confirmation box - StaticPopup_Show("RCLOOTCOUNCIL_CONFIRM_ABORT") - end -end - ---------- removeBtOnClick ------------------ --- When the remove button is clicked --------------------------------------------- -function RCLootCouncil_Mainframe.removeBtOnClick() - if selection[1] then - self:SendCommMessage("RCLootCouncil", "remove "..currentSession.." "..selection[1], channel) - RCLootCouncil_Mainframe.removeEntry(currentSession, selection[1]) - else - self:Print("Couldn't remove the player") - end -end ---------- awardBtOnClick ------------------- --- When the award button is clicked --------------------------------------------- -function RCLootCouncil_Mainframe.awardBtOnClick() - StaticPopup_Show("RCLOOTCOUNCIL_CONFIRM_AWARD", itemRunning, selection[1]) -end - -------------- abortLooting -------------------- --- Aborts the current looting session ------------------------------------------------ -function RCLootCouncil_Mainframe.abortLooting() - self:debugS("Mainframe.abortLooting()") - itemRunning = nil; - lootFramesCreated = false; - CurrentItemTexture:Hide(); - CurrentItemLabel:SetText(" "); - CurrentItemLvl:SetText(" "); - CurrentItemType:SetText(" "); - CurrentItemHover:Hide(); - BtClose:SetText("Close"); - EmptyTexture:Show(); - RCLootCouncil_Mainframe.updateSelection(0, true); - RCLootCouncil_Mainframe.Update(false); - PeopleToRollLabel:Hide() - PeopleToRollString:Hide() - isTesting = false; -end - -function RCLootCouncil_Mainframe.stopLooting() - self:debugS("Mainframe.stopLooting()") - -- clear the entry table efficiently, but keep some of it, as its needed later on. - for i = 1, #entryTable do - wipe(entryTable[i]) - end - lootNum = 0 - currentSession = 1 - lootTable = {} - itemsToLootIndex = {} - votersNames = {} - currentCouncil = {} - RCLootCouncil_LootFrame.hide() - RCLootCouncil_Mainframe.Update(false); -end -------------- ChatCommand --------------------- --- Handles all the chat commands ------------------------------------------------ -function RCLootCouncil:ChatCommand(msg) - local input, arg = string.split(" ", msg, 2); -- Separates the command from the rest - input = input:lower(); -- Lower case command - - if not input or input:trim() == "" or input == 'help' then - print("RCLootCouncil ver. " .. version) - self:Print("- config - Open the options frame") - self:debug("- debug or d - Toggle debugging") - self:Print("- show - Shows the main loot frame") - self:Print("- hide - Hides the main loot frame") - self:Print("- council - displays the current council") - self:Print("- councilAdd (name) or cAdd - adds a new member to the loot council") - self:Print("- remove (name) - removes a player from the loot council") - self:Print("- deleteEntireCouncil - deletes the entire council") - self:Print("- test (#) - emulate a loot session (add a number for raid test)") - self:Print("- version - open the Version Checker (alt. 'v' or 'ver')") - self:Print("- history - open the Loot History") - self:Print("- whisper - displays help to whisper commands (alt. 'his')") - self:Print("- reset - resets the addon's frames' positions") - self:debug("- log - display the debug log") - self:debug("- clearLog - clear the debug log") - - elseif input == 'config' then - --InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) - LibStub("AceConfigDialog-3.0"):Open("RCLootCouncil") - elseif input == 'debug' or input == 'd' then - debug = not debug - if debug then self:Print("Debugging enabled") - else self:Print("Debugging disabled") - end - - elseif input == 'show' then - if not IsInRaid() or isCouncil or isMasterLooter or nnp then -- only the right people may see the window during a raid since they otherwise could watch the entire voting - RCLootCouncil_Mainframe.showMainFrame() - else - self:Print("You are not allowed to see the Voting Frame right now.") - end - - elseif input == 'hide' then - RCLootCouncil_Mainframe.hideMainFrame() - - elseif input == 'council' then - if db.council then - self:Print("Council: ") - for _,t in ipairs(db.council) do print(t) end - else - self:Print("No council exists") - end - - elseif input == 'counciladd' or input == 'cadd' then - if arg then - tinsert(db.council, arg) - self:Print(""..arg.." was added to the council!") - else - self:Print("Please provide a playername") - end - - elseif input == 'remove' then - if arg then - if db.council then - for k,v in ipairs(db.council) do - if v == arg then - tremove(db.council, k) - self:Print(""..arg.." was removed from the council") - end - end - end - end - - elseif input == 'deleteentirecouncil' then - db.council = {} - self:Print("Council wiped") - - elseif input == 'test' then - if (IsInRaid() or nnp) and arg then - RCLootCouncil_Mainframe.getML() - RCLootCouncil_Mainframe.raidTestFrames(tonumber(arg)) - else - if arg then - self:Print("You can only raid test when in a raid and are the group leader/assistant.") - self:Print("Use \"/rc test\" for solo test.") - return; - end - RCLootCouncil_Mainframe.testFrames() - end - - elseif input == "add" and nnp then - -- local _, totalIlvl = GetAverageItemLevel() - local totalIlvl = GetAverageItemLevel() - local gear1, gear2 = RCLootCouncil.getCurrentGear(lootTable[currentSession]); - local _, class = UnitClass("player"); -- non-localized class name - - local toAdd = { - ["i"] = currentSession, - { - GetUnitName("player", false), - guildRank, - RCLootCouncil.getPlayerRole(), - math.floor(totalIlvl), - tonumber(arg), - gear1, - gear2, - 0, - class, - color, - false, - {""}, - nil, - } - } - RCLootCouncil:OnCommReceived("RCLootCouncil", "add "..self:Serialize(toAdd), channel, "Someone else") - - elseif input == 'version' or input == "v" or input == "ver" then - self:EnableModule("RCLootCouncil_VersionFrame") - elseif input == "history" or input == "his" then - self:EnableModule("RCLootHistory") - elseif input == "nnp" then - nnp = not nnp - elseif input == "debugs" and nnp then - superDebug = not superDebug - elseif input == "whisper" then - self:Print("Players can whisper (or through Raidchat if enabled) their current item(s) followed by a keyword to the Master Looter if they doesn't have the addon installed.\nThe keyword list is found under the 'Buttons, Responses and Whispers' optiontab.\nPlayers can whisper 'rchelp' to the Master Looter to retrieve this list.\nNOTE: People should still get the addon installed, otherwise all player information won't be available.") - - elseif input == "reset" then - if RCLootFrame then - RCLootFrame:ClearAllPoints() - RCLootFrame:SetPoint("CENTER", 0, -200) - end - if MainFrame then - MainFrame:ClearAllPoints() - MainFrame:SetPoint("CENTER", 0, 200) - end - if RCVersionFrame then - RCVersionFrame:ClearAllPoints() - RCVersionFrame:SetPoint("CENTER", -400, 0) - end - if RCLootHistoryFrame then - RCLootHistoryFrame:ClearAllPoints() - RCLootHistoryFrame:SetPoint("CENTER", -400, 0) - end - - elseif input == "debuglog" or input == "log" then - for k,v in ipairs(debugLog) do - print(k.." - "..v) - end - elseif input == "clearlog" then - wipe(debugLog) - self:Print("Debug Log cleared.") - else - RCLootCouncil:ChatCommand("help") - end -end - ----------- initiateLoot -------------- --- Start looting an item --------------------------------------- -function RCLootCouncil_initiateLoot(item) - self:debugS("initiateLoot("..tostring(item)..")") - if isRunning or nnp then -- only do stuff if we're using the addon or debugging - if item == nil then -- Be certain we got something here - self:Print("Item wasn't cached, please restart the session!") - return; - end - for i = 1, #lootTable do - local name = GetItemInfo(lootTable[i]) - if name == nil then - self:Print("Items weren't cached, please restart the session!") - return - end - end - hasItemInfo = true - - if itemRunning then -- if we're already trying to handle an item - self:Print("Can't start a new loot session while an item is being considered"); - self:debug("Trying to start new session while another is being considered!!") - return; - else -- we're not running an item - itemRunning = item; - -- create the table of in-raid-councilmembers to send to the councillors - for _, v in ipairs(db.council) do - if UnitInRaid(v) then - tinsert(currentCouncil, v) - end - end - self:SendCommMessage("RCLootCouncil", "council "..self:Serialize(currentCouncil), channel) -- let the members know if they're councilmen - mlDB = db.dbToSend -- create the master looter db - self:SendCommMessage("RCLootCouncil", "mlDB "..self:Serialize(mlDB), channel) -- and send - self:SendCommMessage("RCLootCouncil", "lootTable "..self:Serialize(lootTable), channel) -- tell everyone to do the same - self:SendCommMessage("RCLootCouncil", "start "..lootNum, channel) -- tell the council we've started - self:debug("Added item: "..item) - BtClose:SetText("Cancel Looting") - RCLootCouncil:announceConsideration() -- announce it if it's on - self:debugS("RCLootCouncil_LootFrame:Update() - RCLootCouncil_initiateLoot()") - RCLootCouncil_LootFrame:Update(lootTable) -- setup our own loot frames - RCLootCouncil_Mainframe.prepareLootFrame(item) - end - end -end - -----------initiateNext --------------- --- Initiates the next item --------------------------------------- -function RCLootCouncil:initiateNext(item) - itemRunning = item - RCLootCouncil:announceConsideration() -- announce it if it's on - self:SendCommMessage("RCLootCouncil", "start "..lootNum, channel) -- tell the council to start on the next item - currentSession = lootNum - RCLootCouncil_Mainframe.prepareLootFrame(item) -end - ----------- prepareLootFrame ---------- --- Prepares the loot frame for an item --------------------------------------- -function RCLootCouncil_Mainframe.prepareLootFrame(item) - self:debugS("Mainframe.prepareLootFrame("..tostring(item)..")") - if isMasterLooter or isCouncil or isTesting then - if not itemRunning then -- double check ;) - self:debug("prepareLootFrame called without any item running!") - return - end - GetItemInfo(item); -- query up the item - local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount, thisItemEquipLoc, thisItemTexture = GetItemInfo(item); -- Get the item info - if thisItemTexture then - CurrentItemTexture:SetTexture(thisItemTexture); -- Set the texture of the icon box - else - CurrentItemTexture:SetTexture("Interface\InventoryItems\WoWUnknownItem01"); - end - - CurrentItemTexture:Show(); -- Open up the icon box - EmptyTexture:Hide(); -- Hide the empty texture - - if iLevel then - CurrentItemLvl:SetText("ilvl: "..iLevel); -- Show the Item Level - else - CurrentItemLvl:SetText(""); - end - - if sLink then - CurrentItemLabel:SetText(sLink); -- Set the item link for color and such - CurrentItemLabel:SetFont("Fonts\\FRIZQT__.TTF", 16); - else - CurrentItemLabel:SetText("LOADING"); - end - - if sSubType and sSubType ~= "Miscellaneous" and sSubType ~= "Junk" and thisItemEquipLoc ~= "" then - CurrentItemType:SetText(getglobal(thisItemEquipLoc)..", "..sSubType); -- getGlobal to translate from global constant to localized name - elseif sSubType ~= "Miscellaneous" and sSubType ~= "Junk" then - CurrentItemType:SetText(sSubType) - else - CurrentItemType:SetText(getglobal(thisItemEquipLoc)); - end - - CurrentItemHover:Show(); -- Make sure we can hover the item - MasterlooterLabel:SetText(masterLooter); - - PeopleToRollString:Show() - PeopleToRollLabel:SetText(GetNumGroupMembers()) -- set the amount of people missing the rolling - PeopleToRollLabel:Show() - - -- Award string - AwardString:Hide() - if isMasterLooter or isTesting then - if currentSession > lootNum then - AwardString:Show() - AwardString:SetText("You can't award this item yet!") - AwardString:SetTextColor(1,0,0,1) - end - end - if currentSession < lootNum then - AwardString:SetText("This item has been awarded.") - AwardString:SetTextColor(0,1,0,1) - AwardString:Show() - end - - RCLootCouncil_Mainframe:UpdateSessionButtons() - RCLootCouncil_Mainframe.showMainFrame() - else - self:debug("PrepareLootFrame called without a valid initiator!") - end -end - ---[[ - Used by getCurrentGear to determine slot types - Inspired by EPGPLootMaster - thanks! ---]] -local INVTYPE_Slots = { - INVTYPE_HEAD = "HeadSlot", - INVTYPE_NECK = "NeckSlot", - INVTYPE_SHOULDER = "ShoulderSlot", - INVTYPE_CLOAK = "BackSlot", - INVTYPE_CHEST = "ChestSlot", - INVTYPE_WRIST = "WristSlot", - INVTYPE_HAND = "HandsSlot", - INVTYPE_WAIST = "WaistSlot", - INVTYPE_LEGS = "LegsSlot", - INVTYPE_FEET = "FeetSlot", - INVTYPE_SHIELD = "SecondaryHandSlot", - INVTYPE_ROBE = "ChestSlot", - INVTYPE_2HWEAPON = {"MainHandSlot","SecondaryHandSlot"}, - INVTYPE_WEAPONMAINHAND = "MainHandSlot", - INVTYPE_WEAPONOFFHAND = {"SecondaryHandSlot",["or"] = "MainHandSlot"}, - INVTYPE_WEAPON = {"MainHandSlot","SecondaryHandSlot"}, - INVTYPE_THROWN = "RangedSlot", - INVTYPE_RANGED = "RangedSlot", - INVTYPE_RANGEDRIGHT = "RangedSlot", - INVTYPE_FINGER = {"Finger0Slot","Finger1Slot"}, - INVTYPE_HOLDABLE = {"SecondaryHandSlot", ["or"] = "MainHandSlot"}, - INVTYPE_TRINKET = {"TRINKET0SLOT", "TRINKET1SLOT"} -} - ---------- getCurrentGear ------------------------ --- Returns the player's gear in the given slot(s) --- based on arg (item). -------------------------------------------------- -function RCLootCouncil.getCurrentGear(item) - local itemID = tonumber(strmatch(item, "item:(%d+):")) -- extract itemID - -- check if the item is a token, and if it is, return the matching current gear - if RCTokenTable[itemID] then return GetInventoryItemLink("player", GetInventorySlotInfo(RCTokenTable[itemID])), nil; end - local _, _, _, _, _, _, _, _, thisItemEquipLoc = GetItemInfo(item); - local item1, item2; - local slot = INVTYPE_Slots[thisItemEquipLoc] - if not slot then return nil, nil; end; - item1 = GetInventoryItemLink("player", GetInventorySlotInfo(slot[1] or slot)) - if not item1 and slot['or'] then - item1 = GetInventoryItemLink("player", GetInventorySlotInfo(slot['or'])) - end; - if slot[2] then - item2 = GetInventoryItemLink("player", GetInventorySlotInfo(slot[2])) - end - return item1, item2; -end - ----------- ShowCurrentItemTooltip ------------- --- Shows item running's Tooltip ------------------------------------------------ -function RCLootCouncil_Mainframe.ShowCurrentItemTooltip() - if itemRunning then - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:SetHyperlink(lootTable[currentSession]) - GameTooltip:Show() - end -end - ----------- ShowCurrentGearTooltip ------------- --- Shows the current gear Tooltip ------------------------------------------------ -function RCLootCouncil_Mainframe.ShowCurrentGearTooltip(id) - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - if id then - id = id + offset -- handle the offset - if entryTable[currentSession][id][6] then - GameTooltip:SetHyperlink(entryTable[currentSession][id][6]) - GameTooltip:Show() - end - elseif selection[6] then - GameTooltip:SetHyperlink(selection[6]) - GameTooltip:Show() - end -end - ----------- ShowCurrentGear2Tooltip ------------- --- Shows the current gear2 Tooltip ------------------------------------------------ -function RCLootCouncil_Mainframe.ShowCurrentGear2Tooltip(id) - if id then - id = id + offset -- handle the offset - if entryTable[currentSession][id][7] then - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:SetHyperlink(entryTable[currentSession][id][7]) - GameTooltip:Show() - end - elseif selection[7] then - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:SetHyperlink(selection[7]) - GameTooltip:Show() - end -end - -------------- toolMouseLeave ---------------------------------------- --- Removes the tooltip when mouse leaves the area ------------------------------------------------------------------ -function RCLootCouncil_Mainframe.toolMouseLeave() - GameTooltip:Hide() -end - - ----------- GetGuildRank ------------------- --- returns the player's guild rank -------------------------------------------- -function RCLootCouncil:GetGuildRank() - self:debugS("GetGuildRank()") - GuildRoster() - if IsInGuild() then - _, rank, _ = GetGuildInfo("player"); - if rank then - self:debug("Found guild rank: "..rank) - guildEventUnregister = true; -- make sure we unregister the event - return rank; - else - GuildRoster(); - return "Not Found"; - end - else - return "Unguilded"; - end -end - ----------- setClassIcon ------------------- --- Sets the class-texture to a given class -------------------------------------------- -function RCLootCouncil_Mainframe.setClassIcon(frame, class) - if class then - frame:SetTexture("Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES"); -- this is the image containing all class icons - local coords = CLASS_ICON_TCOORDS[class]; -- get the coordinates of the class icon we want - frame:SetTexCoord(unpack(coords)); -- cut out the region with our class icon according to coords - else -- if there's no class - frame:SetTexture("Interface/ICONS/INV_Sigil_Thorim.png") - end -end - ------------ setCharName ------------------- --- Sets the charName text and color -------------------------------------------- -function RCLootCouncil_Mainframe.setCharName(frame, class, text) - if frame then -- sanity check - frame:SetText(text); -- set the text - local classColor = RAID_CLASS_COLORS[class]; -- get the color code - if not classColor then - -- if class not found display epic color. - classColor = {["r"] = 0.63921568627451, ["g"] = 0.2078431372549, ["b"] = 0.93333333333333, ["a"] = 1.0 } - else - classColor.a = 1.0; - end - frame:SetTextColor(classColor["r"],classColor["g"],classColor["b"],classColor["a"]); -- set the color - end -end - ----------- setCurrentGear ----------------- --- Sets the items in the given frame(s) -------------------------------------------- -function RCLootCouncil_Mainframe.setCurrentGear(item1, item2, gear1Frame, gear2Frame) - if item1 then - local _, _, _, _, _, _, _, _, _, item1Tex = GetItemInfo(item1); -- Get the gear1 item info - gear1Frame:SetTexture(item1Tex) -- set the texture - gear1Frame:Show() - - else -- hide it, in case we're doing a non-item - gear1Frame:Hide() - end - if item2 then -- If a second item was provided - local _, _, _, _, _, _, _, _, _, item2Tex = GetItemInfo(item2); -- Get the gear2 item info - gear2Frame:Show() - gear2Frame:SetTexture(item2Tex) - else -- if not, hide, otherwise it would show a previous gear - gear2Frame:Hide() - end -end - ---------- getPlayerRole --------------- --- Returns the player's role or none ---------------------------------------- -function RCLootCouncil.getPlayerRole(arg) - local role; - if not arg then - role = UnitGroupRolesAssigned("player"); - else - role = arg - end - if role == "TANK" then return "Tank"; - elseif role == "HEALER" then return "Healer"; - elseif role == "DAMAGER" then return "DPS"; - else return "None"; end -end - ------------ handleResponse ----------------- --- Handles the response given by LootFrame --------------------------------------------- -function RCLootCouncil.handleResponse(response, frame) --- entryTable order: (playerName, rank, role, totalIlvl, response, gear1, gear2, votes, class, color[], haveVoted, voters[], note) - local id, note - if type(frame) == "table" then - id = frame.id - note = frame.note - else - id = frame - note = "autopass" - end - RCLootCouncil:debugS("responseID = "..id) - -- local _, totalIlvl = GetAverageItemLevel() - local totalIlvl = GetAverageItemLevel() - local gear1, gear2 = RCLootCouncil.getCurrentGear(lootTable[id]); - local _, class = UnitClass("player"); -- non-localized class name - - local toAdd = { - ["i"] = id, - { - GetUnitName("player", false), - guildRank, - RCLootCouncil.getPlayerRole(), - math.floor(totalIlvl), - response, - gear1, - gear2, - 0, - class, - color, - false, - {""}, - note, - } - } - tinsert(entryTable[id], toAdd[1]) - RCLootCouncil_Mainframe.Update(true); - self:SendCommMessage("RCLootCouncil", "add "..self:Serialize(toAdd), channel) -- tell everyone else to add it -end - - -------------- isSelected ---------------------------------------- --- Tests if they're selected or not. ------------------------------------------------------------------ -function RCLootCouncil_Mainframe.isSelected(id) - id = id + offset -- handle the offset - return entryTable[currentSession][id] == selection -end - ------------- updateSelection ---------------- --- Selects or updates a given entry ---------------------------------------------- -function RCLootCouncil_Mainframe.updateSelection(id, update) - self:debugS("Mainframe.updateSelection("..tostring(id)..", "..tostring(update)..")"); - id = id + offset -- handle the offset - if selection then - for i = 1, MAX_DISPLAY do -- remove any previous selections - getglobal("ContentFrameEntry"..i.."BG"):Hide() - selection = nil; - end - end - if not update then -- set the selection if we didn't just want to update - selection = entryTable[currentSession][id] - end - if selection then -- Check if we should update or user clicked a nonshowing row - -- Initialize variables - local sLink, iLevel, thisItemTexture, sLink2, thisItemTexture2; - if selection[6] then -- if they have the first item link, get its info - _, sLink, _, iLevel, _, _, _, _, _, thisItemTexture = GetItemInfo(selection[6]); - end - if selection[7] then -- if they have 2 item links, then get the second's info - _, sLink2, _, _, _, _, _, _, _, thisItemTexture2 = GetItemInfo(selection[7]); - end - - -- Remove and award button - if isMasterLooter or isTesting then - BtRemove:Show() - BtAward:Hide() - if currentSession == lootNum then - BtAward:Show() - end - else - BtRemove:Hide() - BtAward:Hide() - end - -- Show the if 1 or 2 items stuff - if sLink2 then -- if there's two items, show the dual selection and hide the rest - DualItemTexture1:SetTexture(thisItemTexture) - DualItemTexture2:SetTexture(thisItemTexture2) - DualItemLabel1:SetText(sLink) - DualItemLabel1:SetFont("Fonts\\FRIZQT__.TTF", 14); - DualItemLabel2:SetText(sLink2) - DualItemLabel2:SetFont("Fonts\\FRIZQT__.TTF", 14); - DualItemLabel1:Show() - DualItemLabel2:Show() - DualItemTexture1:Show() - DualItemTexture2:Show() - DualItemSelection1:Show() - DualItemSelection2:Show() - CurrentSelectionLabel:Hide() - CurrentSelectionIlvl:Hide() - CurrentSelectionTexture:Hide() - CurrentSelectionHover:Hide() - - elseif sLink then -- Only show 1 item - CurrentSelectionLabel:SetText(sLink) - CurrentSelectionLabel:SetFont("Fonts\\FRIZQT__.TTF", 16); - CurrentSelectionIlvl:SetText("ilvl: "..iLevel) - CurrentSelectionTexture:SetTexture(thisItemTexture) - CurrentSelectionHover:Show() - CurrentSelectionLabel:Show() - CurrentSelectionIlvl:Show() - CurrentSelectionTexture:Show() - DualItemLabel1:Hide() - DualItemLabel2:Hide() - DualItemTexture1:Hide() - DualItemTexture2:Hide() - DualItemSelection1:Hide() - DualItemSelection2:Hide() - end - - -- show the rest - BtClear:Show() - else -- if there's no selection, hide everything - DualItemLabel1:Hide() - DualItemLabel2:Hide() - DualItemTexture1:Hide() - DualItemTexture2:Hide() - DualItemSelection1:Hide() - DualItemSelection2:Hide() - CurrentSelectionLabel:Hide() - CurrentSelectionIlvl:Hide() - CurrentSelectionTexture:Hide() - CurrentSelectionHover:Hide() - BtRemove:Hide() - BtClear:Hide() - BtAward:Hide() - end - -end - ------------- removeEntry ------------------ --- Removes an entry from the list -------------------------------------------- -function RCLootCouncil_Mainframe.removeEntry(session, name) - self:debugS("Mainframe.removeEntry("..tostring(session)..", "..tostring(name)..")") - local id; - -- find the index of entryTable belonging to name - for i = 1, #entryTable[session] do - if entryTable[session][i][1] == name then - id = i - break; - end - end - if id then - tremove(entryTable[session], id) -- remove the entry - RCLootCouncil_Mainframe.Update(true); -- update - if selection and selection[1] == name then - RCLootCouncil_Mainframe.updateSelection(0, true); -- and clear the selection if we had selected the one to be removed - end - else - self:debug("Couldn't remove entry/Name wasn't listed") - end -end - ------------- vote ------------------------- --- Adds votes to entrytable -------------------------------------------- -function RCLootCouncil_Mainframe.vote(id) - self:debugS("Mainframe.vote("..tostring(id)..")") - if id then - id = id + offset -- handle the offset - if entryTable[currentSession][id][11] then -- if unvote - entryTable[currentSession][id][8] = entryTable[currentSession][id][8] - 1; - entryTable[currentSession][id][11] = false; - for k,v in pairs(entryTable[currentSession][id][12]) do -- remove the voter from voters table - if v == GetUnitName("player", false) then tremove(entryTable[currentSession][id][12], k); end - end - - self:SendCommMessage("RCLootCouncil", "vote "..currentSession.." "..entryTable[currentSession][id][1].." devote", channel) -- tell everyone who you vote for - if isMasterLooter and tContains(votersNames, masterLooter) then - for k,v in pairs(votersNames) do - if v == masterLooter then - tremove(votersNames, k) - end - end - end - RCLootCouncil_Mainframe.Update(true); -- update the list - else -- if vote - if not mlDB.selfVote and GetUnitName("player", false) == entryTable[currentSession][id][1] then -- test that they may vote for themself - self:Print("The master looter has turned Vote For Self OFF") - return; - end - for i = 1, #entryTable[currentSession] do -- test that they are not multivoting - if entryTable[currentSession][i][11] and not mlDB.multiVote then - self:Print("The master looter has turned off multivoting") - return; - end - end - entryTable[currentSession][id][8] = entryTable[currentSession][id][8] + 1; - entryTable[currentSession][id][11] = true - tinsert((entryTable[currentSession][id][12]), GetUnitName("player", false)) -- add the voter to the voters table - self:SendCommMessage("RCLootCouncil", "vote "..currentSession.." "..entryTable[currentSession][id][1].." vote", channel) -- tell everyone who you devote for - if isMasterLooter and not tContains(votersNames, masterLooter) then - tinsert(votersNames, masterLooter) - end - RCLootCouncil_Mainframe.Update(true); -- update the list - end - - else - self:debug("False id @.vote") - end -end - -------------- voteOther ----------------- --- Add another player's vote to the entry ------------------------------------------ -function RCLootCouncil_Mainframe.voteOther(session, name, devote, voter) - self:debugS("Mainframe.voteOther("..tostring(name)..", "..tostring(devote)..", "..tostring(voter)..")") - if name and session then - for i = 1, #entryTable[session] do -- find the id belonging to the name - if entryTable[session][i][1] == name then - if devote == "devote" then - entryTable[session][i][8] = entryTable[session][i][8] - 1; -- remove the vote - for k,v in pairs(entryTable[session][i][12]) do -- remove the voter from voters table - if v == voter then tremove(entryTable[session][i][12], k); end - end - else - entryTable[session][i][8] = entryTable[session][i][8] + 1; -- add the vote - tinsert((entryTable[session][i][12]), voter) -- add the voter to the voters table - end - RCLootCouncil_Mainframe.Update(true); -- update the list - return; - end - end - else - self:debug("Bad name ("..tostring(name)..") or session ("..tostring(session).." in voteOther") - end -end - ----------- award ------------------------ --- Gives the item to the selected player ------------------------------------------ -function RCLootCouncil_Mainframe.award(reason) - self:debugS("Mainframe.award()") - if not selection or lootNum == 0 then -- if noone is selected or if there's not a loot in the list - self:debug("award called without selection or with lootNum = 0") - self:Print("Something went wrong, please try again.") - return; - elseif isTesting then - if IsInRaid() or nnp then -- continue - self:Print("The item would now be awarded to "..selection[1]) - if lootNum < #itemsToLootIndex then -- if there's more items to loot - RCLootCouncil_Mainframe.abortLooting() -- stop the current looting - lootNum = lootNum + 1; - isTesting = true - RCLootCouncil:initiateNext(lootTable[lootNum]); -- start it - else -- if there's not - self:Print("Raid Test concluded.") - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to stop as well - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - CloseButton_OnClick(); - end - else - self:Print("The item would now be awarded to "..selection[1].." and the loot session concluded.") - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - end - return; - else -- if there are - for memberId = 1, 40 do - local candidateName = GetMasterLootCandidate(memberId) - if candidateName and candidateName == selection[1] then - if #itemsToLootIndex > 0 and lootNum > 0 then -- if there really is something to loot - local _, _, lootQuantity = GetLootSlotInfo(itemsToLootIndex[lootNum]) - if lootQuantity > 0 then -- be certain there's an item - GiveMasterLoot(itemsToLootIndex[lootNum], memberId); -- give the item - self:debug(""..selection[1].." was award with "..itemRunning); - else - self:Print("Couldn't award the loot since it has already been awarded!") - return; - end - else -- the function was called by something else - self:debug("award called without items!") - self:Print("Error awarding loot, please restart the looting session.") - return; - end - -- Chat output: - if db.awardAnnouncement then - if db.awardMessageChat1 ~= "NONE" then -- if we want to tell who won - local message = gsub(db.awardMessageText1, "&p", selection[1]) - message = gsub(message, "&i", itemRunning) - SendChatMessage(message, db.awardMessageChat1); -- then do it - end - if db.awardMessageChat2 ~= "NONE" then -- if the user is posting to 2 channels - local message = gsub(db.awardMessageText2, "&p", selection[1]) - message = gsub(message, "&i", itemRunning) - SendChatMessage(message, db.awardMessageChat2); - end - end - - -- Item awards history: - -- lootDB format: "name" = {"lootWon", "date (d/m/y)", "time (h:m:s)", "instance", "boss", "votes", "itemReplaced1", "itemReplaced2"} - local instanceName, _, _, difficultyName = GetInstanceInfo() - local table; - if reason and reason.log then -- not a roll response - table = {["lootWon"] = itemRunning, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = selection[8], ["itemReplaced1"] = selection[6], ["itemReplaced2"] = selection[7], ["response"] = reason.text, ["responseID"] = 0} - elseif not reason then - table = {["lootWon"] = itemRunning, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = selection[8], ["itemReplaced1"] = selection[6], ["itemReplaced2"] = selection[7], ["response"] = buttonsDB[selection[5]]["response"], ["responseID"] = selection[5]} - end - -- The ML sends the history, if he wants others to be able to track it. - if db.sendHistory and table then - self:SendCommMessage("RCLootCouncil", "award "..selection[1].." "..self:Serialize(table), channel) - end - - -- Only store the data if the user wants to - if db.trackAwards and table then - if lootDB[selection[1]] then -- if the name is already registered in the table - tinsert(lootDB[selection[1]], table) - else -- if it isn't - lootDB[selection[1]] = {table}; - end - end - - -- Continue with next item or stop?: - if lootNum < #itemsToLootIndex then -- if there's more items to loot - RCLootCouncil_Mainframe.abortLooting() -- stop the current looting - lootNum = lootNum + 1; - RCLootCouncil:initiateNext(lootTable[lootNum]); -- start it - else -- if there's not - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to stop as well - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - CloseButton_OnClick(); - end - return; - end - end - end - -- if the function haven't returned by now then it means noone was in the raid (i.e. debug) or an error - if nnp and GetNumGroupMembers() == 0 then -- not in group and debugging is on - if #itemsToLootIndex > 0 and lootNum > 0 then - LootSlot(itemsToLootIndex[lootNum]); -- give to self - else - LootSlot(lootNum) - end - local instanceName, _, _, difficultyName = GetInstanceInfo() - local table; - if reason and reason.log then -- not a roll response - table = {["lootWon"] = itemRunning, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = selection[8], ["itemReplaced1"] = selection[6], ["itemReplaced2"] = selection[7], ["response"] = reason.text, ["responseID"] = 0} - elseif not reason then - table = {["lootWon"] = itemRunning, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = selection[8], ["itemReplaced1"] = selection[6], ["itemReplaced2"] = selection[7], ["response"] = buttonsDB[selection[5]]["response"], ["responseID"] = selection[5]} - end - - -- Only store the data if the user wants to - if db.trackAwards and table then - if lootDB[selection[1]] then -- if the name is already registered in the table - tinsert(lootDB[selection[1]], table) - else -- if it isn't - lootDB[selection[1]] = {table}; - end - end - if lootNum < #itemsToLootIndex then -- if there's more items to loot - RCLootCouncil_Mainframe.abortLooting() - lootNum = lootNum + 1; - RCLootCouncil:initiateNext(lootTable[lootNum]); -- start it - else - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - CloseButton_OnClick() - end - return; - else - self:Print("Error awarding the loot"); - end - self:debug("Award function finished without conclusion!") -end - -------------- getGuildRankNum -------------------- --- Gets the actual rank number for the player --------------------------------------------------- -function RCLootCouncil_Mainframe.getGuildRankNum(playerName) - GuildRoster(); - if playerName then - for ci=1, GetNumGuildMembers() do - local name, rank, rankIndex = GetGuildRosterInfo(ci) - -- no need to diff it for pservers - -- name = Ambiguate(name, "none") - if name == playerName then - return rankIndex, rank - end - end - end - return 11 -end - -------------- getLowestItemLevel ----------------- --- Used in sorting --- Returns the lower of 2 item levels --------------------------------------------------- -function RCLootCouncil_Mainframe.getLowestItemLevel(entry) - if entry then - if entry[7] then - local _, _, _, itemLevel = GetItemInfo(entry[6]) - local _, _, _, itemLevel2 = GetItemInfo(entry[7]) - if itemLevel >= itemLevel2 then - return itemLevel2 - else - return itemLevel - end - elseif entry[6] then - local _, _, _, itemLevel = GetItemInfo(entry[6]) - return itemLevel - else - return -1 - end - end - return -1 -end - -------------- sortTable -------------------------- --- Sorts the table when you click on a header --------------------------------------------------- -function RCLootCouncil_Mainframe.sortTable(id, specialSort) - self:debugS("Mainframe.sortTable("..tostring(id)..", "..tostring(specialSort)..")") - if not specialSort then -- just do it the normal way - if currSortIndex == id then -- if we're already sorting this one - if sortMethod == "asc" then -- then switch the order - sortMethod = "desc" - else - sortMethod = "asc" - end - elseif id then -- if we got a valid id - currSortIndex = id -- then initialize our sort index - sortMethod = "asc" -- and the order we're sorting in - if id == 4 then - sortMethod = "desc" -- flip rolls since we've already sorted for that - end - end - else - sortMethod = "asc" - end --- entryTable order: (playerName, rank, role, totalIlvl, response, gear1, gear2, votes, class, color[], haveVoted, voters[]) - if (id == 0) then -- Char Name sorting (alphabetically) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return v1[1] > v2[1] - else - return v1[1] < v2[1] - end - end) - - elseif (id == 1) then -- Guild Rank sorting (numerically) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return (v1 and RCLootCouncil_Mainframe.getGuildRankNum(v1[1]) > RCLootCouncil_Mainframe.getGuildRankNum(v2[1])) - else - return (v1 and RCLootCouncil_Mainframe.getGuildRankNum(v1[1]) < RCLootCouncil_Mainframe.getGuildRankNum(v2[1])) - end - end) - - elseif (id == 2) then -- Role sorting (alphabetically) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return v1[3] > v2[3] - else - return v1[3] < v2[3] - end - end) - - elseif (id == 3) then -- Totalilvl sorting (numerically) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return v1[4] > v2[4] - else - return v1[4] < v2[4] - end - end) - - elseif (id == 4) then -- Response sorting (need/greed/minor/pass) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return v1[5] > v2[5] - else - return v1[5] < v2[5] - end - end) - - elseif (id == 5) then -- Item Level Sorting (lowest item level at the top - largest upgrade so to speak) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return ((v1 ~= nil) and (v2 == nil or ((RCLootCouncil_Mainframe.getLowestItemLevel(v1) ~= -1) and (RCLootCouncil_Mainframe.getLowestItemLevel(v1) > RCLootCouncil_Mainframe.getLowestItemLevel(v2))))) - else - return ((v1 ~= nil) and (v2 == nil or ((RCLootCouncil_Mainframe.getLowestItemLevel(v1) ~= -1) and (RCLootCouncil_Mainframe.getLowestItemLevel(v1) < RCLootCouncil_Mainframe.getLowestItemLevel(v2))))) - end - end) - - elseif (id == 6) then -- votes sorting (numerically) - table.sort(entryTable[currentSession], function(v1, v2) - if v1[5] == mlDB.passButton and db.filterPasses then - return false; - elseif v2[5] == mlDB.passButton and db.filterPasses then - return true - end - if sortMethod == "desc" then - return v1[8] > v2[8] - else - return v1[8] < v2[8] - end - end) - end - RCLootCouncil_Mainframe.Update(true) -end - -------------- getML ----------------------------------- --- returns the masterlooter or the player if debugging --- or activates masterlooting -------------------------------------------------------- -function RCLootCouncil_Mainframe.getML() - --self:debugS("Mainframe.getML()") - if not IsInRaid() and nnp then -- out of raid and debug on - isMasterLooter = true; - return GetUnitName("player", false) - end - local lootMethod, _, MLRaidID = GetLootMethod() - if lootMethod == 'master' then - local name = GetRaidRosterInfo(MLRaidID) - isMasterLooter = name == GetUnitName("player", false) - self:debug("Masterlooter is: "..tostring(name)) - if isMasterLooter and masterLooter ~= name and not isRunning then -- we've been elected ML! - StaticPopup_Show("RCLOOTCOUNCIL_CONFIRM_USAGE") - end - return name; - elseif isRunning and (IsRealRaidLeader() == 1) then -- if masterlooting isn't on, turn it on, but only if we're running and are the raid leader - SetLootMethod("master", GetUnitName("player", false)) - self:Print("Looting method changed to \"Master Looter\"") - isMasterLooter = true - return GetUnitName("player", false); - end - isMasterLooter = false - return ""; -end - -------------- isCouncil ------------------------------- --- returns true if the player is in the council -------------------------------------------------------- -function RCLootCouncil_Mainframe.isCouncil() - --self:debugS("Mainframe.isCouncil()") - if isMasterLooter then return true; end; - if #currentCouncil > 0 then - for _, v in ipairs(currentCouncil) do - if v == GetUnitName("player", false) then - self:debug("I am in the council!") - return true - end - end - return false - else return false; end -end - ------------- setRank ----------------------- --- Gets the minimum rank from RCRankFrame --- and saves the council accordingly --------------------------------------------- -function RCLootCouncil_Mainframe.setRank(rank) - db.minRank = rank; - GuildRoster() - for i = 1, GetNumGuildMembers() do - local name, _, rankIndex = GetGuildRosterInfo(i) -- get info from all guild members - -- no need to diff it for pservers - -- name = Ambiguate(name, "none") - if rankIndex + 1 <= db.minRank then -- if the member is the required rank, or above - table.insert(db.council, name) -- then insert them to the council - end - end -end - --------------- Update ------------------ --- Handles the scrollbar visualization --- and updates the contentFrame --- arg: true to show, false to hide entries ----------------------------------------- -function RCLootCouncil_Mainframe.Update(update) - -- we don't want to enter this function unless we can actually see the Voting Frame - if not isMasterLooter and not isCouncil and not isTesting then return; end; - if update then -- if the table doesn't exist, we want to hide the entries - FauxScrollFrame_Update(ContentFrame, #entryTable[currentSession], MAX_DISPLAY, 20, nil, nil, nil, nil, nil, nil, true); - end - offset = FauxScrollFrame_GetOffset(ContentFrame) - - -- People still to roll string - if #entryTable[currentSession] == GetNumGroupMembers() or (GetNumGroupMembers() == 0 and #entryTable[currentSession] == 1) then -- if everybody has rolled or we're alone - PeopleToRollLabel:SetTextColor(0,1,0,1) -- make the text green - if isMasterLooter and #votersNames == #currentCouncil then - PeopleToRollLabel:SetText("Everyone have rolled and voted!") - elseif isMasterLooter then - PeopleToRollLabel:SetText("Everyone have rolled - "..#votersNames.." of "..#currentCouncil.." have voted!") - PeopleToRollLabel:SetTextColor(1,1,0,1) -- make the text yellow - else - PeopleToRollLabel:SetText("Everyone have rolled!") - end - - local passes = 0 - for j = 1, #entryTable[currentSession] do - if entryTable[currentSession][j][5] == db.passButton then - passes = passes + 1; - end - end - - if db.filterPasses and isMasterLooter and passes == GetNumGroupMembers() or ((GetNumGroupMembers() == 0 and #entryTable[currentSession] == 1 and passes == 1 and isTesting)) then - self:Print("Everyone passed! Turn \"Filter Passes\" off in order to distribute the loot.") - end - - if (GetNumGroupMembers() == 0 and #entryTable[currentSession] == 1 and passes == 1) or not isTesting and passes == GetNumGroupMembers() then - PeopleToRollLabel:SetText("Everyone have passed!") - PeopleToRollLabel:SetTextColor(0.75, 0.75,0.75,1) -- make the text gray - end - - else -- if someone haven't rolled - PeopleToRollLabel:SetTextColor(1,1,1,1) -- make the text white - if isMasterLooter and #votersNames == #currentCouncil then - PeopleToRollLabel:SetText(""..GetNumGroupMembers() - #entryTable[currentSession].." - everyone have voted!") - PeopleToRollLabel:SetTextColor(1,0,0,1) -- make the text red - elseif isMasterLooter and #votersNames > 0 then - PeopleToRollLabel:SetText(""..GetNumGroupMembers() - #entryTable[currentSession].." - "..#votersNames.." of "..#currentCouncil.." have voted!") - else - PeopleToRollLabel:SetText(GetNumGroupMembers() - #entryTable[currentSession]) - end - end - - for i = 1, MAX_DISPLAY do - local line = offset + i; - if update and entryTable[currentSession][line] then -- if there's something at a given entry and we want to update - local entry = entryTable[currentSession][line] - -- Start setting all the text(ures): - RCLootCouncil_Mainframe.setCharName(getglobal("ContentFrameEntry"..i.."CharName"),entry[9], entry[1]) -- set the charName and color - getglobal("ContentFrameEntry"..i.."Rank"):SetText(entry[2]) - getglobal("ContentFrameEntry"..i.."Role"):SetText(entry[3]) - getglobal("ContentFrameEntry"..i.."Totalilvl"):SetText(entry[4]) - getglobal("ContentFrameEntry"..i.."Response"):SetText(mlDB.buttons[entry[5]]["response"]) - getglobal("ContentFrameEntry"..i.."VoteHoverVotes"):SetText(entry[8]) - RCLootCouncil_Mainframe.setClassIcon(getglobal("ContentFrameEntry"..i.."ClassTexture"), entry[9]); -- set the class-texture - - -- set the note button texture - if entry[13] then -- normal - getglobal("ContentFrameEntry"..i.."NoteButton"):SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Up.png") - else -- disabled - getglobal("ContentFrameEntry"..i.."NoteButton"):SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Disabled.png") - end - - -- set the vote button properly - getglobal("ContentFrameEntry"..i.."BtVote"):Show() - if entry[11] then - getglobal("ContentFrameEntry"..i.."BtVote"):SetText("Unvote") - else - getglobal("ContentFrameEntry"..i.."BtVote"):SetText("Vote") - end - - -- set the colors: - local color = mlDB.buttons[entry[5]]["color"] - getglobal("ContentFrameEntry"..i.."Rank"):SetTextColor(color[1],color[2],color[3],color[4]) - getglobal("ContentFrameEntry"..i.."Role"):SetTextColor(color[1],color[2],color[3],color[4]) - getglobal("ContentFrameEntry"..i.."Totalilvl"):SetTextColor(color[1],color[2],color[3],color[4]) - getglobal("ContentFrameEntry"..i.."Response"):SetTextColor(color[1],color[2],color[3],color[4]) - - -- Set the item textures - RCLootCouncil_Mainframe.setCurrentGear(entry[6], entry[7], getglobal("ContentFrameEntry"..i.."CurrentGear1HoverCurrentGear1"),getglobal("ContentFrameEntry"..i.."CurrentGear2HoverCurrentGear2")); - - -- Only show entries if we don't filter for passes - if db.filterPasses and entry[5] == mlDB.passButton then - getglobal("ContentFrameEntry"..i):Hide(); - else - getglobal("ContentFrameEntry"..i):Show(); - end - - else -- if there's nothing at an entry - getglobal("ContentFrameEntry"..i):Hide(); - end - end -end ----------- testFrames --------------- --- Shows all frames for testing -------------------------------------- -function RCLootCouncil_Mainframe.testFrames() - self:debugS("Mainframe.testFrames()") - for j = 1, 9 do - if j == 4 then j = 5 end; -- skip the shirt - local itemLink = GetInventoryItemLink("player", j) - if itemLink ~= nil then - lootTable[1] = itemLink - lootNum = 1; - itemRunning = itemLink - masterLooter = GetUnitName("player", false) - isTesting = true - mlDB = db.dbToSend - RCLootCouncil:announceConsideration() - RCLootCouncil_LootFrame:Update(lootTable) - RCLootCouncil_Mainframe.prepareLootFrame(itemLink) - lootFramesCreated = true - self:Print("Local Solo Test initiated.") - break; - end - end -end ----------- raidTestFrames --------------- --- Tests the frames -------------------------------------- -function RCLootCouncil_Mainframe.raidTestFrames(arg) - self:debugS("Mainframe.raidTestFrames("..arg..")") - if IsInRaid() or nnp then - if (IsRealRaidLeader() == 1) or (UnitIsRaidOfficer("player") == 1) or nnp then -- if we're the group leader/assistant - RCLootCouncil_Mainframe.abortLooting() - RCLootCouncil_Mainframe.stopLooting() - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to stop as well - isRunning = true - masterLooter = GetUnitName("player", false) - - -- increase MAX_ITEMS or run multiple tests to test large loot table - local table = { - 40384, --Betrayer of Humanity - 19019, --Thunderfury, Blessed Blade of the Windseeker - 45038, --Fragment of Val'anyr - 46017, --Val'anyr, Hammer of Ancient Kings - 40343, --Armageddon - 40384, --Illustration of the Dragon Soul - 43952, --Reins of the Azure Drake - 40384, --Torch of Holy Fire - 40399, --Signet of Manifested Pain - 46038, --Dark Matter - 40384, --Betrayer of Humanity - 40384, --Betrayer of Humanity - } - -- get the client to cache all test items - for i = 1, #table do - GetItemInfo(table[i]) - end - -- pick n random items from the test table - for i = 1, arg do - if i > #table or i > MAX_ITEMS then break; end - local j = math.random(1, #table) - local _, link = GetItemInfo(table[j]) - tinsert(lootTable, link) - tinsert(itemsToLootIndex, i) - end - - isTesting = true; - lootNum = 1; - hasItemInfo = true - RCLootCouncil_initiateLoot(lootTable[lootNum]) - self:Print("Raid Test initiated.") - - else - self:Print("Only Group Leader/assistants can issue a raid test.") - end - else - self:Print("You cannot raidtest without being in a raid.") - end -end - ------------ isRunning ------------- --- Sets isRunning = true/false --- or returns the state if arg ---------------------------------------- -function RCLootCouncil.isRunning() - self:debugS("isRunning()") - isRunning = not isRunning - if isRunning then - self:Print("Activated") - masterLooter = RCLootCouncil_Mainframe.getML() - else - self:Print("Deactivated") - end -end - ----------- buttonsToDefault -------------- --- Sets the button/response options back to default ------------------------------------ -function RCLootCouncil:buttonsToDefault() - for i = 1, db.dbToSend.numButtons do - self.db.profile.dbToSend.buttons[i]["text"] = defaults.profile.dbToSend.buttons[i]["text"] - for j = 1, 4 do - self.db.profile.dbToSend.buttons[i]["color"][j] = defaults.profile.dbToSend.buttons[i]["color"][j] - end - self.db.profile.dbToSend.buttons[i]["response"] = defaults.profile.dbToSend.buttons[i]["response"] - self.db.profile.dbToSend.buttons[i]["whisperKey"] = defaults.profile.dbToSend.buttons[i]["whisperKey"] - end - self.db.profile.dbToSend.numButtons = defaults.profile.dbToSend.numButtons; - self.db.profile.dbToSend.passButton = defaults.profile.dbToSend.passButton; - self.db.profile.acceptWhispers = defaults.profile.acceptWhispers; - self.db.profile.acceptRaidChat = defaults.profile.acceptRaidChat; -end - ----------- announceToDefault -------------- --- Sets the button/response options back to default ------------------------------------ -function RCLootCouncil:announceToDefault() - self.db.profile.awardAnnouncement = defaults.profile.awardAnnouncement; - self.db.profile.awardMessageChat1 = defaults.profile.awardMessageChat1; - self.db.profile.awardMessageText1 = defaults.profile.awardMessageText1; - self.db.profile.awardMessageChat2 = defaults.profile.awardMessageChat2; - self.db.profile.awardMessageText2 = defaults.profile.awardMessageText2; - self.db.profile.announceText = defaults.profile.announceText; - self.db.profile.announceChannel = defaults.profile.announceChannel; -end - ---------- otherAwardReasonsToDefault --------- -function RCLootCouncil:otherAwardReasonsToDefault() - self.db.profile.otherAwardReasons = defaults.profile.otherAwardReasons -end - ---------- GetVersion ------------- --- Returns the current version ----------------------------------- -function RCLootCouncil:GetVersion() - return version; -end - ----------- voteHover ------------- --- Displays the voters ----------------------------------- -function RCLootCouncil_Mainframe:voteHover(id) - if (not mlDB.anonymousVoting or (mlDB.masterLooterOnly and (isMasterLooter or isTesting))) and #entryTable[currentSession][id][12] > 1 then -- check if voting is anonymous - if id then - id = id + offset - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:AddLine("Voters\n") - for k,v in pairs(entryTable[currentSession][id][12]) do - GameTooltip:AddLine(v,1,1,1) - end - GameTooltip:Show() - else - self:debug("Bad id in voteHover") - end - end -end - ----------- PeopleToRollHover ---------------- --- Shows which people there's still to roll ---------------------------------------------- -function RCLootCouncil_Mainframe:PeopleToRollHover() - RCLootCouncil:debugS("Mainframe.PeopleToRollHover()") - local peopleToRoll = {} - for i = 1, GetNumGroupMembers() do - local name = GetRaidRosterInfo(i) - local test = true - for j = 1, #entryTable[currentSession] do - if entryTable[currentSession][j][1] == name then test = false; end - end - if test then tinsert(peopleToRoll, name); end - end - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:AddLine("People still to roll\n") - if #peopleToRoll >= 1 then - for k,v in pairs(peopleToRoll) do - GameTooltip:AddLine(v,1,1,1) - end - else - GameTooltip:AddLine("None",1,1,1) - end - if isMasterLooter and (not mlDB.anonymousVoting or (mlDB.anonymousVoting and mlDB.masterLooterOnly)) then -- add the voters info - GameTooltip:AddLine("Voters\n") - for k,v in pairs(currentCouncil) do - if tContains(votersNames, v) then - GameTooltip:AddLine(v,0,1,0) - else - GameTooltip:AddLine(v,1,0,0) - end - end - end - GameTooltip:Show(); -end - ----------- LootOnClick ------------------ --- Hooked from LootButton_OnClick ------------------------------------------ -function RCLootCouncil:LootOnClick(button) - self:debugS("LootOnClick(button)") - if InCombatLockdown() and IsAltKeyDown() then - self:Print("Cannot initiate loot while in combat") - elseif db.altClickLooting and IsAltKeyDown() and not IsShiftKeyDown() and not IsControlKeyDown() then - self:debug("LootOnClick called") - -- check that we don't add an item we're already looting - for k,v in pairs(itemsToLootIndex) do - if v == button.slot then -- if we're already looting that slot - self:Print("That slot is already being looted.") - return; - end - end - for i = 1, #entryTable do -- clear the entryTable for already received answers - wipe(entryTable[i]) - end - if getglobal("ElvLootFrame") then - button.slot = button:GetID() -- ElvUI hack - end - - tinsert(lootTable, GetLootSlotLink(button.slot)) -- add the item link to the table - tinsert(itemsToLootIndex, button.slot) -- add its index to the lootTable - - if #lootTable == 1 then -- only initiate the first item - lootNum = 1 - RCLootCouncil_initiateLoot(GetLootSlotLink(button.slot)) - else -- redo voting if more items were alt clicked before last item was awarded - RCLootCouncil_Mainframe.abortLooting() - self:SendCommMessage("RCLootCouncil", "stop", channel) -- tell the council to stop as well - - -- clear items already looted so they aren't rerolled - if lootNum > 1 then - for i = lootNum-1, 1, -1 do - if not lootTable[i] then break end - tremove(lootTable, i) - tremove(itemsToLootIndex, i) - end - end - - currentSession = 1 - lootNum = 1 - RCLootCouncil_initiateLoot(lootTable[lootNum]) --- RCLootCouncil_LootFrame:Update(lootTable) --- RCLootCouncil_Mainframe:UpdateSessionButtons() - end - end -end - -------------- GetItemsFromMessage ------------ --- Extracts items from a message and adds them --- to the entryFrame. ----------------------------------------------- -function RCLootCouncil:GetItemsFromMessage(msg, sender) - RCLootCouncil:debugS("GetItemsFromMessage("..tostring(msg)..", "..tostring(sender)..")") - if msg == db.announceText or msg == db.awardMessageText1 or msg == db.awardMessageText2 then return; end - if isMasterLooter then - local theItem = msg:find("|Hitem:"); -- See if they linked an item - if theItem then -- If they entered a valid item - self:debugS("item1 might be: "..theItem) - local actualItemString2; -- Initialize for possibility of 2 item links - local startLoc = string.find(msg, "Hitem:") -- Make sure they linked an item - if startLoc > 13 then return; end -- Hitem should start at 12, otherwise it's irrelevant - local endLoc = string.find(msg, "|r", startLoc) - local actualItemString = string.match(msg, "|%x+|Hitem:.-|h.-|h|r"); - self:debugS("actualItemString: "..actualItemString) - startLoc = string.find(msg, "Hitem:", endLoc) --See if they linked a second item - - if startLoc then -- If they did - self:debugS("Two items found!") - local laterString = string.sub(msg, endLoc); - actualItemString2 = string.match(laterString, "|%x+|Hitem:.-|h.-|h|r"); - end - - local _, iLink1 = GetItemInfo(actualItemString); -- Get better info for item 1 - local iLink2; - if actualItemString2 then -- and item 2 - _, iLink2 = GetItemInfo(actualItemString2); - -- also get the new endLoc so we can check for whisperKeys - endLoc = string.find(msg, "|r", startLoc) - end - - -- lets check if they supplied a whisper key - local responseNum = 1; -- default is Main Spec - local restOfMsg = string.sub(msg, endLoc) - local whisperKeys = {} - for i = 1, mlDB.numButtons do --go through all the button - gsub(buttonsDB[i]["whisperKey"], '[%w]+', function(x) tinsert(whisperKeys, {key = x, num = i}) end) -- extract the whisperKeys to a table - end - self:Print("restOfMsg = "..restOfMsg) - for k,v in ipairs(whisperKeys) do - self:Print("whisperKeys["..k.."] = num = "..v.num.." key = "..v.key) - if strmatch(restOfMsg, v.key) then -- if we found a match - responseNum = v.num - break; - end - end - - -- now that the items is in place, we need some info on the player, and we need to generate it from only the name - local name, class, rank, role; - for i = 1, GetNumGroupMembers() do - name, _, _, _, _, class = GetRaidRosterInfo(i) - if name == sender then - role = UnitGroupRolesAssigned("raid"..i) - role = RCLootCouncil.getPlayerRole(role) - _, rank = GetGuildInfo(sender) - break; - end - end - -- add the entry to the player's own entryTable - local toAdd = { - ["i"] = lootNum, - { - sender, - rank or "", - role or "", - 0, - responseNum, - iLink1, - iLink2, - 0, - class, - color, - false, - {""}, - nil, - } - } - RCLootCouncil_Mainframe.removeEntry(lootNum, sender) -- just remove it right away to avoid doubles (.removeEntry will handle errors) - self:SendCommMessage("RCLootCouncil", "remove "..lootNum.." "..sender, channel) - tinsert(entryTable[lootNum], toAdd[1]) - self:SendCommMessage("RCLootCouncil", "add "..self:Serialize(toAdd), channel) - RCLootCouncil_Mainframe.Update(true) - self:Print("Item received and added from "..sender..".") - -- tell the player what they've been added as - SendChatMessage("[RCLootCouncil]: Acknowledged as \""..buttonsDB[responseNum]["response"].."\"", "WHISPER", nil, sender) - end - end -end - ------------- NameHover --------------- --- Creates the tooltip for recent loots --------------------------------------- -function RCLootCouncil_Mainframe:NameHover(id) - if not id then return; end; - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - local name = entryTable[currentSession][id][1] - GameTooltip:AddLine(name) -- add the name as the first line - GameTooltip:AddLine(" ") - -- find the last awarded mainspec item and date - if lootDB[name] then -- if they're even in the db - for i = #lootDB[name], 1, -1 do -- start with the end, and count downwards - if lootDB[name][i]["responseID"] == 1 then -- the last mainspec loot awarded - local dateString = RCLootCouncil:GetNumberOfDaysFromNow(lootDB[name][i]["date"]) - local firstDateString = RCLootCouncil:GetNumberOfDaysFromNow(lootDB[name][1]["date"]) - GameTooltip:AddDoubleLine("Time since last MainSpec loot:", dateString, 1,1,1, 1,1,1) - GameTooltip:AddDoubleLine("Loot:", lootDB[name][i]["lootWon"], 1,1,1, 1,1,1) - GameTooltip:AddDoubleLine("Dropped by:", (lootDB[name][i]["boss"] or "Unknown"), 1,1,1, 0.862745, 0.0784314, 0.235294) - GameTooltip:AddDoubleLine("From:", lootDB[name][i]["instance"], 1,1,1, 0.823529, 0.411765, 0.117647) - GameTooltip:AddDoubleLine("Item(s) replaced:", lootDB[name][i]["itemReplaced1"], 1,1,1, 1,1,1) - if lootDB[name][i]["itemReplaced2"] ~= "" then - GameTooltip:AddDoubleLine(" ", lootDB[name][i]["itemReplaced2"], 1,1,1, 1,1,1) - end - local itemsReceivedToday = {} - local count = 0 - for k = #lootDB[name], 1, -1 do - if lootDB[name][k]["date"] == date("%d/%m/%y") then -- any loots today? - if count <= 8 then -- only show the first 8 items - tinsert(itemsReceivedToday, lootDB[name][k]["lootWon"]) - end - count = count + 1 - end - end - if count > 8 then - tinsert(itemsReceivedToday, "+"..(count-8).." more.") - end - if #itemsReceivedToday > 0 then - GameTooltip:AddLine(" ") - GameTooltip:AddDoubleLine("Item(s) received today:", itemsReceivedToday[1], 1,1,1, 1,1,1) - for k = 2, #itemsReceivedToday do - GameTooltip:AddDoubleLine(" ", itemsReceivedToday[k], 1,1,1, 1,1,1) - end - end - - GameTooltip:AddLine(" ") - GameTooltip:AddLine(name.." has received a total of "..#lootDB[name].." items over "..firstDateString..".", 1,1,1) - GameTooltip:Show() - return; - end - end - -- if it get here, it means, that they've recieved loot, but never mainspec - GameTooltip:AddLine("Has recieved a total of "..#lootDB[name].." items, but not a single one needed for mainspec.", 1,1,1) - GameTooltip:Show() - else -- if they're not - GameTooltip:AddLine("Has not been logged getting any loot!", 1,1,1) - GameTooltip:AddLine("Best give 'em some :)", 1,1,1) - GameTooltip:Show() - end -end - ------------------- GetNumberOfDaysFromNow --------------------- --- Calculates the number of days and years from today to arg. --- Returns a formatted string for use in MoreInfoHover. ---------------------------------------------------------------- -function RCLootCouncil:GetNumberOfDaysFromNow(date) - local d, m, y = strsplit("/", date, 3) - local cDayNumber = time() - local dayNumber = time({year = "20"..y, month = m, day = d}) - local secondsBetween = cDayNumber - dayNumber; - local days = (secondsBetween / 3600) /24; -- recalculate from seconds to days - if days <= 1 then - return "today"; - elseif days > 30 then - local years = 0; - local months = 0; - for i = 1, 1000 do -- "infinity" loop - if days > 30 then -- lets say a month = 30 days for good measures - days = days - 30 - months = months + 1 - end - if months > 12 then - years = years + 1 - end - if days < 30 then - if years >= 1 then - return floor(days).." days, "..months.." months and "..years.." years."; - else - return floor(days).." days and "..months.." months."; - end - end - end - else - return floor(days).." days."; - end -end - ------------- GetVariable --------- --- Returns the variable from string arg ----------------------------------- -function RCLootCouncil:GetVariable(arg) - if arg == "isCouncil" then - return isCouncil; - elseif arg == "isMasterLooter" then - return isMasterLooter; - elseif arg == "isRunning" then - return isRunning; - elseif arg == "mlDB" then - if mlDB then return mlDB; else return db.dbToSend; end; - end -end - ------------- LootBoE ------------------------------- --- Checks if an item is BoE and if we should loot it ----------------------------------------------------- -function RCLootCouncil:LootBoE(item) - if not item then return false; end - GameTooltip:SetOwner(UIParent, "ANCHOR_NONE") - GameTooltip:SetHyperlink(item) - if GameTooltip:NumLines() > 1 then -- check that there is something here - for i = 1, 5 do -- BoE status won't be further away than line 5 - local line = getglobal('GameTooltipTextLeft' .. i) - if line and line.GetText then - if line:GetText() == ITEM_BIND_ON_EQUIP then - GameTooltip:Hide() - if db.autolootBoE then return true; else return false; end - end - end - end - end - GameTooltip:Hide() - return true; -- it's not a BoE -end - ------------announceConsideration ------------------ -function RCLootCouncil:announceConsideration() - if db.announceConsideration then - local message = gsub(db.announceText, "&i", itemRunning) - SendChatMessage(message, db.announceChannel) - end -end - ------------ FilterPasses --------------- -function RCLootCouncil_Mainframe.FilterPasses(get) - if get then - getglobal("MainFrameFilterPasses"):SetChecked(db.filterPasses) - else - db.filterPasses = not db.filterPasses; - getglobal("MainFrameFilterPasses"):SetChecked(db.filterPasses) - RCLootCouncil_Mainframe.Update(true) - end -end - - -------------- SendWhisperHelp --------------- -function RCLootCouncil:SendWhisperHelp(playerName) - RCLootCouncil:debugS("SendWhisperHelp("..tostring(playerName)..")") - local msgToSend, msgToSend1 = "", "[RCLootCouncil]: To be added on the consideration list simply link your item(s) that would be replaced by the item under consideration followed by a keyword from the following list depending on your desire:"; - SendChatMessage(msgToSend1, "WHISPER", nil, playerName) - for i = 1, db.dbToSend.numButtons do - msgToSend = "[RCLootCouncil]: "..buttonsDB[i]["text"]..": " -- i.e. MainSpec/Need: - msgToSend = msgToSend..""..buttonsDB[i]["whisperKey"].."." -- need, mainspec, etc - SendChatMessage(msgToSend, "WHISPER", nil, playerName) - end - self:Print("sent whisper help to "..playerName) -end - --------------- DisplayNote ------------------- -function RCLootCouncil_Mainframe:DisplayNote(id) - GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR") - GameTooltip:AddLine("Notes") - GameTooltip:AddLine(entryTable[currentSession][id][13],1,1,1) - GameTooltip:Show() -end - --------------- DebugLogAdd -------------------- -function RCLootCouncil:DebugLogAdd(msg) - if not IsInRaid() or nnp then return end -- don't log outside raid - local time = date("%X", time()) - msg = time.." - "..msg - if #debugLog < self.db.global.logMaxEntries then - tinsert(debugLog, msg) - else - tremove(debugLog, 1) - tinsert(debugLog, msg) - end -end - --------------- ChangeSession ------------------ -function RCLootCouncil_Mainframe:ChangeSession(id) - RCLootCouncil:debugS("Mainframe:ChangeSession("..tostring(id)..")") - currentSession = id - RCLootCouncil_Mainframe.updateSelection(0, true); - RCLootCouncil_Mainframe.prepareLootFrame(lootTable[id]) -end - --------------- SessionButtonOnEnter ----------- -function RCLootCouncil_Mainframe:SessionButtonOnEnter(id) - GameTooltip:SetOwner(MainFrame, "ANCHOR_RIGHT") - if isMasterLooter and id == lootNum then - GameTooltip:AddLine("This is the next item to award.") - GameTooltip:AddLine("You must award this item before the others.", 1,1,1) - GameTooltip:AddLine("All whispers received will be added to this item.",1,1,1) - elseif id == currentSession then - GameTooltip:AddLine("This item is currently showed.") - elseif id < lootNum then - GameTooltip:AddLine("This item has been awarded!",1,0,0) - else - GameTooltip:AddLine("Click to view the session for:") - GameTooltip:AddLine(lootTable[id],1,1,1) - if isMasterLooter then - GameTooltip:AddLine("You must award the item with a yellow border before awarding this one",1,1,1) - end - end - GameTooltip:Show() -end - -------------- UpdateSessionButtons ------------ -function RCLootCouncil_Mainframe:UpdateSessionButtons() - for i = 1, MAX_ITEMS do - local button = getglobal("RCLootCouncil_SessionButton"..i) - if lootTable[i] then - local _,_,_,_,_,_,_,_,_, texture = GetItemInfo(lootTable[i]); - if not texture then - texture = "Interface\InventoryItems\WoWUnknownItem01" - end - getglobal("RCLootCouncil_SessionButton"..i.."NormalTexture"):SetVertexColor(1,1,1) - if i == lootNum then - button:SetBackdropBorderColor(1,1,0,1) -- yellow - elseif i == currentSession then - button:SetBackdropBorderColor(0,0,0,1) -- white - elseif i < lootNum then - button:SetBackdropBorderColor(1,0,0,1) -- red - getglobal("RCLootCouncil_SessionButton"..i.."NormalTexture"):SetVertexColor(0.3, 0.3, 0.3) - else - getglobal("RCLootCouncil_SessionButton"..i.."NormalTexture"):SetVertexColor(0.3, 0.3, 0.3) - button:SetBackdropBorderColor(0,0,0,1) -- white - end - button:SetNormalTexture(texture) - button:Show() - else - button:Hide() - end - end -end - ------------- EntryOnClick --------------------- -function RCLootCouncil_Mainframe:EntryOnclick(frame, button) - if not RCLootCouncil_Mainframe.isSelected(frame:GetID()) then - RCLootCouncil_Mainframe.updateSelection(frame:GetID()) - end - if button == "RightButton" and isMasterLooter then - ToggleDropDownMenu(1, nil, menuFrame, frame , 0, 0); - end -end - ------------ RightClickMenu ------------------- -function RCLootCouncil_Mainframe_RightClickMenu(menu, level) - if level == 1 then - UIDropDownMenu_AddButton({text = selection[1], isTitle = true, notCheckable = true, disabled = true}, level); - UIDropDownMenu_AddButton({text = "", notCheckable = true, disabled = true}, level); - - if currentSession == lootNum then -- greyout award buttons if we can't award. - UIDropDownMenu_AddButton({text = "Award", notCheckable = true, func = function() if currentSession == lootNum then StaticPopup_Show("RCLOOTCOUNCIL_CONFIRM_AWARD", itemRunning, selection[1]); else self:Print("You cannot award this item yet.")end; end, }, level); - UIDropDownMenu_AddButton({text = "Award for ...", value = "AWARD_FOR", notCheckable = true, hasArrow = true, }, level); - else - UIDropDownMenu_AddButton({text = "Award", notCheckable = true, disabled = true, tooltipTitle = "Illegal Award!", tooltipText = "You have to award the item with the yellow border first.", }, level); - UIDropDownMenu_AddButton({text = "Award for ...", hasArrow = true, notCheckable = true, disabled = true, tooltipTitle = "Illegal Award!", tooltipText = "You have to award the item with the yellow border first.", }, level); - end - - UIDropDownMenu_AddButton({text = "", notCheckable = true, disabled = true}, level); - - UIDropDownMenu_AddButton({text = "Change Response", value = "CHANGE_RESPONSE", notCheckable = true, hasArrow = true, }, level); - UIDropDownMenu_AddButton({text = "Reannounce ...", value = "REANNOUNCE", notCheckable = true, hasArrow = true, }, level) - UIDropDownMenu_AddButton({text = "Remove from consideration", notCheckable = true, func = function() self:SendCommMessage("RCLootCouncil", "remove "..currentSession.." "..selection[1], channel); RCLootCouncil_Mainframe.removeEntry(currentSession, selection[1]); end, }, level); - - elseif level == 2 then - local value = UIDROPDOWNMENU_MENU_VALUE - if value == "AWARD_FOR" then - for k,v in pairs(db.otherAwardReasons) do - UIDropDownMenu_AddButton({text = v.text, notCheckable = true, func = function() RCLootCouncil_Mainframe.award(v)end, }, level) - end - - elseif value == "CHANGE_RESPONSE" then - for k,v in pairs(buttonsDB) do - if k > db.dbToSend.numButtons then break; end - UIDropDownMenu_AddButton({text = v.response, - colorCode = "|cff"..string.format("%02x%02x%02x",255*v.color[1], 255*v.color[2], 255*v.color[3]), - notCheckable = true, - func = function() - for x,y in pairs(entryTable[currentSession]) do - if y[1] == selection[1] then - entryTable[currentSession][x][5] = k - RCLootCouncil_Mainframe.Update(true); - self:SendCommMessage("RCLootCouncil", "change "..self:Serialize({currentSession,x,k}), channel) - return; - end - end - end,}, level) - end - - elseif value == "REANNOUNCE" then - UIDropDownMenu_AddButton({text = selection[1], isTitle = true, notCheckable = true, disabled = true}, level); - UIDropDownMenu_AddButton({text = "This item", notCheckable = true, - func = function() - self:SendCommMessage("RCLootCouncil", "reRoll "..self:Serialize({lootTable[currentSession], currentSession}), "WHISPER", selection[1]) - self:SendCommMessage("RCLootCouncil", "remove "..currentSession.." "..selection[1], channel) - RCLootCouncil_Mainframe.removeEntry(currentSession, selection[1]) - end, - }, level); - - UIDropDownMenu_AddButton({text = "All items", notCheckable = true, - func = function() - local name = selection[1] -- store it - self:SendCommMessage("RCLootCouncil", "lootTable "..self:Serialize(lootTable), "WHISPER", name) - for i = 1, #entryTable do - self:SendCommMessage("RCLootCouncil", "remove "..i.." "..name, channel) - RCLootCouncil_Mainframe.removeEntry(i, name) - end - end, - }, level); - UIDropDownMenu_AddButton({text = "", notCheckable = true, disabled = true}, level); - UIDropDownMenu_AddButton({text = "All items to ...", value = "REANNOUNCE_TO", notCheckable = true, hasArrow = true,}, level); - end - - elseif level == 3 then - if GetNumGroupMembers() > 0 then - for i = 1, GetNumGroupMembers() do - local name = GetRaidRosterInfo(i) - UIDropDownMenu_AddButton({text = name, notCheckable = true, - func = function() - self:SendCommMessage("RCLootCouncil", "lootTable "..self:Serialize(lootTable), "WHISPER", name) - for i = 1, #entryTable do - self:SendCommMessage("RCLootCouncil", "remove "..i.." "..name, channel) - end - end,}, level); - end - else -- we're alone - UIDropDownMenu_AddButton({text = GetUnitName("player", false), notCheckable = true, - func = function() - self:SendCommMessage("RCLootCouncil", "lootTable "..self:Serialize(lootTable), "WHISPER", GetUnitName("player", false)) - for i = 1, #entryTable do - RCLootCouncil_Mainframe.removeEntry(i, GetUnitName("player", false)) - end - end,}, level); - end - end -end - --------------- AutoAward -------------------- -function RCLootCouncil:AutoAward(index, awardTo, itemLink) - self:debugS("AutoAward("..tostring(index)..", "..tostring(awardTo)..")") - if GetUnitName("player", false) == awardTo then -- just take it - local _, item, lootQuantity = GetLootSlotInfo(index) - LootSlot(index) - self:debug(""..awardTo.." was Auto Awarded with "..item); - self:Print(itemLink.." was Auto Awarded to "..awardTo..". Reason: "..db.otherAwardReasons[db.autoAwardReason].text) - - local instanceName, _, _, difficultyName = GetInstanceInfo() - local table; - if db.otherAwardReasons[db.autoAwardReason].log then -- only log if the reasoning allows it - self:debug("table is being created!") - table = {["lootWon"] = itemLink, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = nil, ["itemReplaced1"] = nil, ["itemReplaced2"] = nil, ["response"] = db.otherAwardReasons[db.autoAwardReason].text, ["responseID"] = 0,} - end - - -- The ML sends the history, if he wants others to be able to track it. - if db.sendHistory and table then - self:debug("send history") - self:SendCommMessage("RCLootCouncil", "award "..awardTo.." "..self:Serialize(table), channel) - end - - -- Only store the data if the user wants to - if db.trackAwards and table then - self:debug("we're in the logging!") - if lootDB[awardTo] then -- if the name is already registered in the table - tinsert(lootDB[awardTo], table) - else -- if it isn't - lootDB[awardTo] = {table}; - end - end - return; - end - for memberId = 1, 40 do - local canditateName = GetMasterLootCandidate(memberId) - if canditateName and canditateName == awardTo then - local _, item, lootQuantity = GetLootSlotInfo(index) - if lootQuantity > 0 then -- be certain there's an item - GiveMasterLoot(index, memberId); -- give the item - self:debug(""..awardTo.." was Auto Awarded with "..item); - self:Print(itemLink.." was Auto Awarded to "..awardTo..", Reason: "..db.otherAwardReasons[db.autoAwardReason].text) - else - self:Print("Couldn't award the loot since there was no item!") - return; - end - - local instanceName, _, _, difficultyName = GetInstanceInfo() - local table; - if db.otherAwardReasons[db.autoAwardReason].log then -- only log if the reasoning allows it - table = {["lootWon"] = itemLink, ["date"] = date("%d/%m/%y"), ["time"] = date("%H:%M:%S"), ["instance"] = instanceName.." "..difficultyName, ["boss"] = bossName, ["votes"] = nil, ["itemReplaced1"] = nil, ["itemReplaced2"] = nil, ["response"] = db.otherAwardReasons[db.autoAwardReason].text, ["responseID"] = 0,} - end - - -- The ML sends the history, if he wants others to be able to track it. - if db.sendHistory and table then - self:SendCommMessage("RCLootCouncil", "award "..awardTo.." "..self:Serialize(table), channel) - end - - -- Only store the data if the user wants to - if db.trackAwards and table then - if lootDB[awardTo] then -- if the name is already registered in the table - tinsert(lootDB[awardTo], table) - else -- if it isn't - lootDB[awardTo] = {table}; - end - end - return; - end - end -end diff --git a/Mainframe.xml b/Mainframe.xml deleted file mode 100644 index 7d04cc4..0000000 --- a/Mainframe.xml +++ /dev/null @@ -1,950 +0,0 @@ - -