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