Skip to content

Commit

Permalink
New Theme Engine (#880)
Browse files Browse the repository at this point in the history
This patch significantly enhances the skinning and theme system for AdiBags. The overall goal of this version is to make some more user-friendly defaults for first time users, while also enhancing the ability to customize the look and feel of AdiBags for more advanced users. Highlights include:

* Full Masque support for backpack and banks independently. Configure Masque from the Masque configuration screen.
* Addition of a theme system, where backpack, bank, and reagent bank can be independently themed. Multiple user defined themes can also be saved and loaded. Skins from any previous version of AdiBags will be saved as a new theme called "legacy theme", so that user settings are not lost upon upgrade.
* An external Theme API for addon developers. The AdiBags look and feel can now be modified by external addons, which will allow for a much more customizable experience when integrating with other addons.
* Removal of the "Anchored" mode for bag movement. Bags now can only be moved by clicking and dragging the header of the bag.
* Cleaner defaults for new users, such as a slightly revamped new default theme, normalized scaling, and better initial currency display options.

Overall, this patch should clean up a lot of the major asks people have had of AdiBags over the years. As always, please report any issues you come up against to github.com/AdiAddons/AdiBags/issues
  • Loading branch information
Cidan authored Jan 8, 2023
1 parent c71eba6 commit 026588f
Show file tree
Hide file tree
Showing 17 changed files with 619 additions and 285 deletions.
4 changes: 3 additions & 1 deletion AdiBags.toc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ libs\LibDataBroker-1.1\LibDataBroker-1.1.lua

Localization.lua
core\EventHandlers.lua
core\Fonts.lua
core\Constants.lua
core\Utility.lua
core\Fonts.lua
core\Theme.lua
core\Core.lua
core\Hooks.lua
core\Bags.lua
Expand Down Expand Up @@ -77,6 +78,7 @@ modules\TooltipInfo.lua
modules\SectionVisibilityDropdown.lua
modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\DefaultFilters.lua

Expand Down
4 changes: 3 additions & 1 deletion AdiBags_TBC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ libs\LibDataBroker-1.1\LibDataBroker-1.1.lua

Localization.lua
core\EventHandlers.lua
core\Fonts.lua
core\Constants.lua
core\Utility.lua
core\Fonts.lua
core\Theme.lua
core\Core.lua
core\Hooks.lua
core\Bags.lua
Expand All @@ -73,6 +74,7 @@ modules\TooltipInfo.lua
modules\SectionVisibilityDropdown.lua
modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\DefaultFilters.lua

Expand Down
4 changes: 3 additions & 1 deletion AdiBags_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ libs\LibDataBroker-1.1\LibDataBroker-1.1.lua

Localization.lua
core\EventHandlers.lua
core\Fonts.lua
core\Constants.lua
core\Utility.lua
core\Fonts.lua
core\Theme.lua
core\Core.lua
core\Hooks.lua
core\Bags.lua
Expand All @@ -73,6 +74,7 @@ modules\TooltipInfo.lua
modules\SectionVisibilityDropdown.lua
modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\DefaultFilters.lua

Expand Down
4 changes: 3 additions & 1 deletion AdiBags_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ libs\LibDataBroker-1.1\LibDataBroker-1.1.lua

Localization.lua
core\EventHandlers.lua
core\Fonts.lua
core\Constants.lua
core\Utility.lua
core\Fonts.lua
core\Theme.lua
core\Core.lua
core\Hooks.lua
core\Bags.lua
Expand All @@ -73,6 +74,7 @@ modules\TooltipInfo.lua
modules\SectionVisibilityDropdown.lua
modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\DefaultFilters.lua

Expand Down
217 changes: 123 additions & 94 deletions config/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local unpack = _G.unpack

local safecall = addon.safecall

local AceGUI = LibStub("AceGUI-3.0");
local AceConfigDialog = LibStub('AceConfigDialog-3.0')
local LSM = LibStub('LibSharedMedia-3.0')

Expand Down Expand Up @@ -235,26 +236,71 @@ local function UpdateFilterOrder()
end
end

local function CreateBagOptions(name, key)
local option = {
name = L[name],
type = 'group',
args = {
bagFont = addon:CreateFontOptions(addon.fonts[key].bagFont, L["Bag title"], 5),
sectionFont = addon:CreateFontOptions(addon.fonts[key].sectionFont, L["Section header"], 6),
background = {
name = L['Background'],
type = 'select',
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
dialogControl = 'LSM30_Background',
values = AceGUIWidgetLSMlists.background,
order = 10,
arg = { "theme", key, "background" },
},
insets = {
name = L['Insets'],
type = 'range',
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
order = 20,
min = -16,
max = 16,
step = 1,
arg = { "theme", key, "insets" },
},
border = {
name = L['Border'],
type = 'select',
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
dialogControl = 'LSM30_Border',
values = AceGUIWidgetLSMlists.border,
order = 30,
arg = { "theme", key, "border" },
},
borderWidth = {
name = L['Border Width'],
type = 'range',
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
order = 40,
min = 1,
max = 64,
step = 1,
arg = { "theme", key, "borderWidth" },
},
color = {
name = L['Color'],
type = 'color',
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
order = 50,
hasAlpha = true,
arg = { "theme", key, "color" },
},
}
}
return option
end

--------------------------------------------------------------------------------
-- Core options
--------------------------------------------------------------------------------

local function GetOptions()
if options then return options end

local lockOption = {
name = function()
return addon.anchor:IsShown() and L["Lock anchor"] or L["Unlock anchor"]
end,
desc = L["Click to toggle the bag anchor."],
type = 'execute',
order = 110,
func = function()
addon:ToggleAnchor()
end,
disabled = function(info) return (info.handler and info.handler:IsDisabled(info)) or addon.db.profile.positionMode ~= 'anchored' end,
}

filterOptions._desc = {
name = L['Filters are used to dispatch items in bag sections. One item can only appear in one section. If the same item is selected by several filters, the one with the highest priority wins.'],
type = 'description',
Expand Down Expand Up @@ -328,30 +374,6 @@ local function GetOptions()
order = 100,
inline = true,
args = {
positionMode = {
name = L['Position mode'],
desc = L['Select how the bags are positionned.'],
type = 'select',
order = 100,
values = {
anchored = L['Anchored'],
manual = L['Manual'],
}
},
toggleAnchor = lockOption,
reset = {
name = L['Reset position'],
desc = L['Click there to reset the bag positions and sizes.'],
type = 'execute',
order = 120,
func = function() addon:ResetBagPositions() end,
},
hideAnchor = {
name = L['Do not show anchor point'],
desc = L['Hide the colored corner shown when you move the bag.'],
type = 'toggle',
order = 125,
},
scale = {
name = L['Scale'],
desc = L['Use this to adjust the bag scale.'],
Expand Down Expand Up @@ -436,77 +458,80 @@ local function GetOptions()
},
},
},
skin = {
name = L['Skin'],
theme = {
name = L['Theme'],
type = 'group',
order = 150,
args = {
bagFont = addon:CreateFontOptions(addon.bagFont, L["Bag title"], 10),
sectionFont = addon:CreateFontOptions(addon.sectionFont, L["Section header"], 15),
background = {
name = L['Bag background'],
-- TODO(lobato): Implement at a later date.
currentTheme = {
name = L['Theme Selection'],
desc = L['Select the theme to use for displaying the bags.'],
type = 'select',
order = 10,
values = function()
local themes = {}
for name in pairs(addon.db.profile.theme.themes) do
themes[name] = name
end
return themes
end,
get = function()
return addon.db.profile.theme.currentTheme or 'default'
end,
set = function(_, value)
addon:SetTheme(value)
end,
arg = { "theme", "currentTheme" },
},
themeControls = {
name = L['Theme Controls'],
type = 'group',
inline = true,
order = 20,
args = {
texture = {
name = L['Texture'],
type = 'select',
dialogControl = 'LSM30_Background',
values = AceGUIWidgetLSMlists.background,
topDescription = {
type = 'description',
order = 0,
name = L['All controls are disabled if the selected theme is the default theme. Make a new theme below to edit your theme.'],
},
saveTheme = {
name = L['Save Theme'],
desc = L['Save the current theme settings to the selected theme name.'],
type = 'execute',
order = 10,
arg = { "skin", "background" },
confirm = function() return "Are you sure you want to save and overwrite the theme '"..addon.db.profile.theme.currentTheme.."'?" end,
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
func = function() addon:SaveTheme() end,
},
insets = {
name = L['Insets'],
type = 'range',
deleteTheme = {
name = L['Delete Theme'],
desc = L['Delete the selected theme from the database.'],
type = 'execute',
order = 20,
arg = { "skin", "insets" },
min = -16,
max = 16,
step = 1,
confirm = function() return "Are you sure you want to delete the theme '"..addon.db.profile.theme.currentTheme.."'?" end,
disabled = function() return addon.db.profile.theme.currentTheme == 'default' end,
func = function() addon:DeleteTheme() end,
},
border = {
name = L['Border'],
type = 'select',
dialogControl = 'LSM30_Border',
values = AceGUIWidgetLSMlists.border,
bottomDescription = {
type = 'description',
order = 30,
arg = { "skin", "border" },
name = L['Type in a new theme in the input below and hit enter to create a new theme.'],
},
borderWidth = {
name = L['Border width'],
type = 'range',
newThemeName = {
name = L['New Theme Name'],
desc = L['Type in the name of the new theme to create.'],
type = 'input',
order = 40,
arg = { "skin", "borderWidth" },
min = 1,
max = 64,
step = 1,
},
backpackColor = {
name = L['Backpack color'],
type = 'color',
order = 50,
hasAlpha = true,
arg = { "skin", "BackpackColor" },
validate = function(_, value) return (not addon:ThemeExists(value) and true) or "A theme by that name already exists." end,
get = function() return "" end,
set = function(_, value) addon:NewTheme(value) addon:SetTheme(value) end,
},
bankColor = {
name = L['Bank color'],
type = 'color',
order = 60,
hasAlpha = true,
arg = { "skin", "BankColor" },
},
reagentBankColor = {
name = L['Reagent bank color'],
type = 'color',
order = 70,
hasAlpha = true,
arg = { "skin", "ReagentBankColor" },
},
},
}
},
}
},
backpack = CreateBagOptions("Backpack", "backpack"),
bank = CreateBagOptions("Bank", "bank"),
reagentBank = CreateBagOptions("Reagent Bank", "reagentBank"),
}
},
items = {
name = L['Items'],
Expand Down Expand Up @@ -693,3 +718,7 @@ function addon:OpenOptions(...)
AceConfigDialog:Open(addonName)
end
end

function addon:CloseOptions()
AceConfigDialog:Close(addonName)
end
Loading

0 comments on commit 026588f

Please sign in to comment.