Tercio@23: local AceGUI = LibStub("AceGUI-3.0") Tercio@23: Tercio@23: -- Lua APIs Tercio@23: local pairs, assert, type = pairs, assert, type Tercio@23: Tercio@23: -- WoW APIs Tercio@23: local PlaySound = PlaySound Tercio@23: local CreateFrame, UIParent = CreateFrame, UIParent Tercio@23: Tercio@23: -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded Tercio@23: -- List them here for Mikk's FindGlobals script Tercio@23: -- GLOBALS: GameFontNormal Tercio@23: Tercio@23: ---------------- Tercio@23: -- Main Frame -- Tercio@23: ---------------- Tercio@23: --[[ Tercio@23: Events : Tercio@23: OnClose Tercio@23: Tercio@23: ]] Tercio@23: do Tercio@23: local Type = "Window" Tercio@23: local Version = 4 Tercio@23: Tercio@23: local function frameOnClose(this) Tercio@23: this.obj:Fire("OnClose") Tercio@23: end Tercio@23: Tercio@23: local function closeOnClick(this) Tercio@23: PlaySound("gsTitleOptionExit") Tercio@23: this.obj:Hide() Tercio@23: end Tercio@23: Tercio@23: local function frameOnMouseDown(this) Tercio@23: AceGUI:ClearFocus() Tercio@23: end Tercio@23: Tercio@23: local function titleOnMouseDown(this) Tercio@23: this:GetParent():StartMoving() Tercio@23: AceGUI:ClearFocus() Tercio@23: end Tercio@23: Tercio@23: local function frameOnMouseUp(this) Tercio@23: local frame = this:GetParent() Tercio@23: frame:StopMovingOrSizing() Tercio@23: local self = frame.obj Tercio@23: local status = self.status or self.localstatus Tercio@23: status.width = frame:GetWidth() Tercio@23: status.height = frame:GetHeight() Tercio@23: status.top = frame:GetTop() Tercio@23: status.left = frame:GetLeft() Tercio@23: end Tercio@23: Tercio@23: local function sizerseOnMouseDown(this) Tercio@23: this:GetParent():StartSizing("BOTTOMRIGHT") Tercio@23: AceGUI:ClearFocus() Tercio@23: end Tercio@23: Tercio@23: local function sizersOnMouseDown(this) Tercio@23: this:GetParent():StartSizing("BOTTOM") Tercio@23: AceGUI:ClearFocus() Tercio@23: end Tercio@23: Tercio@23: local function sizereOnMouseDown(this) Tercio@23: this:GetParent():StartSizing("RIGHT") Tercio@23: AceGUI:ClearFocus() Tercio@23: end Tercio@23: Tercio@23: local function sizerOnMouseUp(this) Tercio@23: this:GetParent():StopMovingOrSizing() Tercio@23: end Tercio@23: Tercio@23: local function SetTitle(self,title) Tercio@23: self.titletext:SetText(title) Tercio@23: end Tercio@23: Tercio@23: local function SetStatusText(self,text) Tercio@23: -- self.statustext:SetText(text) Tercio@23: end Tercio@23: Tercio@23: local function Hide(self) Tercio@23: self.frame:Hide() Tercio@23: end Tercio@23: Tercio@23: local function Show(self) Tercio@23: self.frame:Show() Tercio@23: end Tercio@23: Tercio@23: local function OnAcquire(self) Tercio@23: self.frame:SetParent(UIParent) Tercio@23: self.frame:SetFrameStrata("FULLSCREEN_DIALOG") Tercio@23: self:ApplyStatus() Tercio@23: self:EnableResize(true) Tercio@23: self:Show() Tercio@23: end Tercio@23: Tercio@23: local function OnRelease(self) Tercio@23: self.status = nil Tercio@23: for k in pairs(self.localstatus) do Tercio@23: self.localstatus[k] = nil Tercio@23: end Tercio@23: end Tercio@23: Tercio@23: -- called to set an external table to store status in Tercio@23: local function SetStatusTable(self, status) Tercio@23: assert(type(status) == "table") Tercio@23: self.status = status Tercio@23: self:ApplyStatus() Tercio@23: end Tercio@23: Tercio@23: local function ApplyStatus(self) Tercio@23: local status = self.status or self.localstatus Tercio@23: local frame = self.frame Tercio@23: self:SetWidth(status.width or 700) Tercio@23: self:SetHeight(status.height or 500) Tercio@23: if status.top and status.left then Tercio@23: frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) Tercio@23: frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) Tercio@23: else Tercio@23: frame:SetPoint("CENTER",UIParent,"CENTER") Tercio@23: end Tercio@23: end Tercio@23: Tercio@23: local function OnWidthSet(self, width) Tercio@23: local content = self.content Tercio@23: local contentwidth = width - 34 Tercio@23: if contentwidth < 0 then Tercio@23: contentwidth = 0 Tercio@23: end Tercio@23: content:SetWidth(contentwidth) Tercio@23: content.width = contentwidth Tercio@23: end Tercio@23: Tercio@23: Tercio@23: local function OnHeightSet(self, height) Tercio@23: local content = self.content Tercio@23: local contentheight = height - 57 Tercio@23: if contentheight < 0 then Tercio@23: contentheight = 0 Tercio@23: end Tercio@23: content:SetHeight(contentheight) Tercio@23: content.height = contentheight Tercio@23: end Tercio@23: Tercio@23: local function EnableResize(self, state) Tercio@23: local func = state and "Show" or "Hide" Tercio@23: self.sizer_se[func](self.sizer_se) Tercio@23: self.sizer_s[func](self.sizer_s) Tercio@23: self.sizer_e[func](self.sizer_e) Tercio@23: end Tercio@23: Tercio@23: local function Constructor() Tercio@23: local frame = CreateFrame("Frame",nil,UIParent) Tercio@23: local self = {} Tercio@23: self.type = "Window" Tercio@23: Tercio@23: self.Hide = Hide Tercio@23: self.Show = Show Tercio@23: self.SetTitle = SetTitle Tercio@23: self.OnRelease = OnRelease Tercio@23: self.OnAcquire = OnAcquire Tercio@23: self.SetStatusText = SetStatusText Tercio@23: self.SetStatusTable = SetStatusTable Tercio@23: self.ApplyStatus = ApplyStatus Tercio@23: self.OnWidthSet = OnWidthSet Tercio@23: self.OnHeightSet = OnHeightSet Tercio@23: self.EnableResize = EnableResize Tercio@23: Tercio@23: self.localstatus = {} Tercio@23: Tercio@23: self.frame = frame Tercio@23: frame.obj = self Tercio@23: frame:SetWidth(700) Tercio@23: frame:SetHeight(500) Tercio@23: frame:SetPoint("CENTER",UIParent,"CENTER",0,0) Tercio@23: frame:EnableMouse() Tercio@23: frame:SetMovable(true) Tercio@23: frame:SetResizable(true) Tercio@23: frame:SetFrameStrata("FULLSCREEN_DIALOG") Tercio@23: frame:SetScript("OnMouseDown", frameOnMouseDown) Tercio@23: Tercio@23: frame:SetScript("OnHide",frameOnClose) Tercio@23: frame:SetMinResize(240,240) Tercio@23: frame:SetToplevel(true) Tercio@23: Tercio@23: local titlebg = frame:CreateTexture(nil, "BACKGROUND") Tercio@23: titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]]) Tercio@23: titlebg:SetPoint("TOPLEFT", 9, -6) Tercio@23: titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24) Tercio@23: Tercio@23: local dialogbg = frame:CreateTexture(nil, "BACKGROUND") Tercio@23: dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) Tercio@23: dialogbg:SetPoint("TOPLEFT", 8, -24) Tercio@23: dialogbg:SetPoint("BOTTOMRIGHT", -6, 8) Tercio@23: dialogbg:SetVertexColor(0, 0, 0, .75) Tercio@23: Tercio@23: local topleft = frame:CreateTexture(nil, "BORDER") Tercio@23: topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: topleft:SetWidth(64) Tercio@23: topleft:SetHeight(64) Tercio@23: topleft:SetPoint("TOPLEFT") Tercio@23: topleft:SetTexCoord(0.501953125, 0.625, 0, 1) Tercio@23: Tercio@23: local topright = frame:CreateTexture(nil, "BORDER") Tercio@23: topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: topright:SetWidth(64) Tercio@23: topright:SetHeight(64) Tercio@23: topright:SetPoint("TOPRIGHT") Tercio@23: topright:SetTexCoord(0.625, 0.75, 0, 1) Tercio@23: Tercio@23: local top = frame:CreateTexture(nil, "BORDER") Tercio@23: top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: top:SetHeight(64) Tercio@23: top:SetPoint("TOPLEFT", topleft, "TOPRIGHT") Tercio@23: top:SetPoint("TOPRIGHT", topright, "TOPLEFT") Tercio@23: top:SetTexCoord(0.25, 0.369140625, 0, 1) Tercio@23: Tercio@23: local bottomleft = frame:CreateTexture(nil, "BORDER") Tercio@23: bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: bottomleft:SetWidth(64) Tercio@23: bottomleft:SetHeight(64) Tercio@23: bottomleft:SetPoint("BOTTOMLEFT") Tercio@23: bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1) Tercio@23: Tercio@23: local bottomright = frame:CreateTexture(nil, "BORDER") Tercio@23: bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: bottomright:SetWidth(64) Tercio@23: bottomright:SetHeight(64) Tercio@23: bottomright:SetPoint("BOTTOMRIGHT") Tercio@23: bottomright:SetTexCoord(0.875, 1, 0, 1) Tercio@23: Tercio@23: local bottom = frame:CreateTexture(nil, "BORDER") Tercio@23: bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: bottom:SetHeight(64) Tercio@23: bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT") Tercio@23: bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT") Tercio@23: bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1) Tercio@23: Tercio@23: local left = frame:CreateTexture(nil, "BORDER") Tercio@23: left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: left:SetWidth(64) Tercio@23: left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT") Tercio@23: left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT") Tercio@23: left:SetTexCoord(0.001953125, 0.125, 0, 1) Tercio@23: Tercio@23: local right = frame:CreateTexture(nil, "BORDER") Tercio@23: right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) Tercio@23: right:SetWidth(64) Tercio@23: right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT") Tercio@23: right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT") Tercio@23: right:SetTexCoord(0.1171875, 0.2421875, 0, 1) Tercio@23: Tercio@23: local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") Tercio@23: close:SetPoint("TOPRIGHT", 2, 1) Tercio@23: close:SetScript("OnClick", closeOnClick) Tercio@23: self.closebutton = close Tercio@23: close.obj = self Tercio@23: Tercio@23: local titletext = frame:CreateFontString(nil, "ARTWORK") Tercio@23: titletext:SetFontObject(GameFontNormal) Tercio@23: titletext:SetPoint("TOPLEFT", 12, -8) Tercio@23: titletext:SetPoint("TOPRIGHT", -32, -8) Tercio@23: self.titletext = titletext Tercio@23: Tercio@23: local title = CreateFrame("Button", nil, frame) Tercio@23: title:SetPoint("TOPLEFT", titlebg) Tercio@23: title:SetPoint("BOTTOMRIGHT", titlebg) Tercio@23: title:EnableMouse() Tercio@23: title:SetScript("OnMouseDown",titleOnMouseDown) Tercio@23: title:SetScript("OnMouseUp", frameOnMouseUp) Tercio@23: self.title = title Tercio@23: Tercio@23: local sizer_se = CreateFrame("Frame",nil,frame) Tercio@23: sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) Tercio@23: sizer_se:SetWidth(25) Tercio@23: sizer_se:SetHeight(25) Tercio@23: sizer_se:EnableMouse() Tercio@23: sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown) Tercio@23: sizer_se:SetScript("OnMouseUp", sizerOnMouseUp) Tercio@23: self.sizer_se = sizer_se Tercio@23: Tercio@23: local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") Tercio@23: self.line1 = line1 Tercio@23: line1:SetWidth(14) Tercio@23: line1:SetHeight(14) Tercio@23: line1:SetPoint("BOTTOMRIGHT", -8, 8) Tercio@23: line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") Tercio@23: local x = 0.1 * 14/17 Tercio@23: line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) Tercio@23: Tercio@23: local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") Tercio@23: self.line2 = line2 Tercio@23: line2:SetWidth(8) Tercio@23: line2:SetHeight(8) Tercio@23: line2:SetPoint("BOTTOMRIGHT", -8, 8) Tercio@23: line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") Tercio@23: local x = 0.1 * 8/17 Tercio@23: line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) Tercio@23: Tercio@23: local sizer_s = CreateFrame("Frame",nil,frame) Tercio@23: sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0) Tercio@23: sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) Tercio@23: sizer_s:SetHeight(25) Tercio@23: sizer_s:EnableMouse() Tercio@23: sizer_s:SetScript("OnMouseDown",sizersOnMouseDown) Tercio@23: sizer_s:SetScript("OnMouseUp", sizerOnMouseUp) Tercio@23: self.sizer_s = sizer_s Tercio@23: Tercio@23: local sizer_e = CreateFrame("Frame",nil,frame) Tercio@23: sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25) Tercio@23: sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) Tercio@23: sizer_e:SetWidth(25) Tercio@23: sizer_e:EnableMouse() Tercio@23: sizer_e:SetScript("OnMouseDown",sizereOnMouseDown) Tercio@23: sizer_e:SetScript("OnMouseUp", sizerOnMouseUp) Tercio@23: self.sizer_e = sizer_e Tercio@23: Tercio@23: --Container Support Tercio@23: local content = CreateFrame("Frame",nil,frame) Tercio@23: self.content = content Tercio@23: content.obj = self Tercio@23: content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32) Tercio@23: content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13) Tercio@23: Tercio@23: AceGUI:RegisterAsContainer(self) Tercio@23: return self Tercio@23: end Tercio@23: Tercio@23: AceGUI:RegisterWidgetType(Type,Constructor,Version) Tercio@23: end