Skip to content

Commit

Permalink
Keyed config options by constants indead of by text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cidan committed Dec 1, 2023
1 parent 5c23847 commit 187ee09
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions core/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,48 +168,48 @@ const.DATABASE_DEFAULTS = {
enabled = true,
showBagButton = true,
itemLevel = {
Backpack = {
[const.BAG_KIND.BACKPACK] = {
enabled = true,
color = true
},
Bank = {
[const.BAG_KIND.BANK] = {
enabled = true,
color = true
}
},
positions = {
Backpack = {},
Bank = {},
[const.BAG_KIND.BACKPACK] = {},
[const.BAG_KIND.BANK] = {},
},
compaction = {
Backpack = const.GRID_COMPACT_STYLE.NONE,
Bank = const.GRID_COMPACT_STYLE.NONE,
[const.BAG_KIND.BACKPACK] = const.GRID_COMPACT_STYLE.NONE,
[const.BAG_KIND.BANK] = const.GRID_COMPACT_STYLE.NONE,
},
size = {
Backpack = {
[const.BAG_KIND.BACKPACK] = {
columnCount = 3,
itemsPerRow = 5,
width = 700,
height = 500,
},
Bank = {
[const.BAG_KIND.BANK] = {
columnCount = 5,
itemsPerRow = 5,
width = 700,
height = 500,
}
},
views = {
Backpack = const.BAG_VIEW.SECTION_GRID,
Bank = const.BAG_VIEW.SECTION_GRID,
[const.BAG_KIND.BACKPACK] = const.BAG_VIEW.SECTION_GRID,
[const.BAG_KIND.BANK] = const.BAG_VIEW.SECTION_GRID,
},
categoryFilters = {
Backpack = {
[const.BAG_KIND.BACKPACK] = {
Type = true,
Expansion = false,
TradeSkill = false,
},
Bank = {
[const.BAG_KIND.BANK] = {
Type = true,
Expansion = false,
TradeSkill = false,
Expand Down
32 changes: 16 additions & 16 deletions core/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ end

---@param kind BagKind
function DB:GetBagPosition(kind)
return DB.data.profile.positions[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
return DB.data.profile.positions[kind]
end

---@param kind BagKind
---@return BagView
function DB:GetBagView(kind)
return DB.data.profile.views[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
return DB.data.profile.views[kind]
end

---@param kind BagKind
---@param view BagView
function DB:SetBagView(kind, view)
DB.data.profile.views[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'] = view
DB.data.profile.views[kind] = view
end

function DB:GetCategoryFilter(kind, filter)
return DB.data.profile.categoryFilters[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'][filter]
return DB.data.profile.categoryFilters[kind][filter]
end

function DB:SetCategoryFilter(kind, filter, value)
DB.data.profile.categoryFilters[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'][filter] = value
DB.data.profile.categoryFilters[kind][filter] = value
end

---@param show boolean
Expand All @@ -52,58 +52,58 @@ end

---@param kind BagKind
function DB:GetBagSizeInfo(kind)
return DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
return DB.data.profile.size[kind]
end

---@param kind BagKind
---@param count number
function DB:SetBagSizeColumn(kind, count)
DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].columnCount = count
DB.data.profile.size[kind].columnCount = count
end

---@param kind BagKind
---@param count number
function DB:SetBagSizeItems(kind, count)
DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].itemsPerRow = count
DB.data.profile.size[kind].itemsPerRow = count
end

---@param kind BagKind
---@return number, number
function DB:GetBagFrameSize(kind)
local s = DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
local s = DB.data.profile.size[kind]
return s.width, s.height
end

---@param kind BagKind
---@param width number
---@param height number
function DB:SetBagFrameSize(kind, width, height)
DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].width = width
DB.data.profile.size[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].height = height
DB.data.profile.size[kind].width = width
DB.data.profile.size[kind].height = height
end

---@param kind BagKind
---@return GridCompactStyle
function DB:GetBagCompaction(kind)
return DB.data.profile.compaction[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
return DB.data.profile.compaction[kind]
end

---@param kind BagKind
---@param style GridCompactStyle
function DB:SetBagCompaction(kind, style)
DB.data.profile.compaction[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'] = style
DB.data.profile.compaction[kind] = style
end

function DB:GetItemLevelOptions(kind)
return DB.data.profile.itemLevel[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank']
return DB.data.profile.itemLevel[kind]
end

function DB:SetItemLevelEnabled(kind, enabled)
DB.data.profile.itemLevel[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].enabled = enabled
DB.data.profile.itemLevel[kind].enabled = enabled
end

function DB:SetItemLevelColorEnabled(kind, enabled)
DB.data.profile.itemLevel[kind == const.BAG_KIND.BACKPACK and 'Backpack' or 'Bank'].color = enabled
DB.data.profile.itemLevel[kind].color = enabled
end

DB:Enable()

0 comments on commit 187ee09

Please sign in to comment.