Quantcast

SetFont changes, some cleanup

MilleXIV [08-28-16 - 02:47]
SetFont changes, some cleanup

Standarized SetFont to call back to core, makes code look slightly
nicer.

Add ability to set font flags
Filename
core.lua
locales/enUS.lua
modules/armor.lua
modules/currency.lua
modules/gold.lua
modules/micromenu.lua
modules/system.lua
modules/travel.lua
diff --git a/core.lua b/core.lua
index e15dbda..3b1f553 100644
--- a/core.lua
+++ b/core.lua
@@ -46,11 +46,6 @@ XIVBar.defaults = {
       smallFontSize = 11,
       font =  'Homizio Bold'
     },
-
-
-
-
-
     modules = {

     }
@@ -74,6 +69,8 @@ function XIVBar:OnInitialize()
   self.LSM:Register(self.LSM.MediaType.FONT, 'Homizio Bold', self.constants.mediaPath.."homizio_bold.ttf")
   self.frames = {}

+  self.fontFlags = {'', 'OUTLINE', 'THICKOUTLINE', 'MONOCHROME'}
+
   --[[local options = {
     name = "XIV Bar",
     handler = XIVBar,
@@ -256,6 +253,10 @@ function XIVBar:Refresh()
   end
 end

+function XIVBar:GetFont(size)
+  return self.LSM:Fetch(self.LSM.MediaType.FONT, self.db.profile.text.font), size, self.fontFlags[self.db.profile.text.flags]
+end
+
 function XIVBar:GetClassColors()
   return RAID_CLASS_COLORS[self.constants.playerClass].r, RAID_CLASS_COLORS[self.constants.playerClass].g, RAID_CLASS_COLORS[self.constants.playerClass].b, self.db.profile.color.barColor.a
 end
@@ -378,6 +379,15 @@ function XIVBar:GetTextOptions()
         get = function() return self.db.profile.text.smallFontSize; end,
         set = function(info, val) self.db.profile.text.smallFontSize = val; self:Refresh(); end
       },
+      textFlags = {
+        name = L['Text Style'],
+        type = 'select',
+        style = 'dropdown',
+        order = 3,
+        values = self.fontFlags,
+        get = function() return self.db.profile.text.flags; end,
+        set = function(info, val) self.db.profile.text.flags = val; self:Refresh(); end
+      },
     }
   }
 end
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 352e358..f05aba0 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -22,6 +22,7 @@ L['Module Spacing'] = true;
 L['Font'] = true;
 L['Font Size'] = true;
 L['Small Font Size'] = true;
+L['Text Style'] = true;

 -- Text Colors
 L['Text Colors'] = true;
diff --git a/modules/armor.lua b/modules/armor.lua
index 6f3f3e0..5fb7234 100644
--- a/modules/armor.lua
+++ b/modules/armor.lua
@@ -103,12 +103,17 @@ function ArmorModule:Refresh()
   if self.armorFrame == nil then return; end
   if not xb.db.profile.modules.armor.enabled then return; end

+  if InCombatLockdown() then
+    self:UpdateDurabilityText()
+    return
+  end
+
   local iconSize = xb:GetHeight()
   self.armorIcon:SetTexture(self.iconPath)
   --self.armorIcon:SetSize(iconSize, iconSize)
   self.armorIcon:SetPoint('LEFT')

-  self.armorText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, xb.db.profile.text.font), xb.db.profile.text.fontSize)
+  self.armorText:SetFont(xb:GetFont(xb.db.profile.text.fontSize))
   self:UpdateDurabilityText()
   self.armorText:SetPoint('LEFT', self.armorIcon, 'RIGHT', 5, 0)

@@ -150,15 +155,17 @@ function ArmorModule:UpdateDurabilityText()
   end
   self.durabilityAverage = floor((total / maxTotal) * 100)

-  if self.durabilityAverage < db.durabilityMax then
-    text = self.durabilityAverage..'%'
-  end
-
   if (self.durabilityAverage >= db.durabilityMax) or db.alwaysShowIlvl then
     local _, equippedIlvl = GetAverageItemLevel()
-    text = text..floor(equippedIlvl)..' ilvl'
+    text = floor(equippedIlvl)..' ilvl'
   end

+  if self.durabilityAverage <= db.durabilityMax then
+    text = text..' '..self.durabilityAverage..'%'
+  end
+
+
+
   self.armorText:SetText(text)
 end

diff --git a/modules/currency.lua b/modules/currency.lua
index 08f774e..643a8b5 100644
--- a/modules/currency.lua
+++ b/modules/currency.lua
@@ -80,7 +80,7 @@ function CurrencyModule:Refresh()
     self.xpIcon:SetPoint('LEFT')
     self.xpIcon:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)

-    self.xpText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), textHeight)
+    self.xpText:SetFont(xb:GetFont(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..' '..UnitLevel("player")..' '..UnitClass('player')))
     self.xpText:SetPoint('TOPLEFT', self.xpIcon, 'TOPRIGHT', 5, 0)
@@ -145,7 +145,7 @@ function CurrencyModule:StyleCurrencyFrame(curId, i)
   self.curIcons[i]:SetPoint(iconPoint)
   self.curIcons[i]:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)

-  self.curText[i]:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+  self.curText[i]:SetFont(xb:GetFont(db.text.fontSize))
   self.curText[i]:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
   self.curText[i]:SetText(curAmount)
   self.curText[i]:SetPoint(iconPoint, self.curIcons[i], textPoint, padding, 0)
diff --git a/modules/gold.lua b/modules/gold.lua
index 63f9681..6b2930f 100644
--- a/modules/gold.lua
+++ b/modules/gold.lua
@@ -40,13 +40,25 @@ function GoldModule:Refresh()
   if self.goldFrame == nil then return; end
   if not db.modules.gold.enabled then return; end

+  if InCombatLockdown() then
+    self.goldText:SetText(self:FormatCoinText(GetMoney()))
+    if db.modules.gold.showFreeBagSpace then
+      local freeSpace = 0
+      for i = 0, 4 do
+        freeSpace = freeSpace + GetContainerNumFreeSlots(i)
+      end
+      self.bagText:SetText('('..tostring(freeSpace)..')')
+    end
+    return
+  end
+
   local iconSize = db.text.fontSize + db.general.barPadding
   self.goldIcon:SetTexture(xb.constants.mediaPath..'datatexts\\gold')
   self.goldIcon:SetSize(iconSize, iconSize)
   self.goldIcon:SetPoint('LEFT')
   self.goldIcon:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a)

-  self.goldText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+  self.goldText:SetFont(xb:GetFont(db.text.fontSize))
   self.goldText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
   self.goldText:SetText(self:FormatCoinText(GetMoney()))
   self.goldText:SetPoint('LEFT', self.goldIcon, 'RIGHT', 5, 0)
@@ -57,7 +69,7 @@ function GoldModule:Refresh()
     for i = 0, 4 do
       freeSpace = freeSpace + GetContainerNumFreeSlots(i)
     end
-    self.bagText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+    self.bagText:SetFont(xb:GetFont(db.text.fontSize))
     self.bagText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
     self.bagText:SetText('('..tostring(freeSpace)..')')
     self.bagText:SetPoint('LEFT', self.goldText, 'RIGHT', 5, 0)
diff --git a/modules/micromenu.lua b/modules/micromenu.lua
index 5817c4a..f0e8c97 100644
--- a/modules/micromenu.lua
+++ b/modules/micromenu.lua
@@ -113,7 +113,7 @@ function MenuModule:Refresh()
   self.microMenuFrame:SetSize(totalWidth, xb:GetHeight())

   for name, frame in pairs(self.text) do
-    frame:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, xb.db.profile.text.font), xb.db.profile.text.smallFontSize)
+    frame:SetFont(xb:GetFont(xb.db.profile.text.smallFontSize))
     frame:SetPoint('CENTER', self.frames[name], xb.miniTextPosition)
     self.bgTexture[name]:SetColorTexture(xb.db.profile.color.barColor.r, xb.db.profile.color.barColor.g, xb.db.profile.color.barColor.b, xb.db.profile.color.barColor.a)
     self.bgTexture[name]:SetPoint('CENTER', frame, 'CENTER')
diff --git a/modules/system.lua b/modules/system.lua
index b3c3f14..1e8abdf 100644
--- a/modules/system.lua
+++ b/modules/system.lua
@@ -45,7 +45,7 @@ function SystemModule:Refresh()
   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:SetFont(xb:GetFont(db.text.fontSize))

   self.fpsText:SetPoint('RIGHT', -5, 0)
   self.fpsText:SetText('000'..FPS_ABBR) -- get the widest we can be
@@ -56,8 +56,8 @@ function SystemModule:Refresh()
   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)
+  self.pingText:SetFont(xb:GetFont(db.text.fontSize))
+  self.worldPingText:SetFont(xb:GetFont(db.text.fontSize))

   if self.fpsFrame:IsMouseOver() or self.pingFrame:IsMouseOver() then
     self.fpsText:SetTextColor(unpack(xb:HoverColors()))
@@ -84,7 +84,7 @@ function SystemModule:Refresh()
   self.fpsFrame:SetSize(fpsWidest + iconSize + 5, xb:GetHeight())
   self.fpsFrame:SetPoint('LEFT')

-  self.pingFrame:SetSize(pingWidest + iconSize + 5, xb:GetHeight())
+  self.pingFrame:SetSize(pingWidest + iconSize, xb:GetHeight())
   self.pingFrame:SetPoint('LEFT', self.fpsFrame, 'RIGHT', 5, 0)

   self.systemFrame:SetSize(self.fpsFrame:GetWidth() + self.pingFrame:GetWidth(), xb:GetHeight())
diff --git a/modules/travel.lua b/modules/travel.lua
index 3877bef..ebd13b8 100644
--- a/modules/travel.lua
+++ b/modules/travel.lua
@@ -230,7 +230,7 @@ function TravelModule:CreatePortPopup()
         local button = CreateFrame('BUTTON', nil, self.portPopup)
         local buttonText = button:CreateFontString(nil, 'OVERLAY')

-        buttonText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+        buttonText:SetFont(xb:GetFont(db.text.fontSize))
         buttonText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a)
         buttonText:SetText(v.text)
         buttonText:SetPoint('LEFT')
@@ -308,7 +308,7 @@ function TravelModule:Refresh()
   --local iconSize = (xb:GetHeight() / 2)
   local iconSize = db.text.fontSize + db.general.barPadding

-  self.hearthText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+  self.hearthText:SetFont(xb:GetFont(db.text.fontSize))
   self.hearthText:SetText(GetBindLocation())

   self.hearthButton:SetSize(self.hearthText:GetWidth() + iconSize + db.general.barPadding, xb:GetHeight())
@@ -323,7 +323,7 @@ function TravelModule:Refresh()

   self:SetHearthColor()

-  self.portText:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize)
+  self.portText:SetFont(xb:GetFont(db.text.fontSize))
   self.portText:SetText(db.modules.travel.portItem.text)

   self.portButton:SetSize(self.portText:GetWidth() + iconSize + db.general.barPadding, xb:GetHeight())