Skip to content

Commit

Permalink
Lables are off per default
Browse files Browse the repository at this point in the history
  • Loading branch information
zanony committed Sep 1, 2019
1 parent 1f84965 commit c0ac224
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ChocolateBar.Jostle = {}
ChocolateBar.Bar = {}
ChocolateBar.ChocolatePiece = {}
ChocolateBar.Drag = {}
local modules = {}
ChocolateBar.modules = {}

local Drag = ChocolateBar.Drag
local Chocolate = ChocolateBar.ChocolatePiece
Expand Down Expand Up @@ -68,7 +68,7 @@ local defaults = {
},
objSettings = {
['*'] = {
barName = "", align = "left", enabled = true, showText = true, showLabel = true,
barName = "", align = "left", enabled = true, showText = true, showLabel = false,
showIcon = true, index = 500, width = 0,
},
},
Expand Down Expand Up @@ -120,13 +120,13 @@ function ChocolateBar:OnInitialize()
end
self:AnchorBars()

for name, module in pairs(modules) do
for name, module in pairs(self.modules) do
moduleDB = self.db.profile.moduleOptions[name] or {}
self.db.profile.moduleOptions[name] = moduleDB
if module.OnInitialize then module:OnInitialize(moduleDB) end
end

ChocolateBar:RegisterOptions(db, chocolateBars, modules)
ChocolateBar:RegisterOptions(db, chocolateBars, self.modules)
--_G.InterfaceOptions_AddCategory(self:CreateOptionPanel());
end

Expand All @@ -144,11 +144,11 @@ function ChocolateBar:OnEnable()
end

function ChocolateBar:NewModule(name, moduleDefaults, options, optionsKey)
module = modules[name] or {}
local module = self.modules[name] or {}
module.default = defaults
module.options = options
defaults.profile.moduleOptions[name] = moduleDefaults
modules[name] = module
self.modules[name] = module
return module
end

Expand Down Expand Up @@ -261,7 +261,7 @@ end
--------
function ChocolateBar:LibDataBroker_DataObjectCreated(event, name, obj, noupdate)
local t = obj.type

if t == "data source" or t == "launcher" then
if db.objSettings[name].enabled then
self:EnableDataObject(name, obj, noupdate)
Expand Down
38 changes: 38 additions & 0 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,8 @@ function ChocolateBar:AddObjectOptions(name,obj)
cleanName = string.gsub(cleanName, "\|r", "")
cleanName = string.gsub(cleanName, "[%c \127]", "")

--if obj.enabled then self:AddDefaultModuleOptions(name, obj) end

--use cleanName of name because aceconfig does not like some characters in the plugin names
chocolateOptions[cleanName] = {
--name = GetObjectText,
Expand Down Expand Up @@ -1707,6 +1709,42 @@ function ChocolateBar:AddObjectOptions(name,obj)
}
end

local function GetModuleEnabled(info)
local name = info[#info-2]
return ChocolateBar.db.moduleOptions[name].enabled
end

local function SetModuleEnabled(info, value)
local name = info[#info-2]
ChocolateBar.db.moduleOptions[name].enabled = value
end

function ChocolateBar:AddDefaultModuleOptions(name, obj)
self.db.moduleOptions[name] = {}
local moduleOptions = {
inline = true,
name=name,
type="group",
order = 0,
args={
label = {
order = 2,
type = "description",
name = "description",
},
enabled = {
type = 'toggle',
order = 3,
name = L["Enabled"],
desc = L["Enabled"],
get = GetModuleEnabled,
set = SetModuleEnabled,
},
},
}
self:AddModuleOptions(name, moduleOptions)
end

function ChocolateBar:AddCustomPluginOptions(pluginName, customOptions)
for cleanName, options in pairs(chocolateOptions) do
if cleanName == pluginName then
Expand Down
1 change: 0 additions & 1 deletion localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local AceLocale = LibStub:GetLibrary("AceLocale-3.0")
local L = AceLocale:NewLocale("ChocolateBar", "enUS", true)
if not L then return end


L["Custom Label"] = true
L["Change the label of this plugin."] = true
L["Show Label"] = true
Expand Down
1 change: 1 addition & 0 deletions modules/CB_PlayedTime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local dataobj = LibStub("LibDataBroker-1.1"):NewDataObject("PlayedTime", {
--icon = "Interface\\AddOns\\ChocolateBar\\pics\\ChocolatePiece",
label = "Played Time",
text = "---",
enabled = true,
})

acetimer:ScheduleTimer(function()
Expand Down

0 comments on commit c0ac224

Please sign in to comment.