Mercurial > wow > ouroloot
comparison LibFarmbuyer.lua @ 69:8442272a8418
- Make sure popup dialogs are on top of Ace3's widgets.
- Minor code reorganization. Safety hook for future boss-entry code.
- Avoid same bug from a couple revs ago when adding manual boss kills.
- Ask players about snapshot data when manually entering boss kills.
- Blizzard rearranged the button order in 3-entry popups some time ago
and I failed to adapt the code until now.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 11 May 2012 03:08:12 +0000 |
parents | 81d5449621f8 |
children | 32eb24fb2ebf |
comparison
equal
deleted
inserted
replaced
68:3bed6d51e077 | 69:8442272a8418 |
---|---|
52 | 52 |
53 - new(...), del(t), copy(t), clear() | 53 - new(...), del(t), copy(t), clear() |
54 Ditto for table recycling. | 54 Ditto for table recycling. |
55 ]] | 55 ]] |
56 | 56 |
57 local MAJOR, MINOR = "LibFarmbuyer", 16 | 57 local MAJOR, MINOR = "LibFarmbuyer", 17 |
58 assert(LibStub,MAJOR.." requires LibStub") | 58 assert(LibStub,MAJOR.." requires LibStub") |
59 local lib = LibStub:NewLibrary(MAJOR, MINOR) | 59 local lib = LibStub:NewLibrary(MAJOR, MINOR) |
60 if not lib then return end | 60 if not lib then return end |
61 | 61 |
62 _G[MAJOR] = lib | 62 _G[MAJOR] = lib |
165 if editbox:GetText() == "" then return end | 165 if editbox:GetText() == "" then return end |
166 local dialog = editbox:GetParent() | 166 local dialog = editbox:GetParent() |
167 StaticPopupDialogs[dialog.which].OnAccept (dialog, dialog.data, dialog.data2) | 167 StaticPopupDialogs[dialog.which].OnAccept (dialog, dialog.data, dialog.data2) |
168 dialog:Hide() | 168 dialog:Hide() |
169 end | 169 end |
170 local function OnShow_witheditbox (dialog, data) | 170 local function OnShow_ontop (dialog, data) |
171 local info = StaticPopupDialogs[dialog.which] | 171 local info = StaticPopupDialogs[dialog.which] |
172 --dialog[info.hasWideEditBox and "wideEditBox" or "editBox"]:SetFocus() | 172 -- ace3's elements are hardcoded to this strata, make sure popups |
173 dialog.editBox:SetFocus() | 173 -- can also be seen (their toplevel=true attribute handles the |
174 -- framelevels within the same strata) | |
175 info.saved_strata = dialog:GetFrameStrata() | |
176 dialog:SetFrameStrata("FULLSCREEN_DIALOG") | |
177 if info.hasEditBox then | |
178 dialog.editBox:SetFocus() | |
179 end | |
174 if info.farm_OnShow then | 180 if info.farm_OnShow then |
175 return info.farm_OnShow (dialog, data) | 181 return info.farm_OnShow (dialog, data) |
176 end | 182 end |
177 end | 183 end |
178 local function OnAccept_witheditbox (dialog, data, data2) | 184 local function OnAccept_witheditbox (dialog, data, data2) |
181 dialog.usertext = dialog.editBox:GetText():trim() | 187 dialog.usertext = dialog.editBox:GetText():trim() |
182 if info.farm_OnAccept then | 188 if info.farm_OnAccept then |
183 return info.farm_OnAccept (dialog, data, data2) | 189 return info.farm_OnAccept (dialog, data, data2) |
184 end | 190 end |
185 end | 191 end |
186 local function OnHide_cleanup (dialog) | 192 local function OnHide_cleanup (dialog, data) |
193 local info = StaticPopupDialogs[dialog.which] | |
194 if info.farm_OnHide then | |
195 return info.farm_OnHide (dialog, data) | |
196 end | |
187 dialog.data = nil | 197 dialog.data = nil |
188 dialog.data2 = nil | 198 dialog.data2 = nil |
199 dialog:SetFrameStrata(info.saved_strata or "DIALOG") | |
189 end | 200 end |
190 | 201 |
191 --[[ | 202 --[[ |
192 StaticPopup | 203 StaticPopup |
193 ]] | 204 ]] |
194 function lib.StaticPopup (t) | 205 function lib.StaticPopup (t) |
195 if t.hasEditBox then | 206 if t.hasEditBox then |
196 t.EditBoxOnTextChanged = EditBoxOnTextChanged_notempty | 207 t.EditBoxOnTextChanged = EditBoxOnTextChanged_notempty |
197 t.EditBoxOnEnterPressed = EditBoxOnEnterPressed_accept | 208 t.EditBoxOnEnterPressed = EditBoxOnEnterPressed_accept |
198 if t.OnShow then | |
199 t.farm_OnShow = t.OnShow | |
200 end | |
201 t.OnShow = OnShow_witheditbox | |
202 if t.OnAccept then | 209 if t.OnAccept then |
203 t.farm_OnAccept = t.OnAccept | 210 t.farm_OnAccept = t.OnAccept |
204 end | 211 end |
205 t.OnAccept = OnAccept_witheditbox | 212 t.OnAccept = OnAccept_witheditbox |
206 -- this calls OnCancel with "clicked", unless noCancelOnEscape is set | 213 -- this calls OnCancel with "clicked", unless noCancelOnEscape is set |
207 t.EditBoxOnEscapePressed = StaticPopup_EscapePressed | 214 t.EditBoxOnEscapePressed = StaticPopup_EscapePressed |
208 end | 215 end |
209 | 216 |
210 if not t.OnHide then | 217 t.farm_OnShow = t.OnShow |
211 t.OnHide = OnHide_cleanup | 218 t.OnShow = OnShow_ontop |
212 end | 219 t.farm_OnHide = t.OnHide |
220 t.OnHide = OnHide_cleanup | |
213 | 221 |
214 t.timeout = 0 | 222 t.timeout = 0 |
215 t.whileDead = true | 223 t.whileDead = true |
216 t.hideOnEscape = true | 224 t.hideOnEscape = true |
217 t.enterClicksFirstButton = true | 225 t.enterClicksFirstButton = true |