vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Lexan! |
||
3 | BULLETPROOF GLASS ON YOUR AH, BANK AND MAIL WINDOWS! |
||
4 | </needless cheesiness> |
||
5 | |||
6 | By Neronix (Hellscream EU, neronix@gmail.com) |
||
7 | Portions of the AH protector code from Auctioneer |
||
8 | This mod is licensed under the GNU GPL |
||
9 | --]] |
||
10 | |||
11 | Lexan = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceHook-2.0", "AceConsole-2.0") |
||
12 | |||
13 | function Lexan:OnInitialize() |
||
14 | -- No config table --> New user --> Create table and set default |
||
15 | if ( not LexanConfig ) then |
||
16 | LexanConfig = { |
||
17 | Esc = false |
||
18 | } |
||
19 | end |
||
20 | |||
21 | Lexan:RegisterChatCommand({ "/lexan" }, { |
||
22 | desc = self.notes, |
||
23 | type = "group", |
||
24 | args = { |
||
25 | esc = { |
||
26 | name = 'Use Esc', |
||
27 | desc = 'Toggle the ability for the Esc button to close the AH window', |
||
28 | type = 'toggle', |
||
29 | get = function() return LexanConfig.Esc; end, |
||
30 | set = function(val) LexanConfig.Esc = val end, |
||
31 | } |
||
32 | } |
||
33 | }) |
||
34 | end |
||
35 | |||
36 | function Lexan:OnEnable() |
||
37 | self:Hook("ToggleGameMenu") -- Allows us to handle Esc closing the AH window |
||
38 | self:Hook("ToggleWorldMap") -- Tame that mappy bitch! |
||
39 | |||
40 | self:RegisterEvent("AUCTION_HOUSE_SHOW") |
||
41 | self:RegisterEvent("AUCTION_HOUSE_CLOSED") |
||
42 | |||
43 | -- If 1, then the user blocked trades him/herself, meaning we don't need to handle it. |
||
44 | if ( GetCVar("BlockTrades") == "0" ) then |
||
45 | |||
46 | self:RegisterEvent("MAIL_SHOW", "AntiTrade_ON") |
||
47 | self:RegisterEvent("MAIL_CLOSED", "AntiTrade_OFF") |
||
48 | self:RegisterEvent("BANKFRAME_OPENED", "AntiTrade_ON") |
||
49 | self:RegisterEvent("BANKFRAME_CLOSED", "AntiTrade_OFF") |
||
50 | end |
||
51 | end |
||
52 | |||
53 | function Lexan:OnDisable() -- Just in case that the luser disables while protection is enforced, for whatever strange reason... |
||
54 | self:AH_OFF() |
||
55 | self:AntiTrade_OFF() |
||
56 | end |
||
57 | |||
58 | -- ToggleGameMenu is what Esc is bound to by default |
||
59 | function Lexan:ToggleGameMenu(clicked) |
||
60 | -- If the user wants Esc to close the AH window, and the AH window's open, |
||
61 | -- Then do the standard protection disabling routine and let the normal esc stuff handle everything else |
||
62 | if LexanConfig.Esc == true and Lexan.AHProtected == true then |
||
63 | self:AH_OFF() |
||
64 | end |
||
65 | self.hooks["ToggleGameMenu"].orig(clicked) |
||
66 | end |
||
67 | |||
68 | function Lexan:ToggleWorldMap() |
||
69 | -- Prevents conflicts with MetaMap |
||
70 | if METAMAP_VERSION then |
||
71 | MetaMap_ToggleFrame(WorldMapFrame) |
||
72 | |||
73 | -- Prevents conflicts with Atlas' world map replacer. If they're around, then let Atlas handle it |
||
74 | elseif AtlasOptions and Atlas_ReplaceWorldMap() == true then |
||
75 | Atlas_Toggle() |
||
76 | |||
77 | -- End of anti-conflict stuff |
||
78 | |||
79 | -- Instead of putting the frame through the UIPanels system, we just do shit the basic way :P |
||
80 | -- I.e. instead of Show/HideUIPanel, we just do Frame:Show/Hide |
||
81 | |||
82 | -- Hide |
||
83 | elseif WorldMapFrame:IsVisible() then |
||
84 | WorldMapFrame:Hide() |
||
85 | |||
86 | -- Show |
||
87 | else |
||
88 | WorldMapFrame:EnableMouse(1) -- This prevents tooltips from stuff underneath the world map appearing when the world map is on |
||
89 | SetupWorldMapScale(WorldMapFrame) |
||
90 | WorldMapFrame:Show() |
||
91 | end |
||
92 | end |
||
93 | |||
94 | function Lexan:AUCTION_HOUSE_SHOW() |
||
95 | |||
96 | -- Checking for presence of AuctionFrame (Can't do shit without it :P) |
||
97 | if AuctionFrame and AuctionFrame:IsShown() and not self.AHProtected then |
||
98 | |||
99 | -- We're protecting, so... |
||
100 | self.AHProtected = true |
||
101 | |||
102 | -- If the frame is the current doublewide frame, then clear the doublewide |
||
103 | if ( GetDoublewideFrame() == AuctionFrame ) then |
||
104 | SetDoublewideFrame(nil) |
||
105 | end |
||
106 | |||
107 | -- Remove AuctionFrame from the window handling system |
||
108 | -- Essentially the part we've been waiting for... |
||
109 | UIPanelWindows["AuctionFrame"] = nil |
||
110 | |||
111 | -- Protection done!! |
||
112 | end |
||
113 | end |
||
114 | |||
115 | function Lexan:AUCTION_HOUSE_CLOSED() |
||
116 | |||
117 | -- For a start, is protection even on? |
||
118 | if ( self.AHProtected ) and ( AuctionFrame) then |
||
119 | |||
120 | self.AHProtected = false |
||
121 | |||
122 | -- Put the frame back into the UI window handling system |
||
123 | UIPanelWindows["AuctionFrame"] = { area = "doublewide", pushable = 0 }; |
||
124 | if ( AuctionFrame:IsVisible() ) then |
||
125 | SetDoublewideFrame(AuctionFrame) |
||
126 | end |
||
127 | end |
||
128 | end |
||
129 | |||
130 | function Lexan:AntiTrade_ON() |
||
131 | if ( GetCVar("BlockTrades") == "0" ) and ( not self.TradesBlockedByUser ) then |
||
132 | |||
133 | -- Just in case the luser logs out via chat command in a city with the |
||
134 | -- windows open, which would cause trades to remain blocked. Not good :P |
||
135 | self:RegisterEvent("PLAYER_LEAVING_WORLD", "AntiTrade_OFF") |
||
136 | |||
137 | SetCVar("BlockTrades", "1") |
||
138 | self.TradesBlockedByMod = true |
||
139 | end |
||
140 | end |
||
141 | |||
142 | function Lexan:AntiTrade_OFF() |
||
143 | if ( self.TradesBlockedByMod ) then |
||
144 | self:UnregisterEvent("PLAYER_LEAVING_WORLD") -- We don't need it anymore for now |
||
145 | |||
146 | SetCVar("BlockTrades", "0") |
||
147 | self.TradesBlockedByMod = false |
||
148 | end |
||
149 | end |