changeset 89:b3ed963f482d v.2.1.92

- /dvc command needed a pre-defined enclosure to properly work through SlashCmdList - /dvn <profile name> and /dvn save <profile name> should resolve to and update the correct profile. - set some globals indicating the name and index of the workspace in use - DEVIAN_WORKSPACE (bool) - DEVIAN_PNAME (string) - DEVIAN_PID (number)
author Nenue
date Wed, 10 Aug 2016 06:58:27 -0400
parents 7ff0579e5a6e
children 44bdeab03764
files Devian.lua UI.lua
diffstat 2 files changed, 77 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/Devian.lua	Tue Jul 26 09:50:45 2016 -0400
+++ b/Devian.lua	Wed Aug 10 06:58:27 2016 -0400
@@ -18,6 +18,8 @@
 local playerRealm = playerName .. '-' .. GetRealmName()
 local num_dock_tabs = 0
 DEVIAN_WORKSPACE = false
+DEVIAN_PNAME = 'Dvn'
+DEVIAN_PID = 0
 
 
 DevianLoadMessage = setmetatable({}, {
@@ -224,11 +226,15 @@
   currentProfile.char[playerRealm] = currentProfile.char[playerRealm] or {}
   if currentProfile.workspace then
     DEVIAN_WORKSPACE = true
+    DEVIAN_PNAME = name
+    DEVIAN_PID = id
     setprinthandler(D.Message)
   else
     DEVIAN_WORKSPACE = false
+    DEVIAN_PNAME = ''
     print = function() end
   end
+  DEVIAN_PID =id
 
   D.unlisted = currentProfile.unlisted
   D.channels = currentProfile.channels
@@ -278,26 +284,57 @@
     return D.New(self, tag)
   elseif mode == 'remove' then
     return D.Remove(self, tag)
-  elseif tonumber(mode) ~= nil or mode == 'save' then
-    -- either a number of the save command
+  elseif mode ~= nil then
+    -- profile selector or save command
     if mode == 'save' then
       list_id = tonumber(tag)
-      if list_id == nil then
-        D:Print(L('Invalid ID from arg', tag))
+    else
+      list_id = tonumber(mode)
+    end
+
+    if not list_id then
+      if db.profilesName[tostring(list_id)] then
+        list_id = db.profilesName[tostring(list_id)]
+      else
+
+        D:Print(L('Unable to resolve profile ID/name', list_id, dest))
+        return
       end
+    end
+
+
+    if mode == 'save' then
       D.Profile(list_id, dest)
       scan_func = D.Save
-      D:Print("Profile |cFFFFFF00".. list_id .."|r saved.")
+
+
+      local name = currentProfile.name
+      if dest then
+        dest = dest:gsub("$%s+", ''):gsub("%s+^", '')
+        if dest then
+          if name then
+            db.profilesName[name] = nil
+          end
+          db.profiles[list_id].name = dest
+          db.profilesName[dest] = list_id
+        end
+      end
+
+
+      D:Print("Profile |cFFFFFF00".. list_id .."|r:|cFF00FFFF".. name .."|r saved.")
     else
 
-      D.LoadMessage "Switched profiles."
+      if db.profiles[list_id] then
+        D.LoadMessage ("Switched profiles.")
+        if list_id ~= db.main_profile then
+          db.last_profile = list_id
+        end
+        db.current_profile = list_id
+        scan_func = D.Load
+      else
+        return D:PrintHelp()
+      end
 
-      list_id = tonumber(mode)
-      if list_id ~= db.main_profile then
-        db.last_profile = list_id
-      end
-      db.current_profile = list_id
-      scan_func = D.Load
     end
   elseif mode == nil then
     list_id = (db.current_profile ~= db.main_profile) and db.main_profile or db.last_profile
@@ -305,6 +342,8 @@
     db.current_profile = list_id
     scan_func = D.Load
   else
+
+
     return D:PrintHelp()
   end
 
@@ -595,29 +634,11 @@
   D:Print('Tag color cache cleared.')
 end
 
-function D:OnEnable()
 
-  -- commands
-  local cmdlist = {
-    ['dfs'] = 'FrameHelper_Update',
-    ['dvn'] = "Command",
-    ['devian'] = "Command",
-    ['dvc'] = function() D:Console_Toggle() end,
-    ['dvncolors'] = "UnsetColors",
-    ['cleandvn'] = "SetDefaultsAll",
-    ['resetdvn'] = "SetDefaults",
-  }
-  for cmd, func in pairs(cmdlist) do
-    local CMD = cmd:upper()
-    _G['SLASH_' .. CMD:upper() .. '1'] = "/"..cmd
-    if type(func == 'string') then
-      SlashCmdList[CMD] = D[func]
-    else
-      SlashCmdList[CMD] = func
-    end
+function D.ConsoleCommand (cmd)
+  D:Console_Toggle(cmd)
+end
 
-  end
-end
 
 function D:OnInitialize()
   L = D.L
@@ -639,6 +660,28 @@
   end
 
 
+  -- commands
+  local cmdlist = {
+    ['dvn'] = "Command",
+    ['devian'] = "Command",
+    ['dvc'] = "ConsoleCommand",
+    ['dvncolors'] = "UnsetColors",
+    ['cleandvn'] = "SetDefaultsAll",
+    ['resetdvn'] = "SetDefaults",
+  }
+  for cmd, func in pairs(cmdlist) do
+    local CMD = cmd:upper()
+    _G['SLASH_' .. CMD .. '1'] = "/"..cmd
+
+    if type(func == 'string') then
+      print('SLASH_' .. CMD .. '1','/'.. cmd, func)
+      SlashCmdList[CMD] = D[func]
+    else
+      print('SLASH_' .. CMD .. '1','/'.. cmd, func)
+      SlashCmdList[CMD] = func
+    end
+  end
+
   --- initialize the current profile
   local id, name = D.Profile(db.current_profile or 1)
   D:Print('Using profile |cFFFFFF00'.. id ..'|r: |cFF00FF00'..currentProfile.name..'|r')
@@ -677,3 +720,4 @@
     D:UpdateDock()
   end
 end
+
--- a/UI.lua	Tue Jul 26 09:50:45 2016 -0400
+++ b/UI.lua	Wed Aug 10 06:58:27 2016 -0400
@@ -457,67 +457,3 @@
     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:SetColorTexture(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