Add toc-file for classic

This commit is contained in:
robin 2021-05-22 09:21:26 +02:00
parent 016b8f76a9
commit d777bde173
9 changed files with 205 additions and 22 deletions

6
BrokerPack-Classic.toc Normal file
View File

@ -0,0 +1,6 @@
## Interface: 11302
## Title: BrokerPack
## OptionalDeps: zzLib, Ace3
## SavedVariables: BrokerPackDB
Libs\embeds.xml
pack.xml

View File

@ -3,7 +3,7 @@ local childName = addon['childName']
local child = addon[childName]
local modName = "autogreed"
local events = {}
local db
local db, dbm
-- local L = LibStub('AceLocale-3.0'):GetLocale(childName, true)
local orbList = {
[45087] = true, -- runed orb
@ -28,17 +28,17 @@ local defaults = {
}
local function getPref2(key)
local db = child['MH_GetDB'](modName, defaults)
return db[key]
-- local db = child['MH_GetDB'](modName, defaults)
return dbm[key]
end
local function getPref(pref)
return getPref2(pref[#pref])
end
local function setPref(pref,value)
local db = child['MH_GetDB'](modName, defaults)
db[pref[#pref]] = value
local function setPref(pref, value)
-- local db = child['MH_GetDB'](modName, defaults)
dbm[pref[#pref]] = value
end
local function checkPrefType(key, prefType)
@ -49,7 +49,7 @@ local function checkPrefType(key, prefType)
end
local function initDBCheck()
for key,value in pairs(defaults) do
for key, value in pairs(defaults) do
checkPrefType(key, type(defaults[key]))
end
end
@ -93,13 +93,27 @@ local function START_LOOT_ROLL(_, event, id, ...)
end
end
end
local function OnEnable()
local frm = format("%sSettings", modName)
db[frm] = db[frm] or CopyTable(defaults)
dbm = db[frm]
child:RegisterEvent(events)
end
local function OnDisable()
child:UnregisterEvent(events)
end
local init = {
Setup = function(self)
db = child['db']
if(db[modName]) then
child:RegisterEvent(events)
OnEnable()
end
child:AddCE(modName)
child['mhmods'][modName] = {
db = dbm,
['Enable'] = OnEnable,
['Disable'] = OnDisable
}
child:AddME(modName)
end
}
addon.RegisterCallback(init, format('Init%s', childName), 'Setup')

View File

@ -8,11 +8,21 @@ function events:DUEL_REQUESTED(_, event)
StaticPopup_Hide(event)
CancelDuel()
end
local function OnEnable()
child:RegisterEvent(events)
end
local function OnDisable()
child:UnregisterEvent(events)
end
local init = {
Setup = function(self)
db = child['db']
child['mhmods'][modName] = {
['Enable'] = OnEnable,
['Disable'] = OnDisable
}
if(db[modName]) then
child:RegisterEvent(events)
OnEnable()
end
child:AddCE(modName)
end

View File

@ -2,6 +2,7 @@ local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local zzLDB = LibStub:GetLibrary("zzLDB")
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
local function OnClick(self, button)
zzLDB:DefaultOnClick(self, button, addon, childName)
end
@ -9,9 +10,9 @@ local function OnTooltipShow(tip)
tip:AddLine(childName)
end
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
['type'] = 'data source', -- required: 'data source' or 'launcher'
['type'] = 'launcher', -- required: 'data source' or 'launcher'
['text'] = childName, -- required/optional for launcher
['icon'] = 'Interface\\Icons\\INV_Misc_Bag_10_Blue', -- optional/required for launcher
['icon'] = format("%s\\icon2.tga", folder), -- optional/required for launcher
['OnClick'] = OnClick, -- optional/required for launcher
['OnTooltipShow'] = OnTooltipShow, -- optional
}

View File

@ -1,13 +1,38 @@
local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local events = child['events']
local events = {}
local db
local mods = {}
local registered = {}
local inited = {}
child['mhmods'] = child['mhmods'] or {}
LibStub("zzHelper"):Embed(child)
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
addon['callbacks']:Fire(format("Init%s", childName))
end
local function iterateModuls()
for _, modul in ipairs(child['mhmods']) do
if((child:IsClassic() and not modul['skipClassic']) or not child:IsClassic()) then
mods[#mods + 1] = modul['name']
for _, event in ipairs(modul['events']) do
events[modul['name']] = { [event] = modul['onevent']}
if(not registered[event]) then
registered[event] = true
addon:RegisterFunc(event, "OnEvent", eventHandler)
end
end
-- addon:AddConfigEntry(childName, "toggle",modul['name'],modul['message'],nil,1,nil,nil,nil,nil,options['args'][childName])
child:AddCE(modul['name'],modul['message'])
if(type(modul['init']) == 'function' and db[modul['name']]) then
modul['init']()
inited[modul['name']] = true
end
end
end
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
@ -16,11 +41,18 @@ child['specs'] = {
['ldb'] = child['ldb'],
['defaults'] = {
['profile'] = {
[childName] = {}
[childName] = {
['test'] = false,
['sellgrey'] = true,
['noduel'] = true,
['autorepair'] = false,
['hideclock'] = true,
}
}
}
}
function events:PLAYER_ENTERING_WORLD(_, event)
child:UnregisterEvent(event)
-- iterateModuls()
end
child:NewAddOn(...)

View File

@ -3,4 +3,27 @@ local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "deDE", false)
if L then
L['noduel_message'] = "Duelle ablehnen"
L["autogreed_message"] = "Gier/Entzaubern von gr\195\188nem/blauem Loot"
L["autogreed_group"] = "Auto-Gier"
L['Disenchant'] = "Entzaubern"
L['DE green'] = "Gr\195\188n entzaubern"
L['DE blue'] = "Blau entzaubern"
L['DE epic'] = "Lila entzaubern"
L['Bind on Equip'] = "BoE - Beim Anlegen gebunden"
L['Greed BoE'] = "Gier auf BoE"
L['Show BoE'] = "Zeige BoE"
L['SkipGreed'] = format("1, |c%s2|r, |c%s3|r, |c%s4|r Gier nur bis zu dieser Qualit\195\164t",select(4,GetItemQualityColor(2)),select(4,GetItemQualityColor(3)),select(4,GetItemQualityColor(4)))
L['Pass green BoE'] = "Passe gr\195\188nes BoE"
L['Pass blue BoE'] = "Passe blaues BoE"
L['Pass epic BoE'] = "Passe lila BoE"
L['Misc'] = "Verschiedenes"
L['Show Need Rolls'] = "Zeige Bedarf"
L['Show items you can roll need for. Set minimum quality to hide low level items.'] = "Zeige Bedarf-Items. Setze minimale Qualit\195\164t um niedrige Items auszublenden."
L['Minimum Quality'] = "Minimale Qualit\195\164t"
L["Dont show items with a quality lower than minimum quality when 'Show Need Rolls' is active. -1 means automagically your current average Itemlevel - 18"] = true
L['Ignore orbs'] = true
L['Show Pets'] = true
L['Show Mounts'] = true
L['Show Holiday-Items'] = true
L['Show Questitems'] = true
end

View File

@ -2,5 +2,28 @@ local addonname, addon = ...
local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "enUS", true)
if L then
L[childName] = childName
L['noduel_message'] = "Reject duels"
L['autogreed_message'] = "Greed or disentchant blue and green"
L['autogreed_group'] = "Autogreed"
L['Disenchant'] = true
L['DE green'] = true
L['DE blue'] = true
L['DE epic'] = true
L['Bind on Equip'] = true
L['Greed BoE'] = true
L['Show BoE'] = true
L['SkipGreed'] = format("1, |c%s2|r, |c%s3|r, |c%s4|r Skip greeding BoE when quality is higher",select(4,GetItemQualityColor(2)),select(4,GetItemQualityColor(3)),select(4,GetItemQualityColor(4)))
L['Pass green BoE'] = true
L['Pass blue BoE'] = true
L['Pass epic BoE'] = true
L['Misc'] = true
L['Show Need Rolls'] = true
L['Show items you can roll need for. Set minimum quality to hide low level items.'] = true
L['Minimum Quality'] = true
L["Dont show items with a quality lower than minimum quality when 'Show Need Rolls' is active. -1 means automagically your current average Itemlevel - 18"] = true
L['Ignore orbs'] = true
L['Show Pets'] = true
L['Show Mounts'] = true
L['Show Holiday-Items'] = true
L['Show Questitems'] = true
end

View File

@ -1,7 +1,9 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="init.lua"/>
<Script file="locale_enUS.lua"/>
<Script file="locale_deDE.lua"/>
<Script file="prefs.lua"/>
<Script file="broker.lua"/>
<Script file="core.lua"/>
<Include file="Moduls\Moduls.xml"/>
</Ui>

View File

@ -1,12 +1,84 @@
local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local init = {
Setup = function(self)
local config = LibStub:GetLibrary("zzConfig")
local options = child['options']
local main = options['args'][childName]
-- print("setup prefs", childName)
local config = LibStub:GetLibrary("zzConfig")
local options
local db
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
function child:PrefChanged(pref, value, oldvalue)
print(pref[#pref], value)
local modName = pref[#pref]
if(modName and child['mhmods'][modName]) then
local modul = child['mhmods'][modName]
if(value) then
modul:Enable()
else
modul:Disable()
end
end
end
function child:AddCE(modName)
local options = child['options']
local main = options['args'][childName]
config:AddConfigEntry(main, modName, "toggle", L[format('%s_message', modName)], nil, 1)
end
local mods = {
autogreed = function(menu)
config:AddConfigEntry(menu,"disenchant","header",L["Disenchant"],nil,1)
config:AddConfigEntry(menu,"deGreen","toggle",L["DE green"],nil,2)
config:AddConfigEntry(menu,"deBlue","toggle",L["DE blue"],nil,3)
config:AddConfigEntry(menu,"deEpic","toggle",L["DE epic"],nil,4)
config:AddConfigEntry(menu,"boe","header",L["Bind on Equip"],nil,5)
config:AddConfigEntry(menu,"greedBOE","toggle",L["Greed BoE"],nil,6)
config:AddConfigEntry(menu,"showBOE","range",L["Show BoE"],L['SkipGreed'],7,1,4,1,false)
config:AddConfigEntry(menu,"passGreen","toggle",L["Pass green BoE"],nil,8)
config:AddConfigEntry(menu,"passBlue","toggle",L["Pass blue BoE"],nil,9)
config:AddConfigEntry(menu,"passEpic","toggle",L["Pass epic BoE"],nil,10)
config:AddConfigEntry(menu,"misc","header",L["Misc"],nil,11)
config:AddConfigEntry(menu,"skipNeed","toggle",L["Show Need Rolls"],L["Show items you can roll need for. Set minimum quality to hide low level items."],12)
config:AddConfigEntry(menu,"skipQuality","range",L["Minimum Quality"],L["Dont show items with a quality lower than minimum quality when 'Show Need Rolls' is active. -1 means automagically your current average Itemlevel - 18"],13,-1,1000,1,false)
config:AddConfigEntry(menu,"ignoreOrbs","toggle",L["Ignore orbs"],nil,14)
config:AddConfigEntry(menu,"skipPet","toggle",L["Show Pets"],nil,15)
config:AddConfigEntry(menu,"skipMount","toggle",L["Show Mounts"],nil,16)
config:AddConfigEntry(menu,"skipHoliday","toggle",L["Show Holiday-Items"],nil,17)
config:AddConfigEntry(menu,"skipQuest","toggle",L["Show Questitems"],nil,18)
end
}
-- addon.RegisterCallback(init, format("Init%s", childName), 'Setup')
function child:AddME(modName)
child:AddCE(modName)
if(modName and type(mods[modName]) == 'function') then
local menu = config:AddConfigMenu(child['options'], L[format('%s_group', modName)], 2, { db = child['mhmods'][modName]['db']})
mods[modName](menu)
end
end
child['MH_GetPref'] = function(key)
return db[key]
end
child['MH_GetDB'] = function(subTable, def)
if(not subTable) then return db end
def = def or {}
local key = format("%sSettings", subTable)
db[key] = db[key] or CopyTable(def)
return db[key]
end
child['MH_SetPref'] = function(key, value)
db[key] = value
end
child['MH_GetOptions'] = function()
return child['options']
end
local init = {
Setup = function(self)
db = child['db']
options = child['options']
local main = options['args'][childName]
-- print("setup prefs", childName)
local menu = child:AddME('autogreed', {db = dbm})
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')