Quantcast

Hide Bar in combat functionality added. Little fixes to other modules too.

Mikeprod [11-16-16 - 11:38]
Hide Bar in combat functionality added. Little fixes to other modules too.
Filename
XIV_Databar.toc
core.lua
locales/deDE.lua
locales/enUS.lua
locales/frFR.lua
locales/ruRU.lua
locales/zhCN.lua
modules/armor.lua
modules/currency.lua
modules/mastervolume.lua
diff --git a/XIV_Databar.toc b/XIV_Databar.toc
index 6abd5c4..dcce8cf 100644
--- a/XIV_Databar.toc
+++ b/XIV_Databar.toc
@@ -1,7 +1,7 @@
 ## Interface: 70100
 ## Title: XIV_Databar
 ## Author: |cffbbbbbbMille|cff990000XIV|r
-## Version: 2.0.11
+## Version: 2.0.12
 ## Notes: Adds a bottombar by the request of |cffffffffu/sammojo|r on Reddit, Icons made by |cffffffffu/sammojo|r. Previously maintained by |cff00FF99Saxitoxin|r.
 ## SavedVariables: TEST_CONFIG, XIVBarDB
 ## X-Issues: https://github.com/MilleXIV/XIV_Databar/issues
diff --git a/core.lua b/core.lua
index 41ca209..3a8986c 100644
--- a/core.lua
+++ b/core.lua
@@ -24,7 +24,8 @@ XIVBar.defaults = {
             moduleSpacing = 30,
             barFullscreen = true,
             barWidth = GetScreenWidth(),
-            barHoriz = 'CENTER'
+            barHoriz = 'CENTER',
+			barCombatHide = false
         },
         color = {
             barColor = {
@@ -199,6 +200,27 @@ function XIVBar:CreateMainBar()
     end
 end

+function XIVBar:HideBarEvent()
+	local bar = self:GetFrame("bar")
+	if self.db.profile.general.barCombatHide then
+		bar:RegisterEvent("PLAYER_REGEN_ENABLED")
+		bar:RegisterEvent("PLAYER_REGEN_DISABLED")
+
+		bar:SetScript("OnEvent", function(_, event, ...)
+			if event=="PLAYER_REGEN_DISABLED" and XIV_Databar:IsVisible() then
+				XIV_Databar:Hide()
+			end
+			if event=="PLAYER_REGEN_ENABLED" and not XIV_Databar:IsVisible() then
+				XIV_Databar:Show()
+			end
+		end)
+	else
+		bar:UnregisterEvent("PLAYER_REGEN_ENABLED")
+		bar:UnregisterEvent("PLAYER_REGEN_DISABLED")
+		bar.OnEvent = nil
+	end
+end
+
 function XIVBar:GetHeight()
     return (self.db.profile.text.fontSize * 2) + self.db.profile.general.barPadding
 end
@@ -206,6 +228,7 @@ end
 function XIVBar:Refresh()
     if self.frames.bar == nil then return; end

+	self:HideBarEvent()
     self.miniTextPosition = "TOP"
     if self.db.profile.general.barPosition == 'TOP' then
 		hooksecurefunc("UIParent_UpdateTopFramePositions",function(self)
@@ -433,10 +456,17 @@ function XIVBar:GetGeneralOptions()
 				inline = true,
 				order = 3,
 				args = {
+					barCombatHide = {
+						name = L['Hide Bar in combat'],
+						type = "toggle",
+						order = 9,
+						get = function() return self.db.profile.general.barCombatHide; end,
+						set = function(_,val) self.db.profile.general.barCombatHide = val; self:Refresh(); end
+					},
 					barPadding = {
 						name = L['Bar Padding'],
 						type = 'range',
-						order = 9,
+						order = 10,
 						min = 0,
 						max = 10,
 						step = 1,
@@ -446,7 +476,7 @@ function XIVBar:GetGeneralOptions()
 					moduleSpacing = {
 						name = L['Module Spacing'],
 						type = 'range',
-						order = 10,
+						order = 11,
 						min = 10,
 						max = 50,
 						step = 1,
diff --git a/locales/deDE.lua b/locales/deDE.lua
index c9e9006..b138651 100644
--- a/locales/deDE.lua
+++ b/locales/deDE.lua
@@ -15,6 +15,7 @@ L['Bottom'] = "Unten";
 L['Bar Color'] = "Leistenfarbe";
 L['Use Class Color for Bar'] = "Benutze Klassenfarbe für Leiste";
 L["Miscellaneous"] = true;
+L['Hide Bar in combat'] = true;
 L['Bar Padding'] = "Leistenabstand";
 L['Module Spacing'] = "Modulabstand";
 L['Hide order hall bar'] = true;
@@ -76,6 +77,7 @@ L['Always Show Item Level'] = "Rüstungslevel immer anzeigen";
 L['Minimum Durability to Become Active'] = "Minimale Haltbarkeit für Anzeige";
 L['Maximum Durability to Show Item Level'] = "Maximale Haltbarkeit für Rüstungslevel-Anzeige";

+L['Master Volume'] =true;
 L["Volume step"] = true;

 L['Time Format'] = "Uhrzeit-Format";
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 59e35a4..cd683f2 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -14,6 +14,7 @@ L['Bottom'] = true;
 L['Bar Color'] = true;
 L['Use Class Color for Bar'] = true;
 L["Miscellaneous"] = true;
+L['Hide Bar in combat'] = true;
 L['Bar Padding'] = true;
 L['Module Spacing'] = true;
 L['Hide order hall bar'] = true;
@@ -75,6 +76,7 @@ L['Always Show Item Level'] = true;
 L['Minimum Durability to Become Active'] = true;
 L['Maximum Durability to Show Item Level'] = true;

+L['Master Volume'] = true;
 L["Volume step"] = true;

 L['Time Format'] = true;
diff --git a/locales/frFR.lua b/locales/frFR.lua
index 2b4b27b..bc4c5a3 100644
--- a/locales/frFR.lua
+++ b/locales/frFR.lua
@@ -15,6 +15,7 @@ L['Bottom'] = "Bas";
 L['Bar Color'] = "Couleur de la barre";
 L['Use Class Color for Bar'] = "Utiliser la couleur de classe pour la barre";
 L["Miscellaneous"] = "Divers";
+L['Hide Bar in combat'] = "Cacher la barre en combat";
 L['Bar Padding'] = "Décalage de la barre";
 L['Module Spacing'] = "Espacement des modules";
 L['Hide order hall bar'] = "Cacher la barre du hall de classe";
@@ -76,6 +77,7 @@ L['Always Show Item Level'] = "Toujours montrer le niveau d'objet";
 L['Minimum Durability to Become Active'] = "Activation au minimum de durabilité";
 L['Maximum Durability to Show Item Level'] = "Durabilité maximum pour montrer le niveau d'item";

+L['Master Volume'] = "Volume principal";
 L["Volume step"] = "Incrément de volume";

 L['Time Format'] = "Format de l'heure";
diff --git a/locales/ruRU.lua b/locales/ruRU.lua
index 6306d3b..f75c091 100644
--- a/locales/ruRU.lua
+++ b/locales/ruRU.lua
@@ -15,6 +15,7 @@ L['Bottom'] = "Внизу";
 L['Bar Color'] = "Цвет полосы";
 L['Use Class Color for Bar'] = "Использовать цвет класса для полосы";
 L["Miscellaneous"] = "Разное";
+L['Hide Bar in combat'] = true;
 L['Bar Padding'] = "Заполнение";
 L['Module Spacing'] = "Расстояние между модулями";
 L['Hide order hall bar'] = "Прятать полосу оплота класса";
@@ -76,6 +77,7 @@ L['Always Show Item Level'] = "Всегда показывать уровень
 L['Minimum Durability to Become Active'] = "Прочность, до которой загораются цифры";
 L['Maximum Durability to Show Item Level'] = "Прочность, после которой показывается уровень предметов";

+L['Master Volume'] = true;
 L["Volume step"] = true;

 L['Time Format'] = "Формат времени";
diff --git a/locales/zhCN.lua b/locales/zhCN.lua
index d1bfc76..3a03ed8 100644
--- a/locales/zhCN.lua
+++ b/locales/zhCN.lua
@@ -15,6 +15,7 @@ L['Bottom'] = "底部";
 L['Bar Color'] = "条颜色";
 L['Use Class Color for Bar'] = "条使用职业颜色";
 L["Miscellaneous"] = "杂项";
+L['Hide Bar in combat'] = true;
 L['Bar Padding'] = "条填充";
 L['Module Spacing'] = "模块间距";
 L['Hide order hall bar'] = "隐藏职业大厅条";
@@ -76,6 +77,7 @@ L['Always Show Item Level'] = "始终显示物品等级";
 L['Minimum Durability to Become Active'] = "最低耐久度变得活跃";
 L['Maximum Durability to Show Item Level'] = "最大耐久度显示物品等级";

+L['Master Volume'] = true;
 L["Volume step"] = true;

 L['Time Format'] = "时间格式";
diff --git a/modules/armor.lua b/modules/armor.lua
index 94e8ad6..138ea94 100644
--- a/modules/armor.lua
+++ b/modules/armor.lua
@@ -53,22 +53,26 @@ function ArmorModule:RegisterFrameEvents()
   self.armorButton:RegisterUnitEvent('UNIT_INVENTORY_CHANGED', 'player')

   self.armorButton:SetScript('OnEnter', function()
-    ArmorModule:SetArmorColor()
-    GameTooltip:SetOwner(ArmorModule.armorFrame, 'ANCHOR_'..xb.miniTextPosition)
-    GameTooltip:AddLine("[|cff6699FF"..AUCTION_CATEGORY_ARMOR.."|r]")
-    GameTooltip:AddLine(" ")
-    for i,v in pairs(ArmorModule.durabilityList) do
-      if v.max ~= nil and v.max > 0 then
-        local perc = floor((v.cur / v.max)  * 100)
-        GameTooltip:AddDoubleLine(v.text, string.format('%d/%d (%d%%)', v.cur, v.max, perc), 1, 1, 0, 1, 1, 1)
-      end
-    end
-    GameTooltip:Show()
+	if not InCombatLockdown() then
+		ArmorModule:SetArmorColor()
+		GameTooltip:SetOwner(ArmorModule.armorFrame, 'ANCHOR_'..xb.miniTextPosition)
+		GameTooltip:AddLine("[|cff6699FF"..AUCTION_CATEGORY_ARMOR.."|r]")
+		GameTooltip:AddLine(" ")
+		for i,v in pairs(ArmorModule.durabilityList) do
+		  if v.max ~= nil and v.max > 0 then
+			local perc = floor((v.cur / v.max)  * 100)
+			GameTooltip:AddDoubleLine(v.text, string.format('%d/%d (%d%%)', v.cur, v.max, perc), 1, 1, 0, 1, 1, 1)
+		  end
+		end
+		GameTooltip:Show()
+	end
   end)

   self.armorButton:SetScript('OnLeave', function()
-    self:SetArmorColor()
-    GameTooltip:Hide()
+	if not InCombatLockdown() then
+		self:SetArmorColor()
+		GameTooltip:Hide()
+	end
   end)

   self.armorButton:SetScript('OnEvent', function(_, event)
diff --git a/modules/currency.lua b/modules/currency.lua
index 7612496..1aa10a9 100644
--- a/modules/currency.lua
+++ b/modules/currency.lua
@@ -58,10 +58,6 @@ function CurrencyModule:Refresh()
       self.xpBar:SetValue(UnitXP('player'))
       self.xpText:SetText(string.upper(LEVEL..' '..UnitLevel("player")..' '..UnitClass('player')))
     end
-    self:RegisterEvent('PLAYER_REGEN_ENABLED', function()
-      self:Refresh()
-      self:UnregisterEvent('PLAYER_REGEN_ENABLED')
-    end)
     return
   end
   if self.currencyFrame == nil then return; end
diff --git a/modules/mastervolume.lua b/modules/mastervolume.lua
index 937e668..697dd21 100644
--- a/modules/mastervolume.lua
+++ b/modules/mastervolume.lua
@@ -162,7 +162,7 @@ end

 function VolumeModule:GetConfig()
   return {
-    name = self:GetName(),
+    name = L['Master Volume'],
     type = "group",
     args = {
       enable = {