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