Skip to content

Commit

Permalink
wip section and item database
Browse files Browse the repository at this point in the history
  • Loading branch information
Cidan committed Nov 8, 2023
1 parent fc8cc50 commit 29a0ff9
Showing 6 changed files with 95 additions and 2 deletions.
2 changes: 2 additions & 0 deletions BetterBags.toc
Original file line number Diff line number Diff line change
@@ -28,6 +28,8 @@ core\hooks.lua
debug\debug.lua
debug\frames.lua

data\items.lua

frames\section.lua
frames\bag.lua

5 changes: 5 additions & 0 deletions core/init.lua
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@ local BagFrame = addon:GetModule('BagFrame')
---@class Constants: AceModule
local const = addon:GetModule('Constants')

---@class Items: AceModule
local items = addon:GetModule('Items')

---@class BagFrames
---@field Backpack Bag
---@field Bank Bag
@@ -35,6 +38,8 @@ function addon:OnInitialize()

addon.Bags.Backpack = BagFrame:Create(const.BAG_KIND.BACKPACK)
addon.Bags.Bank = BagFrame:Create(const.BAG_KIND.BANK)

items:Enable()
end

-- OnEnable is called when the addon is enabled.
22 changes: 22 additions & 0 deletions data/items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local addonName = ...

---@class BetterBags: AceAddon
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)

---@class Items: AceModule
local items = addon:NewModule('Items')

---@class Item A single item a player can interact with.
local itemProto = {}

-- Create will create a new item and return it.
---@return Item
function items:Create()
---@class Item
local item = setmetatable({}, { __index = itemProto })
return item
end

function items:OnEnable()
--TODO(lobato): Load all items from the inventory.
end
5 changes: 5 additions & 0 deletions debug/debug.lua
Original file line number Diff line number Diff line change
@@ -5,4 +5,9 @@ local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)

---@class Debug: AceModule
local debug = addon:NewModule('Debug')

function debug:OnEnable()
print("BetterBags: debug mode enabled")
end

debug:Enable()
5 changes: 4 additions & 1 deletion frames/bag.lua
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ local LSM = LibStub('LibSharedMedia-3.0')
---@field leftHeader Frame The top left header of the bag.
---@field title FontString The title of the bag.
---@field content Frame The main content frame of the bag.

local bagProto = {}

function bagProto:Show()
@@ -48,6 +47,10 @@ function bagProto:Toggle()
end
end

--- Draw is the main entry point for drawing the bag.
function bagProto:Draw()

end
-------
--- Bag Frame
-------
58 changes: 57 additions & 1 deletion frames/section.lua
Original file line number Diff line number Diff line change
@@ -4,4 +4,60 @@ local addonName = ...
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)

---@class SectionFrame: AceModule
local sectionFrame = addon:NewModule('Section')
local sectionFrame = addon:NewModule('Section')

---@class Debug: AceModule
local debug = addon:GetModule('Debug')
-------
--- Section Prototype
-------

--- Section is a view of a single bag section. A section
--- has a title, and contains all the items views for a section.
---
--- Sections can be rendered in multiple different ways, such as
--- a list of icons, a list of rows, or a grid of icons.
---@class Section
---@field frame Frame The raw frame of the section.
---@field title FontString The title of the section.
local sectionProto = {}

-- Grid will render the section as a grid of icons.
function sectionProto:Grid()
end

-- List will render the section as a list of rows, with optional icons.
function sectionProto:List()
end

-------
--- Section Frame
-------

-- Create will create a new section view as a child of the
-- given parent.
---@param parent Frame
---@return Section
function sectionFrame:Create(parent)
---@class Section
local s = {}
setmetatable(s, { __index = sectionProto })

---@class Frame: BackdropTemplate
local f = CreateFrame("Frame", nil, nil, "BackdropTemplate")
f.SetParent(parent)
s.frame = f

debug:DrawDebugBorder(f, 1, 1, 1)

-- Create the section title.
local title = s.frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetText("Not set")
title:SetFontObject("GameFontNormal")
title:SetHeight(18)
title:SetJustifyH("LEFT")
title:SetPoint("BOTTOMLEFT", s.frame, "TOPLEFT", 0, -4)
s.title = title

return s
end

0 comments on commit 29a0ff9

Please sign in to comment.