Quantcast

System module, fixing some incombat errors

MilleXIV [08-27-16 - 23:09]
System module, fixing some incombat errors
Filename
locales/enUS.lua
modules/clock.lua
modules/currency.lua
modules/load_modules.xml
modules/micromenu.lua
modules/old/system.lua
modules/system.lua
modules/travel.lua
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 4077283..352e358 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -83,3 +83,11 @@ L['Currency Select'] = true;
 L['First Currency'] = true;
 L['Second Currency'] = true;
 L['Third Currency'] = true;
+
+L['System'] = true;
+L['Show World Ping'] = true;
+L['Number of Addons To Show'] = true;
+L['Addons to Show in Tooltip'] = true;
+L['Show All Addons in Tooltip with Shift'] = true;
+L['Memory Usage'] = true;
+L['Garbage Collect'] = true;
diff --git a/modules/clock.lua b/modules/clock.lua
index 0835524..ab3efe9 100644
--- a/modules/clock.lua
+++ b/modules/clock.lua
@@ -65,8 +65,13 @@ function ClockModule:Refresh()
   if self.clockFrame == nil then return; end
   if not db.modules.clock.enabled then return; end

+  if InCombatLockdown() then
+    self:SetClockColor()
+    return
+  end
+
   self.clockText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.modules.clock.fontSize)
-  ClockModule:SetClockColor()
+  self:SetClockColor()

   self.clockFrame:SetSize(self.clockText:GetStringWidth(), self.clockText:GetStringHeight())
   self.clockFrame:SetPoint('CENTER')
diff --git a/modules/currency.lua b/modules/currency.lua
index 2dd4f2b..08f774e 100644
--- a/modules/currency.lua
+++ b/modules/currency.lua
@@ -32,7 +32,7 @@ end

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

@@ -49,6 +49,18 @@ function CurrencyModule:OnDisable()
 end

 function CurrencyModule:Refresh()
+
+  xb.constants.playerLevel = UnitLevel("player")
+  if InCombatLockdown() then
+    self.xpBar:SetMinMaxValues(0, UnitXPMax('player'))
+    self.xpBar:SetValue(UnitXP('player'))
+    self.xpText:SetText(string.upper(LEVEL..' '..UnitLevel("player")..' '..UnitClass('player')))
+    self:RegisterEvent('PLAYER_REGEN_ENABLED', function()
+      self:Refresh()
+      self:UnregisterEvent('PLAYER_REGEN_ENABLED')
+    end)
+    return
+  end
   local db = xb.db.profile
   if self.currencyFrame == nil then return; end
   if not db.modules.currency.enabled then return; end
@@ -70,7 +82,7 @@ function CurrencyModule:Refresh()

     self.xpText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), textHeight)
     self.xpText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
-    self.xpText:SetText(string.upper(LEVEL..' '..tostring(xb.constants.playerLevel)..' '..UnitClass('player')))
+    self.xpText:SetText(string.upper(LEVEL..' '..UnitLevel("player")..' '..UnitClass('player')))
     self.xpText:SetPoint('TOPLEFT', self.xpIcon, 'TOPRIGHT', 5, 0)

     self.xpBar:SetStatusBarTexture(1, 1, 1)
@@ -86,8 +98,6 @@ function CurrencyModule:Refresh()

     self.xpBarBg:SetAllPoints()
     self.xpBarBg:SetColorTexture(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
-    --self.xpBar = self.xpBar or CreateFrame('STATUSBAR', nil, self.xpFrame)
-    --self.xpBarBg = self.xpBarBg or self.xpBar:CreateTexture(nil, 'BACKGROUND')
     self.currencyFrame:SetSize(iconSize + self.xpText:GetStringWidth() + 5, xb:GetHeight())
     self.xpFrame:SetAllPoints()
     self.xpFrame:Show()
@@ -105,7 +115,7 @@ function CurrencyModule:Refresh()
   end -- show currencies

   --self.currencyFrame:SetSize(self.goldButton:GetSize())
-  self.currencyFrame:SetPoint('RIGHT', self.currencyFrame:GetParent(), 'LEFT', -(db.general.moduleSpacing), 0)
+  self.currencyFrame:SetPoint('LEFT', self.currencyFrame:GetParent(), 'RIGHT', db.general.moduleSpacing, 0)
 end

 function CurrencyModule:StyleCurrencyFrame(curId, i)
diff --git a/modules/load_modules.xml b/modules/load_modules.xml
index 9b18e8a..df85e5f 100644
--- a/modules/load_modules.xml
+++ b/modules/load_modules.xml
@@ -6,4 +6,5 @@
   <Script file="travel.lua" />
   <Script file="gold.lua" />
   <Script file="currency.lua" />
+  <Script file="system.lua" />
 </Ui>
diff --git a/modules/micromenu.lua b/modules/micromenu.lua
index 282f6c4..5817c4a 100644
--- a/modules/micromenu.lua
+++ b/modules/micromenu.lua
@@ -83,6 +83,14 @@ function MenuModule:Refresh()

   if not xb.db.profile.modules.microMenu.enabled then return; end

+  if InCombatLockdown() then
+    self:RegisterEvent('PLAYER_REGEN_ENABLED', function()
+      self:Refresh()
+      self:UnregisterEvent('PLAYER_REGEN_ENABLED')
+    end)
+    return
+  end
+
   self.iconSize = xb:GetHeight();

   local colors = xb.db.profile.color
@@ -183,6 +191,16 @@ function MenuModule:RegisterFrameEvents()
         GameTooltip:Hide()
         leaveFunc()
       end)
+      frame:SetScript('OnUpdate', function(self, elapsed)
+        if self.elapsed then
+          self.elapsed = self.elapsed + elapsed
+          if elapsed > 10 then
+            MenuModule:UpdateGuildText()
+          end
+        else
+          self.elapsed = elapsed
+        end
+      end)
     elseif name == 'social' then
       local leaveFunc = self:DefaultLeave(name)
       frame:SetScript("OnEnter", self:SocialHover(self:DefaultHover(name)))
@@ -199,6 +217,9 @@ function MenuModule:RegisterFrameEvents()
   self:RegisterEvent('GUILD_ROSTER_UPDATE', function()
     self:UpdateGuildText(true)
   end)
+  self:RegisterEvent('CHAT_MSG_GUILD', function()
+    self:UpdateGuildText(true)
+  end)
   self:RegisterEvent('BN_FRIEND_ACCOUNT_ONLINE', 'UpdateFriendText')
   self:RegisterEvent('BN_FRIEND_ACCOUNT_OFFLINE', 'UpdateFriendText')
   self:RegisterEvent('FRIENDLIST_UPDATE', 'UpdateFriendText')
diff --git a/modules/old/system.lua b/modules/old/system.lua
new file mode 100644
index 0000000..649f9c5
--- /dev/null
+++ b/modules/old/system.lua
@@ -0,0 +1,228 @@
+local addon, ns = ...
+local cfg = ns.cfg
+local unpack = unpack
+--------------------------------------------------------------
+if not cfg.system.show then return end
+
+local onHover = false
+
+ local memformat = function(number)
+    if number > 1024 then
+      return string.format("%.2f|r mb", (number / 1024))
+    else
+      return string.format("%.1f|r kb", floor(number))
+    end
+  end
+
+local systemFrame = CreateFrame("Frame",nil, cfg.SXframe)
+systemFrame:SetPoint("RIGHT", -350,0)
+systemFrame:SetSize(120, 16)
+---------------------------------------------------------------------
+
+local addoncompare = function(a, b)
+	return a.memory > b.memory
+end
+
+ local function systemBarOnEnter()
+ if not cfg.system.showTooltip then return end
+	GameTooltip:SetOwner(systemFrame, cfg.tooltipPos)
+	GameTooltip:AddLine("[|cff6699FFPerformance|r]")
+	GameTooltip:AddLine(" ")
+	---------------------------------------------------
+	local color = { r=1, g=1, b=0 }
+    local blizz = collectgarbage("count")
+    local addons = {}
+    local enry, memory
+    local total = 0
+    local nr = 0
+	local numberOfAddons = 0
+    UpdateAddOnMemoryUsage()
+	if IsShiftKeyDown() then
+    GameTooltip:AddLine("Top "..cfg.system.addonListShift.." AddOns", 1,1,0)
+	else
+	GameTooltip:AddLine("Top "..cfg.system.addonList.." AddOns", 1,1,0)
+	end
+    GameTooltip:AddLine(" ")
+    for i=1, GetNumAddOns(), 1 do
+      if (GetAddOnMemoryUsage(i) > 0 ) then
+        memory = GetAddOnMemoryUsage(i)
+        entry = {name = GetAddOnInfo(i), memory = memory}
+        table.insert(addons, entry)
+        total = total + memory
+      end
+    end
+    table.sort(addons, addoncompare)
+    for _, entry in pairs(addons) do
+		if IsShiftKeyDown() then
+			numberOfAddons = cfg.system.addonListShift
+		else
+			numberOfAddons = cfg.system.addonList
+		end
+		if nr < numberOfAddons then
+			GameTooltip:AddDoubleLine(entry.name, memformat(entry.memory), 1, 1, 0, 1, 1, 1)
+			nr = nr+1
+		end
+    end
+    GameTooltip:AddLine(" ")
+    GameTooltip:AddDoubleLine("Total", memformat(total), 1,1,0, 1,1,0)
+    GameTooltip:AddDoubleLine("Total incl. Blizzard", memformat(blizz), 1,1,0, 1,1,0)
+	GameTooltip:AddLine(" ")
+	GameTooltip:AddDoubleLine("<Left-click>", "Force garbage collection", 1, 1, 0, 1, 1, 1)
+	if not IsShiftKeyDown() then
+		GameTooltip:AddDoubleLine("<Shift-hold>", "Show |cffffff00"..cfg.system.addonListShift.."|r addons", 1, 1, 0, 1, 1, 1)
+	end
+	-------------------------------------------
+	GameTooltip:Show()
+end
+
+local function systemBarOnLeave()
+	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
+end
+
+---------------------------------------------------------------------
+
+local pingFrame = CreateFrame("BUTTON","SX_pingFrame", systemFrame)
+pingFrame:SetPoint("CENTER")
+pingFrame:SetSize(16, 16)
+pingFrame:EnableMouse(true)
+pingFrame:RegisterForClicks("AnyUp")
+
+local pingIcon = pingFrame:CreateTexture(nil,"OVERLAY",nil,7)
+pingIcon:SetSize(16, 16)
+pingIcon:SetPoint("CENTER")
+pingIcon:SetTexture(cfg.mediaFolder.."datatexts\\ping")
+pingIcon:SetVertexColor(unpack(cfg.color.normal))
+
+local pingText = pingFrame:CreateFontString(nil, "OVERLAY")
+pingText:SetFont(cfg.text.font, cfg.text.normalFontSize)
+pingText:SetPoint("LEFT", pingIcon,"RIGHT",2,0)
+pingText:SetTextColor(unpack(cfg.color.normal))
+
+pingFrame:SetScript("OnEnter", function()
+	if InCombatLockdown() then return end
+	pingIcon:SetVertexColor(unpack(cfg.color.hover))
+	onHover = true
+	systemBarOnEnter()
+end)
+
+pingFrame:SetScript("OnLeave", function()
+	pingIcon:SetVertexColor(unpack(cfg.color.normal))
+	onHover = false
+	systemBarOnLeave()
+end)
+
+pingFrame:SetScript("OnClick", function(self, button, down)
+	if InCombatLockdown() then return end
+	if button == "LeftButton" then
+		UpdateAddOnMemoryUsage()
+		local before = gcinfo()
+		collectgarbage()
+		UpdateAddOnMemoryUsage()
+		local after = gcinfo()
+		print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after))
+	elseif button == "RightButton" then
+		ToggleFrame(VideoOptionsFrame)
+	end
+end)
+---------------------------------------------------------------------
+local fpsFrame = CreateFrame("BUTTON",nil, systemFrame)
+fpsFrame:SetPoint("LEFT")
+fpsFrame:SetSize(16, 16)
+fpsFrame:EnableMouse(true)
+fpsFrame:RegisterForClicks("AnyUp")
+
+local fpsIcon = fpsFrame:CreateTexture(nil,"OVERLAY",nil,7)
+fpsIcon:SetSize(16, 16)
+fpsIcon:SetPoint("LEFT")
+fpsIcon:SetTexture(cfg.mediaFolder.."datatexts\\fps")
+fpsIcon:SetVertexColor(unpack(cfg.color.normal))
+
+local fpsText = fpsFrame:CreateFontString(nil, "OVERLAY")
+fpsText:SetFont(cfg.text.font, cfg.text.normalFontSize)
+fpsText:SetPoint("LEFT", fpsIcon,"RIGHT",2,0)
+fpsText:SetTextColor(unpack(cfg.color.normal))
+
+fpsFrame:SetScript("OnEnter", function()
+	if InCombatLockdown() then return end
+	fpsIcon:SetVertexColor(unpack(cfg.color.hover))
+	onHover = true
+	systemBarOnEnter()
+end)
+
+fpsFrame:SetScript("OnLeave", function()
+	fpsIcon:SetVertexColor(unpack(cfg.color.normal))
+	onHover = false
+	systemBarOnLeave()
+end)
+
+fpsFrame:SetScript("OnClick", function(self, button, down)
+	if InCombatLockdown() then return end
+	if button == "LeftButton" then
+		UpdateAddOnMemoryUsage()
+		local before = gcinfo()
+		collectgarbage()
+		UpdateAddOnMemoryUsage()
+		local after = gcinfo()
+		print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after))
+	elseif button == "RightButton" then
+		ToggleFrame(VideoOptionsFrame)
+	end
+end)
+---------------------------------------------------------------------
+
+local function SXUImemory()
+local t = 0
+UpdateAddOnMemoryUsage()
+for i=1, GetNumAddOns(), 1 do
+	t = t + GetAddOnMemoryUsage(i)
+end
+return cfg.memformat(t)
+
+end
+
+local function updatePerformanceText()
+	local fps = floor(GetFramerate())
+	local BWIn, BWOut, LCHome, LCWorld = GetNetStats()
+  local pingString = LCHome.."ms";
+  if cfg.system.showWorldPing then
+    pingString = pingString.." "..LCWorld.."ms"
+  end
+
+	pingText:SetText(pingString)
+	pingFrame:SetSize(pingText:GetStringWidth()+18, 16)
+	fpsText:SetText(fps.."fps")
+	fpsFrame:SetSize(fpsText:GetStringWidth()+18, 16)
+	if onHover then
+		systemBarOnEnter()
+	end
+end
+
+local elapsed = 0
+systemFrame:SetScript('OnUpdate', function(self, e)
+	elapsed = elapsed + e
+	if elapsed >= 1 then
+		updatePerformanceText()
+		elapsed = 0
+	end
+end)
+
+local eventframe = CreateFrame("Frame")
+eventframe:RegisterEvent("MODIFIER_STATE_CHANGED")
+
+eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...)
+
+if event == "MODIFIER_STATE_CHANGED" then
+		if InCombatLockdown() then return end
+		if arg1 == "LSHIFT" or arg1 == "RSHIFT" then
+			if arg2 == 1 then
+					if onHover then
+		systemBarOnEnter()
+	end
+			elseif arg2 == 0 then
+					if onHover then
+		systemBarOnEnter()
+	end
+			end
+		end
+	end
+end)
diff --git a/modules/system.lua b/modules/system.lua
index 649f9c5..b3c3f14 100644
--- a/modules/system.lua
+++ b/modules/system.lua
@@ -1,228 +1,315 @@
-local addon, ns = ...
-local cfg = ns.cfg
-local unpack = unpack
---------------------------------------------------------------
-if not cfg.system.show then return end
-
-local onHover = false
-
- local memformat = function(number)
-    if number > 1024 then
-      return string.format("%.2f|r mb", (number / 1024))
-    else
-      return string.format("%.1f|r kb", floor(number))
-    end
+local AddOnName, XIVBar = ...;
+local _G = _G;
+local xb = XIVBar;
+local L = XIVBar.L;
+
+local SystemModule = xb:NewModule("SystemModule", 'AceEvent-3.0', 'AceHook-3.0')
+
+function SystemModule:GetName()
+  return L['System'];
+end
+
+function SystemModule:OnInitialize()
+  self.elapsed = 0
+end
+
+function SystemModule:OnEnable()
+  if self.systemFrame == nil then
+    self.systemFrame = CreateFrame("FRAME", nil, xb:GetFrame('goldFrame'))
+    xb:RegisterFrame('systemFrame', self.systemFrame)
   end

-local systemFrame = CreateFrame("Frame",nil, cfg.SXframe)
-systemFrame:SetPoint("RIGHT", -350,0)
-systemFrame:SetSize(120, 16)
----------------------------------------------------------------------
+  self:CreateFrames()
+  self:RegisterFrameEvents()
+  self:Refresh()
+end

-local addoncompare = function(a, b)
-	return a.memory > b.memory
+function SystemModule:OnDisable()
+  self.systemFrame:Hide()
 end

- local function systemBarOnEnter()
- if not cfg.system.showTooltip then return end
-	GameTooltip:SetOwner(systemFrame, cfg.tooltipPos)
-	GameTooltip:AddLine("[|cff6699FFPerformance|r]")
-	GameTooltip:AddLine(" ")
-	---------------------------------------------------
-	local color = { r=1, g=1, b=0 }
-    local blizz = collectgarbage("count")
-    local addons = {}
-    local enry, memory
-    local total = 0
-    local nr = 0
-	local numberOfAddons = 0
-    UpdateAddOnMemoryUsage()
-	if IsShiftKeyDown() then
-    GameTooltip:AddLine("Top "..cfg.system.addonListShift.." AddOns", 1,1,0)
-	else
-	GameTooltip:AddLine("Top "..cfg.system.addonList.." AddOns", 1,1,0)
-	end
-    GameTooltip:AddLine(" ")
-    for i=1, GetNumAddOns(), 1 do
-      if (GetAddOnMemoryUsage(i) > 0 ) then
-        memory = GetAddOnMemoryUsage(i)
-        entry = {name = GetAddOnInfo(i), memory = memory}
-        table.insert(addons, entry)
-        total = total + memory
-      end
-    end
-    table.sort(addons, addoncompare)
-    for _, entry in pairs(addons) do
-		if IsShiftKeyDown() then
-			numberOfAddons = cfg.system.addonListShift
-		else
-			numberOfAddons = cfg.system.addonList
-		end
-		if nr < numberOfAddons then
-			GameTooltip:AddDoubleLine(entry.name, memformat(entry.memory), 1, 1, 0, 1, 1, 1)
-			nr = nr+1
-		end
-    end
-    GameTooltip:AddLine(" ")
-    GameTooltip:AddDoubleLine("Total", memformat(total), 1,1,0, 1,1,0)
-    GameTooltip:AddDoubleLine("Total incl. Blizzard", memformat(blizz), 1,1,0, 1,1,0)
-	GameTooltip:AddLine(" ")
-	GameTooltip:AddDoubleLine("<Left-click>", "Force garbage collection", 1, 1, 0, 1, 1, 1)
-	if not IsShiftKeyDown() then
-		GameTooltip:AddDoubleLine("<Shift-hold>", "Show |cffffff00"..cfg.system.addonListShift.."|r addons", 1, 1, 0, 1, 1, 1)
-	end
-	-------------------------------------------
-	GameTooltip:Show()
+function SystemModule:Refresh()
+  local db = xb.db.profile
+  if self.systemFrame == nil then return; end
+  if not db.modules.system.enabled then return; end
+
+  if InCombatLockdown() then
+    self:UpdateTexts()
+    return
+  end
+
+  local iconSize = db.text.fontSize + db.general.barPadding
+
+  self.fpsIcon:SetTexture(xb.constants.mediaPath..'datatexts\\fps')
+  self.fpsIcon:SetSize(iconSize, iconSize)
+  self.fpsIcon:SetPoint('LEFT')
+  self.fpsIcon:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)
+
+  self.fpsText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+
+  self.fpsText:SetPoint('RIGHT', -5, 0)
+  self.fpsText:SetText('000'..FPS_ABBR) -- get the widest we can be
+  local fpsWidest = self.fpsText:GetStringWidth() + 5
+
+  self.pingIcon:SetTexture(xb.constants.mediaPath..'datatexts\\ping')
+  self.pingIcon:SetSize(iconSize, iconSize)
+  self.pingIcon:SetPoint('LEFT')
+  self.pingIcon:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)
+
+  self.pingText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+  self.worldPingText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+
+  if self.fpsFrame:IsMouseOver() or self.pingFrame:IsMouseOver() then
+    self.fpsText:SetTextColor(unpack(xb:HoverColors()))
+    self.pingText:SetTextColor(unpack(xb:HoverColors()))
+    self.worldPingText:SetTextColor(unpack(xb:HoverColors()))
+  else
+    self.fpsText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+    self.pingText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+    self.worldPingText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  end
+
+  self.worldPingText:SetText('000'..MILLISECONDS_ABBR)
+  self.pingText:SetText('000'..MILLISECONDS_ABBR) -- get the widest we can be
+
+  local pingWidest = self.pingText:GetStringWidth() + 5
+  if db.modules.system.showWorld then
+    self.worldPingText:SetPoint('LEFT', self.pingText, 'RIGHT', 5, 0)
+    pingWidest = pingWidest + self.worldPingText:GetStringWidth() + 5
+  end
+  self.pingText:SetPoint('LEFT', self.pingIcon, 'RIGHT', 5, 0)
+
+  self:UpdateTexts()
+
+  self.fpsFrame:SetSize(fpsWidest + iconSize + 5, xb:GetHeight())
+  self.fpsFrame:SetPoint('LEFT')
+
+  self.pingFrame:SetSize(pingWidest + iconSize + 5, xb:GetHeight())
+  self.pingFrame:SetPoint('LEFT', self.fpsFrame, 'RIGHT', 5, 0)
+
+  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)
 end

-local function systemBarOnLeave()
-	if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end
+function SystemModule:UpdateTexts()
+  self.fpsText:SetText(floor(GetFramerate())..FPS_ABBR)
+  local _, _, homePing, worldPing = GetNetStats()
+  self.pingText:SetText(floor(homePing)..MILLISECONDS_ABBR)
+  self.worldPingText:SetText(floor(worldPing)..MILLISECONDS_ABBR)
+end
+
+function SystemModule:CreateFrames()
+  self.fpsFrame = self.fpsFrame or CreateFrame('BUTTON', nil, self.systemFrame)
+  self.fpsIcon = self.fpsIcon or self.fpsFrame:CreateTexture(nil, 'OVERLAY')
+  self.fpsText = self.fpsText or self.fpsFrame:CreateFontString(nil, 'OVERLAY')
+
+  self.pingFrame = self.pingFrame or CreateFrame('BUTTON', nil, self.systemFrame)
+  self.pingIcon = self.pingIcon or self.pingFrame:CreateTexture(nil, 'OVERLAY')
+  self.pingText = self.pingText or self.pingFrame:CreateFontString(nil, 'OVERLAY')
+  self.worldPingText = self.worldPingText or self.pingFrame:CreateFontString(nil, 'OVERLAY')
 end

----------------------------------------------------------------------
-
-local pingFrame = CreateFrame("BUTTON","SX_pingFrame", systemFrame)
-pingFrame:SetPoint("CENTER")
-pingFrame:SetSize(16, 16)
-pingFrame:EnableMouse(true)
-pingFrame:RegisterForClicks("AnyUp")
-
-local pingIcon = pingFrame:CreateTexture(nil,"OVERLAY",nil,7)
-pingIcon:SetSize(16, 16)
-pingIcon:SetPoint("CENTER")
-pingIcon:SetTexture(cfg.mediaFolder.."datatexts\\ping")
-pingIcon:SetVertexColor(unpack(cfg.color.normal))
-
-local pingText = pingFrame:CreateFontString(nil, "OVERLAY")
-pingText:SetFont(cfg.text.font, cfg.text.normalFontSize)
-pingText:SetPoint("LEFT", pingIcon,"RIGHT",2,0)
-pingText:SetTextColor(unpack(cfg.color.normal))
-
-pingFrame:SetScript("OnEnter", function()
-	if InCombatLockdown() then return end
-	pingIcon:SetVertexColor(unpack(cfg.color.hover))
-	onHover = true
-	systemBarOnEnter()
-end)
-
-pingFrame:SetScript("OnLeave", function()
-	pingIcon:SetVertexColor(unpack(cfg.color.normal))
-	onHover = false
-	systemBarOnLeave()
-end)
-
-pingFrame:SetScript("OnClick", function(self, button, down)
-	if InCombatLockdown() then return end
-	if button == "LeftButton" then
-		UpdateAddOnMemoryUsage()
-		local before = gcinfo()
-		collectgarbage()
-		UpdateAddOnMemoryUsage()
-		local after = gcinfo()
-		print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after))
-	elseif button == "RightButton" then
-		ToggleFrame(VideoOptionsFrame)
-	end
-end)
----------------------------------------------------------------------
-local fpsFrame = CreateFrame("BUTTON",nil, systemFrame)
-fpsFrame:SetPoint("LEFT")
-fpsFrame:SetSize(16, 16)
-fpsFrame:EnableMouse(true)
-fpsFrame:RegisterForClicks("AnyUp")
-
-local fpsIcon = fpsFrame:CreateTexture(nil,"OVERLAY",nil,7)
-fpsIcon:SetSize(16, 16)
-fpsIcon:SetPoint("LEFT")
-fpsIcon:SetTexture(cfg.mediaFolder.."datatexts\\fps")
-fpsIcon:SetVertexColor(unpack(cfg.color.normal))
-
-local fpsText = fpsFrame:CreateFontString(nil, "OVERLAY")
-fpsText:SetFont(cfg.text.font, cfg.text.normalFontSize)
-fpsText:SetPoint("LEFT", fpsIcon,"RIGHT",2,0)
-fpsText:SetTextColor(unpack(cfg.color.normal))
-
-fpsFrame:SetScript("OnEnter", function()
-	if InCombatLockdown() then return end
-	fpsIcon:SetVertexColor(unpack(cfg.color.hover))
-	onHover = true
-	systemBarOnEnter()
-end)
-
-fpsFrame:SetScript("OnLeave", function()
-	fpsIcon:SetVertexColor(unpack(cfg.color.normal))
-	onHover = false
-	systemBarOnLeave()
-end)
-
-fpsFrame:SetScript("OnClick", function(self, button, down)
-	if InCombatLockdown() then return end
-	if button == "LeftButton" then
-		UpdateAddOnMemoryUsage()
-		local before = gcinfo()
-		collectgarbage()
-		UpdateAddOnMemoryUsage()
-		local after = gcinfo()
-		print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after))
-	elseif button == "RightButton" then
-		ToggleFrame(VideoOptionsFrame)
-	end
-end)
----------------------------------------------------------------------
-
-local function SXUImemory()
-local t = 0
-UpdateAddOnMemoryUsage()
-for i=1, GetNumAddOns(), 1 do
-	t = t + GetAddOnMemoryUsage(i)
+function SystemModule:HoverFunction()
+  if InCombatLockdown() then return; end
+  self.fpsText:SetTextColor(unpack(xb:HoverColors()))
+  self.pingText:SetTextColor(unpack(xb:HoverColors()))
+  self.worldPingText:SetTextColor(unpack(xb:HoverColors()))
+  if xb.db.profile.modules.system.showTooltip then
+    self:ShowTooltip()
+  end
+end
+
+function SystemModule:LeaveFunction()
+  if InCombatLockdown() then return; end
+  local db = xb.db.profile
+  self.fpsText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  self.pingText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  self.worldPingText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
+  if xb.db.profile.modules.system.showTooltip then
+    GameTooltip:Hide()
+  end
 end
-return cfg.memformat(t)

+function SystemModule:RegisterFrameEvents()
+
+  self.fpsFrame:EnableMouse(true)
+  self.fpsFrame:RegisterForClicks("AnyUp")
+
+  self.pingFrame:EnableMouse(true)
+  self.pingFrame:RegisterForClicks("AnyUp")
+
+  self.fpsFrame:SetScript('OnEnter', function()
+    self:HoverFunction()
+  end)
+  self.fpsFrame:SetScript('OnLeave', function()
+    self:LeaveFunction()
+  end)
+
+  self.pingFrame:SetScript('OnEnter', function()
+    self:HoverFunction()
+  end)
+  self.pingFrame:SetScript('OnLeave', function()
+    self:LeaveFunction()
+  end)
+
+  --[[self.fpsFrame:SetScript('OnKeyDown', function()
+    if IsShiftKeyDown() and self.fpsFrame:IsMouseOver() then
+      if xb.db.profile.modules.system.showTooltip then
+        self:ShowTooltip()
+      end
+    end
+  end)
+
+  self.pingFrame:SetScript('OnKeyDown', function()
+    if IsShiftKeyDown() and self.pingFrame:IsMouseOver() then
+      if xb.db.profile.modules.system.showTooltip then
+        self:ShowTooltip()
+      end
+    end
+  end)
+
+  self.fpsFrame:SetScript('OnKeyUp', function()
+    if self.fpsFrame:IsMouseOver() then
+      if xb.db.profile.modules.system.showTooltip then
+        self:ShowTooltip()
+      end
+    end
+  end)
+
+  self.pingFrame:SetScript('OnKeyUp', function()
+    if self.pingFrame:IsMouseOver() then
+      if xb.db.profile.modules.system.showTooltip then
+        self:ShowTooltip()
+      end
+    end
+  end)]]--
+
+  self.fpsFrame:SetScript('OnClick', function(_, button)
+    if InCombatLockdown() then return; end
+    if button == 'LeftButton' then
+      collectgarbage()
+    end
+  end)
+
+  self.pingFrame:SetScript('OnClick', function(_, button)
+    if InCombatLockdown() then return; end
+    if button == 'LeftButton' then
+      collectgarbage()
+    end
+  end)
+
+  self.fpsFrame:SetScript('OnUpdate', function(self, elapsed)
+    SystemModule.elapsed = SystemModule.elapsed + elapsed
+    if SystemModule.elapsed >= 1 then
+      if InCombatLockdown() then
+        SystemModule:UpdateTexts()
+      else
+        SystemModule:Refresh()
+      end
+      SystemModule.elapsed = 0
+    end
+  end)
 end

-local function updatePerformanceText()
-	local fps = floor(GetFramerate())
-	local BWIn, BWOut, LCHome, LCWorld = GetNetStats()
-  local pingString = LCHome.."ms";
-  if cfg.system.showWorldPing then
-    pingString = pingString.." "..LCWorld.."ms"
+function SystemModule:ShowTooltip()
+  local totalAddons = GetNumAddOns()
+  local totalUsage = 0
+  local memTable = {}
+
+  UpdateAddOnMemoryUsage()
+
+  for i = 1, totalAddons do
+    local _, aoName, _ = GetAddOnInfo(i)
+    local mem = GetAddOnMemoryUsage(i)
+    tinsert(memTable, {memory = mem, name = aoName})
+  end
+
+  table.sort(memTable, function(a, b)
+    return a.memory > b.memory
+  end)
+
+  GameTooltip:SetOwner(self.systemFrame, 'ANCHOR_'..xb.miniTextPosition)
+  GameTooltip:ClearLines()
+  GameTooltip:AddLine("[|cff6699FF"..L['Memory Usage'].."|r]")
+
+  local toLoop = xb.db.profile.modules.system.addonsToShow
+  if IsShiftKeyDown() and xb.db.profile.modules.system.showAllOnShift then
+    toLoop = totalAddons
   end

-	pingText:SetText(pingString)
-	pingFrame:SetSize(pingText:GetStringWidth()+18, 16)
-	fpsText:SetText(fps.."fps")
-	fpsFrame:SetSize(fpsText:GetStringWidth()+18, 16)
-	if onHover then
-		systemBarOnEnter()
-	end
+  for i = 1, toLoop do
+    local memString = ''
+    if memTable[i].memory > 0 then
+      if memTable[i].memory > 1024 then
+        memString = string.format("%.2f MB", (memTable[i].memory / 1024))
+      else
+        memString = string.format("%.0f KB", floor(memTable[i].memory))
+      end
+      GameTooltip:AddDoubleLine(memTable[i].name, memString, 1, 1, 0, 1, 1, 1)
+    end
+  end
+
+  GameTooltip:AddLine(" ")
+  GameTooltip:AddDoubleLine('<'..L['Left-Click']..'>', L['Garbage Collect'], 1, 1, 0, 1, 1, 1)
+  GameTooltip:Show()
+end
+
+function SystemModule:GetDefaultOptions()
+  return 'system', {
+      enabled = true,
+      showTooltip = true,
+      showWorld = true,
+      addonsToShow = 10,
+      showAllOnShift = true
+    }
 end

-local elapsed = 0
-systemFrame:SetScript('OnUpdate', function(self, e)
-	elapsed = elapsed + e
-	if elapsed >= 1 then
-		updatePerformanceText()
-		elapsed = 0
-	end
-end)
-
-local eventframe = CreateFrame("Frame")
-eventframe:RegisterEvent("MODIFIER_STATE_CHANGED")
-
-eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...)
-
-if event == "MODIFIER_STATE_CHANGED" then
-		if InCombatLockdown() then return end
-		if arg1 == "LSHIFT" or arg1 == "RSHIFT" then
-			if arg2 == 1 then
-					if onHover then
-		systemBarOnEnter()
-	end
-			elseif arg2 == 0 then
-					if onHover then
-		systemBarOnEnter()
-	end
-			end
-		end
-	end
-end)
+function SystemModule:GetConfig()
+  return {
+    name = self:GetName(),
+    type = "group",
+    args = {
+      enable = {
+        name = ENABLE,
+        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,
+        width = "full"
+      },
+      showTooltip = {
+        name = L['Show Tooltips'],
+        order = 1,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.system.showTooltip; end,
+        set = function(_, val) xb.db.profile.modules.system.showTooltip = val; self:Refresh(); end
+      },
+      showWorld = {
+        name = L['Show World Ping'],
+        order = 2,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.system.showWorld; end,
+        set = function(_, val) xb.db.profile.modules.system.showWorld = val; self:Refresh(); end
+      },
+      addonsToShow = {
+        name = L['Addons to Show in Tooltip'], -- DROPDOWN, GoldModule:GetCurrencyOptions
+        type = "range",
+        order = 3,
+        min = 1,
+        max = 25,
+        step = 1,
+        get = function() return xb.db.profile.modules.system.addonsToShow; end,
+        set = function(info, value) xb.db.profile.modules.system.addonsToShow = value; self:Refresh(); end,
+      },
+      showAllOnShift = {
+        name = L['Show All Addons in Tooltip with Shift'],
+        order = 4,
+        type = "toggle",
+        get = function() return xb.db.profile.modules.system.showAllOnShift; end,
+        set = function(_, val) xb.db.profile.modules.system.showAllOnShift = val; self:Refresh(); end
+      }
+    }
+  }
+end
diff --git a/modules/travel.lua b/modules/travel.lua
index db1f5c2..3877bef 100644
--- a/modules/travel.lua
+++ b/modules/travel.lua
@@ -297,6 +297,13 @@ end
 function TravelModule:Refresh()
   if self.hearthFrame == nil then return; end

+  if InCombatLockdown() then
+    self.hearthText:SetText(GetBindLocation())
+    self.portText:SetText(xb.db.modules.travel.portItem.text)
+    self:SetHearthColor()
+    self:SetPortColor()
+  end
+
   local db = xb.db.profile
   --local iconSize = (xb:GetHeight() / 2)
   local iconSize = db.text.fontSize + db.general.barPadding