diff --git a/env/api.lua b/env/api.lua new file mode 100644 index 00000000..7d4e4a6b --- /dev/null +++ b/env/api.lua @@ -0,0 +1,322 @@ +pfUI.api = { } + +-- [ strsplit ] +-- Splits a string using a delimiter. +-- 'delimiter' [string] characters that will be interpreted as delimiter +-- characters (bytes) in the string. +-- 'subject' [string] String to split. +-- return: [list] a list of strings. +function pfUI.api.strsplit(delimiter, subject) + local ret = {} + local sector = subject + while true do + local pos = strfind(sector, delimiter) + if pos then + table.insert(ret, strsub(sector,1,pos-1)) + sector = strsub(sector,pos+1) + else + table.insert(ret, sector) + return unpack(ret) + end + end +end + +-- [ round ] +-- Rounds a float number into specified places after comma. +-- 'input' [float] the number that should be rounded. +-- 'places' [int] amount of places after the comma. +-- returns: [float] rounded number. +function pfUI.api.round(input, places) + if not places then places = 0 end + if type(input) == "number" and type(places) == "number" then + local pow = 1 + for i = 1, places do pow = pow * 10 end + return floor(input * pow + 0.5) / pow + end +end + +-- [ Create Gold String ] +-- Transforms a amount of copper into a fully fledged gold string +-- 'money' [int] the amount of coppy (GetMoney()) +-- return: [string] a colorized string which is split into +-- gold,silver and copper values. +function pfUI.api.CreateGoldString(money) + local gold = floor(money/ 100 / 100) + local silver = floor(mod((money/100),100)) + local copper = floor(mod(money,100)) + + local string = "" + if gold > 0 then string = string .. "|cffffffff" .. gold .. "|cffffd700g" end + if silver > 0 then string = string .. "|cffffffff " .. silver .. "|cffc7c7cfs" end + string = string .. "|cffffffff " .. copper .. "|cffeda55fc" + + return string +end + +-- [ Copy Table ] +-- By default a table assignment only will be a reference instead of a copy. +-- This is used to create a replicate of the actual table. +-- 'src' [table] the table that should be copied. +-- return: [table] the replicated table. +function pfUI.api.CopyTable(src) + local lookup_table = {} + local function _copy(src) + if type(src) ~= "table" then + return src + elseif lookup_table[src] then + return lookup_table[src] + end + local new_table = {} + lookup_table[src] = new_table + for index, value in pairs(src) do + new_table[_copy(index)] = _copy(value) + end + return setmetatable(new_table, getmetatable(src)) + end + return _copy(src) +end + +-- [ Update Movable ] +-- Loads and update the configured position of the specified frame. +-- It also creates an entry in the movables table. +-- 'frame' [frame] the frame that should be updated. +function pfUI.api:UpdateMovable(frame) + local name = frame:GetName() + + if not pfUI.movables[name] then + pfUI.movables[name] = true + table.insert(pfUI.movables, name) + end + + if pfUI_config["position"][frame:GetName()] then + if pfUI_config["position"][frame:GetName()]["scale"] then + frame:SetScale(pfUI_config["position"][frame:GetName()].scale) + end + + if pfUI_config["position"][frame:GetName()]["xpos"] then + frame:ClearAllPoints() + frame:SetPoint("TOPLEFT", pfUI_config["position"][frame:GetName()].xpos, pfUI_config["position"][frame:GetName()].ypos) + end + end +end + +-- [ Create Backdrop ] +-- Creates a pfUI compatible frame as backdrop element +-- 'f' [frame] the frame which should get a backdrop. +-- 'inset' [int] backdrop inset, defaults to border size. +-- 'legacy' [bool] use legacy backdrop instead of creating frames. +-- 'transp' [bool] force default transparency of 0.8. +function pfUI.api:CreateBackdrop(f, inset, legacy, transp) + -- use default inset if nothing is given + local border = inset + if not border then + border = tonumber(pfUI_config.appearance.border.default) + end + + -- bg and edge colors + if not pfUI.cache.br then + local br, bg, bb, ba = pfUI.api.strsplit(",", pfUI_config.appearance.border.background) + local er, eg, eb, ea = pfUI.api.strsplit(",", pfUI_config.appearance.border.color) + pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba = br, bg, bb, ba + pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea = er, eg, eb, ea + end + + local br, bg, bb, ba = pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba + local er, eg, eb, ea = pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea + if transp then ba = .8 end + + -- use legacy backdrop handling + if legacy then + f:SetBackdrop(pfUI.backdrop) + f:SetBackdropColor(br, bg, bb, ba) + f:SetBackdropBorderColor(er, eg, eb , ea) + return + end + + -- increase clickable area if available + if f.SetHitRectInsets then + f:SetHitRectInsets(-border,-border,-border,-border) + end + + -- use new backdrop behaviour + if not f.backdrop then + f:SetBackdrop(nil) + + local border = tonumber(border) - 1 + local backdrop = pfUI.backdrop + if border < 1 then backdrop = pfUI.backdrop_small end + local b = CreateFrame("Frame", nil, f) + b:SetPoint("TOPLEFT", f, "TOPLEFT", -border, border) + b:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", border, -border) + + local level = f:GetFrameLevel() + if level < 1 then + --f:SetFrameLevel(level + 1) + b:SetFrameLevel(level) + else + b:SetFrameLevel(level - 1) + end + + f.backdrop = b + b:SetBackdrop(backdrop) + end + + local b = f.backdrop + b:SetBackdropColor(br, bg, bb, ba) + b:SetBackdropBorderColor(er, eg, eb , ea) +end + +-- [ Skin Button ] +-- Applies pfUI skin to buttons: +-- 'button' [frame/string] the button that should be skinned. +-- 'cr' [int] mouseover color (red), defaults to classcolor. +-- 'cg' [int] mouseover color (green), defaults to classcolor. +-- 'cb' [int] mouseover color (blue), defaults to classcolor. +function pfUI.api:SkinButton(button, cr, cg, cb) + local b = getglobal(button) + if not b then b = button end + if not cr or not cg or not cb then + _, class = UnitClass("player") + local color = RAID_CLASS_COLORS[class] + cr, cg, cb = color.r , color.g, color.b + end + pfUI.api:CreateBackdrop(b, nil, true) + b:SetNormalTexture(nil) + b:SetHighlightTexture(nil) + b:SetPushedTexture(nil) + b:SetDisabledTexture(nil) + b:SetScript("OnEnter", function() + pfUI.api:CreateBackdrop(b, nil, true) + b:SetBackdropBorderColor(cr,cg,cb,1) + end) + b:SetScript("OnLeave", function() + pfUI.api:CreateBackdrop(b, nil, true) + end) + b:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") +end + +-- [ Question Dialog ] +-- Creates a pfUI user dialog popup: +-- 'text' [string] text that will be displayed. +-- 'yes' [function] function that is triggered on 'Okay' button. +-- 'no' [function] function that is triggered on 'Cancel' button. +-- 'editbox' [bool] if set, a inputfield will be shown. it can be. +-- accessed with "GetParent().input". +function pfUI.api:CreateQuestionDialog(text, yes, no, editbox) + -- do not allow multiple instances of question dialogs + if pfQuestionDialog and pfQuestionDialog:IsShown() then + pfQuestionDialog:Hide() + pfQuestionDialog = nil + return + end + + -- add default values + if not yes then + yes = function() message("You clicked OK") end + end + + if not no then + no = function() this:GetParent():Hide() end + end + + if not text then + text = "Are you sure?" + end + + local border = tonumber(pfUI_config.appearance.border.default) + local padding = 15 + -- frame + local question = CreateFrame("Frame", "pfQuestionDialog", UIParent) + question:SetWidth(300) + question:SetHeight(100) + question:SetPoint("CENTER", 0, 0) + question:SetFrameStrata("TOOLTIP") + question:SetMovable(true) + question:EnableMouse(true) + question:SetScript("OnMouseDown",function() + this:StartMoving() + end) + + question:SetScript("OnMouseUp",function() + this:StopMovingOrSizing() + end) + pfUI.api:CreateBackdrop(question) + + -- text + question.text = question:CreateFontString("Status", "LOW", "GameFontNormal") + question.text:SetFontObject(GameFontWhite) + question.text:SetPoint("TOP", 0, -padding) + question.text:SetText(text) + question.text:SetWidth(question:GetWidth() - border * 2) + + -- editbox + if editbox then + question.input = CreateFrame("EditBox", "pfQuestionDialogEdit", question) + pfUI.api:CreateBackdrop(question.input) + question.input:SetTextColor(.2,1,.8,1) + question.input:SetJustifyH("CENTER") + question.input:SetAutoFocus(false) + question.input:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", border, -padding) + question.input:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", -border, -padding) + question.input:SetHeight(20) + + question.input:SetFontObject(GameFontNormal) + question.input:SetScript("OnEscapePressed", function() this:ClearFocus() end) + end + + -- buttons + question.yes = CreateFrame("Button", "pfQuestionDialogYes", question, "UIPanelButtonTemplate") + pfUI.api:SkinButton(question.yes) + question.yes:SetWidth(100) + question.yes:SetHeight(20) + question.yes:SetText("Okay") + question.yes:SetScript("OnClick", yes) + + if question.input then + question.yes:SetPoint("TOPLEFT", question.input, "BOTTOMLEFT", -border, -padding) + else + question.yes:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", 0, -padding) + end + + question.no = CreateFrame("Button", "pfQuestionDialogNo", question, "UIPanelButtonTemplate") + pfUI.api:SkinButton(question.no) + question.no:SetWidth(85) + question.no:SetHeight(20) + question.no:SetText("Cancel") + question.no:SetScript("OnClick", no) + + if question.input then + question.no:SetPoint("TOPRIGHT", question.input, "BOTTOMRIGHT", border, -padding) + else + question.no:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", 0, -padding) + end + + question.close = CreateFrame("Button", "pfQuestionDialogClose", question) + question.close:SetPoint("TOPRIGHT", -border, -border) + pfUI.api:CreateBackdrop(question.close) + question.close:SetHeight(10) + question.close:SetWidth(10) + question.close.texture = question.close:CreateTexture("pfQuestionDialogCloseTex") + question.close.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\close") + question.close.texture:ClearAllPoints() + question.close.texture:SetAllPoints(question.close) + question.close.texture:SetVertexColor(1,.25,.25,1) + question.close:SetScript("OnEnter", function () + this.backdrop:SetBackdropBorderColor(1,.25,.25,1) + end) + + question.close:SetScript("OnLeave", function () + pfUI.api:CreateBackdrop(this) + end) + + question.close:SetScript("OnClick", function() + this:GetParent():Hide() + end) + + -- resize window + local textspace = question.text:GetHeight() + padding + local inputspace = 0 + if question.input then inputspace = question.input:GetHeight() + padding end + local buttonspace = question.no:GetHeight() + padding + question:SetHeight(textspace + inputspace + buttonspace + border) +end diff --git a/env/functions.lua b/env/functions.lua deleted file mode 100644 index 68285529..00000000 --- a/env/functions.lua +++ /dev/null @@ -1,55 +0,0 @@ --- a real "round" instead of ceil or floor -function round(input, places) - if not places then places = 0 end - if type(input) == "number" and type(places) == "number" then - local pow = 1 - for i = 1, places do pow = pow * 10 end - return floor(input * pow + 0.5) / pow - end -end - -function strsplit(delimiter, subject) - local ret = {} - local sector = subject - while true do - local pos = strfind(sector, delimiter) - if pos then - table.insert(ret, strsub(sector,1,pos-1)) - sector = strsub(sector,pos+1) - else - table.insert(ret, sector) - return unpack(ret) - end - end -end - -function CreateGoldString(money) - local gold = floor(money/ 100 / 100) - local silver = floor(mod((money/100),100)) - local copper = floor(mod(money,100)) - - local string = "" - if gold > 0 then string = string .. "|cffffffff" .. gold .. "|cffffd700g" end - if silver > 0 then string = string .. "|cffffffff " .. silver .. "|cffc7c7cfs" end - string = string .. "|cffffffff " .. copper .. "|cffeda55fc" - - return string -end - -function CopyTable(src) - local lookup_table = {} - local function _copy(src) - if type(src) ~= "table" then - return src - elseif lookup_table[src] then - return lookup_table[src] - end - local new_table = {} - lookup_table[src] = new_table - for index, value in pairs(src) do - new_table[_copy(index)] = _copy(value) - end - return setmetatable(new_table, getmetatable(src)) - end - return _copy(src) -end \ No newline at end of file diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 7b21e8dd..16ed0643 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -38,7 +38,7 @@ pfUI:RegisterModule("actionbar", function () if ( this.rangeTimer <= 0.1 ) then if ( IsActionInRange( ActionButton_GetPagedID(this)) == 0 ) then if not this.a then - this.r,this.g,this.b,this.a = strsplit(",", pfUI_config.bars.rangecolor) + this.r,this.g,this.b,this.a = pfUI.api.strsplit(",", pfUI_config.bars.rangecolor) end getglobal(this:GetName() .. 'Icon'):SetVertexColor(this.r, this.g, this.b, this.a) elseif IsUsableAction(ActionButton_GetPagedID(this)) then @@ -117,8 +117,8 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.pet:Show() pfUI.bars.pet:SetFrameStrata("LOW") pfUI.bars.pet:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, default_border * 5) - pfUI.utils:UpdateMovable(pfUI.bars.pet) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.pet, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.pet) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.pet, default_border) end pfUI.bars.pet:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 10 - default_border) pfUI.bars.pet:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) @@ -130,7 +130,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("PetActionButton"..i-1) or b b:ClearAllPoints() b:SetParent(pfUI.bars.pet) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) @@ -157,7 +157,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("ShapeshiftButton"..i-1) or b b:ClearAllPoints() b:SetParent(pfUI.bars.shapeshift) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) @@ -169,8 +169,8 @@ pfUI:RegisterModule("actionbar", function () --pfUI.bars.shapeshift:SetFrameStrata("LOW") pfUI.bars.shapeshift:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, default_border * 5) - pfUI.utils:UpdateMovable(pfUI.bars.shapeshift) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.shapeshift, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.shapeshift) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.shapeshift, default_border) end pfUI.bars.shapeshift:SetWidth((pfUI_config.bars.icon_size + default_border*3) * shapeshiftbuttons - default_border) pfUI.bars.shapeshift:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) @@ -191,7 +191,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarBottomLeftButton"..i-1) or b b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("TOPLEFT", tonumber(default_border), -tonumber(default_border)) @@ -206,8 +206,8 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.bottomleft:Show() pfUI.bars.bottomleft:SetFrameStrata("LOW") pfUI.bars.bottomleft:SetPoint("BOTTOMRIGHT", pfUI.bars.bottom, "BOTTOMLEFT", -default_border*5, 0) - pfUI.utils:UpdateMovable(pfUI.bars.bottomleft) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.bottomleft, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.bottomleft) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomleft, default_border) end pfUI.bars.bottomleft:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 6 - default_border) pfUI.bars.bottomleft:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 2 - default_border) @@ -227,7 +227,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarBottomRightButton"..i-1) or b b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) @@ -240,7 +240,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarBottomRightButton"..i-6) b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) b:SetPoint("LEFT", b2, "RIGHT", -pfUI_config.bars.icon_size, pfUI_config.bars.icon_size + default_border*3) end @@ -253,8 +253,8 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.bottomright:Show() pfUI.bars.bottomright:SetFrameStrata("LOW") pfUI.bars.bottomright:SetPoint("BOTTOMLEFT", pfUI.bars.bottom, "BOTTOMRIGHT", default_border*5, 0) - pfUI.utils:UpdateMovable(pfUI.bars.bottomright) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.bottomright, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.bottomright) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomright, default_border) end pfUI.bars.bottomright:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 6 - default_border) pfUI.bars.bottomright:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 2 - default_border) @@ -275,7 +275,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarRightButton"..i-1) or b b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) @@ -288,7 +288,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarRightButton"..i-6) b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) b:SetPoint("LEFT", b2, "RIGHT", -pfUI_config.bars.icon_size, pfUI_config.bars.icon_size + default_border*3) end @@ -301,8 +301,8 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.vertical:Show() pfUI.bars.vertical:SetFrameStrata("LOW") pfUI.bars.vertical:SetPoint("RIGHT", -5, 0) - pfUI.utils:UpdateMovable(pfUI.bars.vertical) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.vertical, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.vertical) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.vertical, default_border) end pfUI.bars.vertical:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) pfUI.bars.vertical:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 12 - default_border) @@ -322,7 +322,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("MultiBarLeftButton"..i-1) or b b:ClearAllPoints() b:SetParent(tf) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("TOPLEFT", tonumber(default_border), -tonumber(default_border)) @@ -339,15 +339,15 @@ pfUI:RegisterModule("actionbar", function () -- create bottom bar frame pfUI.bars.bottom:SetFrameStrata("LOW") pfUI.bars.bottom:SetPoint("BOTTOM", 0, 5) - pfUI.utils:UpdateMovable(pfUI.bars.bottom) - if pfUI_config.bars.background == "1" then pfUI.utils:CreateBackdrop(pfUI.bars.bottom, default_border) end + pfUI.api:UpdateMovable(pfUI.bars.bottom) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottom, default_border) end for i=1, 12 do local b = getglobal("ActionButton"..i) local b2 = getglobal("ActionButton"..i-1) or b b:ClearAllPoints() b:SetParent(pfUI.bars.bottom) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) @@ -366,7 +366,7 @@ pfUI:RegisterModule("actionbar", function () local b2 = getglobal("BonusActionButton"..i-1) or b b:ClearAllPoints() b:SetParent(BonusActionBarFrame) - pfUI.utils:CreateBackdrop(b, default_border) + pfUI.api:CreateBackdrop(b, default_border) if i == 1 then b:SetPoint("BOTTOMLEFT", tonumber(default_border) - 4, tonumber(default_border)) diff --git a/modules/addons.lua b/modules/addons.lua index f68caf31..3be4cc95 100644 --- a/modules/addons.lua +++ b/modules/addons.lua @@ -5,7 +5,7 @@ pfUI:RegisterModule("addons", function () pfUI.addons:SetWidth(400) pfUI.addons:SetPoint("CENTER", 0,0) pfUI.addons:EnableMouseWheel(1) - pfUI.utils:CreateBackdrop(pfUI.addons, nil, nil, true) + pfUI.api:CreateBackdrop(pfUI.addons, nil, nil, true) pfUI.addons:SetMovable(true) pfUI.addons:EnableMouse(true) pfUI.addons:SetScript("OnMouseDown",function() @@ -34,7 +34,7 @@ pfUI:RegisterModule("addons", function () pfUI.addons.close = CreateFrame("Button", "pfBagClose", pfUI.addons) pfUI.addons.close:SetPoint("TOPRIGHT", -pfUI_config.appearance.border.default*2,-pfUI_config.appearance.border.default*2 ) - pfUI.utils:CreateBackdrop(pfUI.addons.close) + pfUI.api:CreateBackdrop(pfUI.addons.close) pfUI.addons.close:SetHeight(15) pfUI.addons.close:SetWidth(15) pfUI.addons.close.texture = pfUI.addons.close:CreateTexture("pfBagClose") @@ -44,12 +44,12 @@ pfUI:RegisterModule("addons", function () pfUI.addons.close.texture:SetPoint("BOTTOMRIGHT", pfUI.addons.close, "BOTTOMRIGHT", -4, 4) pfUI.addons.close.texture:SetVertexColor(1,.25,.25,1) pfUI.addons.close:SetScript("OnEnter", function () - pfUI.utils:CreateBackdrop(pfUI.addons.close) + pfUI.api:CreateBackdrop(pfUI.addons.close) pfUI.addons.close.backdrop:SetBackdropBorderColor(1,.25,.25,1) end) pfUI.addons.close:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(pfUI.addons.close) + pfUI.api:CreateBackdrop(pfUI.addons.close) end) pfUI.addons.close:SetScript("OnClick", function() @@ -88,7 +88,7 @@ pfUI:RegisterModule("addons", function () frame.input:SetNormalTexture("") frame.input:SetPushedTexture("") frame.input:SetHighlightTexture("") - pfUI.utils:CreateBackdrop(frame.input, nil, true) + pfUI.api:CreateBackdrop(frame.input, nil, true) --frame.input:SetBackdrop(pfUI.backdrop) frame.input:SetBackdropBorderColor(.3,.3,.3,1) frame.input:SetWidth(14) @@ -167,7 +167,7 @@ pfUI:RegisterModule("addons", function () pfUI.addons.deco:ClearAllPoints() pfUI.addons.deco:SetPoint("TOPLEFT", pfUI.addons.scroll, "TOPLEFT", -5, 5) pfUI.addons.deco:SetPoint("BOTTOMRIGHT", pfUI.addons.scroll, "BOTTOMRIGHT", 5, -5) - pfUI.utils:CreateBackdrop(pfUI.addons.deco, nil, nil, true) + pfUI.api:CreateBackdrop(pfUI.addons.deco, nil, nil, true) pfUI.addons.deco.up = CreateFrame("Frame", nil, pfUI.addons.deco) pfUI.addons.deco.up:SetPoint("TOPRIGHT", 0,0) diff --git a/modules/bags.lua b/modules/bags.lua index 3855ef52..90d44c4e 100644 --- a/modules/bags.lua +++ b/modules/bags.lua @@ -195,7 +195,7 @@ pfUI:RegisterModule("bags", function () pfUI.bag:CreateAdditions(frame) frame:SetFrameStrata("HIGH") - pfUI.utils:CreateBackdrop(frame, default_border) + pfUI.api:CreateBackdrop(frame, default_border) pfUI.bag.button_size = (frame:GetWidth() + default_border - 10*default_border*3) / 10 --message(frame:GetWidth() .. " should be " .. pfUI.bag.button_size*10 + 10*default_border*3) @@ -253,7 +253,7 @@ pfUI:RegisterModule("bags", function () if bag == -1 then tpl = "BankItemButtonGenericTemplate" end pfUI.bags[bag].slots[slot] = {} pfUI.bags[bag].slots[slot].frame = CreateFrame("Button", "pfBag" .. bag .. "item" .. slot, pfUI.bags[bag], tpl) - pfUI.utils:CreateBackdrop(pfUI.bags[bag].slots[slot].frame, default_border) + pfUI.api:CreateBackdrop(pfUI.bags[bag].slots[slot].frame, default_border) pfUI.bags[bag].slots[slot].frame:SetNormalTexture("") pfUI.bags[bag].slots[slot].bag = bag @@ -348,7 +348,7 @@ pfUI:RegisterModule("bags", function () end frame.bagslots:SetPoint("BOTTOM"..position, frame, "TOP"..position, 0, default_border*3) - pfUI.utils:CreateBackdrop(frame.bagslots, default_border) + pfUI.api:CreateBackdrop(frame.bagslots, default_border) local extra = 0 if frame == pfUI.bag.left and GetNumBankSlots() < 6 then extra = 1 end @@ -381,7 +381,7 @@ pfUI:RegisterModule("bags", function () frame.bagslots.slots[slot].frame:SetScript("OnEnter", function() for slot, f in ipairs(pfUI.bags[this.slot + 1].slots) do - pfUI.utils:CreateBackdrop(f.frame, default_border) + pfUI.api:CreateBackdrop(f.frame, default_border) f.frame.backdrop:SetBackdropBorderColor(.2,1,.8,1) end end) @@ -399,7 +399,7 @@ pfUI:RegisterModule("bags", function () frame.bagslots.slots[slot].frame:SetWidth(pfUI.bag.button_size/5*4) local id, texture = GetInventorySlotInfo("Bag" .. slot .. append) - pfUI.utils:CreateBackdrop(frame.bagslots.slots[slot].frame, default_border) + pfUI.api:CreateBackdrop(frame.bagslots.slots[slot].frame, default_border) frame.bagslots.slots[slot].frame:Show() local numSlots, full = GetNumBankSlots() @@ -416,7 +416,7 @@ pfUI:RegisterModule("bags", function () frame.bagslots.buy = CreateFrame("Button", "pfBagSlotBuy", frame.bagslots) end frame.bagslots.buy:SetPoint("RIGHT", frame.bagslots, "RIGHT", -default_border, 0) - pfUI.utils:CreateBackdrop(frame.bagslots.buy, default_border) + pfUI.api:CreateBackdrop(frame.bagslots.buy, default_border) frame.bagslots.buy:SetHeight(pfUI.bag.button_size/5*4) frame.bagslots.buy:SetWidth(pfUI.bag.button_size/5*4) frame.bagslots.buy:SetText("+") @@ -445,7 +445,7 @@ pfUI:RegisterModule("bags", function () frame.close = CreateFrame("Button", "pfBagClose", UIParent) frame.close:SetParent(frame) frame.close:SetPoint("TOPRIGHT", -default_border*1,-default_border ) - pfUI.utils:CreateBackdrop(frame.close, default_border) + pfUI.api:CreateBackdrop(frame.close, default_border) frame.close:SetHeight(12) frame.close:SetWidth(12) frame.close.texture = frame.close:CreateTexture("pfBagClose") @@ -459,7 +459,7 @@ pfUI:RegisterModule("bags", function () end) frame.close:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(frame.close, default_border) + pfUI.api:CreateBackdrop(frame.close, default_border) end) frame.close:SetScript("OnClick", function() @@ -472,7 +472,7 @@ pfUI:RegisterModule("bags", function () frame.bags = CreateFrame("Button", "pfBagSlotShow", UIParent) frame.bags:SetParent(frame) frame.bags:SetPoint("TOPRIGHT", frame.close, "TOPLEFT", -default_border*3, 0) - pfUI.utils:CreateBackdrop(frame.bags, default_border) + pfUI.api:CreateBackdrop(frame.bags, default_border) frame.bags:SetHeight(12) frame.bags:SetWidth(12) frame.bags:SetTextColor(1,1,.25,1) @@ -490,7 +490,7 @@ pfUI:RegisterModule("bags", function () end) frame.bags:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(frame.bags, default_border) + pfUI.api:CreateBackdrop(frame.bags, default_border) frame.bags.texture:SetVertexColor(.25,.25,.25,1) end) @@ -508,7 +508,7 @@ pfUI:RegisterModule("bags", function () frame.keys = CreateFrame("Button", "pfBagSlotShow", UIParent) frame.keys:SetParent(frame) frame.keys:SetPoint("TOPRIGHT", frame.bags, "TOPLEFT", -default_border*3, 0) - pfUI.utils:CreateBackdrop(frame.keys, default_border) + pfUI.api:CreateBackdrop(frame.keys, default_border) frame.keys:SetHeight(12) frame.keys:SetWidth(12) frame.keys:SetTextColor(1,1,.25,1) @@ -526,7 +526,7 @@ pfUI:RegisterModule("bags", function () end) frame.keys:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(frame.keys, default_border) + pfUI.api:CreateBackdrop(frame.keys, default_border) frame.keys.texture:SetVertexColor(.25,.25,.25,1) end) @@ -547,7 +547,7 @@ pfUI:RegisterModule("bags", function () frame.search:SetHeight(12) frame.search:SetPoint("TOPLEFT", frame, "TOPLEFT", default_border, -default_border) frame.search:SetPoint("TOPRIGHT", frame.keys, "TOPLEFT", -default_border*3, -default_border) - pfUI.utils:CreateBackdrop(frame.search, default_border) + pfUI.api:CreateBackdrop(frame.search, default_border) frame.search.edit = CreateFrame("EditBox", "pfUIBagSearch", frame.search, "InputBoxTemplate") pfUIBagSearchLeft:SetTexture(nil) @@ -608,7 +608,7 @@ pfUI:RegisterModule("bags", function () frame.close = CreateFrame("Button", "pfBagClose", UIParent) frame.close:SetParent(frame) frame.close:SetPoint("TOPRIGHT", -default_border*1,-default_border ) - pfUI.utils:CreateBackdrop(frame.close, default_border) + pfUI.api:CreateBackdrop(frame.close, default_border) frame.close:SetHeight(12) frame.close:SetWidth(12) frame.close.texture = frame.close:CreateTexture("pfBagClose") @@ -622,7 +622,7 @@ pfUI:RegisterModule("bags", function () end) frame.close:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(frame.close, default_border) + pfUI.api:CreateBackdrop(frame.close, default_border) end) frame.close:SetScript("OnClick", function() @@ -635,7 +635,7 @@ pfUI:RegisterModule("bags", function () frame.bags = CreateFrame("Button", "pfBagSlotShow", UIParent) frame.bags:SetParent(frame) frame.bags:SetPoint("TOPRIGHT", frame.close, "TOPLEFT", -default_border*3, 0) - pfUI.utils:CreateBackdrop(frame.bags, default_border) + pfUI.api:CreateBackdrop(frame.bags, default_border) frame.bags:SetHeight(12) frame.bags:SetWidth(12) frame.bags:SetTextColor(1,1,.25,1) @@ -653,7 +653,7 @@ pfUI:RegisterModule("bags", function () end) frame.bags:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(frame.bags, default_border) + pfUI.api:CreateBackdrop(frame.bags, default_border) frame.bags.texture:SetVertexColor(.25,.25,.25,1) end) diff --git a/modules/buff.lua b/modules/buff.lua index 2f88234c..33b6d27b 100644 --- a/modules/buff.lua +++ b/modules/buff.lua @@ -56,7 +56,7 @@ pfUI:RegisterModule("buff", function () local border = getglobal(buff:GetName().."Border") local _, _, mainhand, _, _, offhand = GetWeaponEnchantInfo() if buff then - pfUI.utils:CreateBackdrop(buff) + pfUI.api:CreateBackdrop(buff) icon:SetTexCoord(.08, .92, .08, .92) border:Hide() end @@ -108,7 +108,7 @@ pfUI:RegisterModule("buff", function () elseif i > 16 then buff:SetPoint("TOPRIGHT", getglobal("BuffButton" .. i-1), "TOPLEFT", -7, 0) end - pfUI.utils:CreateBackdrop(buff) + pfUI.api:CreateBackdrop(buff) text:SetPoint("TOP", buff, "BOTTOM", 0 , -pfUI_config.appearance.border.default*2) icon:SetTexCoord(.08, .92, .08, .92) if border then diff --git a/modules/castbar.lua b/modules/castbar.lua index 57ebb376..7eb4c77c 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -17,7 +17,7 @@ pfUI:RegisterModule("castbar", function () -- setup player castbar pfUI.castbar.player = CreateFrame("Frame",nil, pfUI.uf.player) - pfUI.utils:CreateBackdrop(pfUI.castbar.player, default_border) + pfUI.api:CreateBackdrop(pfUI.castbar.player, default_border) pfUI.castbar.player:SetHeight(pfUI_config.global.font_size * 2) pfUI.castbar.player:SetPoint("TOPRIGHT",pfUI.uf.player,"BOTTOMRIGHT",0,-default_border*3) pfUI.castbar.player:SetPoint("TOPLEFT",pfUI.uf.player,"BOTTOMLEFT",0,-default_border*3) @@ -31,7 +31,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.player.bar:SetAllPoints(pfUI.castbar.player) pfUI.castbar.player.bar:SetMinMaxValues(0, 100) pfUI.castbar.player.bar:SetValue(20) - local r,g,b,a = strsplit(",", pfUI_config.appearance.castbar.castbarcolor) + local r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.castbar.castbarcolor) pfUI.castbar.player.bar:SetStatusBarColor(r,g,b,a) -- text left @@ -73,7 +73,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.player.delay = 0 pfUI.castbar.player.spell = arg1 pfUI.castbar.player.bar.left:SetText(arg1) - local r,g,b,a = strsplit(",", pfUI_config.appearance.castbar.castbarcolor) + local r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.castbar.castbarcolor) pfUI.castbar.player.bar:SetStatusBarColor(r,g,b,a) pfUI.castbar.player.startTime = GetTime() pfUI.castbar.player.maxValue = pfUI.castbar.player.startTime + (arg2 / 1000) @@ -91,7 +91,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.player.delay = 0 pfUI.castbar.player.spell = arg2 pfUI.castbar.player.bar.left:SetText(arg2) - local r,g,b,a = strsplit(",", pfUI_config.appearance.castbar.channelcolor) + local r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.castbar.channelcolor) pfUI.castbar.player.bar:SetStatusBarColor(r,g,b,a) pfUI.castbar.player.maxValue = nil pfUI.castbar.player.startTime = GetTime() @@ -158,15 +158,15 @@ pfUI:RegisterModule("castbar", function () -- cast if ( pfUI.castbar.player.casting ) then local status = GetTime() - local cur = round(GetTime() - pfUI.castbar.player.startTime,1) - local max = round(pfUI.castbar.player.maxValue - pfUI.castbar.player.startTime,1) + local cur = pfUI.api.round(GetTime() - pfUI.castbar.player.startTime,1) + local max = pfUI.api.round(pfUI.castbar.player.maxValue - pfUI.castbar.player.startTime,1) local delay = pfUI.castbar.player.delay if cur > max then cur = max end if ( status > pfUI.castbar.player.maxValue ) then status = pfUI.castbar.player.maxValue end if delay > 0 then - delay = "|cffffaaaa+" .. round(delay,1) .. " |r " + delay = "|cffffaaaa+" .. pfUI.api.round(delay,1) .. " |r " pfUI.castbar.player.bar.right:SetText(delay .. cur .. " / " .. max) else pfUI.castbar.player.bar.right:SetText(cur .. " / " .. max) @@ -177,8 +177,8 @@ pfUI:RegisterModule("castbar", function () elseif ( pfUI.castbar.player.channeling ) then local time = GetTime() local barValue = pfUI.castbar.player.startTime + (pfUI.castbar.player.endTime - time) - local cur = round(pfUI.castbar.player.endTime - GetTime(),1) - local max = round(pfUI.castbar.player.endTime - pfUI.castbar.player.startTime,1) + local cur = pfUI.api.round(pfUI.castbar.player.endTime - GetTime(),1) + local max = pfUI.api.round(pfUI.castbar.player.endTime - pfUI.castbar.player.startTime,1) local delay = pfUI.castbar.player.delay if cur > max then cur = max end if ( time > pfUI.castbar.player.endTime ) then @@ -190,7 +190,7 @@ pfUI:RegisterModule("castbar", function () return end if delay > 0 then - delay = "|cffffaaaa-" .. round(delay,1) .. " |r " + delay = "|cffffaaaa-" .. pfUI.api.round(delay,1) .. " |r " pfUI.castbar.player.bar.right:SetText(delay .. cur) else pfUI.castbar.player.bar.right:SetText(cur) @@ -202,7 +202,7 @@ pfUI:RegisterModule("castbar", function () if pfUI.uf.target then pfUI.castbar.target = CreateFrame("Frame",nil, pfUI.uf.target) - pfUI.utils:CreateBackdrop(pfUI.castbar.target, default_border) + pfUI.api:CreateBackdrop(pfUI.castbar.target, default_border) pfUI.castbar.target:SetHeight(pfUI_config.global.font_size * 2) pfUI.castbar.target:SetPoint("TOPRIGHT",pfUI.uf.target,"BOTTOMRIGHT",0,-default_border*3) pfUI.castbar.target:SetPoint("TOPLEFT",pfUI.uf.target,"BOTTOMLEFT",0,-default_border*3) @@ -214,7 +214,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.target.bar:SetAllPoints(pfUI.castbar.target) pfUI.castbar.target.bar:SetMinMaxValues(0, 100) pfUI.castbar.target.bar:SetValue(20) - local r,g,b,a = strsplit(",", pfUI_config.appearance.castbar.castbarcolor) + local r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.castbar.castbarcolor) pfUI.castbar.target.bar:SetStatusBarColor(r,g,b,a) -- text left @@ -256,7 +256,7 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.target.bar:SetMinMaxValues(0, casttime) pfUI.castbar.target.bar:SetValue(GetTime() - starttime) pfUI.castbar.target.bar.left:SetText(spellname) - pfUI.castbar.target.bar.right:SetText(round(GetTime() - starttime,1) .. " / " .. casttime) + pfUI.castbar.target.bar.right:SetText(pfUI.api.round(GetTime() - starttime,1) .. " / " .. casttime) end else pfUI.castbar.target.casterDB[UnitName("target")] = nil diff --git a/modules/chat.lua b/modules/chat.lua index 0eb11d4f..8a9584da 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -11,10 +11,10 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left:SetWidth(pfUI_config.chat.left.width) pfUI.chat.left:SetHeight(pfUI_config.chat.left.height) pfUI.chat.left:SetPoint("BOTTOMLEFT", 5,5) - pfUI.utils:UpdateMovable(pfUI.chat.left) - pfUI.utils:CreateBackdrop(pfUI.chat.left, default_border, nil, true) + pfUI.api:UpdateMovable(pfUI.chat.left) + pfUI.api:CreateBackdrop(pfUI.chat.left, default_border, nil, true) if pfUI_config.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", pfUI_config.chat.global.background) + local r, g, b, a = pfUI.api.strsplit(",", pfUI_config.chat.global.background) pfUI.chat.left.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -23,7 +23,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left.panelTop:SetHeight(pfUI_config.global.font_size+default_border*2) pfUI.chat.left.panelTop:SetPoint("TOPLEFT", pfUI.chat.left, "TOPLEFT", default_border, -default_border) pfUI.chat.left.panelTop:SetPoint("TOPRIGHT", pfUI.chat.left, "TOPRIGHT", -default_border, -default_border) - pfUI.utils:CreateBackdrop(pfUI.chat.left.panelTop, default_border, nil, true) + pfUI.api:CreateBackdrop(pfUI.chat.left.panelTop, default_border, nil, true) -- whisper forwarding pfUI.chat.left.panelTop.proxy = CreateFrame("Button", "leftChatWhisperProxy", pfUI.chat.left.panelTop) @@ -94,7 +94,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left.panelTop.proxyName:SetPoint("CENTER", 0, 0) pfUI.chat.left.panelTop.proxyName:SetHeight(100) pfUI.chat.left.panelTop.proxyName:SetWidth(200) - pfUI.utils:CreateBackdrop(pfUI.chat.left.panelTop.proxyName, default_border) + pfUI.api:CreateBackdrop(pfUI.chat.left.panelTop.proxyName, default_border) pfUI.chat.left.panelTop.proxyName:SetScript("OnShow", function() pfUI.chat.left.panelTop.proxyName.input:SetText(pfUI.chat.left.panelTop.proxy.forwardto) end) @@ -109,7 +109,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left.panelTop.proxyName.input = CreateFrame("EditBox", nil, pfUI.chat.left.panelTop.proxyName) pfUI.chat.left.panelTop.proxyName.input:SetTextColor(.2,1.1,1) pfUI.chat.left.panelTop.proxyName.input:SetJustifyH("CENTER") - pfUI.utils:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.input, default_border) + pfUI.api:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.input, default_border) pfUI.chat.left.panelTop.proxyName.input:SetPoint("TOPLEFT" , pfUI.chat.left.panelTop.proxyName, "TOPLEFT", 20, -40) pfUI.chat.left.panelTop.proxyName.input:SetPoint("BOTTOMRIGHT" , pfUI.chat.left.panelTop.proxyName, "BOTTOMRIGHT", -20, 40) pfUI.chat.left.panelTop.proxyName.input:SetFontObject(GameFontWhite) @@ -123,7 +123,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left.panelTop.proxyName.okay:SetWidth(80) pfUI.chat.left.panelTop.proxyName.okay:SetHeight(20) pfUI.chat.left.panelTop.proxyName.okay:SetPoint("BOTTOMRIGHT", -10, 10) - pfUI.utils:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.okay, default_border) + pfUI.api:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.okay, default_border) pfUI.chat.left.panelTop.proxyName.okay.text = pfUI.chat.left.panelTop.proxyName.okay:CreateFontString("Status", "LOW", "GameFontNormal") pfUI.chat.left.panelTop.proxyName.okay.text:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") pfUI.chat.left.panelTop.proxyName.okay.text:ClearAllPoints() @@ -143,7 +143,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left.panelTop.proxyName.abort:SetWidth(80) pfUI.chat.left.panelTop.proxyName.abort:SetHeight(20) pfUI.chat.left.panelTop.proxyName.abort:SetPoint("BOTTOMLEFT", 10, 10) - pfUI.utils:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.abort, default_border) + pfUI.api:CreateBackdrop(pfUI.chat.left.panelTop.proxyName.abort, default_border) pfUI.chat.left.panelTop.proxyName.abort.text = pfUI.chat.left.panelTop.proxyName.abort:CreateFontString("Status", "LOW", "GameFontNormal") pfUI.chat.left.panelTop.proxyName.abort.text:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") pfUI.chat.left.panelTop.proxyName.abort.text:ClearAllPoints() @@ -163,10 +163,10 @@ pfUI:RegisterModule("chat", function () pfUI.chat.right:SetWidth(pfUI_config.chat.right.width) pfUI.chat.right:SetHeight(pfUI_config.chat.right.height) pfUI.chat.right:SetPoint("BOTTOMRIGHT", -5,5) - pfUI.utils:UpdateMovable(pfUI.chat.right) - pfUI.utils:CreateBackdrop(pfUI.chat.right, default_border, nil, true) + pfUI.api:UpdateMovable(pfUI.chat.right) + pfUI.api:CreateBackdrop(pfUI.chat.right, default_border, nil, true) if pfUI_config.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", pfUI_config.chat.global.background) + local r, g, b, a = pfUI.api.strsplit(",", pfUI_config.chat.global.background) pfUI.chat.right.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -175,7 +175,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.right.panelTop:SetHeight(pfUI_config.global.font_size+default_border*2) pfUI.chat.right.panelTop:SetPoint("TOPLEFT", pfUI.chat.right, "TOPLEFT", default_border, -default_border) pfUI.chat.right.panelTop:SetPoint("TOPRIGHT", pfUI.chat.right, "TOPRIGHT", -default_border, -default_border) - pfUI.utils:CreateBackdrop(pfUI.chat.right.panelTop, default_border, nil, true) + pfUI.api:CreateBackdrop(pfUI.chat.right.panelTop, default_border, nil, true) pfUI.chat:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.chat:RegisterEvent("UI_SCALE_CHANGED") @@ -483,7 +483,7 @@ pfUI:RegisterModule("chat", function () anchor = pfUI.chat.left end pfUI.chat.editbox:SetPoint("BOTTOM", anchor, "TOP", 0, default_border*4) - pfUI.utils:UpdateMovable(pfUI.chat.editbox) + pfUI.api:UpdateMovable(pfUI.chat.editbox) if pfUI_config.chat.text.input_width == "0" then pfUI.chat.editbox:SetWidth(default_border*3 + pfUI_config.bars.icon_size * 12 + default_border * 12) -- actionbar size @@ -493,7 +493,7 @@ pfUI:RegisterModule("chat", function () ChatFrameEditBox:SetParent(pfUI.chat.editbox) ChatFrameEditBox:SetAllPoints(pfUI.chat.editbox) - pfUI.utils:CreateBackdrop(ChatFrameEditBox, default_border) + pfUI.api:CreateBackdrop(ChatFrameEditBox, default_border) for i,v in ipairs({ChatFrameEditBox:GetRegions()}) do if i==6 or i==7 or i==8 then v:Hide() end @@ -556,7 +556,7 @@ pfUI:RegisterModule("chat", function () local left = string.sub(pfUI_config.chat.text.timebracket, 1, 1) local right = string.sub(pfUI_config.chat.text.timebracket, 2, 2) - local r,g,b,a = strsplit(",", pfUI_config.chat.text.timecolor) + local r,g,b,a = pfUI.api.strsplit(",", pfUI_config.chat.text.timecolor) local chex = string.format("%02x%02x%02x%02x", a*255, r*255, g*255, b*255) text = "|c" .. chex .. left .. date(pfUI_config.chat.text.timeformat) .. right .. "|r " .. text end diff --git a/modules/cooldown.lua b/modules/cooldown.lua index baf9f367..bc7dab04 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -26,19 +26,19 @@ pfUI:RegisterModule("cooldown", function () if remaining > 99 then remaining = remaining / 60 unit = "m" - r,g,b,a = strsplit(",", pfUI_config.appearance.cd.mincolor) + r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.cd.mincolor) end if remaining > 99 then remaining = remaining / 60 unit = "h" - r,g,b,a = strsplit(",", pfUI_config.appearance.cd.hourcolor) + r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.cd.hourcolor) end if remaining > 99 then remaining = remaining / 24 unit = "d" - r,g,b,a = strsplit(",", pfUI_config.appearance.cd.daycolor) + r,g,b,a = pfUI.api.strsplit(",", pfUI_config.appearance.cd.daycolor) end - this.text:SetText(round(remaining) .. unit) + this.text:SetText(pfUI.api.round(remaining) .. unit) this.text:SetTextColor(r,g,b,a) else this:Hide() diff --git a/modules/group.lua b/modules/group.lua index a802803f..a1521ffc 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -86,7 +86,7 @@ pfUI:RegisterModule("group", function () pfUI.uf.group[i]:SetWidth(175) pfUI.uf.group[i]:SetHeight(40 + 2*default_border + pfUI_config.unitframes.group.pspace) pfUI.uf.group[i]:SetPoint("TOPLEFT", 5, -5 - ((i-1)*55)) - pfUI.utils:UpdateMovable(pfUI.uf.group[i]) + pfUI.api:UpdateMovable(pfUI.uf.group[i]) pfUI.uf.group[i]:Hide() pfUI.uf.group[i].id = i pfUI.uf.group[i].label = "party" @@ -96,7 +96,7 @@ pfUI:RegisterModule("group", function () pfUI.uf.group[i].hp:SetWidth(175) pfUI.uf.group[i].hp:SetHeight(30) pfUI.uf.group[i].hp:SetPoint("TOP", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.uf.group[i].hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.group[i].hp, default_border) pfUI.uf.group[i].hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.group[i].hp) pfUI.uf.group[i].hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -107,7 +107,7 @@ pfUI:RegisterModule("group", function () pfUI.uf.group[i].power:SetWidth(175) pfUI.uf.group[i].power:SetHeight(10) pfUI.uf.group[i].power:SetPoint("BOTTOM", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.uf.group[i].power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.group[i].power, default_border) pfUI.uf.group[i].power.bar = CreateFrame("StatusBar", nil, pfUI.uf.group[i].power) pfUI.uf.group[i].power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") diff --git a/modules/gui.lua b/modules/gui.lua index 80cd87cd..6656def4 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -10,7 +10,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:SetHeight(500) pfUI.gui:Hide() - pfUI.utils:CreateBackdrop(pfUI.gui, nil, nil, true) + pfUI.api:CreateBackdrop(pfUI.gui, nil, nil, true) pfUI.gui:SetPoint("CENTER",0,0) pfUI.gui:SetMovable(true) pfUI.gui:EnableMouse(true) @@ -50,7 +50,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui.reloadDialog:Hide() tinsert(UISpecialFrames, "pfReloadDiag") - pfUI.utils:CreateBackdrop(pfUI.gui.reloadDialog) + pfUI.api:CreateBackdrop(pfUI.gui.reloadDialog) pfUI.gui.reloadDialog:SetPoint("CENTER",0,0) pfUI.gui.reloadDialog.text = pfUI.gui.reloadDialog:CreateFontString("Status", "LOW", "GameFontNormal") @@ -59,7 +59,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui.reloadDialog.text:SetText("Some settings need to reload the UI to take effect.\nDo you want to reloadUI now?") pfUI.gui.reloadDialog.yes = CreateFrame("Button", "pfReloadYes", pfUI.gui.reloadDialog, "UIPanelButtonTemplate") - pfUI.utils:CreateBackdrop(pfUI.gui.reloadDialog.yes, nil, true) + pfUI.api:CreateBackdrop(pfUI.gui.reloadDialog.yes, nil, true) pfUI.gui.reloadDialog.yes:SetWidth(100) pfUI.gui.reloadDialog.yes:SetHeight(20) pfUI.gui.reloadDialog.yes:SetPoint("BOTTOMLEFT", 20,15) @@ -157,7 +157,7 @@ pfUI:RegisterModule("gui", function () frame.drag = CreateFrame("Frame", nil, frame) frame.drag:SetAllPoints(frame) frame.drag:SetFrameStrata("DIALOG") - pfUI.utils:CreateBackdrop(frame.drag, nil, nil, true) + pfUI.api:CreateBackdrop(frame.drag, nil, nil, true) frame.drag.backdrop:SetBackdropBorderColor(.2, 1, .8) frame.drag:EnableMouseWheel(1) frame.drag.text = frame.drag:CreateFontString("Status", "LOW", "GameFontNormal") @@ -170,7 +170,7 @@ pfUI:RegisterModule("gui", function () frame.drag:SetAlpha(1) frame.drag:SetScript("OnMouseWheel", function() - local scale = round(frame:GetScale() + arg1/10, 1) + local scale = pfUI.api.round(frame:GetScale() + arg1/10, 1) if IsShiftKeyDown() and strsub(frame:GetName(),0,6) == "pfRaid" then for i=1,40 do @@ -302,12 +302,12 @@ pfUI:RegisterModule("gui", function () for _, hide in pairs(elements) do hide:Hide() - pfUI.utils:CreateBackdrop(hide.switch, nil, true) + pfUI.api:CreateBackdrop(hide.switch, nil, true) end pfUI.gui.scroll:SetScrollChild(frame) pfUI.gui.scroll:UpdateScrollState() pfUI.gui.scroll:SetVerticalScroll(0) - pfUI.utils:CreateBackdrop(frame.switch, nil, true) + pfUI.api:CreateBackdrop(frame.switch, nil, true) frame.switch:SetBackdropBorderColor(.2,1,.8) frame:Show() end @@ -342,7 +342,7 @@ pfUI:RegisterModule("gui", function () else frame.switch:SetPoint("TOPLEFT", default_border, -pfUI.gui.tabTop* (22 + default_border) -default_border) end - pfUI.utils:CreateBackdrop(frame.switch, nil, true) + pfUI.api:CreateBackdrop(frame.switch, nil, true) frame.switch.text = frame.switch:CreateFontString("Status", "LOW", "GameFontNormal") frame.switch.text:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") frame.switch.text:SetAllPoints(frame.switch) @@ -419,19 +419,19 @@ pfUI:RegisterModule("gui", function () frame.color = CreateFrame("Button", nil, frame) frame.color:SetWidth(12) frame.color:SetHeight(12) - pfUI.utils:CreateBackdrop(frame.color) + pfUI.api:CreateBackdrop(frame.color) frame.color:SetPoint("TOPRIGHT" , 0, -4) frame.color.prev = frame.color.backdrop:CreateTexture("OVERLAY") frame.color.prev:SetAllPoints(frame.color) - local cr, cg, cb, ca = strsplit(",", category[config]) + local cr, cg, cb, ca = pfUI.api.strsplit(",", category[config]) if not cr or not cg or not cb or not ca then cr, cg, cb, ca = 1, 1, 1, 1 end frame.color.prev:SetTexture(cr,cg,cb,ca) frame.color:SetScript("OnClick", function() - local cr, cg, cb, ca = strsplit(",", category[config]) + local cr, cg, cb, ca = pfUI.api.strsplit(",", category[config]) if not cr or not cg or not cb or not ca then cr, cg, cb, ca = 1, 1, 1, 1 end @@ -441,10 +441,10 @@ pfUI:RegisterModule("gui", function () local r,g,b = ColorPickerFrame:GetColorRGB() local a = 1 - OpacitySliderFrame:GetValue() - r = round(r, 1) - g = round(g, 1) - b = round(b, 1) - a = round(a, 1) + r = pfUI.api.round(r, 1) + g = pfUI.api.round(g, 1) + b = pfUI.api.round(b, 1) + a = pfUI.api.round(a, 1) preview:SetTexture(r,g,b,a) @@ -469,7 +469,7 @@ pfUI:RegisterModule("gui", function () end if widget == "warning" then - pfUI.utils:CreateBackdrop(frame, nil, true) + pfUI.api:CreateBackdrop(frame, nil, true) frame:SetBackdropBorderColor(1,.5,.5) frame:SetHeight(50) frame:SetPoint("TOPLEFT", 25, parent.objectCount * -35) @@ -517,8 +517,8 @@ pfUI:RegisterModule("gui", function () -- use button widget if widget == "button" then frame.button = CreateFrame("Button", "pfButton", frame, "UIPanelButtonTemplate") - pfUI.utils:CreateBackdrop(frame.button, nil, true) - pfUI.utils:SkinButton(frame.button) + pfUI.api:CreateBackdrop(frame.button, nil, true) + pfUI.api:SkinButton(frame.button) frame.button:SetWidth(85) frame.button:SetHeight(20) frame.button:SetPoint("TOPRIGHT", -(parent.lineCount-1) * 90, -5) @@ -534,7 +534,7 @@ pfUI:RegisterModule("gui", function () frame.input:SetNormalTexture("") frame.input:SetPushedTexture("") frame.input:SetHighlightTexture("") - pfUI.utils:CreateBackdrop(frame.input, nil, true) + pfUI.api:CreateBackdrop(frame.input, nil, true) frame.input:SetWidth(14) frame.input:SetHeight(14) frame.input:SetPoint("TOPRIGHT" , 0, -4) @@ -597,7 +597,7 @@ pfUI:RegisterModule("gui", function () for i,v in ipairs({frame.input:GetRegions()}) do if v.SetTexture then v:Hide() end if v.SetTextColor then v:SetTextColor(.2,1,.8) end - if v.SetBackdrop then pfUI.utils:CreateBackdrop(v) end + if v.SetBackdrop then pfUI.api:CreateBackdrop(v) end end end @@ -609,7 +609,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui.deco:ClearAllPoints() pfUI.gui.deco:SetPoint("TOPLEFT", pfUI.gui, "TOPLEFT", 4*default_border + 100,-2*default_border) pfUI.gui.deco:SetPoint("BOTTOMRIGHT", pfUI.gui, "BOTTOMRIGHT", -2*default_border,2*default_border) - pfUI.utils:CreateBackdrop(pfUI.gui.deco, nil, nil, true) + pfUI.api:CreateBackdrop(pfUI.gui.deco, nil, nil, true) pfUI.gui.deco.up = CreateFrame("Frame", nil, pfUI.gui.deco) pfUI.gui.deco.up:SetPoint("TOPLEFT", pfUI.gui.deco, "TOPLEFT", 0,0) @@ -730,9 +730,9 @@ pfUI:RegisterModule("gui", function () -- load profile pfUI.gui:CreateConfig(pfUI.gui.global, "Load profile", pfUI_config.global, "profile", "button", function() if pfUI_config.global.profile and pfUI_profiles[pfUI_config.global.profile] then - pfUI.utils:CreateQuestionDialog("Load profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() + pfUI.api:CreateQuestionDialog("Load profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() local selp = pfUI_config.global.profile - pfUI_config = CopyTable(pfUI_profiles[pfUI_config.global.profile]) + pfUI_config = pfUI.api.CopyTable(pfUI_profiles[pfUI_config.global.profile]) pfUI_config.global.profile = selp ReloadUI() end) @@ -742,7 +742,7 @@ pfUI:RegisterModule("gui", function () -- delete profile pfUI.gui:CreateConfig(pfUI.gui.global, "Delete profile", pfUI_config.global, "profile", "button", function() if pfUI_config.global.profile and pfUI_profiles[pfUI_config.global.profile] then - pfUI.utils:CreateQuestionDialog("Delete profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() + pfUI.api:CreateQuestionDialog("Delete profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() pfUI_profiles[pfUI_config.global.profile] = nil pfUpdateProfiles() this:GetParent():Hide() @@ -753,9 +753,9 @@ pfUI:RegisterModule("gui", function () -- save profile pfUI.gui:CreateConfig(pfUI.gui.global, "Save profile", pfUI_config.global, "profile", "button", function() if pfUI_config.global.profile and pfUI_profiles[pfUI_config.global.profile] then - pfUI.utils:CreateQuestionDialog("Save current settings to profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() + pfUI.api:CreateQuestionDialog("Save current settings to profile '|cff33ffcc" .. pfUI_config.global.profile .. "|r'?", function() if pfUI_profiles[pfUI_config.global.profile] then - pfUI_profiles[pfUI_config.global.profile] = CopyTable(pfUI_config) + pfUI_profiles[pfUI_config.global.profile] = pfUI.api.CopyTable(pfUI_config) end this:GetParent():Hide() end) @@ -764,7 +764,7 @@ pfUI:RegisterModule("gui", function () -- create profile pfUI.gui:CreateConfig(pfUI.gui.global, "Create Profile", pfUI_config.global, "profile", "button", function() - pfUI.utils:CreateQuestionDialog("Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten.", + pfUI.api:CreateQuestionDialog("Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten.", function() local profile = this:GetParent().input:GetText() local bad = string.gsub(profile,"([%w%s]+)","") @@ -773,7 +773,7 @@ pfUI:RegisterModule("gui", function () else profile = (string.gsub(profile,"^%s*(.-)%s*$", "%1")) if profile and profile ~= "" then - pfUI_profiles[profile] = CopyTable(pfUI_config) + pfUI_profiles[profile] = pfUI.api.CopyTable(pfUI_config) pfUpdateProfiles() this:GetParent():Hide() end diff --git a/modules/loot.lua b/modules/loot.lua index db6c223c..ea2d179d 100644 --- a/modules/loot.lua +++ b/modules/loot.lua @@ -73,9 +73,9 @@ pfUI:RegisterModule("loot", function () local color = ITEM_QUALITY_COLORS[maxrarity] if maxrarity <= 1 then - pfUI.utils:CreateBackdrop(pfUI.loot) + pfUI.api:CreateBackdrop(pfUI.loot) else - pfUI.utils:CreateBackdrop(pfUI.loot) + pfUI.api:CreateBackdrop(pfUI.loot) pfUI.loot.backdrop:SetBackdropBorderColor(color.r, color.g, color.b, 1) end pfUI.loot:SetHeight(math.max((real*22)+4*pfUI_config.appearance.border.default), 20) @@ -137,7 +137,7 @@ pfUI:RegisterModule("loot", function () frame.ficon:SetWidth(frame:GetHeight() - 2*pfUI_config.appearance.border.default) frame.ficon:ClearAllPoints() frame.ficon:SetPoint("RIGHT", frame) - pfUI.utils:CreateBackdrop(frame.ficon) + pfUI.api:CreateBackdrop(frame.ficon) frame.icon = frame.ficon:CreateTexture(nil, "ARTWORK") frame.icon:SetTexCoord(.07, .93, .07, .93) diff --git a/modules/minimap.lua b/modules/minimap.lua index 0a2229ce..d805b0a9 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -15,9 +15,9 @@ pfUI:RegisterModule("minimap", function () end) pfUI.minimap = CreateFrame("Frame","pfMinimap",UIParent) - pfUI.utils:CreateBackdrop(pfUI.minimap) + pfUI.api:CreateBackdrop(pfUI.minimap) pfUI.minimap:SetPoint("TOPRIGHT", UIParent, -5, -5) - pfUI.utils:UpdateMovable(pfUI.minimap) + pfUI.api:UpdateMovable(pfUI.minimap) pfUI.minimap:SetWidth(140) pfUI.minimap:SetHeight(140) pfUI.minimap:SetFrameStrata("BACKGROUND") diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 316702bf..259c41c8 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -279,7 +279,7 @@ pfUI:RegisterModule("nameplates", function () else healthbar.castbar:SetMinMaxValues(0, pfUI.castbar.target.casterDB[name:GetText()]["casttime"]) healthbar.castbar:SetValue(GetTime() - pfUI.castbar.target.casterDB[name:GetText()]["starttime"]) - healthbar.castbar.text:SetText(round( pfUI.castbar.target.casterDB[name:GetText()]["starttime"] + pfUI.castbar.target.casterDB[name:GetText()]["casttime"] - GetTime(),1)) + healthbar.castbar.text:SetText(pfUI.api.round( pfUI.castbar.target.casterDB[name:GetText()]["starttime"] + pfUI.castbar.target.casterDB[name:GetText()]["casttime"] - GetTime(),1)) if healthbar.castbar.spell then if pfUI_config.nameplates.spellname == "1" then healthbar.castbar.spell:SetText(pfUI.castbar.target.casterDB[name:GetText()]["cast"]) diff --git a/modules/panel.lua b/modules/panel.lua index a2e4918a..92c5e1f8 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -51,7 +51,7 @@ pfUI:RegisterModule("panel", function () pfUI.panel.clock.timerFrame:SetWidth(120) pfUI.panel.clock.timerFrame:SetHeight(35) pfUI.panel.clock.timerFrame:SetPoint("TOP", 0, -100) - pfUI.utils:UpdateMovable(pfUI.panel.clock.timerFrame) + pfUI.api:UpdateMovable(pfUI.panel.clock.timerFrame) pfUI.panel.clock.timerFrame.text = pfUI.panel.clock.timerFrame:CreateFontString("Status", "LOW", "GameFontNormal") pfUI.panel.clock.timerFrame.text:SetFontObject(GameFontWhite) @@ -115,13 +115,13 @@ pfUI:RegisterModule("panel", function () GameTooltip:AddDoubleLine("Active Addons", "|cffffffff" .. active .. "|cff555555 / |cffffffff" .. GetNumAddOns()) GameTooltip:AddLine(" ") local nin, nout, nping = GetNetStats() - GameTooltip:AddDoubleLine("Network Down", "|cffffffff" .. round(nin,1) .. "KB/s") - GameTooltip:AddDoubleLine("Network Up", "|cffffffff" .. round(nout,1) .. "KB/s") + GameTooltip:AddDoubleLine("Network Down", "|cffffffff" .. pfUI.api.round(nin,1) .. "KB/s") + GameTooltip:AddDoubleLine("Network Up", "|cffffffff" .. pfUI.api.round(nout,1) .. "KB/s") GameTooltip:AddDoubleLine("Network Latency", "|cffffffff" .. nping .. "ms") GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine("Graphic Renderer", "|cffffffff" .. GetCVar("gxApi")) GameTooltip:AddDoubleLine("Screen Resolution", "|cffffffff" .. GetCVar("gxResolution")) - GameTooltip:AddDoubleLine("UI-Scale", "|cffffffff" .. round(UIParent:GetEffectiveScale(),2)) + GameTooltip:AddDoubleLine("UI-Scale", "|cffffffff" .. pfUI.api.round(UIParent:GetEffectiveScale(),2)) GameTooltip:Show() end @@ -301,7 +301,7 @@ pfUI:RegisterModule("panel", function () GameTooltip_SetDefaultAnchor(GameTooltip, this) GameTooltip:AddLine("|cffffffff" .. real) GameTooltip:AddLine(sub) - GameTooltip:AddLine("|cffaaaaaa" .. round(posX*100,1) .. " / " .. round(posY*100,1)) + GameTooltip:AddLine("|cffaaaaaa" .. pfUI.api.round(posX*100,1) .. " / " .. pfUI.api.round(posY*100,1)) GameTooltip:Show() end @@ -366,14 +366,14 @@ pfUI:RegisterModule("panel", function () end pfUI.panel.left:SetHeight(pfUI_config.global.font_size+default_border*2) - pfUI.utils:CreateBackdrop(pfUI.panel.left, default_border, nil, true) + pfUI.api:CreateBackdrop(pfUI.panel.left, default_border, nil, true) pfUI.panel.left.hide = CreateFrame("Button", nil, pfUI.panel.left) pfUI.panel.left.hide:ClearAllPoints() pfUI.panel.left.hide:SetWidth(12) pfUI.panel.left.hide:SetHeight(pfUI.panel.left:GetHeight()) pfUI.panel.left.hide:SetPoint("LEFT", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.panel.left.hide, default_border) + pfUI.api:CreateBackdrop(pfUI.panel.left.hide, default_border) pfUI.panel.left.hide.texture = pfUI.panel.left.hide:CreateTexture("pfPanelLeftHide") pfUI.panel.left.hide.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\left") pfUI.panel.left.hide.texture:ClearAllPoints() @@ -432,14 +432,14 @@ pfUI:RegisterModule("panel", function () pfUI.panel.right:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 5) end pfUI.panel.right:SetHeight(pfUI_config.global.font_size+default_border*2) - pfUI.utils:CreateBackdrop(pfUI.panel.right, default_border, nil, true) + pfUI.api:CreateBackdrop(pfUI.panel.right, default_border, nil, true) pfUI.panel.right.hide = CreateFrame("Button", nil, pfUI.panel.right) pfUI.panel.right.hide:ClearAllPoints() pfUI.panel.right.hide:SetWidth(12) pfUI.panel.right.hide:SetHeight(pfUI.panel.right:GetHeight()) pfUI.panel.right.hide:SetPoint("RIGHT", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.panel.right.hide, default_border) + pfUI.api:CreateBackdrop(pfUI.panel.right.hide, default_border) pfUI.panel.right.hide.texture = pfUI.panel.right.hide:CreateTexture("pfPanelRightHide") pfUI.panel.right.hide.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\right") pfUI.panel.right.hide.texture:ClearAllPoints() @@ -487,8 +487,8 @@ pfUI:RegisterModule("panel", function () pfUI.panel.right.right.text:SetFontObject(GameFontWhite) pfUI.panel.minimap = CreateFrame("Button", "pfPanelMinimap", UIParent) - pfUI.utils:CreateBackdrop(pfUI.panel.minimap, default_border) - pfUI.utils:UpdateMovable(pfUI.panel.minimap) + pfUI.api:CreateBackdrop(pfUI.panel.minimap, default_border) + pfUI.api:UpdateMovable(pfUI.panel.minimap) pfUI.panel.minimap:SetHeight(pfUI_config.global.font_size+default_border*2) if pfUI.minimap then pfUI.panel.minimap:SetPoint("TOP", pfUI.minimap, "BOTTOM", 0 , -default_border*3) @@ -507,7 +507,7 @@ pfUI:RegisterModule("panel", function () if pfUI_config.panel.micro.enable == "1" then pfUI.panel.microbutton = CreateFrame("Frame", "pfPanelMicroButton", UIParent) pfUI.panel.microbutton:SetPoint("TOP", 0, 0) - pfUI.utils:UpdateMovable(pfUI.panel.microbutton) + pfUI.api:UpdateMovable(pfUI.panel.microbutton) pfUI.panel.microbutton:SetHeight(23) pfUI.panel.microbutton:SetWidth(145) pfUI.panel.microbutton:SetFrameStrata("BACKGROUND") @@ -534,7 +534,7 @@ pfUI:RegisterModule("panel", function () button.frame:SetScale(1.4) button.frame:SetPoint("TOPLEFT", button, "TOPLEFT", 1, -16) button.frame:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -1, 1) - pfUI.utils:CreateBackdrop(button.frame, default_border) + pfUI.api:CreateBackdrop(button.frame, default_border) button:Show() end end diff --git a/modules/pet.lua b/modules/pet.lua index 4f1d118c..f5fbdb2d 100644 --- a/modules/pet.lua +++ b/modules/pet.lua @@ -15,7 +15,7 @@ pfUI:RegisterModule("pet", function () pfUI.uf.pet:SetHeight(20 + 2*default_border + pfUI_config.unitframes.pet.pspace) pfUI.uf.pet:ClearAllPoints() pfUI.uf.pet:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 163) - pfUI.utils:UpdateMovable(pfUI.uf.pet) + pfUI.api:UpdateMovable(pfUI.uf.pet) pfUI.uf.pet:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.pet:SetScript("OnEnter", function() @@ -140,7 +140,7 @@ pfUI:RegisterModule("pet", function () pfUI.uf.pet.hp:SetWidth(100) pfUI.uf.pet.hp:SetHeight(17) pfUI.uf.pet.hp:SetPoint("TOP", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.uf.pet.hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.pet.hp, default_border) pfUI.uf.pet.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.pet.hp) pfUI.uf.pet.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -162,7 +162,7 @@ pfUI:RegisterModule("pet", function () pfUI.uf.pet.power:SetPoint("BOTTOM", 0, 0) pfUI.uf.pet.power:SetWidth(100) pfUI.uf.pet.power:SetHeight(3) - pfUI.utils:CreateBackdrop(pfUI.uf.pet.power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.pet.power, default_border) pfUI.uf.pet.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.pet.power) pfUI.uf.pet.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -225,7 +225,7 @@ pfUI:RegisterModule("pet", function () local buffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 for i=1, 16 do local texture, stacks = UnitBuff("pet",i) - pfUI.utils:CreateBackdrop(pfUI.uf.pet.buff.buffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.pet.buff.buffs[i], default_border) pfUI.uf.pet.buff.buffs[i]:SetNormalTexture(texture) for i,v in ipairs({pfUI.uf.pet.buff.buffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end @@ -299,7 +299,7 @@ pfUI:RegisterModule("pet", function () (row)*((2*default_border) + buffsize + 1) + (2*default_border + 1)) local texture, stacks = UnitDebuff("pet",i) - pfUI.utils:CreateBackdrop(pfUI.uf.pet.debuff.debuffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.pet.debuff.debuffs[i], default_border) pfUI.uf.pet.debuff.debuffs[i]:SetNormalTexture(texture) for i,v in ipairs({pfUI.uf.pet.debuff.debuffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end diff --git a/modules/player.lua b/modules/player.lua index a1bbd4f7..c5706e9e 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -17,7 +17,7 @@ pfUI:RegisterModule("player", function () pfUI.uf.player:SetWidth(pfUI_config.unitframes.player.width) pfUI.uf.player:SetHeight(pfUI_config.unitframes.player.height + pfUI_config.unitframes.player.pheight + 2*default_border + pfUI_config.unitframes.player.pspace) pfUI.uf.player:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", -75, 125) - pfUI.utils:UpdateMovable(pfUI.uf.player) + pfUI.api:UpdateMovable(pfUI.uf.player) pfUI.uf.player:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.player:SetScript("OnEnter", function() GameTooltip_SetDefaultAnchor(GameTooltip, this) @@ -246,7 +246,7 @@ pfUI:RegisterModule("player", function () pfUI.uf.player.hp:SetPoint("TOP", 0, 0) pfUI.uf.player.hp:SetWidth(pfUI_config.unitframes.player.width) pfUI.uf.player.hp:SetHeight(pfUI_config.unitframes.player.height) - pfUI.utils:CreateBackdrop(pfUI.uf.player.hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.player.hp, default_border) pfUI.uf.player.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.player.hp) pfUI.uf.player.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -300,7 +300,7 @@ pfUI:RegisterModule("player", function () pfUI.uf.player.power:SetPoint("BOTTOM", 0, 0) pfUI.uf.player.power:SetWidth(pfUI_config.unitframes.player.width) pfUI.uf.player.power:SetHeight(pfUI_config.unitframes.player.pheight) - pfUI.utils:CreateBackdrop(pfUI.uf.player.power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.player.power, default_border) pfUI.uf.player.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.player.power) pfUI.uf.player.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -338,7 +338,7 @@ pfUI:RegisterModule("player", function () this.energy = UnitMana("player") - local value = round((GetTime() - this.lastTick) * 100) + local value = pfUI.api.round((GetTime() - this.lastTick) * 100) local pos = pfUI_config.unitframes.player.width / 200 * value this.spark:SetPoint("LEFT", pos-((pfUI_config.unitframes.player.pheight+5)/2), 0) end) @@ -458,7 +458,7 @@ pfUI:RegisterModule("player", function () function pfUI.uf.player.buff.RefreshBuffs() for i=1, 16 do local stacks = GetPlayerBuffApplications(GetPlayerBuff(i-1,"HELPFUL")) - pfUI.utils:CreateBackdrop(pfUI.uf.player.buff.buffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.player.buff.buffs[i], default_border) pfUI.uf.player.buff.buffs[i]:SetNormalTexture(GetPlayerBuffTexture(GetPlayerBuff(i-1,"HELPFUL"))) for i,v in ipairs({pfUI.uf.player.buff.buffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end @@ -582,7 +582,7 @@ pfUI:RegisterModule("player", function () local bid = GetPlayerBuff(i-1, "HARMFUL"); local stacks = GetPlayerBuffApplications(bid) - pfUI.utils:CreateBackdrop(pfUI.uf.player.debuff.debuffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.player.debuff.debuffs[i], default_border) pfUI.uf.player.debuff.debuffs[i]:SetNormalTexture(GetPlayerBuffTexture(bid)) for i,v in ipairs({pfUI.uf.player.debuff.debuffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end diff --git a/modules/raid.lua b/modules/raid.lua index 6ae1f70d..11a53167 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -44,7 +44,7 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i]:SetWidth(50) pfUI.uf.raid[i]:SetHeight(30 + 2*default_border + pfUI_config.unitframes.raid.pspace) pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1) * (54+default_border) + 5, pfUI_config.chat.left.height + 10 + ((g-1)*(37+default_border))+default_border) - pfUI.utils:UpdateMovable(pfUI.uf.raid[i]) + pfUI.api:UpdateMovable(pfUI.uf.raid[i]) pfUI.uf.raid[i]:Hide() pfUI.uf.raid[i].id = 0 @@ -52,7 +52,7 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i].hp:SetPoint("TOP", 0, 0) pfUI.uf.raid[i].hp:SetWidth(50) pfUI.uf.raid[i].hp:SetHeight(27) - pfUI.utils:CreateBackdrop(pfUI.uf.raid[i].hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.raid[i].hp, default_border) pfUI.uf.raid[i].hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.raid[i].hp) pfUI.uf.raid[i].hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -63,7 +63,7 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i].power:SetPoint("BOTTOM", 0, 0) pfUI.uf.raid[i].power:SetWidth(50) pfUI.uf.raid[i].power:SetHeight(3) - pfUI.utils:CreateBackdrop(pfUI.uf.raid[i].power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.raid[i].power, default_border) pfUI.uf.raid[i].power.bar = CreateFrame("StatusBar", nil, pfUI.uf.raid[i].power) pfUI.uf.raid[i].power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") diff --git a/modules/sellvalue.lua b/modules/sellvalue.lua index 25b4126e..da43fff3 100644 --- a/modules/sellvalue.lua +++ b/modules/sellvalue.lua @@ -26,15 +26,15 @@ pfUI:RegisterModule("sellvalue", function () GameTooltip:AddLine(" ") if count > 1 then - GameTooltip:AddDoubleLine("Sell:", CreateGoldString(sell) .. "|cff555555 // " .. CreateGoldString(sell*count), 1, 1, 1); + GameTooltip:AddDoubleLine("Sell:", pfUI.api.CreateGoldString(sell) .. "|cff555555 // " .. pfUI.api.CreateGoldString(sell*count), 1, 1, 1); else - GameTooltip:AddDoubleLine("Sell:", CreateGoldString(sell * count), 1, 1, 1); + GameTooltip:AddDoubleLine("Sell:", pfUI.api.CreateGoldString(sell * count), 1, 1, 1); end if count > 1 then - GameTooltip:AddDoubleLine("Buy:", CreateGoldString(buy) .. "|cff555555 // " .. CreateGoldString(buy*count), 1, 1, 1); + GameTooltip:AddDoubleLine("Buy:", pfUI.api.CreateGoldString(buy) .. "|cff555555 // " .. pfUI.api.CreateGoldString(buy*count), 1, 1, 1); else - GameTooltip:AddDoubleLine("Buy:", CreateGoldString(buy), 1, 1, 1); + GameTooltip:AddDoubleLine("Buy:", pfUI.api.CreateGoldString(buy), 1, 1, 1); end end GameTooltip:Show() diff --git a/modules/skin.lua b/modules/skin.lua index c651fbcc..8a3cc2d4 100644 --- a/modules/skin.lua +++ b/modules/skin.lua @@ -46,12 +46,12 @@ pfUI:RegisterModule("skin", function () GameMenuButtonContinue:SetPoint("BOTTOM", 0, 10) for _, button in pairs(buttons) do - pfUI.utils:SkinButton(button, cr, cg, cb) + pfUI.api:SkinButton(button, cr, cg, cb) end for _, box in pairs(boxes) do local b = getglobal(box) - pfUI.utils:CreateBackdrop(b, nil, true, true) + pfUI.api:CreateBackdrop(b, nil, true, true) end for i,v in ipairs({GameMenuFrame:GetRegions()}) do @@ -62,8 +62,8 @@ pfUI:RegisterModule("skin", function () end end -pfUI.utils:CreateBackdrop(ShoppingTooltip1) -pfUI.utils:CreateBackdrop(ShoppingTooltip2) +pfUI.api:CreateBackdrop(ShoppingTooltip1) +pfUI.api:CreateBackdrop(ShoppingTooltip2) ShoppingTooltip1:SetScript("OnShow", function() local a, b, c, d, e = this:GetPoint() @@ -79,7 +79,7 @@ ShoppingTooltip2:SetScript("OnShow", function() this:SetPoint(a, b, c, d, e) end) -pfUI.utils:CreateBackdrop(TicketStatusFrame) +pfUI.api:CreateBackdrop(TicketStatusFrame) TicketStatusFrame:ClearAllPoints() TicketStatusFrame:SetPoint("TOP", 0, -5) function TicketStatusFrame_OnEvent() diff --git a/modules/target.lua b/modules/target.lua index 810dbc33..e27df58d 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -23,7 +23,7 @@ pfUI:RegisterModule("target", function () pfUI.uf.target:SetWidth(pfUI_config.unitframes.target.width) pfUI.uf.target:SetHeight(pfUI_config.unitframes.target.height + pfUI_config.unitframes.target.pheight + 2*default_border + pfUI_config.unitframes.target.pspace) pfUI.uf.target:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 75, 125) - pfUI.utils:UpdateMovable(pfUI.uf.target) + pfUI.api:UpdateMovable(pfUI.uf.target) pfUI.uf.target:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.target:SetScript("OnEnter", function() GameTooltip_SetDefaultAnchor(GameTooltip, this) @@ -271,7 +271,7 @@ pfUI:RegisterModule("target", function () pfUI.uf.target.hp:SetWidth(pfUI_config.unitframes.target.width) pfUI.uf.target.hp:SetHeight(pfUI_config.unitframes.target.height) pfUI.uf.target.hp:SetPoint("TOP", 0, 0) - pfUI.utils:CreateBackdrop(pfUI.uf.target.hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.target.hp, default_border) pfUI.uf.target.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.target.hp) pfUI.uf.target.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -328,7 +328,7 @@ pfUI:RegisterModule("target", function () pfUI.uf.target.power:SetPoint("BOTTOM", 0, 0) pfUI.uf.target.power:SetWidth(pfUI_config.unitframes.target.width) pfUI.uf.target.power:SetHeight(pfUI_config.unitframes.target.pheight) - pfUI.utils:CreateBackdrop(pfUI.uf.target.power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.target.power, default_border) pfUI.uf.target.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.target.power) pfUI.uf.target.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -376,7 +376,7 @@ pfUI:RegisterModule("target", function () pfUI.uf.target["combopoint" .. point]:SetFrameStrata("HIGH") pfUI.uf.target["combopoint" .. point]:SetWidth(5) pfUI.uf.target["combopoint" .. point]:SetHeight(5) - pfUI.utils:CreateBackdrop(pfUI.uf.target["combopoint" .. point]) + pfUI.api:CreateBackdrop(pfUI.uf.target["combopoint" .. point]) pfUI.uf.target["combopoint" .. point]:SetPoint("TOPLEFT", pfUI.uf.target, "TOPRIGHT", pfUI_config.appearance.border.default*3, -(point - 1) * (5 + pfUI_config.appearance.border.default*3)) if point < 3 then local tex = pfUI.uf.target["combopoint" .. point]:CreateTexture("OVERLAY") @@ -470,7 +470,7 @@ pfUI:RegisterModule("target", function () function pfUI.uf.target.buff.RefreshBuffs() for i=1, 16 do local texture, stacks = UnitBuff("target",i) - pfUI.utils:CreateBackdrop(pfUI.uf.target.buff.buffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.target.buff.buffs[i], default_border) pfUI.uf.target.buff.buffs[i]:SetNormalTexture(texture) for i,v in ipairs({pfUI.uf.target.buff.buffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end @@ -560,7 +560,7 @@ pfUI:RegisterModule("target", function () invert * (row)*((2*default_border) + pfUI_config.unitframes.debuff_size + 1) + invert * (2*default_border + 1)) local texture, stacks = UnitDebuff("target",i) - pfUI.utils:CreateBackdrop(pfUI.uf.target.debuff.debuffs[i], default_border) + pfUI.api:CreateBackdrop(pfUI.uf.target.debuff.debuffs[i], default_border) pfUI.uf.target.debuff.debuffs[i]:SetNormalTexture(texture) for i,v in ipairs({pfUI.uf.target.debuff.debuffs[i]:GetRegions()}) do if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end diff --git a/modules/targettarget.lua b/modules/targettarget.lua index c1f361c1..c35b923f 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -23,7 +23,7 @@ pfUI:RegisterModule("targettarget", function () pfUI.uf.targettarget:SetWidth(100) pfUI.uf.targettarget:SetHeight(20 + 2*default_border + pfUI_config.unitframes.ttarget.pspace) pfUI.uf.targettarget:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 125) - pfUI.utils:UpdateMovable(pfUI.uf.targettarget) + pfUI.api:UpdateMovable(pfUI.uf.targettarget) pfUI.uf.targettarget:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.targettarget:SetScript("OnEnter", function() @@ -160,7 +160,7 @@ pfUI:RegisterModule("targettarget", function () pfUI.uf.targettarget.hp:SetPoint("TOP", 0, 0) pfUI.uf.targettarget.hp:SetWidth(100) pfUI.uf.targettarget.hp:SetHeight(17) - pfUI.utils:CreateBackdrop(pfUI.uf.targettarget.hp, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.targettarget.hp, default_border) pfUI.uf.targettarget.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.targettarget.hp) pfUI.uf.targettarget.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -197,7 +197,7 @@ pfUI:RegisterModule("targettarget", function () end pfUI.uf.targettarget.power = CreateFrame("Frame",nil, pfUI.uf.targettarget) - pfUI.utils:CreateBackdrop(pfUI.uf.targettarget.power, default_border) + pfUI.api:CreateBackdrop(pfUI.uf.targettarget.power, default_border) pfUI.uf.targettarget.power:SetPoint("BOTTOM", 0, 0) pfUI.uf.targettarget.power:SetWidth(100) pfUI.uf.targettarget.power:SetHeight(4) diff --git a/modules/thirdparty.lua b/modules/thirdparty.lua index ad152231..9969056f 100644 --- a/modules/thirdparty.lua +++ b/modules/thirdparty.lua @@ -86,7 +86,7 @@ pfUI:RegisterModule("thirdparty", function () pfUIhookWIM_PostMessage = WIM_PostMessage WIM_PostMessage = function(user, msg, ttype, from, raw_msg) pfUIhookWIM_PostMessage(user, msg, ttype, from, raw_msg) - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user)) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user)) getglobal("WIM_msgFrame" .. user .. "From"):ClearAllPoints() getglobal("WIM_msgFrame" .. user .. "From"):SetPoint("TOP", 0, -10) @@ -104,7 +104,7 @@ pfUI:RegisterModule("thirdparty", function () getglobal("WIM_msgFrame" .. user .. "ScrollingMessageFrame"):SetPoint("BOTTOMRIGHT", getglobal("WIM_msgFrame" .. user), "BOTTOMRIGHT", -32, 32) getglobal("WIM_msgFrame" .. user .. "ScrollingMessageFrame"):SetFont(STANDARD_TEXT_FONT, 12) - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "MsgBox")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "MsgBox")) getglobal("WIM_msgFrame" .. user .. "MsgBox"):ClearAllPoints() getglobal("WIM_msgFrame" .. user .. "MsgBox"):SetPoint("TOPLEFT", getglobal("WIM_msgFrame" .. user .. "ScrollingMessageFrame"), "BOTTOMLEFT", 0, -5) getglobal("WIM_msgFrame" .. user .. "MsgBox"):SetPoint("TOPRIGHT", getglobal("WIM_msgFrame" .. user .. "ScrollingMessageFrame"), "BOTTOMRIGHT", 0, -5) @@ -114,27 +114,27 @@ pfUI:RegisterModule("thirdparty", function () if i==6 then v:SetTexture(.1,.1,.1,.5) end end - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton1")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton1")) for i,v in ipairs({getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton1"):GetRegions()}) do if i >= 2 and i < 7 then v:SetTexture(.1,.1,.1,0) end end - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton2")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton2")) for i,v in ipairs({getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton2"):GetRegions()}) do if i >= 2 and i < 7 then v:SetTexture(.1,.1,.1,0) end end - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton3")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton3")) for i,v in ipairs({getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton3"):GetRegions()}) do if i >= 2 and i < 7 then v:SetTexture(.1,.1,.1,0) end end - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton4")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton4")) for i,v in ipairs({getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton4"):GetRegions()}) do if i >= 2 and i < 7 then v:SetTexture(.1,.1,.1,0) end end - pfUI.utils:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton5")) + pfUI.api:CreateBackdrop(getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton5")) for i,v in ipairs({getglobal("WIM_msgFrame" .. user .. "ShortcutFrameButton5"):GetRegions()}) do if i >= 2 and i < 7 then v:SetTexture(.1,.1,.1,0) end end @@ -311,7 +311,7 @@ pfUI:RegisterModule("thirdparty", function () pfUI.bag.right.sort:SetPoint("TOPRIGHT", -pfUI_config.appearance.border.default*14 - 45, -pfUI_config.appearance.border.default) pfUI.bag.right.sort:SetPoint("TOPRIGHT", pfUI.bag.right.keys, "TOPLEFT", -pfUI_config.appearance.border.default*3, 0) - pfUI.utils:CreateBackdrop(pfUI.bag.right.sort) + pfUI.api:CreateBackdrop(pfUI.bag.right.sort) pfUI.bag.right.sort:SetHeight(12) pfUI.bag.right.sort:SetWidth(12) pfUI.bag.right.sort:SetTextColor(1,1,.25,1) @@ -329,7 +329,7 @@ pfUI:RegisterModule("thirdparty", function () end) pfUI.bag.right.sort:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(pfUI.bag.right.sort) + pfUI.api:CreateBackdrop(pfUI.bag.right.sort) pfUI.bag.right.sort.texture:SetVertexColor(.25,.25,.25,1) end) @@ -349,7 +349,7 @@ pfUI:RegisterModule("thirdparty", function () pfUI.bag.left.sort:SetPoint("TOPRIGHT", -pfUI_config.appearance.border.default*14 - 45, -pfUI_config.appearance.border.default) pfUI.bag.left.sort:SetPoint("TOPRIGHT", pfUI.bag.left.bags, "TOPLEFT", -pfUI_config.appearance.border.default*3, 0) - pfUI.utils:CreateBackdrop(pfUI.bag.left.sort) + pfUI.api:CreateBackdrop(pfUI.bag.left.sort) pfUI.bag.left.sort:SetHeight(12) pfUI.bag.left.sort:SetWidth(12) pfUI.bag.left.sort:SetTextColor(1,1,.25,1) @@ -367,7 +367,7 @@ pfUI:RegisterModule("thirdparty", function () end) pfUI.bag.left.sort:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(pfUI.bag.left.sort) + pfUI.api:CreateBackdrop(pfUI.bag.left.sort) pfUI.bag.left.sort.texture:SetVertexColor(.25,.25,.25,1) end) diff --git a/modules/tooltip.lua b/modules/tooltip.lua index 104aeaa4..4282eb2f 100644 --- a/modules/tooltip.lua +++ b/modules/tooltip.lua @@ -1,5 +1,5 @@ pfUI:RegisterModule("tooltip", function () -pfUI.utils:CreateBackdrop(GameTooltip) +pfUI.api:CreateBackdrop(GameTooltip) if pfUI_config.tooltip.position == "cursor" then function GameTooltip_SetDefaultAnchor(tooltip, parent) @@ -61,8 +61,8 @@ pfUI.utils:CreateBackdrop(GameTooltip) _, hpm = GameTooltipStatusBar:GetMinMaxValues() if hp and hpm then - if hp >= 1000 then hp = round(hp / 1000, 1) .. "k" end - if hpm >= 1000 then hpm = round(hpm / 1000, 1) .. "k" end + if hp >= 1000 then hp = pfUI.api.round(hp / 1000, 1) .. "k" end + if hpm >= 1000 then hpm = pfUI.api.round(hpm / 1000, 1) .. "k" end pfUI.tooltipStatusBar.HP:SetText(hp .. " / " .. hpm) end end) @@ -72,7 +72,7 @@ pfUI.utils:CreateBackdrop(GameTooltip) GameTooltipStatusBar:SetPoint("BOTTOMLEFT", GameTooltip, "TOPLEFT", 0, 0) GameTooltipStatusBar:SetPoint("BOTTOMRIGHT", GameTooltip, "TOPRIGHT", 0, 0) GameTooltipStatusBar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.utils:CreateBackdrop(GameTooltipStatusBar) + pfUI.api:CreateBackdrop(GameTooltipStatusBar) GameTooltipStatusBar.SetStatusBarColor_orig = GameTooltipStatusBar.SetStatusBarColor GameTooltipStatusBar.SetStatusBarColor = function() return end @@ -132,8 +132,8 @@ pfUI.utils:CreateBackdrop(GameTooltip) end if hp and hpm then - if hp >= 1000 then hp = round(hp / 1000, 1) .. "k" end - if hpm >= 1000 then hpm = round(hpm / 1000, 1) .. "k" end + if hp >= 1000 then hp = pfUI.api.round(hp / 1000, 1) .. "k" end + if hpm >= 1000 then hpm = pfUI.api.round(hpm / 1000, 1) .. "k" end pfUI.tooltipStatusBar.HP:SetText(hp .. " / " .. hpm) end GameTooltip:Show() diff --git a/modules/uf_tukui.lua b/modules/uf_tukui.lua index 5a08f748..5b4d152b 100644 --- a/modules/uf_tukui.lua +++ b/modules/uf_tukui.lua @@ -4,7 +4,7 @@ pfUI:RegisterModule("uf_tukui", function () if pfUI_config.unitframes.layout == "tukui" then pfUI.uf.player.caption = CreateFrame("Frame",nil, pfUI.uf.player) -pfUI.utils:CreateBackdrop( pfUI.uf.player.caption) +pfUI.api:CreateBackdrop( pfUI.uf.player.caption) pfUI.uf.player.caption:SetHeight(pfUI_config.global.font_size * 2) pfUI.uf.player.caption:SetPoint("TOPRIGHT",pfUI.uf.player,"BOTTOMRIGHT",0,-1) pfUI.uf.player.caption:SetPoint("TOPLEFT",pfUI.uf.player,"BOTTOMLEFT",0,-1) @@ -16,7 +16,7 @@ pfUI.utils:CreateBackdrop( pfUI.uf.player.caption) pfUI.uf.player.powerText:SetPoint("LEFT",pfUI.uf.player.caption, "LEFT", 5, 0) pfUI.uf.target.caption = CreateFrame("Frame",nil, pfUI.uf.target) -pfUI.utils:CreateBackdrop( pfUI.uf.target.caption) +pfUI.api:CreateBackdrop( pfUI.uf.target.caption) pfUI.uf.target.caption:SetHeight(pfUI_config.global.font_size * 2) pfUI.uf.target.caption:SetPoint("TOPRIGHT",pfUI.uf.target,"BOTTOMRIGHT",0,-1) pfUI.uf.target.caption:SetPoint("TOPLEFT",pfUI.uf.target,"BOTTOMLEFT",0,-1) diff --git a/modules/unitframes.lua b/modules/unitframes.lua index 2174423e..a70fa79e 100644 --- a/modules/unitframes.lua +++ b/modules/unitframes.lua @@ -22,7 +22,7 @@ function pfUI.uf:AddIcon(frame, pos, icon) end end frame.icon[pos].tex:SetTexture(icon) - pfUI.utils:CreateBackdrop(frame.icon[pos], nil, true) + pfUI.api:CreateBackdrop(frame.icon[pos], nil, true) frame.icon[pos]:Show() end diff --git a/modules/xpbar.lua b/modules/xpbar.lua index 694349ad..dcd8630f 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -9,7 +9,7 @@ pfUI:RegisterModule("xpbar", function () pfUI.xp:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) end pfUI.xp:SetFrameStrata("BACKGROUND") - pfUI.utils:CreateBackdrop(pfUI.xp) + pfUI.api:CreateBackdrop(pfUI.xp) pfUI.xp:RegisterEvent("PLAYER_LEVEL_UP") pfUI.xp:RegisterEvent("PLAYER_XP_UPDATE") pfUI.xp:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -51,12 +51,12 @@ pfUI:RegisterModule("xpbar", function () pfUI.xp.mouseover = true pfUI.xp:SetAlpha(1) local xp, xpmax, exh = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion() - local xp_perc = round(xp / xpmax * 100) + local xp_perc = pfUI.api.round(xp / xpmax * 100) local remaining = xpmax - xp - local remaining_perc = round(remaining / xpmax * 100) + local remaining_perc = pfUI.api.round(remaining / xpmax * 100) local exh_perc = 0 if GetXPExhaustion() then - exh_perc = round(GetXPExhaustion() / xpmax * 100) + exh_perc = pfUI.api.round(GetXPExhaustion() / xpmax * 100) end GameTooltip:ClearLines() @@ -109,7 +109,7 @@ pfUI:RegisterModule("xpbar", function () pfUI.rep:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0) end pfUI.rep:SetFrameStrata("BACKGROUND") - pfUI.utils:CreateBackdrop(pfUI.rep) + pfUI.api:CreateBackdrop(pfUI.rep) pfUI.rep.bar = CreateFrame("StatusBar", nil, pfUI.rep) pfUI.rep.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") @@ -171,7 +171,7 @@ pfUI:RegisterModule("xpbar", function () GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:AddLine("|cff555555Reputation") GameTooltip:AddLine(name .. " (" .. GetText("FACTION_STANDING_LABEL"..standingID, gender) .. ")", color.r + .3, color.g + .3, color.b + .3) - GameTooltip:AddLine(barValue .. " / " .. barMax .. " (" .. round(barValue / barMax * 100) .. "%)",1,1,1) + GameTooltip:AddLine(barValue .. " / " .. barMax .. " (" .. pfUI.api.round(barValue / barMax * 100) .. "%)",1,1,1) GameTooltip:Show() pfUI.rep.mouseover = true diff --git a/pfUI.lua b/pfUI.lua index 97d0bc5d..37f2581e 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -70,8 +70,6 @@ pfUI:SetScript("OnEvent", function() end end end - - end) function pfUI:RegisterModule(n, f) @@ -95,231 +93,6 @@ pfUI.backdrop_underline = { insets = {left = 0, right = 0, top = 0, bottom = 0}, } -pfUI.utils = CreateFrame("Frame",nil,UIParent) - -function pfUI.utils:UpdateMovable(frame) - local name = frame:GetName() - - if not pfUI.movables[name] then - pfUI.movables[name] = true - table.insert(pfUI.movables, name) - end - - if pfUI_config["position"][frame:GetName()] then - if pfUI_config["position"][frame:GetName()]["scale"] then - frame:SetScale(pfUI_config["position"][frame:GetName()].scale) - end - - if pfUI_config["position"][frame:GetName()]["xpos"] then - frame:ClearAllPoints() - frame:SetPoint("TOPLEFT", pfUI_config["position"][frame:GetName()].xpos, pfUI_config["position"][frame:GetName()].ypos) - end - end -end - -function pfUI.utils:CreateBackdrop(f, inset, legacy, transp) - -- use default inset if nothing is given - local border = inset - if not border then - border = tonumber(pfUI_config.appearance.border.default) - end - - -- bg and edge colors - if not pfUI.cache.br then - local br, bg, bb, ba = strsplit(",", pfUI_config.appearance.border.background) - local er, eg, eb, ea = strsplit(",", pfUI_config.appearance.border.color) - pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba = br, bg, bb, ba - pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea = er, eg, eb, ea - end - - local br, bg, bb, ba = pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba - local er, eg, eb, ea = pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea - if transp then ba = .8 end - - -- use legacy backdrop handling - if legacy then - f:SetBackdrop(pfUI.backdrop) - f:SetBackdropColor(br, bg, bb, ba) - f:SetBackdropBorderColor(er, eg, eb , ea) - return - end - - -- increase clickable area if available - if f.SetHitRectInsets then - f:SetHitRectInsets(-border,-border,-border,-border) - end - - -- use new backdrop behaviour - if not f.backdrop then - f:SetBackdrop(nil) - - local border = tonumber(border) - 1 - local backdrop = pfUI.backdrop - if border < 1 then backdrop = pfUI.backdrop_small end - local b = CreateFrame("Frame", nil, f) - b:SetPoint("TOPLEFT", f, "TOPLEFT", -border, border) - b:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", border, -border) - - local level = f:GetFrameLevel() - if level < 1 then - --f:SetFrameLevel(level + 1) - b:SetFrameLevel(level) - else - b:SetFrameLevel(level - 1) - end - - f.backdrop = b - b:SetBackdrop(backdrop) - end - - local b = f.backdrop - b:SetBackdropColor(br, bg, bb, ba) - b:SetBackdropBorderColor(er, eg, eb , ea) -end - - -function pfUI.utils:SkinButton(button, cr, cg, cb) - local b = getglobal(button) - if not b then b = button end - if not cr or not cg or not cb then - _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] - cr, cg, cb = color.r , color.g, color.b - end - pfUI.utils:CreateBackdrop(b, nil, true) - b:SetNormalTexture(nil) - b:SetHighlightTexture(nil) - b:SetPushedTexture(nil) - b:SetDisabledTexture(nil) - b:SetScript("OnEnter", function() - pfUI.utils:CreateBackdrop(b, nil, true) - b:SetBackdropBorderColor(cr,cg,cb,1) - end) - b:SetScript("OnLeave", function() - pfUI.utils:CreateBackdrop(b, nil, true) - end) - b:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") -end - -function pfUI.utils:CreateQuestionDialog(text, yes, no, editbox) - -- do not allow multiple instances of question dialogs - if pfQuestionDialog and pfQuestionDialog:IsShown() then - pfQuestionDialog:Hide() - pfQuestionDialog = nil - return - end - - -- add default values - if not yes then - yes = function() message("You clicked OK") end - end - - if not no then - no = function() this:GetParent():Hide() end - end - - if not text then - text = "Are you sure?" - end - - local border = tonumber(pfUI_config.appearance.border.default) - local padding = 15 - -- frame - local question = CreateFrame("Frame", "pfQuestionDialog", UIParent) - question:SetWidth(300) - question:SetHeight(100) - question:SetPoint("CENTER", 0, 0) - question:SetFrameStrata("TOOLTIP") - question:SetMovable(true) - question:EnableMouse(true) - question:SetScript("OnMouseDown",function() - this:StartMoving() - end) - - question:SetScript("OnMouseUp",function() - this:StopMovingOrSizing() - end) - pfUI.utils:CreateBackdrop(question) - - -- text - question.text = question:CreateFontString("Status", "LOW", "GameFontNormal") - question.text:SetFontObject(GameFontWhite) - question.text:SetPoint("TOP", 0, -padding) - question.text:SetText(text) - question.text:SetWidth(question:GetWidth() - border * 2) - - -- editbox - if editbox then - question.input = CreateFrame("EditBox", "pfQuestionDialogEdit", question) - pfUI.utils:CreateBackdrop(question.input) - question.input:SetTextColor(.2,1,.8,1) - question.input:SetJustifyH("CENTER") - question.input:SetAutoFocus(false) - question.input:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", border, -padding) - question.input:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", -border, -padding) - question.input:SetHeight(20) - - question.input:SetFontObject(GameFontNormal) - question.input:SetScript("OnEscapePressed", function() this:ClearFocus() end) - end - - -- buttons - question.yes = CreateFrame("Button", "pfQuestionDialogYes", question, "UIPanelButtonTemplate") - pfUI.utils:SkinButton(question.yes) - question.yes:SetWidth(100) - question.yes:SetHeight(20) - question.yes:SetText("Okay") - question.yes:SetScript("OnClick", yes) - - if question.input then - question.yes:SetPoint("TOPLEFT", question.input, "BOTTOMLEFT", -border, -padding) - else - question.yes:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", 0, -padding) - end - - question.no = CreateFrame("Button", "pfQuestionDialogNo", question, "UIPanelButtonTemplate") - pfUI.utils:SkinButton(question.no) - question.no:SetWidth(85) - question.no:SetHeight(20) - question.no:SetText("Cancel") - question.no:SetScript("OnClick", no) - - if question.input then - question.no:SetPoint("TOPRIGHT", question.input, "BOTTOMRIGHT", border, -padding) - else - question.no:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", 0, -padding) - end - - question.close = CreateFrame("Button", "pfQuestionDialogClose", question) - question.close:SetPoint("TOPRIGHT", -border, -border) - pfUI.utils:CreateBackdrop(question.close) - question.close:SetHeight(10) - question.close:SetWidth(10) - question.close.texture = question.close:CreateTexture("pfQuestionDialogCloseTex") - question.close.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\close") - question.close.texture:ClearAllPoints() - question.close.texture:SetAllPoints(question.close) - question.close.texture:SetVertexColor(1,.25,.25,1) - question.close:SetScript("OnEnter", function () - this.backdrop:SetBackdropBorderColor(1,.25,.25,1) - end) - - question.close:SetScript("OnLeave", function () - pfUI.utils:CreateBackdrop(this) - end) - - question.close:SetScript("OnClick", function() - this:GetParent():Hide() - end) - - -- resize window - local textspace = question.text:GetHeight() + padding - local inputspace = 0 - if question.input then inputspace = question.input:GetHeight() + padding end - local buttonspace = question.no:GetHeight() + padding - question:SetHeight(textspace + inputspace + buttonspace + border) -end - message = function (msg) DEFAULT_CHAT_FRAME:AddMessage("|cffcccc33INFO: |cffffff55"..msg) end @@ -354,7 +127,7 @@ function pfUI.info:ShowInfoBox(text, time, parent, height) pfUI.info:SetWidth(pfUI.info.text:GetStringWidth() + 50) pfUI.info:SetHeight(height) - pfUI.utils:CreateBackdrop(pfUI.info) + pfUI.api:CreateBackdrop(pfUI.info) pfUI.info:SetPoint("TOP", 0, -25) pfUI.info.timeout:ClearAllPoints() diff --git a/pfUI.toc b/pfUI.toc index a4c8f9e6..c0f7e641 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -17,8 +17,8 @@ env\locales_zhCN.lua env\locales_ruRU.lua # environment +env\api.lua env\colors.lua -env\functions.lua env\fonts.lua env\selldata.lua