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