Quantcast

Bar length settings

MilleXIV [08-28-16 - 03:04]
Bar length settings

As per ticket #17
Filename
core.lua
locales/enUS.lua
diff --git a/core.lua b/core.lua
index 3b1f553..d236e6d 100644
--- a/core.lua
+++ b/core.lua
@@ -11,7 +11,10 @@ XIVBar.defaults = {
     general = {
       barPosition = "BOTTOM",
       barPadding = 3,
-      moduleSpacing = 30
+      moduleSpacing = 30,
+      barFullscreen = true,
+      barWidth = GetScreenWidth(),
+      barHoriz = 'CENTER'
     },
     color = {
       barColor = {
@@ -118,6 +121,7 @@ function XIVBar:OnInitialize()
           general = self:GetGeneralOptions(),
           text = self:GetTextOptions(),
           textColors = self:GetTextColorOptions(), -- colors
+          positionOptions = self:GetPositionOptions(),
         }
       }, -- general
       modules = {
@@ -236,8 +240,17 @@ function XIVBar:Refresh()
   local barColor = self.db.profile.color.barColor
   self.frames.bar:ClearAllPoints()
   self.frames.bar:SetPoint(self.db.profile.general.barPosition)
-  self.frames.bar:SetPoint("LEFT")
-  self.frames.bar:SetPoint("RIGHT")
+  if self.db.profile.general.barFullscreen then
+    self.frames.bar:SetPoint("LEFT")
+    self.frames.bar:SetPoint("RIGHT")
+  else
+    local relativePoint = self.db.profile.general.barHoriz
+    if relativePoint == 'CENTER' then
+      relativePoint = 'BOTTOM'
+    end
+    self.frames.bar:SetPoint(self.db.profile.general.barHoriz, self.frames.bar:GetParent(), relativePoint)
+    self.frames.bar:SetWidth(self.db.profile.general.barWidth)
+  end
   self.frames.bar:SetHeight(self:GetHeight())

   self.frames.bgTexture:SetAllPoints()
@@ -278,8 +291,6 @@ function XIVBar:HexToRGBA(hex)
   return (tonumber(rhex, 16) / 255), (tonumber(ghex, 16) / 255), (tonumber(bhex, 16) / 255), (tonumber(ahex, 16) / 255)
 end

-
-
 function XIVBar:GetGeneralOptions()
   return {
     name = L['General'],
@@ -338,6 +349,45 @@ function XIVBar:GetGeneralOptions()
   }
 end

+function XIVBar:GetPositionOptions()
+  return {
+    name = L['Positioning Options'],
+    type = "group",
+    order = 4,
+    inline = true,
+    args = {
+      fullScreen = {
+        name = L['Full Screen'],
+        type = 'toggle',
+        order = 0,
+        get = function() return self.db.profile.general.barFullscreen; end,
+        set = function(info, value) self.db.profile.general.barFullscreen = value; self:Refresh(); end,
+      },
+      barPosition = {
+        name = L['Horizontal Position'],
+        type = "select",
+        order = 1,
+        values = {LEFT = L['Left'], CENTER = L['Center'], RIGHT = L['Right']},
+        style = "dropdown",
+        get = function() return self.db.profile.general.barHoriz; end,
+        set = function(info, value) self.db.profile.general.barHoriz = value; self:Refresh(); end,
+        disabled = function() return self.db.profile.general.barFullscreen; end
+      },
+      barWidth = {
+        name = L['Bar Width'],
+        type = 'range',
+        order = 2,
+        min = 200,
+        max = GetScreenWidth(),
+        step = 1,
+        get = function() return self.db.profile.general.barWidth; end,
+        set = function(info, val) self.db.profile.general.barWidth = val; self:Refresh(); end,
+        disabled = function() return self.db.profile.general.barFullscreen; end
+      }
+    }
+  }
+end
+
 function XIVBar:GetTextOptions()
   local t = self.LSM:List(self.LSM.MediaType.FONT);
   local fontList = {};
diff --git a/locales/enUS.lua b/locales/enUS.lua
index f05aba0..1be2a6a 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -18,6 +18,15 @@ L['Use Class Colors for Bar'] = true;
 L['Bar Padding'] = true;
 L['Module Spacing'] = true;

+-- Positioning Options
+L['Positioning Options'] = true;
+L['Full Screen'] = true;
+L['Horizontal Position'] = true;
+L['Bar Width'] = true;
+L['Left'] = true;
+L['Center'] = true;
+L['Right'] = true;
+
 -- Media
 L['Font'] = true;
 L['Font Size'] = true;