1 local AceGUI = LibStub("AceGUI-3.0")
4 local pairs, assert, type = pairs, assert, type
7 local PlaySound = PlaySound
8 local CreateFrame, UIParent = CreateFrame, UIParent
10 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
11 -- List them here for Mikk's FindGlobals script
12 -- GLOBALS: GameFontNormal
26 local function frameOnShow(this)
27 this.obj:Fire("OnShow")
30 local function frameOnClose(this)
31 this.obj:Fire("OnClose")
34 local function closeOnClick(this)
35 PlaySound(PlaySoundKitID and "gsTitleOptionExit" or 799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
39 local function frameOnMouseDown(this)
43 local function titleOnMouseDown(this)
44 this:GetParent():StartMoving()
48 local function frameOnMouseUp(this)
49 local frame = this:GetParent()
50 frame:StopMovingOrSizing()
51 local self = frame.obj
52 local status = self.status or self.localstatus
53 status.width = frame:GetWidth()
54 status.height = frame:GetHeight()
55 status.top = frame:GetTop()
56 status.left = frame:GetLeft()
59 local function sizerseOnMouseDown(this)
60 this:GetParent():StartSizing("BOTTOMRIGHT")
64 local function sizersOnMouseDown(this)
65 this:GetParent():StartSizing("BOTTOM")
69 local function sizereOnMouseDown(this)
70 this:GetParent():StartSizing("RIGHT")
74 local function sizerOnMouseUp(this)
75 this:GetParent():StopMovingOrSizing()
78 local function SetTitle(self,title)
79 self.titletext:SetText(title)
82 local function SetStatusText(self,text)
83 -- self.statustext:SetText(text)
86 local function Hide(self)
90 local function Show(self)
94 local function OnAcquire(self)
95 self.frame:SetParent(UIParent)
96 self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
98 self:EnableResize(true)
102 local function OnRelease(self)
104 for k in pairs(self.localstatus) do
105 self.localstatus[k] = nil
109 -- called to set an external table to store status in
110 local function SetStatusTable(self, status)
111 assert(type(status) == "table")
116 local function ApplyStatus(self)
117 local status = self.status or self.localstatus
118 local frame = self.frame
119 self:SetWidth(status.width or 700)
120 self:SetHeight(status.height or 500)
121 if status.top and status.left then
122 frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
123 frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
125 frame:SetPoint("CENTER",UIParent,"CENTER")
129 local function OnWidthSet(self, width)
130 local content = self.content
131 local contentwidth = width - 34
132 if contentwidth < 0 then
135 content:SetWidth(contentwidth)
136 content.width = contentwidth
140 local function OnHeightSet(self, height)
141 local content = self.content
142 local contentheight = height - 57
143 if contentheight < 0 then
146 content:SetHeight(contentheight)
147 content.height = contentheight
150 local function EnableResize(self, state)
151 local func = state and "Show" or "Hide"
152 self.sizer_se[func](self.sizer_se)
153 self.sizer_s[func](self.sizer_s)
154 self.sizer_e[func](self.sizer_e)
157 local function Constructor()
158 local frame = CreateFrame("Frame",nil,UIParent)
164 self.SetTitle = SetTitle
165 self.OnRelease = OnRelease
166 self.OnAcquire = OnAcquire
167 self.SetStatusText = SetStatusText
168 self.SetStatusTable = SetStatusTable
169 self.ApplyStatus = ApplyStatus
170 self.OnWidthSet = OnWidthSet
171 self.OnHeightSet = OnHeightSet
172 self.EnableResize = EnableResize
174 self.localstatus = {}
180 frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
182 frame:SetMovable(true)
183 frame:SetResizable(true)
184 frame:SetFrameStrata("FULLSCREEN_DIALOG")
185 frame:SetScript("OnMouseDown", frameOnMouseDown)
187 frame:SetScript("OnShow",frameOnShow)
188 frame:SetScript("OnHide",frameOnClose)
189 frame:SetMinResize(240,240)
190 frame:SetToplevel(true)
192 local titlebg = frame:CreateTexture(nil, "BACKGROUND")
193 titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
194 titlebg:SetPoint("TOPLEFT", 9, -6)
195 titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
197 local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
198 dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
199 dialogbg:SetPoint("TOPLEFT", 8, -24)
200 dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
201 dialogbg:SetVertexColor(0, 0, 0, .75)
203 local topleft = frame:CreateTexture(nil, "BORDER")
204 topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
206 topleft:SetHeight(64)
207 topleft:SetPoint("TOPLEFT")
208 topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
210 local topright = frame:CreateTexture(nil, "BORDER")
211 topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
212 topright:SetWidth(64)
213 topright:SetHeight(64)
214 topright:SetPoint("TOPRIGHT")
215 topright:SetTexCoord(0.625, 0.75, 0, 1)
217 local top = frame:CreateTexture(nil, "BORDER")
218 top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
220 top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
221 top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
222 top:SetTexCoord(0.25, 0.369140625, 0, 1)
224 local bottomleft = frame:CreateTexture(nil, "BORDER")
225 bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
226 bottomleft:SetWidth(64)
227 bottomleft:SetHeight(64)
228 bottomleft:SetPoint("BOTTOMLEFT")
229 bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
231 local bottomright = frame:CreateTexture(nil, "BORDER")
232 bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
233 bottomright:SetWidth(64)
234 bottomright:SetHeight(64)
235 bottomright:SetPoint("BOTTOMRIGHT")
236 bottomright:SetTexCoord(0.875, 1, 0, 1)
238 local bottom = frame:CreateTexture(nil, "BORDER")
239 bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
241 bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
242 bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
243 bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
245 local left = frame:CreateTexture(nil, "BORDER")
246 left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
248 left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
249 left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
250 left:SetTexCoord(0.001953125, 0.125, 0, 1)
252 local right = frame:CreateTexture(nil, "BORDER")
253 right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
255 right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
256 right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
257 right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
259 local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
260 close:SetPoint("TOPRIGHT", 2, 1)
261 close:SetScript("OnClick", closeOnClick)
262 self.closebutton = close
265 local titletext = frame:CreateFontString(nil, "ARTWORK")
266 titletext:SetFontObject(GameFontNormal)
267 titletext:SetPoint("TOPLEFT", 12, -8)
268 titletext:SetPoint("TOPRIGHT", -32, -8)
269 self.titletext = titletext
271 local title = CreateFrame("Button", nil, frame)
272 title:SetPoint("TOPLEFT", titlebg)
273 title:SetPoint("BOTTOMRIGHT", titlebg)
275 title:SetScript("OnMouseDown",titleOnMouseDown)
276 title:SetScript("OnMouseUp", frameOnMouseUp)
279 local sizer_se = CreateFrame("Frame",nil,frame)
280 sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
281 sizer_se:SetWidth(25)
282 sizer_se:SetHeight(25)
283 sizer_se:EnableMouse()
284 sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
285 sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
286 self.sizer_se = sizer_se
288 local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
292 line1:SetPoint("BOTTOMRIGHT", -8, 8)
293 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
294 local x = 0.1 * 14/17
295 line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
297 local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
301 line2:SetPoint("BOTTOMRIGHT", -8, 8)
302 line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
304 line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
306 local sizer_s = CreateFrame("Frame",nil,frame)
307 sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
308 sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
309 sizer_s:SetHeight(25)
310 sizer_s:EnableMouse()
311 sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
312 sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
313 self.sizer_s = sizer_s
315 local sizer_e = CreateFrame("Frame",nil,frame)
316 sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
317 sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
319 sizer_e:EnableMouse()
320 sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
321 sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
322 self.sizer_e = sizer_e
325 local content = CreateFrame("Frame",nil,frame)
326 self.content = content
328 content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
329 content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
331 AceGUI:RegisterAsContainer(self)
335 AceGUI:RegisterWidgetType(Type,Constructor,Version)