-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ConsolePort support to Retail and Classic.
Added various events for better hooking of BetterBags events.
- Loading branch information
Showing
11 changed files
with
176 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
---@diagnostic disable: duplicate-set-field,duplicate-doc-field,duplicate-doc-alias | ||
local addonName = ... ---@type string | ||
|
||
---@class BetterBags: AceAddon | ||
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName) | ||
|
||
---@class Localization: AceModule | ||
local L = addon:GetModule('Localization') | ||
|
||
---@class Database: AceModule | ||
local DB = addon:GetModule('Database') | ||
|
||
---@class Constants: AceModule | ||
local const = addon:GetModule('Constants') | ||
|
||
---@class Config: AceModule | ||
local config = addon:GetModule('Config') | ||
|
||
---@class Events: AceModule | ||
local events = addon:GetModule('Events') | ||
|
||
|
||
local GUI = LibStub('AceGUI-3.0') | ||
|
||
---@return AceConfig.OptionsTable | ||
function config:GetGeneralOptions() | ||
---@type AceConfig.OptionsTable | ||
local options = { | ||
type = "group", | ||
name = L:G("General"), | ||
order = 0, | ||
args = { | ||
newItemTime = { | ||
type = "range", | ||
order = 2, | ||
name = L:G("New Item Duration"), | ||
desc = L:G("The time, in minutes, to consider an item a new item."), | ||
min = 0, | ||
max = 240, | ||
step = 5, | ||
get = function() | ||
return DB:GetData().profile.newItemTime / 60 | ||
end, | ||
set = function(_, value) | ||
DB:GetData().profile.newItemTime = value * 60 | ||
end, | ||
} | ||
} | ||
} | ||
return options | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
---@diagnostic disable: duplicate-set-field,duplicate-doc-field,duplicate-doc-alias | ||
local addonName = ... ---@type string | ||
|
||
---@class BetterBags: AceAddon | ||
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName) | ||
|
||
---@class Events: AceModule | ||
local events = addon:GetModule('Events') | ||
|
||
---@class Context: AceModule | ||
local context = addon:GetModule('Context') | ||
|
||
---@class Config: AceModule | ||
local config = addon:GetModule('Config') | ||
|
||
---@class ConsolePort: AceModule | ||
---@field private enabled boolean | ||
local consoleport = addon:NewModule('ConsolePort') | ||
|
||
function consoleport:OnInitialize() | ||
self.enabled = ConsolePort and true or false | ||
end | ||
|
||
function consoleport:OnEnable() | ||
if not self.enabled then return end | ||
self:Add(addon.Bags.Backpack.frame) | ||
self:Add(addon.Bags.Bank.frame) | ||
|
||
-- Context menus are created on demand, so we need to listen for the context/show event to add them. | ||
events:RegisterMessage('context/show', function() | ||
local listCount = 1 | ||
local buttonCount = 1 | ||
while _G[format('L_DropDownList%d', listCount)] ~= nil do | ||
self:Add(_G[format('L_DropDownList%d', listCount)]) | ||
while _G[format('L_DropDownList%dButton%d', listCount, buttonCount)] ~= nil do | ||
self:Add(_G[format('L_DropDownList%dButton%d', listCount, buttonCount)]) | ||
buttonCount = buttonCount + 1 | ||
end | ||
listCount = listCount + 1 | ||
buttonCount = 1 | ||
end | ||
self:Select(_G['L_DropDownList1Button2']) | ||
end) | ||
|
||
-- Overwrite the config open function so that it opens to Blizzard config when using ConsolePort | ||
config.Open = function(me) | ||
---@cast me +Config | ||
if addon.isClassic then | ||
InterfaceOptionsFrame_OpenToCategory(me.frame) | ||
else | ||
Settings.OpenToCategory(me.category) | ||
end | ||
end | ||
end | ||
|
||
---@param frame Frame | ||
function consoleport:Add(frame) | ||
if not self.enabled then return end | ||
ConsolePort:AddInterfaceCursorFrame(frame) | ||
end | ||
|
||
---@param frame Frame | ||
function consoleport:Select(frame) | ||
if not self.enabled then return end | ||
ConsolePort:SetCursorNode(frame) | ||
end | ||
|
||
---@return boolean | ||
function consoleport:Active() | ||
return self.enabled | ||
end |