Mercurial > wow > devian
comparison Console.lua @ 100:790dca545f1d v3.0
- Configuration structure overheal; clearing 'Devian.lua' from SaveVariables will be necessary
- Removed dependence on embedded libraries.
- Console/dock frames are now implemented as XML mixin structures
- Console dropdown menu option to 'Pin' frames
- Hold SHIFT while clicking dock buttons will cause all but that tab to be closed
author | Nenue |
---|---|
date | Tue, 17 Jan 2017 14:25:18 -0500 |
parents | 7d94df3804a7 |
children | c3e7d2a3f4e9 |
comparison
equal
deleted
inserted
replaced
99:7d94df3804a7 | 100:790dca545f1d |
---|---|
27 self:RegisterEvent('PLAYER_STARTED_MOVING') | 27 self:RegisterEvent('PLAYER_STARTED_MOVING') |
28 self:RegisterEvent('PLAYER_STOPPED_MOVING') | 28 self:RegisterEvent('PLAYER_STOPPED_MOVING') |
29 | 29 |
30 UIDropDownMenu_Initialize(self.DropdownFrame, function() | 30 UIDropDownMenu_Initialize(self.DropdownFrame, function() |
31 local info = UIDropDownMenu_CreateInfo() | 31 local info = UIDropDownMenu_CreateInfo() |
32 info.notCheckable = 1 | |
33 info.text = 'Pin' | 32 info.text = 'Pin' |
34 info.func = function() self:Pin() end | 33 info.func = function() self:Pin() end |
34 info.isNotRadio = true | |
35 info.checked = (self.pinned) | |
35 UIDropDownMenu_AddButton(info) | 36 UIDropDownMenu_AddButton(info) |
37 | |
38 info.notCheckable = 1 | |
36 if self.minimized then | 39 if self.minimized then |
37 info.text = 'Maximize' | 40 info.text = 'Maximize' |
38 info.func = function() self:Maximize() end | 41 info.func = function() self:Maximize() end |
39 else | 42 else |
40 info.text = 'Minimize' | 43 info.text = 'Minimize' |
50 ToggleDropDownMenu(1, nil, self.DropdownFrame, button, 0, 0) | 53 ToggleDropDownMenu(1, nil, self.DropdownFrame, button, 0, 0) |
51 end) | 54 end) |
52 | 55 |
53 self.width = self:GetWidth() | 56 self.width = self:GetWidth() |
54 self.height = self:GetWidth() | 57 self.height = self:GetWidth() |
58 self.isHover = false | |
55 end | 59 end |
56 | 60 |
57 function DevianConsoleMixin:Setup(info) | 61 function DevianConsoleMixin:Setup(info) |
58 for k,v in pairs(info) do | 62 for k,v in pairs(info) do |
59 self[k] = v | 63 self[k] = v |
79 if D.channels[id][k] ~= v then | 83 if D.channels[id][k] ~= v then |
80 D.channels[id][k] = v | 84 D.channels[id][k] = v |
81 end | 85 end |
82 end | 86 end |
83 end | 87 end |
88 D.channels[id].isPressed = nil | |
89 D.channels[id].isHover = nil | |
84 end | 90 end |
85 | 91 |
86 function DevianConsoleMixin:Pin(pinned) | 92 function DevianConsoleMixin:Pin(pinned) |
87 self.pinned = pinned or (not self.pinned) | 93 self.pinned = pinned or (not self.pinned) |
88 self:Update(true) | 94 self:Update(true) |
89 end | 95 end |
90 | 96 |
91 function DevianConsoleMixin:Update(setFinal) | 97 function DevianConsoleMixin:Update(setFinal) |
92 self.title:SetText(self.index..' '.. (self.signature or '?')) | |
93 self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.x, self.y) | 98 self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.x, self.y) |
94 | 99 |
95 if self.minimized then | 100 if self.minimized then |
96 self:SetHeight(20) | 101 self:SetHeight(20) |
97 self:SetMaxResize(GetScreenWidth(),20) | 102 self:SetMaxResize(GetScreenWidth(),20) |
104 end | 109 end |
105 | 110 |
106 | 111 |
107 -- oldprint(self:GetName(), self.x, self.y) | 112 -- oldprint(self:GetName(), self.x, self.y) |
108 | 113 |
109 local isFront = D.currentProfile.current_channel == self.index | 114 local isFront = (D.currentProfile.current_channel == self.index) |
110 local r,g,b,a = unpack(D.db.backborder) | 115 local r,g,b,a = unpack(D.db.backborder) |
111 if isFront then | 116 if isFront then |
112 r,g,b,a = unpack(D.db.frontborder) | 117 r,g,b,a = unpack(D.db.frontborder) |
113 self.backdrop:SetColorTexture(0,0,0,1) | 118 self.backdrop:SetColorTexture(0,0,0,1) |
114 else | 119 elseif self.pinned then |
115 self.backdrop:SetColorTexture(0,0,0,0.5) | 120 self.backdrop:SetColorTexture(0,0,0,1) |
116 | 121 r,g,b,a = unpack(D.db.backborder) |
117 end | 122 self.DropdownButton.Background:SetGradient('VERTICAL', .65,.35,.25, .15, .11, .05) |
123 else | |
124 self.DropdownButton.Background:SetGradient('VERTICAL', .25,.35,.65, .05, .11, .15) | |
125 self.backdrop:SetColorTexture(0,0,0,1) | |
126 if self.raised then | |
127 self.raised = nil | |
128 self:Lower() | |
129 end | |
130 end | |
131 if self.isPressed then | |
132 r,g,b,a = 1,1,1,1 | |
133 elseif self.isHover then | |
134 r,g,b,a = .5,.5,.5,1 | |
135 end | |
136 | |
137 | |
118 for name, region in pairs(self.border) do | 138 for name, region in pairs(self.border) do |
119 region:SetColorTexture(r,g,b,a) | 139 region:SetColorTexture(r,g,b,a) |
120 end | 140 end |
141 self.title:SetText(self.index..' '.. (self.signature or '?') .. (' '..self:GetFrameLevel())) | |
121 | 142 |
122 --oldprint(self:GetID(), self.enabled, self.minimized, self.x, self.y) | 143 --oldprint(self:GetID(), self.enabled, self.minimized, self.x, self.y) |
123 self.isFront = isFront | 144 self.isFront = isFront |
124 self:SetShown(self.enabled) | 145 self:SetShown(self.enabled) |
125 self.backdrop:SetShown(self.enabled) | 146 self.backdrop:SetShown(self.enabled) |
174 self.minimized = nilnil | 195 self.minimized = nilnil |
175 self:Update(true) | 196 self:Update(true) |
176 end | 197 end |
177 | 198 |
178 function DevianConsoleMixin:OnMouseDown(button) | 199 function DevianConsoleMixin:OnMouseDown(button) |
179 | 200 self.isPressed = true |
201 self:Update() | |
202 end | |
203 | |
204 | |
205 function DevianConsoleMixin:OnMouseUp(button) | |
206 self.isPressed = nil | |
180 if button == 'LeftButton' then | 207 if button == 'LeftButton' then |
208 --print('go to front') | |
181 self:ToFront() | 209 self:ToFront() |
182 end | |
183 end | |
184 | |
185 | |
186 function DevianConsoleMixin:OnMouseUp(button) | |
187 if button == 'LeftButton' then | |
188 self:ToFront() | |
189 else | 210 else |
190 self:MinMax() | 211 self:MinMax() |
191 end | 212 end |
192 end | 213 end |
193 | 214 |
194 function DevianConsoleMixin:OnLeave() | 215 function DevianConsoleMixin:OnLeave() |
216 self.isHover = nil | |
217 self:Update() | |
195 end | 218 end |
196 | 219 |
197 function DevianConsoleMixin:OnEnter() | 220 function DevianConsoleMixin:OnEnter() |
221 self.isHover = true | |
222 self:Update() | |
198 end | 223 end |
199 | 224 |
200 function DevianConsoleMixin:OnDragStart() | 225 function DevianConsoleMixin:OnDragStart() |
201 self:ToFront() | 226 self:ToFront() |
202 self:StartMoving() | 227 self:StartMoving() |
221 self:SetClampRectInsets(0,0,0,0) | 246 self:SetClampRectInsets(0,0,0,0) |
222 | 247 |
223 self:Update(true) | 248 self:Update(true) |
224 | 249 |
225 D.IterateChannels(function(frame) | 250 D.IterateChannels(function(frame) |
226 frame:Update() | 251 frame:Update(true) |
227 end, self) | 252 end, self) |
228 end | 253 end |
229 | 254 |
230 function DevianConsoleMixin:ToFront() | 255 function DevianConsoleMixin:ToFront() |
256 D.currentProfile.current_channel = self.index | |
257 | |
231 self:Raise() | 258 self:Raise() |
232 D.currentProfile.current_channel = self.index | |
233 for index, channel in ipairs(D.console) do | 259 for index, channel in ipairs(D.console) do |
234 channel:Update() | 260 channel:Update(true) |
235 end | 261 end |
236 end | 262 end |
237 | 263 |
238 function DevianConsoleMixin:Toggle() | 264 function DevianConsoleMixin:Toggle(value) |
239 self.enabled = (not self.enabled) | 265 if value == nil then |
240 --oldprint(self:GetID(), self.enabled) | 266 value = (not self.enabled) |
241 self:Update() | 267 end |
268 | |
269 self.enabled = value | |
270 D:Print('Console #'..self:GetID(), self.enabled and 'open' or 'closed') | |
271 | |
272 self:Update(true) | |
242 end | 273 end |
243 | 274 |
244 function DevianConsoleMixin:OnEvent(event, arg) | 275 function DevianConsoleMixin:OnEvent(event, arg) |
245 oldprint(event, arg) | 276 --oldprint(event, arg) |
246 local db = D.db | 277 local db = D.db |
247 if self.enabled then | 278 if self.enabled then |
279 | |
280 local progress = self.moveFade:GetProgress() or 1 | |
281 self.moveFade:Stop() | |
282 | |
248 if event == 'PLAYER_STARTED_MOVING' then | 283 if event == 'PLAYER_STARTED_MOVING' then |
249 self.moveFade:GetProgress() | 284 local F1 = self.moveFade.alphaOut |
285 F1:SetFromAlpha(db.movement_fade_from + (1-progress)) | |
286 F1:SetToAlpha(db.movement_fade_to) | |
287 F1:SetDuration(db.movement_fade_time * (1-progress)) | |
288 self.moveFade:Play() | |
289 self:EnableMouse(false) | |
290 elseif event == 'PLAYER_STOPPED_MOVING' then | |
250 self.moveFade:Stop() | 291 self.moveFade:Stop() |
251 local F1 = self.moveFade.alphaOut | 292 local F1 = self.moveFade.alphaOut |
252 F1:SetFromAlpha(db.movement_fade_from) | 293 F1:SetFromAlpha(db.movement_fade_to + (1-progress)) |
253 F1:SetToAlpha(db.movement_fade_to) | |
254 F1:SetDuration(db.movement_fade_time) | |
255 self.moveFade:Play() | |
256 self:EnableMouse(false) | |
257 else | |
258 self.moveFade:Stop() | |
259 local F1 = self.moveFade.alphaOut | |
260 F1:SetToAlpha(db.movement_fade_from) | 294 F1:SetToAlpha(db.movement_fade_from) |
261 F1:SetFromAlpha(db.movement_fade_to) | 295 F1:SetDuration(db.movement_fade_time * (progress)) |
262 F1:SetDuration(db.movement_fade_time) | |
263 self.moveFade:Play() | 296 self.moveFade:Play() |
264 self:EnableMouse(true) | 297 self:EnableMouse(true) |
265 end | 298 end |
266 end | 299 end |
267 end | 300 end |
282 frame:SetMinResize(200, frame.height) | 315 frame:SetMinResize(200, frame.height) |
283 frame:SetMaxResize(GetScreenWidth(), frame.height) | 316 frame:SetMaxResize(GetScreenWidth(), frame.height) |
284 end | 317 end |
285 frame:StartSizing() | 318 frame:StartSizing() |
286 end | 319 end |
320 | |
287 function DevianConsoleSizeButtonMixin:OnDragStop() | 321 function DevianConsoleSizeButtonMixin:OnDragStop() |
288 local frame = self:GetParent() | 322 local frame = self:GetParent() |
289 frame:OnDragStop() | 323 frame:OnDragStop() |
290 end | 324 end |