Quantcast

Bunch of updates

MilleXIV [08-28-16 - 15:06]
Bunch of updates

Tradeskill module, enabling/disabling issue fixes
Filename
locales/enUS.lua
modules/armor.lua
modules/clock.lua
modules/currency.lua
modules/gold.lua
modules/load_modules.xml
modules/old/tradeskill.lua
modules/system.lua
modules/tradeskill.lua
modules/travel.lua
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 1be2a6a..b2cd922 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -101,3 +101,6 @@ L['Addons to Show in Tooltip'] = true;
 L['Show All Addons in Tooltip with Shift'] = true;
 L['Memory Usage'] = true;
 L['Garbage Collect'] = true;
+
+L['Use Class Colors'] = true;
+L['Cooldowns'] = true;
diff --git a/modules/armor.lua b/modules/armor.lua
index 5fb7234..e7698cf 100644
--- a/modules/armor.lua
+++ b/modules/armor.lua
@@ -30,8 +30,8 @@ function ArmorModule:OnEnable()
   if self.armorFrame == nil then
     self.armorFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
     xb:RegisterFrame('armorFrame', self.armorFrame)
-    self.armorFrame:Show()
   end
+  self.armorFrame:Show()
   self:CreateFrames()
   self:RegisterFrameEvents()
   self:Refresh()
@@ -188,7 +188,14 @@ function ArmorModule:GetConfig()
         order = 0,
         type = "toggle",
         get = function() return xb.db.profile.modules.armor.enabled; end,
-        set = function(_, val) xb.db.profile.modules.armor.enabled = val; self:Refresh(); end
+        set = function(_, val)
+          xb.db.profile.modules.armor.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end
       },
       ilvlAlways = {
         name = L['Always Show Item Level'],
diff --git a/modules/clock.lua b/modules/clock.lua
index ab3efe9..888d9c8 100644
--- a/modules/clock.lua
+++ b/modules/clock.lua
@@ -3,7 +3,7 @@ local _G = _G;
 local xb = XIVBar;
 local L = XIVBar.L;

-local ClockModule = xb:NewModule("ClockModule")
+local ClockModule = xb:NewModule("ClockModule", 'AceEvent-3.0')

 function ClockModule:GetName()
   return L['Clock'];
@@ -49,6 +49,7 @@ function ClockModule:OnEnable()
     self.clockFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
     xb:RegisterFrame('clockFrame', self.clockFrame)
   end
+  self.clockFrame:Show()
   self.elapsed = 0
   self:CreateFrames()
   self:CreateClickFunctions()
@@ -70,7 +71,7 @@ function ClockModule:Refresh()
     return
   end

-  self.clockText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.modules.clock.fontSize)
+  self.clockText:SetFont(xb:GetFont(db.modules.clock.fontSize))
   self:SetClockColor()

   self.clockFrame:SetSize(self.clockText:GetStringWidth(), self.clockText:GetStringHeight())
@@ -81,7 +82,7 @@ function ClockModule:Refresh()

   self.clockText:SetPoint('CENTER')

-  self.eventText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.smallFontSize)
+  self.eventText:SetFont(xb:GetFont(db.text.smallFontSize))
   self.eventText:SetPoint('CENTER', self.clockText, xb.miniTextPosition)
 end

@@ -191,7 +192,14 @@ function ClockModule:GetConfig()
         order = 0,
         type = "toggle",
         get = function() return xb.db.profile.modules.clock.enabled; end,
-        set = function(_, val) xb.db.profile.modules.clock.enabled = val; end,
+        set = function(_, val)
+          xb.db.profile.modules.clock.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
         width = "full"
       },
       useServerTime = {
diff --git a/modules/currency.lua b/modules/currency.lua
index 643a8b5..dbee410 100644
--- a/modules/currency.lua
+++ b/modules/currency.lua
@@ -32,10 +32,11 @@ end

 function CurrencyModule:OnEnable()
   if self.currencyFrame == nil then
-    self.currencyFrame = CreateFrame("FRAME", 'XIV_currencyFrame', xb:GetFrame('clockFrame'))
+    self.currencyFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
     xb:RegisterFrame('currencyFrame', self.currencyFrame)
   end

+  self.currencyFrame:Show()
   self:CreateFrames()
   self:RegisterFrameEvents()
   self:Refresh()
@@ -115,7 +116,13 @@ function CurrencyModule:Refresh()
   end -- show currencies

   --self.currencyFrame:SetSize(self.goldButton:GetSize())
-  self.currencyFrame:SetPoint('LEFT', self.currencyFrame:GetParent(), 'RIGHT', db.general.moduleSpacing, 0)
+  local relativeAnchorPoint = 'RIGHT'
+  local xOffset = db.general.moduleSpacing
+  if not xb:GetFrame('tradeskillFrame'):IsVisible() then
+    relativeAnchorPoint = 'LEFT'
+    xOffset = 0
+  end
+  self.currencyFrame:SetPoint('LEFT', xb:GetFrame('tradeskillFrame'), relativeAnchorPoint, xOffset, 0)
 end

 function CurrencyModule:StyleCurrencyFrame(curId, i)
@@ -129,7 +136,7 @@ function CurrencyModule:StyleCurrencyFrame(curId, i)

   local iconPoint = 'RIGHT'
   local textPoint = 'LEFT'
-  local padding = -5
+  local padding = -3

   if xb.db.profile.modules.currency.textOnRight then
     iconPoint = 'LEFT'
@@ -224,6 +231,19 @@ function CurrencyModule:RegisterFrameEvents()
     local db = xb.db.profile
     self.xpText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
   end)
+
+  self:RegisterMessage('XIVBar_FrameHide', function(_, name)
+    if name == 'tradeskillFrame' then
+      self:Refresh()
+    end
+  end)
+
+  self:RegisterMessage('XIVBar_FrameShow', function(_, name)
+    if name == 'tradeskillFrame' then
+      self:Refresh()
+    end
+  end)
+
   --[[
   self.goldButton:EnableMouse(true)
   self.goldButton:RegisterForClicks("AnyUp")
@@ -322,7 +342,14 @@ function CurrencyModule:GetConfig()
         order = 0,
         type = "toggle",
         get = function() return xb.db.profile.modules.currency.enabled; end,
-        set = function(_, val) xb.db.profile.modules.currency.enabled = val; self:Refresh(); end,
+        set = function(_, val)
+          xb.db.profile.modules.currency.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
         width = "full"
       },
       showXPbar = {
diff --git a/modules/gold.lua b/modules/gold.lua
index 6b2930f..9c09d7c 100644
--- a/modules/gold.lua
+++ b/modules/gold.lua
@@ -15,9 +15,10 @@ end

 function GoldModule:OnEnable()
   if self.goldFrame == nil then
-    self.goldFrame = CreateFrame("FRAME", nil, xb:GetFrame('hearthFrame'))
+    self.goldFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
     xb:RegisterFrame('goldFrame', self.goldFrame)
   end
+  self.goldFrame:Show()
   if xb.db.factionrealm[xb.constants.playerName] == nil then
     xb.db.factionrealm[xb.constants.playerName] = {currentMoney = GetMoney()}
   else
@@ -83,7 +84,14 @@ function GoldModule:Refresh()
   self.goldButton:SetPoint('LEFT')

   self.goldFrame:SetSize(self.goldButton:GetSize())
-  self.goldFrame:SetPoint('RIGHT', self.goldFrame:GetParent(), 'LEFT', -(db.general.moduleSpacing), 0)
+
+  local relativeAnchorPoint = 'LEFT'
+  local xOffset = db.general.moduleSpacing
+  if not xb:GetFrame('travelFrame'):IsVisible() then
+    relativeAnchorPoint = 'RIGHT'
+    xOffset = 0
+  end
+  self.goldFrame:SetPoint('RIGHT', xb:GetFrame('travelFrame'), relativeAnchorPoint, -(xOffset), 0)
 end

 function GoldModule:CreateFrames()
@@ -133,6 +141,18 @@ function GoldModule:RegisterFrameEvents()
     if InCombatLockdown() then return; end
     ToggleAllBags()
   end)
+
+  self:RegisterMessage('XIVBar_FrameHide', function(_, name)
+    if name == 'travelFrame' then
+      self:Refresh()
+    end
+  end)
+
+  self:RegisterMessage('XIVBar_FrameShow', function(_, name)
+    if name == 'travelFrame' then
+      self:Refresh()
+    end
+  end)
 end

 function GoldModule:PLAYER_MONEY()
@@ -191,7 +211,14 @@ function GoldModule:GetConfig()
         order = 0,
         type = "toggle",
         get = function() return xb.db.profile.modules.gold.enabled; end,
-        set = function(_, val) xb.db.profile.modules.gold.enabled = val; self:Refresh(); end,
+        set = function(_, val)
+          xb.db.profile.modules.gold.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
         width = "full"
       },
       showSmallCoins = {
diff --git a/modules/load_modules.xml b/modules/load_modules.xml
index df85e5f..ee7ec0d 100644
--- a/modules/load_modules.xml
+++ b/modules/load_modules.xml
@@ -5,6 +5,7 @@
   <Script file="armor.lua" />
   <Script file="travel.lua" />
   <Script file="gold.lua" />
+  <Script file="tradeskill.lua" />
   <Script file="currency.lua" />
   <Script file="system.lua" />
 </Ui>
diff --git a/modules/old/tradeskill.lua b/modules/old/tradeskill.lua
new file mode 100644
index 0000000..433d6d3
--- /dev/null
+++ b/modules/old/tradeskill.lua
@@ -0,0 +1,292 @@
+local addon, ns = ...
+local cfg = ns.cfg
+local unpack = unpack
+--------------------------------------------------------------
+if not cfg.tradeSkill.show then return end
+
+if not IsAddOnLoaded("Blizzard_TradeSkillUI") then
+	TradeSkillFrame_LoadUI();
+end
+
+local proffessions = {
+	['ALCHEMY'] = {"Alchemical Catalyst", "Secrets of Draenor Alchemy", "Northrend Alchemy Research"},
+	['BLACKSMITHING'] = {"Truesteel Ignot", "Secrets of Draenor Blacksmithing"},
+	['ENCHANTING'] = {"Temporal Crystal", "Secrets of Draenor Enchanting"},
+	['ENGINEERING'] = {"Gearsoring Parts", "Secrets of Draenor Engineering"},
+	['INSCRIPTION'] = {"War Paints", "Secrets of Draenor Inscription","Draenor Merchant Order"},
+	['JEWELCRAFTING'] = {"Taladite Crystal", "Secrets of Draenor Jewelcrafting"},
+	['LEATHERWORKING'] = {"Burnished Leather", "Secrets of Draenor Leatherworking"},
+	['TAILORING'] = {"Hexweave Cloth", "Secrets of Draenor Tailoring"},
+}
+
+local profIcons = {
+	[164] = 'blacksmithing',
+	[165] = 'leatherworking',
+	[171] = 'alchemy',
+	[182] = 'herbalism',
+	[186] = 'mining',
+	[202] = 'engineering',
+	[333] = 'enchanting',
+	[755] = 'jewelcrafting',
+	[773] = 'inscription',
+	[197] = 'tailoring',
+	[393] = 'skinning'
+}
+
+local prof1OnCooldown = false
+local prof2OnCooldown = false
+
+local tradeSkillFrame = CreateFrame("Frame",nil, cfg.SXframe)
+tradeSkillFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 110,0)
+tradeSkillFrame:SetSize(16, 16)
+---------------------------------------------------------------------
+local primaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame)
+primaryTradeSkillFrame:SetSize(16, 16)
+primaryTradeSkillFrame:SetPoint("LEFT")
+primaryTradeSkillFrame:EnableMouse(true)
+primaryTradeSkillFrame:RegisterForClicks("AnyUp")
+
+local primaryTradeSkillIcon = primaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7)
+primaryTradeSkillIcon:SetSize(16, 16)
+primaryTradeSkillIcon:SetPoint("LEFT")
+primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+
+local primaryTradeSkillText = primaryTradeSkillFrame:CreateFontString(nil, "OVERLAY")
+primaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize)
+primaryTradeSkillText:SetPoint("RIGHT",primaryTradeSkillFrame,2,0 )
+primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+
+local primaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, primaryTradeSkillFrame)
+primaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1)
+primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
+primaryTradeSkillStatusbar:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2)
+
+local primaryTradeSkillStatusbarBG = primaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7)
+primaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2)
+primaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive))
+
+primaryTradeSkillFrame:SetScript("OnEnter", function()
+	if InCombatLockdown() then return end
+	primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover))
+	primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover))
+	if not cfg.tradeSkill.showTooltip then return end
+	GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos)
+	addCooldownsToTooltip()
+	GameTooltip:Show()
+end)
+
+primaryTradeSkillFrame:SetScript("OnLeave", function()
+	if prof1OnCooldown then
+		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
+		primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
+	else
+		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+		primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+	end
+	primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
+	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
+end)
+
+primaryTradeSkillFrame:SetScript("OnClick", function(self, button, down)
+	if InCombatLockdown() then return end
+	if button == "LeftButton" then
+		local prof1, prof2 = GetProfessions()
+		if prof1 then
+			if (GetProfessionInfo(prof1) == ('Herbalism')) then
+				ToggleSpellBook(BOOKTYPE_PROFESSION)
+			elseif(GetProfessionInfo(prof1) == ('Skinning')) then
+				ToggleSpellBook(BOOKTYPE_PROFESSION)
+			elseif(GetProfessionInfo(prof1) == ('Mining')) then
+				CastSpellByName("Smelting")
+			else
+				CastSpellByName((GetProfessionInfo(prof1)))
+			end
+		end
+	elseif button == "RightButton" then
+		ToggleSpellBook(BOOKTYPE_PROFESSION)
+	end
+end)
+---------------------------------------------------------------------
+local secondaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame)
+secondaryTradeSkillFrame:SetPoint("RIGHT")
+secondaryTradeSkillFrame:SetSize(16, 16)
+secondaryTradeSkillFrame:EnableMouse(true)
+secondaryTradeSkillFrame:RegisterForClicks("AnyUp")
+
+local secondaryTradeSkillIcon = secondaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7)
+secondaryTradeSkillIcon:SetSize(16, 16)
+secondaryTradeSkillIcon:SetPoint("LEFT")
+secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+
+local secondaryTradeSkillText = secondaryTradeSkillFrame:CreateFontString(nil, "OVERLAY")
+secondaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize)
+secondaryTradeSkillText:SetPoint("LEFT", secondaryTradeSkillIcon,"RIGHT",2,0)
+secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+
+local secondaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, secondaryTradeSkillFrame)
+secondaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1)
+secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
+secondaryTradeSkillStatusbar:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2)
+
+local secondaryTradeSkillStatusbarBG = secondaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7)
+secondaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2)
+secondaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive))
+
+secondaryTradeSkillFrame:SetScript("OnEnter", function()
+	if InCombatLockdown() then return end
+	secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover))
+	secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover))
+	if not cfg.tradeSkill.showTooltip then return end
+	GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos)
+	addCooldownsToTooltip()
+	GameTooltip:Show()
+end)
+
+secondaryTradeSkillFrame:SetScript("OnLeave", function()
+	if prof2OnCooldown then
+		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
+		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
+	else
+		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+	end
+	secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
+	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
+end)
+
+secondaryTradeSkillFrame:SetScript("OnClick", function(self, button, down)
+	if InCombatLockdown() then return end
+	if button == "LeftButton" then
+		local prof1, prof2 = GetProfessions()
+		if prof2 then
+			if (GetProfessionInfo(prof2) == ('Herbalism')) then
+				ToggleSpellBook(BOOKTYPE_PROFESSION)
+			elseif(GetProfessionInfo(prof2) == ('Skinning')) then
+				ToggleSpellBook(BOOKTYPE_PROFESSION)
+			elseif(GetProfessionInfo(prof2) == ('Mining')) then
+				CastSpellByName("Smelting")
+			else
+				CastSpellByName((GetProfessionInfo(prof2)))
+			end
+		end
+	elseif button == "RightButton" then
+		ToggleSpellBook(BOOKTYPE_PROFESSION)
+	end
+end)
+---------------------------------------------------------------------
+
+local eventframe = CreateFrame("Frame")
+eventframe:RegisterEvent("PLAYER_ENTERING_WORLD")
+eventframe:RegisterEvent("TRADE_SKILL_UPDATE")
+eventframe:RegisterEvent("TRAINER_CLOSED")
+eventframe:RegisterEvent("SPELLS_CHANGED")
+eventframe:RegisterUnitEvent("UNIT_SPELLCAST_STOP", "player")
+
+eventframe:SetScript("OnEvent", function(self,event, ...)
+	local prof1, prof2 = GetProfessions()
+	if prof1 then
+		local prof1Name, _, prof1Rank, prof1MaxRank, _, _, prof1SkillLine = GetProfessionInfo(prof1)
+		prof1Name = string.upper(prof1Name)
+		primaryTradeSkillText:SetText(prof1Name)
+		primaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..profIcons[prof1SkillLine])
+		if prof1Rank == prof1MaxRank then
+			primaryTradeSkillStatusbar:Hide()
+		else
+			primaryTradeSkillStatusbar:Show()
+		end
+		primaryTradeSkillStatusbar:SetMinMaxValues(0, prof1MaxRank)
+		primaryTradeSkillStatusbar:SetValue(prof1Rank)
+		primaryTradeSkillFrame:SetSize(primaryTradeSkillText:GetStringWidth()+18, 16)
+		primaryTradeSkillStatusbar:SetSize(primaryTradeSkillText:GetStringWidth(),3)
+		primaryTradeSkillStatusbarBG:SetSize(primaryTradeSkillText:GetStringWidth(),3)
+		primaryTradeSkillFrame:Show()
+		primaryTradeSkillFrame:EnableMouse(true)
+
+		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+		primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+
+		--[[for i=1,GetNumTradeSkills() do
+			local cooldown = GetTradeSkillCooldown(i)
+			if cooldown then
+				local name = GetTradeSkillInfo(i)
+				for k, v in pairs(proffessions) do
+					for u = 1, #v do
+						if k == prof1Name then
+							if v[u] == name then
+								if not prof1OnCooldown then prof1OnCooldown = true end
+								primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
+								primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
+								if not prof1OnCooldown then
+									primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+									primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+								end
+							end
+						end
+					end
+				end
+			end
+		end]]--
+	else
+		primaryTradeSkillFrame:Hide()
+		primaryTradeSkillFrame:EnableMouse(false)
+	end
+
+	if prof2 then
+		local prof2Name, _, prof2rank, prof2maxRank, _, _, prof2SkillLine = GetProfessionInfo(prof2)
+		prof2Name = string.upper(prof2Name)
+		secondaryTradeSkillText:SetText(prof2Name)
+		secondaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..profIcons[prof2SkillLine])
+		if prof2rank == prof2maxRank then
+			secondaryTradeSkillStatusbar:Hide()
+		else
+			secondaryTradeSkillStatusbar:Show()
+		end
+		secondaryTradeSkillStatusbar:SetMinMaxValues(0, prof2maxRank)
+		secondaryTradeSkillStatusbar:SetValue(prof2rank)
+		secondaryTradeSkillFrame:SetSize(secondaryTradeSkillText:GetStringWidth()+18, 16)
+		secondaryTradeSkillStatusbar:SetSize(secondaryTradeSkillText:GetStringWidth(),3)
+		secondaryTradeSkillStatusbarBG:SetSize(secondaryTradeSkillText:GetStringWidth(),3)
+		secondaryTradeSkillFrame:Show()
+		secondaryTradeSkillFrame:EnableMouse(true)
+
+		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+
+		--[[for i=1,GetNumTradeSkills() do
+			local cooldown = GetTradeSkillCooldown(i)
+			if cooldown then
+				local name = GetTradeSkillInfo(i)
+				for k, v in pairs(proffessions) do
+					for u = 1, #v do
+						if k == prof2Name then
+							if v[u] == name then
+								if not prof2OnCooldown then prof2OnCooldown = true end
+								secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
+								secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
+								if not prof2OnCooldown then
+									secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
+									secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
+								end
+							end
+						end
+					end
+				end
+			end
+		end]]--
+	else
+		secondaryTradeSkillFrame:Hide()
+		secondaryTradeSkillFrame:EnableMouse(false)
+	end
+	tradeSkillFrame:SetSize((primaryTradeSkillFrame:GetWidth())+(secondaryTradeSkillFrame:GetWidth()+4), 16)
+end)
+
+
+function addCooldownsToTooltip()
+	for i,v in pairs(C_TradeSkillUI.GetFilteredRecipeIDs()) do
+	  local _, cooldown, secondsToCooldown, dunno = C_TradeSkillUI.GetRecipeCooldown(v)
+	  if cooldown then
+	    local name = C_TradeSkillUI.GetRecipeInfo(v).name
+	    GameTooltip:AddDoubleLine(name, SecondsToTime(secondsToCooldown), 1, 1, 0, 1, 1, 1)
+	  end
+	end
+end
diff --git a/modules/system.lua b/modules/system.lua
index 1e8abdf..fe4ad77 100644
--- a/modules/system.lua
+++ b/modules/system.lua
@@ -15,10 +15,11 @@ end

 function SystemModule:OnEnable()
   if self.systemFrame == nil then
-    self.systemFrame = CreateFrame("FRAME", nil, xb:GetFrame('goldFrame'))
+    self.systemFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
     xb:RegisterFrame('systemFrame', self.systemFrame)
   end

+  self.systemFrame:Show()
   self:CreateFrames()
   self:RegisterFrameEvents()
   self:Refresh()
@@ -90,7 +91,13 @@ function SystemModule:Refresh()
   self.systemFrame:SetSize(self.fpsFrame:GetWidth() + self.pingFrame:GetWidth(), xb:GetHeight())

   --self.systemFrame:SetSize()
-  self.systemFrame:SetPoint('RIGHT', self.systemFrame:GetParent(), 'LEFT', -(db.general.moduleSpacing), 0)
+  local relativeAnchorPoint = 'LEFT'
+  local xOffset = db.general.moduleSpacing
+  if not xb:GetFrame('goldFrame'):IsVisible() then
+    relativeAnchorPoint = 'RIGHT'
+    xOffset = 0
+  end
+  self.systemFrame:SetPoint('RIGHT', xb:GetFrame('goldFrame'), relativeAnchorPoint, -(xOffset), 0)
 end

 function SystemModule:UpdateTexts()
@@ -211,6 +218,18 @@ function SystemModule:RegisterFrameEvents()
       SystemModule.elapsed = 0
     end
   end)
+
+  self:RegisterMessage('XIVBar_FrameHide', function(_, name)
+    if name == 'goldFrame' then
+      self:Refresh()
+    end
+  end)
+
+  self:RegisterMessage('XIVBar_FrameShow', function(_, name)
+    if name == 'goldFrame' then
+      self:Refresh()
+    end
+  end)
 end

 function SystemModule:ShowTooltip()
@@ -276,7 +295,14 @@ function SystemModule:GetConfig()
         order = 0,
         type = "toggle",
         get = function() return xb.db.profile.modules.system.enabled; end,
-        set = function(_, val) xb.db.profile.modules.system.enabled = val; self:Refresh(); end,
+        set = function(_, val)
+          xb.db.profile.modules.system.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
         width = "full"
       },
       showTooltip = {
diff --git a/modules/tradeskill.lua b/modules/tradeskill.lua
index 433d6d3..1a1e8c6 100644
--- a/modules/tradeskill.lua
+++ b/modules/tradeskill.lua
@@ -1,292 +1,295 @@
-local addon, ns = ...
-local cfg = ns.cfg
-local unpack = unpack
---------------------------------------------------------------
-if not cfg.tradeSkill.show then return end
-
-if not IsAddOnLoaded("Blizzard_TradeSkillUI") then
-	TradeSkillFrame_LoadUI();
+local AddOnName, XIVBar = ...;
+local _G = _G;
+local xb = XIVBar;
+local L = XIVBar.L;
+
+local TradeskillModule = xb:NewModule("TradeskillModule", 'AceEvent-3.0')
+
+function TradeskillModule:GetName()
+  return TRADESKILLS;
+end
+
+function TradeskillModule:OnInitialize()
+  self.profIcons = {
+  	[164] = 'blacksmithing',
+  	[165] = 'leatherworking',
+  	[171] = 'alchemy',
+  	[182] = 'herbalism',
+  	[186] = 'mining',
+  	[202] = 'engineering',
+  	[333] = 'enchanting',
+  	[755] = 'jewelcrafting',
+  	[773] = 'inscription',
+  	[197] = 'tailoring',
+  	[393] = 'skinning'
+  }
+end
+
+function TradeskillModule:OnEnable()
+  if self.tradeskillFrame == nil then
+    self.tradeskillFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
+    xb:RegisterFrame('tradeskillFrame', self.tradeskillFrame)
+  end
+
+  self.tradeskillFrame:Show()
+
+  local prof1, prof2, _ = GetProfessions()
+  self.prof1 = prof1
+  self.prof2 = prof2
+
+  self:CreateFrames()
+  self:RegisterFrameEvents()
+  self:Refresh()
+end
+
+function TradeskillModule:OnDisable()
+  self.tradeskillFrame:Hide()
+  self:UnregisterEvent('TRADE_SKILL_UPDATE')
+  self:UnregisterEvent('SPELLS_CHANGED')
+  self:UnregisterEvent('UNIT_SPELLCAST_STOP')
+end
+
+function TradeskillModule:UpdateProfValues()
+  if self.prof1 then
+    local _, _, skill, cap, _ = GetProfessionInfo(self.prof1)
+    self.firstProfBar:SetMinMaxValues(1, cap)
+    self.firstProfBar:SetValue(skill)
+  end
+
+  if self.prof2 then
+    local _, _, skill, cap, _ = GetProfessionInfo(self.prof2)
+    self.secondProfBar:SetMinMaxValues(1, cap)
+    self.secondProfBar:SetValue(skill)
+  end
+end
+
+function TradeskillModule:Refresh()
+  if InCombatLockdown() then
+    self:UpdateProfValues()
+    return
+  end
+  local db = xb.db.profile
+  if self.tradeskillFrame == nil then return; end
+  if not db.modules.tradeskill.enabled then return; end
+  local iconSize = db.text.fontSize + db.general.barPadding
+
+  local totalWidth = 0
+
+  if self.prof1 then
+    self:StyleTradeskillFrame('firstProf', self.prof1)
+    totalWidth = totalWidth + self.firstProfFrame:GetWidth()
+    self.firstProfFrame:SetPoint('LEFT')
+  end
+
+  if self.prof2 then
+    self:StyleTradeskillFrame('secondProf', self.prof2)
+    totalWidth = totalWidth + self.secondProfFrame:GetWidth()
+    self.secondProfFrame:SetPoint('LEFT', self.firstProfFrame, 'RIGHT', 5, 0)
+  end
+
+  self:UpdateProfValues()
+
+  self.tradeskillFrame:SetSize(totalWidth, xb:GetHeight())
+
+  --self.tradeskillFrame:SetSize(self.goldButton:GetSize())
+
+  local relativeAnchorPoint = 'RIGHT'
+  local xOffset = db.general.moduleSpacing
+  if not xb:GetFrame('clockFrame'):IsVisible() then
+    relativeAnchorPoint = 'LEFT'
+    xOffset = 0
+  end
+  self.tradeskillFrame:SetPoint('LEFT', xb:GetFrame('clockFrame'), relativeAnchorPoint, xOffset, 0)
+end
+
+function TradeskillModule:StyleTradeskillFrame(framePrefix, profIndex)
+  local db = xb.db.profile
+  local iconSize = db.text.fontSize + db.general.barPadding
+  local name, _, skill, cap, _, spellOffset, skillLine, _ = GetProfessionInfo(profIndex)
+  local icon = xb.constants.mediaPath..'profession\\'..self.profIcons[skillLine]
+
+  local textHeight = floor((xb:GetHeight() - 4) / 2)
+  if skill == cap then
+    textHeight = db.text.fontSize
+  end
+  self[framePrefix..'Icon']:SetTexture(icon)
+  self[framePrefix..'Icon']:SetSize(iconSize, iconSize)
+  self[framePrefix..'Icon']:SetPoint('LEFT')
+  self[framePrefix..'Icon']:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)
+
+  self[framePrefix..'Text']:SetFont(xb:GetFont(textHeight))
+  self[framePrefix..'Text']:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  self[framePrefix..'Text']:SetText(string.upper(name))
+
+  if skill == cap then
+    self[framePrefix..'Text']:SetPoint('LEFT', self[framePrefix..'Icon'], 'RIGHT', 5, 0)
+  else
+    self[framePrefix..'Text']:SetPoint('TOPLEFT', self[framePrefix..'Icon'], 'TOPRIGHT', 5, 0)
+    self[framePrefix..'Bar']:SetStatusBarTexture(1, 1, 1)
+    if db.modules.tradeskill.barCC then
+      self[framePrefix..'Bar']:SetStatusBarColor(xb:GetClassColors())
+    else
+      self[framePrefix..'Bar']:SetStatusBarColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)
+    end
+    self[framePrefix..'Bar']:SetSize(self[framePrefix..'Text']:GetStringWidth(), (iconSize - textHeight - 2))
+    self[framePrefix..'Bar']:SetPoint('BOTTOMLEFT', self[framePrefix..'Icon'], 'BOTTOMRIGHT', 5, 0)
+
+    self[framePrefix..'BarBg']:SetAllPoints()
+    self[framePrefix..'BarBg']:SetColorTexture(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  end
+  self[framePrefix..'Frame']:SetSize(iconSize + self[framePrefix..'Text']:GetStringWidth() + 5, xb:GetHeight())
+
+  self[framePrefix..'Frame']:SetAttribute('spell', name) --- While this is usually the type of thing I'd put into RegisterFrameEvents(), I need it to update
+end
+
+function TradeskillModule:CreateFrames()
+  self.firstProfFrame = self.firstProfFrame or CreateFrame("BUTTON", nil, self.tradeskillFrame, 'SecureActionButtonTemplate')
+  self.firstProfIcon = self.firstProfIcon or self.firstProfFrame:CreateTexture(nil, 'OVERLAY')
+  self.firstProfText = self.firstProfText or self.firstProfFrame:CreateFontString(nil, 'OVERLAY')
+  self.firstProfBar = self.firstProfBar or CreateFrame('STATUSBAR', nil, self.firstProfFrame)
+  self.firstProfBarBg = self.firstProfBarBg or self.firstProfBar:CreateTexture(nil, 'BACKGROUND')
+
+  self.secondProfFrame = self.secondProfFrame or CreateFrame("BUTTON", nil, self.tradeskillFrame, 'SecureActionButtonTemplate')
+  self.secondProfIcon = self.secondProfIcon or self.secondProfFrame:CreateTexture(nil, 'OVERLAY')
+  self.secondProfText = self.secondProfText or self.secondProfFrame:CreateFontString(nil, 'OVERLAY')
+  self.secondProfBar = self.secondProfBar or CreateFrame('STATUSBAR', nil, self.secondProfFrame)
+  self.secondProfBarBg = self.secondProfBarBg or self.secondProfBar:CreateTexture(nil, 'BACKGROUND')
+end
+
+function TradeskillModule:RegisterFrameEvents()
+
+  self:RegisterEvent('TRADE_SKILL_UPDATE', 'Refresh')
+  self:RegisterEvent('SPELLS_CHANGED', 'Refresh')
+  self.tradeskillFrame:RegisterUnitEvent('UNIT_SPELLCAST_STOP', 'player')
+  self.tradeskillFrame:SetScript('OnEvent', function(_, event)
+    if event == 'UNIT_SPELLCAST_STOP' then
+      self:Refresh()
+    end
+  end)
+
+  self.firstProfFrame:EnableMouse(true)
+  self.firstProfFrame:RegisterForClicks('AnyUp')
+
+  self.firstProfFrame:SetScript('OnEnter', function()
+    if InCombatLockdown() then return; end
+    self.firstProfText:SetTextColor(unpack(xb:HoverColors()))
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      self:ShowTooltip()
+    end
+  end)
+  self.firstProfFrame:SetScript('OnLeave', function()
+    if InCombatLockdown() then return; end
+    local db = xb.db.profile
+    self.firstProfText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      GameTooltip:Hide()
+    end
+  end)
+  self.firstProfFrame:SetAttribute('*type1', 'spell')
+  self.firstProfFrame:SetAttribute('unit', 'player')
+
+  self.secondProfFrame:EnableMouse(true)
+  self.secondProfFrame:RegisterForClicks('AnyUp')
+
+  self.secondProfFrame:SetScript('OnEnter', function()
+    if InCombatLockdown() then return; end
+    self.secondProfText:SetTextColor(unpack(xb:HoverColors()))
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      self:ShowTooltip()
+    end
+  end)
+  self.secondProfFrame:SetScript('OnLeave', function()
+    if InCombatLockdown() then return; end
+    local db = xb.db.profile
+    self.secondProfText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      GameTooltip:Hide()
+    end
+  end)
+  self.secondProfFrame:SetAttribute('*type1', 'spell')
+  self.secondProfFrame:SetAttribute('unit', 'player')
+
+  self.tradeskillFrame:EnableMouse(true)
+  self.tradeskillFrame:SetScript('OnEnter', function()
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      self:ShowTooltip()
+    end
+  end)
+  self.tradeskillFrame:SetScript('OnLeave', function()
+    if xb.db.profile.modules.tradeskill.showTooltip then
+      GameTooltip:Hide()
+    end
+  end)
+
+  self:RegisterMessage('XIVBar_FrameHide', function(_, name)
+    if name == 'clockFrame' then
+      self:Refresh()
+    end
+  end)
+
+  self:RegisterMessage('XIVBar_FrameShow', function(_, name)
+    if name == 'clockFrame' then
+      self:Refresh()
+    end
+  end)
+end
+
+function TradeskillModule:ShowTooltip()
+  return
+  --[[
+  GameTooltip:SetOwner(self.tradeskillFrame, 'ANCHOR_'..xb.miniTextPosition)
+  GameTooltip:AddLine("[|cff6699FF"..L['Cooldowns'].."|r]")
+  GameTooltip:AddLine(" ")
+
+  local recipeIds = C_TradeSkillUI.GetAllRecipeIDs()
+
+  GameTooltip:AddLine(" ")
+  GameTooltip:AddDoubleLine('<'..L['Left-Click']..'>', L['Toggle Currency Frame'], 1, 1, 0, 1, 1, 1)
+  GameTooltip:Show()]]--
+end
+
+function TradeskillModule:GetDefaultOptions()
+  return 'tradeskill', {
+      enabled = true,
+      barCC = false,
+      showTooltip = true
+    }
 end

-local proffessions = {
-	['ALCHEMY'] = {"Alchemical Catalyst", "Secrets of Draenor Alchemy", "Northrend Alchemy Research"},
-	['BLACKSMITHING'] = {"Truesteel Ignot", "Secrets of Draenor Blacksmithing"},
-	['ENCHANTING'] = {"Temporal Crystal", "Secrets of Draenor Enchanting"},
-	['ENGINEERING'] = {"Gearsoring Parts", "Secrets of Draenor Engineering"},
-	['INSCRIPTION'] = {"War Paints", "Secrets of Draenor Inscription","Draenor Merchant Order"},
-	['JEWELCRAFTING'] = {"Taladite Crystal", "Secrets of Draenor Jewelcrafting"},
-	['LEATHERWORKING'] = {"Burnished Leather", "Secrets of Draenor Leatherworking"},
-	['TAILORING'] = {"Hexweave Cloth", "Secrets of Draenor Tailoring"},
-}
-
-local profIcons = {
-	[164] = 'blacksmithing',
-	[165] = 'leatherworking',
-	[171] = 'alchemy',
-	[182] = 'herbalism',
-	[186] = 'mining',
-	[202] = 'engineering',
-	[333] = 'enchanting',
-	[755] = 'jewelcrafting',
-	[773] = 'inscription',
-	[197] = 'tailoring',
-	[393] = 'skinning'
-}
-
-local prof1OnCooldown = false
-local prof2OnCooldown = false
-
-local tradeSkillFrame = CreateFrame("Frame",nil, cfg.SXframe)
-tradeSkillFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 110,0)
-tradeSkillFrame:SetSize(16, 16)
----------------------------------------------------------------------
-local primaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame)
-primaryTradeSkillFrame:SetSize(16, 16)
-primaryTradeSkillFrame:SetPoint("LEFT")
-primaryTradeSkillFrame:EnableMouse(true)
-primaryTradeSkillFrame:RegisterForClicks("AnyUp")
-
-local primaryTradeSkillIcon = primaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7)
-primaryTradeSkillIcon:SetSize(16, 16)
-primaryTradeSkillIcon:SetPoint("LEFT")
-primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-
-local primaryTradeSkillText = primaryTradeSkillFrame:CreateFontString(nil, "OVERLAY")
-primaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize)
-primaryTradeSkillText:SetPoint("RIGHT",primaryTradeSkillFrame,2,0 )
-primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-
-local primaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, primaryTradeSkillFrame)
-primaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1)
-primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
-primaryTradeSkillStatusbar:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2)
-
-local primaryTradeSkillStatusbarBG = primaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7)
-primaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2)
-primaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive))
-
-primaryTradeSkillFrame:SetScript("OnEnter", function()
-	if InCombatLockdown() then return end
-	primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover))
-	primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover))
-	if not cfg.tradeSkill.showTooltip then return end
-	GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos)
-	addCooldownsToTooltip()
-	GameTooltip:Show()
-end)
-
-primaryTradeSkillFrame:SetScript("OnLeave", function()
-	if prof1OnCooldown then
-		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
-		primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
-	else
-		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-		primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-	end
-	primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
-	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
-end)
-
-primaryTradeSkillFrame:SetScript("OnClick", function(self, button, down)
-	if InCombatLockdown() then return end
-	if button == "LeftButton" then
-		local prof1, prof2 = GetProfessions()
-		if prof1 then
-			if (GetProfessionInfo(prof1) == ('Herbalism')) then
-				ToggleSpellBook(BOOKTYPE_PROFESSION)
-			elseif(GetProfessionInfo(prof1) == ('Skinning')) then
-				ToggleSpellBook(BOOKTYPE_PROFESSION)
-			elseif(GetProfessionInfo(prof1) == ('Mining')) then
-				CastSpellByName("Smelting")
-			else
-				CastSpellByName((GetProfessionInfo(prof1)))
-			end
-		end
-	elseif button == "RightButton" then
-		ToggleSpellBook(BOOKTYPE_PROFESSION)
-	end
-end)
----------------------------------------------------------------------
-local secondaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame)
-secondaryTradeSkillFrame:SetPoint("RIGHT")
-secondaryTradeSkillFrame:SetSize(16, 16)
-secondaryTradeSkillFrame:EnableMouse(true)
-secondaryTradeSkillFrame:RegisterForClicks("AnyUp")
-
-local secondaryTradeSkillIcon = secondaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7)
-secondaryTradeSkillIcon:SetSize(16, 16)
-secondaryTradeSkillIcon:SetPoint("LEFT")
-secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-
-local secondaryTradeSkillText = secondaryTradeSkillFrame:CreateFontString(nil, "OVERLAY")
-secondaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize)
-secondaryTradeSkillText:SetPoint("LEFT", secondaryTradeSkillIcon,"RIGHT",2,0)
-secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-
-local secondaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, secondaryTradeSkillFrame)
-secondaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1)
-secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
-secondaryTradeSkillStatusbar:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2)
-
-local secondaryTradeSkillStatusbarBG = secondaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7)
-secondaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2)
-secondaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive))
-
-secondaryTradeSkillFrame:SetScript("OnEnter", function()
-	if InCombatLockdown() then return end
-	secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover))
-	secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover))
-	if not cfg.tradeSkill.showTooltip then return end
-	GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos)
-	addCooldownsToTooltip()
-	GameTooltip:Show()
-end)
-
-secondaryTradeSkillFrame:SetScript("OnLeave", function()
-	if prof2OnCooldown then
-		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
-		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
-	else
-		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-	end
-	secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal))
-	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
-end)
-
-secondaryTradeSkillFrame:SetScript("OnClick", function(self, button, down)
-	if InCombatLockdown() then return end
-	if button == "LeftButton" then
-		local prof1, prof2 = GetProfessions()
-		if prof2 then
-			if (GetProfessionInfo(prof2) == ('Herbalism')) then
-				ToggleSpellBook(BOOKTYPE_PROFESSION)
-			elseif(GetProfessionInfo(prof2) == ('Skinning')) then
-				ToggleSpellBook(BOOKTYPE_PROFESSION)
-			elseif(GetProfessionInfo(prof2) == ('Mining')) then
-				CastSpellByName("Smelting")
-			else
-				CastSpellByName((GetProfessionInfo(prof2)))
-			end
-		end
-	elseif button == "RightButton" then
-		ToggleSpellBook(BOOKTYPE_PROFESSION)
-	end
-end)
----------------------------------------------------------------------
-
-local eventframe = CreateFrame("Frame")
-eventframe:RegisterEvent("PLAYER_ENTERING_WORLD")
-eventframe:RegisterEvent("TRADE_SKILL_UPDATE")
-eventframe:RegisterEvent("TRAINER_CLOSED")
-eventframe:RegisterEvent("SPELLS_CHANGED")
-eventframe:RegisterUnitEvent("UNIT_SPELLCAST_STOP", "player")
-
-eventframe:SetScript("OnEvent", function(self,event, ...)
-	local prof1, prof2 = GetProfessions()
-	if prof1 then
-		local prof1Name, _, prof1Rank, prof1MaxRank, _, _, prof1SkillLine = GetProfessionInfo(prof1)
-		prof1Name = string.upper(prof1Name)
-		primaryTradeSkillText:SetText(prof1Name)
-		primaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..profIcons[prof1SkillLine])
-		if prof1Rank == prof1MaxRank then
-			primaryTradeSkillStatusbar:Hide()
-		else
-			primaryTradeSkillStatusbar:Show()
-		end
-		primaryTradeSkillStatusbar:SetMinMaxValues(0, prof1MaxRank)
-		primaryTradeSkillStatusbar:SetValue(prof1Rank)
-		primaryTradeSkillFrame:SetSize(primaryTradeSkillText:GetStringWidth()+18, 16)
-		primaryTradeSkillStatusbar:SetSize(primaryTradeSkillText:GetStringWidth(),3)
-		primaryTradeSkillStatusbarBG:SetSize(primaryTradeSkillText:GetStringWidth(),3)
-		primaryTradeSkillFrame:Show()
-		primaryTradeSkillFrame:EnableMouse(true)
-
-		primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-		primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-
-		--[[for i=1,GetNumTradeSkills() do
-			local cooldown = GetTradeSkillCooldown(i)
-			if cooldown then
-				local name = GetTradeSkillInfo(i)
-				for k, v in pairs(proffessions) do
-					for u = 1, #v do
-						if k == prof1Name then
-							if v[u] == name then
-								if not prof1OnCooldown then prof1OnCooldown = true end
-								primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
-								primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
-								if not prof1OnCooldown then
-									primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-									primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-								end
-							end
-						end
-					end
-				end
-			end
-		end]]--
-	else
-		primaryTradeSkillFrame:Hide()
-		primaryTradeSkillFrame:EnableMouse(false)
-	end
-
-	if prof2 then
-		local prof2Name, _, prof2rank, prof2maxRank, _, _, prof2SkillLine = GetProfessionInfo(prof2)
-		prof2Name = string.upper(prof2Name)
-		secondaryTradeSkillText:SetText(prof2Name)
-		secondaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..profIcons[prof2SkillLine])
-		if prof2rank == prof2maxRank then
-			secondaryTradeSkillStatusbar:Hide()
-		else
-			secondaryTradeSkillStatusbar:Show()
-		end
-		secondaryTradeSkillStatusbar:SetMinMaxValues(0, prof2maxRank)
-		secondaryTradeSkillStatusbar:SetValue(prof2rank)
-		secondaryTradeSkillFrame:SetSize(secondaryTradeSkillText:GetStringWidth()+18, 16)
-		secondaryTradeSkillStatusbar:SetSize(secondaryTradeSkillText:GetStringWidth(),3)
-		secondaryTradeSkillStatusbarBG:SetSize(secondaryTradeSkillText:GetStringWidth(),3)
-		secondaryTradeSkillFrame:Show()
-		secondaryTradeSkillFrame:EnableMouse(true)
-
-		secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-		secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-
-		--[[for i=1,GetNumTradeSkills() do
-			local cooldown = GetTradeSkillCooldown(i)
-			if cooldown then
-				local name = GetTradeSkillInfo(i)
-				for k, v in pairs(proffessions) do
-					for u = 1, #v do
-						if k == prof2Name then
-							if v[u] == name then
-								if not prof2OnCooldown then prof2OnCooldown = true end
-								secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive))
-								secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive))
-								if not prof2OnCooldown then
-									secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal))
-									secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal))
-								end
-							end
-						end
-					end
-				end
-			end
-		end]]--
-	else
-		secondaryTradeSkillFrame:Hide()
-		secondaryTradeSkillFrame:EnableMouse(false)
-	end
-	tradeSkillFrame:SetSize((primaryTradeSkillFrame:GetWidth())+(secondaryTradeSkillFrame:GetWidth()+4), 16)
-end)
-
-
-function addCooldownsToTooltip()
-	for i,v in pairs(C_TradeSkillUI.GetFilteredRecipeIDs()) do
-	  local _, cooldown, secondsToCooldown, dunno = C_TradeSkillUI.GetRecipeCooldown(v)
-	  if cooldown then
-	    local name = C_TradeSkillUI.GetRecipeInfo(v).name
-	    GameTooltip:AddDoubleLine(name, SecondsToTime(secondsToCooldown), 1, 1, 0, 1, 1, 1)
-	  end
-	end
+function TradeskillModule:GetConfig()
+  return {
+    name = self:GetName(),
+    type = "group",
+    args = {
+      enable = {
+        name = ENABLE,
+        order = 0,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.tradeskill.enabled; end,
+        set = function(_, val)
+          xb.db.profile.modules.tradeskill.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
+        width = "full"
+      },
+      barCC = {
+        name = L['Use Class Colors'],
+        order = 2,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.tradeskill.barCC; end,
+        set = function(_, val) xb.db.profile.modules.tradeskill.barCC = val; self:Refresh(); end
+      },
+      showTooltip = {
+        name = L['Show Tooltips'],
+        order = 3,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.tradeskill.showTooltip; end,
+        set = function(_, val) xb.db.profile.modules.tradeskill.showTooltip = val; self:Refresh(); end
+      }
+    }
+  }
 end
diff --git a/modules/travel.lua b/modules/travel.lua
index ebd13b8..a0cfbe0 100644
--- a/modules/travel.lua
+++ b/modules/travel.lua
@@ -63,14 +63,19 @@ end
 function TravelModule:OnEnable()
   if self.hearthFrame == nil then
     self.hearthFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar'))
-    xb:RegisterFrame('hearthFrame', self.hearthFrame)
+    xb:RegisterFrame('travelFrame', self.hearthFrame)
   end
+  self.hearthFrame:Show()
   self:CreateFrames()
   self:RegisterFrameEvents()
   self:Refresh()
 end

 function TravelModule:OnDisable()
+  self.hearthFrame:Hide()
+  self:UnregisterEvent('SPELLS_CHANGED')
+  self:UnregisterEvent('BAG_UPDATE_DELAYED')
+  self:UnregisterEvent('HEARTHSTONE_BOUND')
 end

 function TravelModule:CreateFrames()
@@ -355,6 +360,31 @@ end

 function TravelModule:GetDefaultOptions()
   return 'travel', {
+    enabled = true,
     portItem = {portId = 110560, text = GARRISON_LOCATION_TOOLTIP}
   }
 end
+
+function TravelModule:GetConfig()
+  return {
+    name = self:GetName(),
+    type = "group",
+    args = {
+      enable = {
+        name = ENABLE,
+        order = 0,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.travel.enabled; end,
+        set = function(_, val)
+          xb.db.profile.modules.travel.enabled = val
+          if val then
+            self:Enable()
+          else
+            self:Disable()
+          end
+        end,
+        width = "full"
+      }
+    }
+  }
+end