# HG changeset patch # User Nenue # Date 1460195479 14400 # Node ID da5ff1fc9fb678d2560d71d062d44c78ff3d81e6 # Parent d636ff1b17ceb35ab5be61fb24891a9f833c4c30 - Fixed an issue with creating more than one output channel per UI session. - Cleanup of globals for slightly better performance when printing to a lot of channels at once diff -r d636ff1b17ce -r da5ff1fc9fb6 Devian.lua --- a/Devian.lua Mon Mar 28 02:09:53 2016 -0400 +++ b/Devian.lua Sat Apr 09 05:51:19 2016 -0400 @@ -5,7 +5,9 @@ --GLOBALS: Devian, DevCon, DevianLoadMessage local ADDON, D = ... - +local sub, GetTime, print, _G = string.sub, GetTime, print, _G +local format, setmetatable, getprinthandler, setprinthandler = string.format, setmetatable, getprinthandler, setprinthandler +local tinsert = tinsert local currentProfile local playerName = UnitName("player") local playerRealm = playerName .. '-' .. GetRealmName() @@ -46,7 +48,7 @@ return k end, __call = function(t,k,...) - return string.format((t[k] or k) , ...) + return format((t[k] or k) , ...) end }) @@ -208,7 +210,7 @@ D.sig = {} D.sigID = {} D.IDsig = {} - D.dock = DevianDock + D.dock = _G.DevianDock D.dock.buttons = D.dock.buttons or {} return id, name @@ -244,7 +246,7 @@ D:Print("Profile |cFFFFFF00".. list_id .."|r saved.") else - DevianLoadMessage = "Switched profiles." + _G.DevianLoadMessage = "Switched profiles." list_id = tonumber(mode) if list_id ~= db.main_profile then @@ -255,7 +257,7 @@ end elseif mode == nil then list_id = (db.current_profile ~= db.main_profile) and db.main_profile or db.last_profile - DevianLoadMessage = "Switched between main and recent profile ("..db.current_profile..' and '..list_id..')' + _G.DevianLoadMessage = "Switched between main and recent profile ("..db.current_profile..' and '..list_id..')' db.current_profile = list_id scan_func = D.Load else @@ -276,7 +278,7 @@ end if scan_func == D.Load then - ReloadUI() + _G.ReloadUI() end D.Profile(db.current_profile) end @@ -375,6 +377,7 @@ -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. -- @param ... Output contents. + function D.Message(prefix, ...) if not currentProfile.workspace then return D.oldprint(prefix, ...) @@ -424,17 +427,17 @@ if type(var) == 'table' then if type(var.GetName) == 'function' then - var = '' + var = '[table:'..tostring(var:GetName())..']' else var = '<'..tostring(var)..'>' end elseif type(var) == 'boolean' then - var = var and 'true' or 'false' + var = var and '[true]' or '[false]' elseif type(var) == 'function' then - var = '' + var = '['..tostring(var)..']' elseif type(var) == 'nil' then - var = 'nil' + var = '[nil]' else var = tostring(var) end @@ -444,7 +447,7 @@ local message = concat(buffer, ' ') for id, channel in pairs(sendq) do if channel.width < 250 then - prefix = string.sub(prefix, 0,2) + prefix = sub(prefix, 0,2) end channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime()) if not D.dock.buttons[id].newMessage then @@ -469,6 +472,7 @@ local blocked = {profiles = true, debugmode = true} D.SetDefaults = function() + local DevianDB = _G.DevianDB for k,v in pairs(DevianDB) do if not blocked[k] then DevianDB[k] = nil @@ -479,13 +483,13 @@ DevianDB[k] = v end end - DevianLoadMessage = "Non-user SavedVars have been reset." - ReloadUI() + _G.DevianLoadMessage = "Non-user SavedVars have been reset." + _G.ReloadUI() end D.SetDefaultsAll = function () - DevianDB = nil - DevianLoadMessage = "All SavedVars wiped." - ReloadUI() + _G.DevianDB = nil + _G.DevianLoadMessage = "All SavedVars wiped." + _G.ReloadUI() end D.ConfigCommand = function(self, input) if not self.config then @@ -499,6 +503,7 @@ -- commands local cmdlist = { + ['dfs'] = 'FrameHelper_Update', ['dvn'] = "Command", ['devian'] = "Command", ['dvc'] = "Console_Toggle", @@ -521,9 +526,9 @@ self.db = db --- - if DevianLoadMessage then - D:Print(DevianLoadMessage) - DevianLoadMessage = nil + if _G.DevianLoadMessage then + D:Print(_G.DevianLoadMessage) + _G.DevianLoadMessage = nil end @@ -557,7 +562,7 @@ D.console[currentProfile.current_channel]:ToFront() -- bring the current channel to the front end - DevianDock:Show() + _G.DevianDock:Show() D:UpdateDock() end end diff -r d636ff1b17ce -r da5ff1fc9fb6 UI.lua --- a/UI.lua Mon Mar 28 02:09:53 2016 -0400 +++ b/UI.lua Sat Apr 09 05:51:19 2016 -0400 @@ -320,7 +320,7 @@ end -- new channel overrides if isNew then - if D.sigID[sig]then -- find a non-clashing signature + if D.sigID[sig] then -- find a non-clashing signature local result, i = sig, 1 while D.sigID[result] do result = sig .. i @@ -330,6 +330,8 @@ end t_id = self.max_channel + 1 t_info.index = t_id + + self.max_channel = t_id --@debug@ --print('setchan(3a) t_id, isNew, sig, t_info.signature=', t_id, isNew, sig, t_info.signature)--@end-debug@ else @@ -452,3 +454,67 @@ self:Print('toggled: '..concat(result, ', ')) end end + +local frame_helper = CreateFrame('Frame', 'DevianFrameHelper', UIParent) +frame_helper.fill = frame_helper:CreateTexture(nil, 'BACKGROUND') +frame_helper.fill:SetTexture(1,0,0,1) +frame_helper.fill:SetAllPoints(frame_helper) +D.FrameHelper_Update = function(input, editbox) + local frame, func = D:GetArgs(input,2) + + if type(frame) == 'string' then + if not _G[frame] then + return + end + frame = _G[frame] + elseif type(frame) == 'table' and frame.IsVisible then + local x, y = frame:GetCenter() + if not (x or y) then + frame_helper:ClearAllPoints() + frame_helper:SetPoint('CENTER') + end + else + local frame = EnumerateFrames(); -- Get the first frame + while frame do + if ( frame:IsVisible() and MouseIsOver(frame) ) then + print(frame:GetName() or string.format("[Unnamed Frame: %s]", tostring(frame))); + end + frame = EnumerateFrames(frame); -- Get the next frame + end + end + + frame_helper:SetPoint('TOPLEFT', UIParent, 'BOTTOMLEFT', frameHandle:GetLeft(), frameHandle:GetTop()) + frame_helper:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMLEFT', frameHandle:GetRight(), frameHandle:GetBottom()) + +end + + +local frame_guide_init = function(self) + self.testU = self.testU or self:CreateTexture('TestU', 'OVERLAY', 'VnTestLine') + self.testB = self.testB or self:CreateTexture('TestB', 'OVERLAY', 'VnTestLine') + self.testL = self.testL or self:CreateTexture('TestL', 'OVERLAY', 'VnTestLine') + self.testR = self.testR or self:CreateTexture('TestR', 'OVERLAY', 'VnTestLine') +end +local frame_guide = function(self, target) + if not target then return end + if target:IsDragging() then return end + local thickness = 1 + local midX, midY = target:GetCenter() + local width, height = target:GetWidth() * 1.5, target:GetHeight() * 1.5 + --print('frame', target:GetLeft(), target:GetTop(), target:GetRight(), target:GetBottom()) + self.testB:ClearAllPoints() + self.testB:SetPoint('TOP', UIParent, 'BOTTOMLEFT', midX, target:GetBottom()) + self.testB:SetSize(width,thickness) + + self.testU:ClearAllPoints() + self.testU:SetPoint('BOTTOM', UIParent, 'BOTTOMLEFT', midX, target:GetTop()) + self.testU:SetSize(width,thickness) + + self.testL:ClearAllPoints() + self.testL:SetPoint('RIGHT', UIParent, 'BOTTOMLEFT', target:GetLeft(), midY) + self.testL:SetSize(thickness,height) + + self.testR:ClearAllPoints() + self.testR:SetPoint('LEFT', UIParent, 'BOTTOMLEFT', target:GetRight(), midY) + self.testR:SetSize(thickness,height) +end \ No newline at end of file