From d777bde1734ddbc70ca0a1142c596d2c4252fca2 Mon Sep 17 00:00:00 2001 From: robin Date: Sat, 22 May 2021 09:21:26 +0200 Subject: [PATCH] Add toc-file for classic --- BrokerPack-Classic.toc | 6 +++ zz_MiscHelper/Moduls/autogreed.lua | 32 +++++++---- zz_MiscHelper/Moduls/noduel.lua | 12 ++++- zz_MiscHelper/broker.lua | 5 +- zz_MiscHelper/core.lua | 36 ++++++++++++- zz_MiscHelper/locale_deDE.lua | 23 ++++++++ zz_MiscHelper/locale_enUS.lua | 25 ++++++++- zz_MiscHelper/pack.xml | 2 + zz_MiscHelper/prefs.lua | 86 +++++++++++++++++++++++++++--- 9 files changed, 205 insertions(+), 22 deletions(-) create mode 100644 BrokerPack-Classic.toc diff --git a/BrokerPack-Classic.toc b/BrokerPack-Classic.toc new file mode 100644 index 0000000..c34d4cb --- /dev/null +++ b/BrokerPack-Classic.toc @@ -0,0 +1,6 @@ +## Interface: 11302 +## Title: BrokerPack +## OptionalDeps: zzLib, Ace3 +## SavedVariables: BrokerPackDB +Libs\embeds.xml +pack.xml \ No newline at end of file diff --git a/zz_MiscHelper/Moduls/autogreed.lua b/zz_MiscHelper/Moduls/autogreed.lua index 8077e55..a9042d6 100644 --- a/zz_MiscHelper/Moduls/autogreed.lua +++ b/zz_MiscHelper/Moduls/autogreed.lua @@ -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') \ No newline at end of file diff --git a/zz_MiscHelper/Moduls/noduel.lua b/zz_MiscHelper/Moduls/noduel.lua index 7e39f74..2c66d59 100644 --- a/zz_MiscHelper/Moduls/noduel.lua +++ b/zz_MiscHelper/Moduls/noduel.lua @@ -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 diff --git a/zz_MiscHelper/broker.lua b/zz_MiscHelper/broker.lua index 4cd0a46..b9422a1 100644 --- a/zz_MiscHelper/broker.lua +++ b/zz_MiscHelper/broker.lua @@ -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 } diff --git a/zz_MiscHelper/core.lua b/zz_MiscHelper/core.lua index 27368b0..fdefddc 100644 --- a/zz_MiscHelper/core.lua +++ b/zz_MiscHelper/core.lua @@ -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(...) \ No newline at end of file diff --git a/zz_MiscHelper/locale_deDE.lua b/zz_MiscHelper/locale_deDE.lua index 086f7b9..2564123 100644 --- a/zz_MiscHelper/locale_deDE.lua +++ b/zz_MiscHelper/locale_deDE.lua @@ -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 \ No newline at end of file diff --git a/zz_MiscHelper/locale_enUS.lua b/zz_MiscHelper/locale_enUS.lua index b177803..efd7c5e 100644 --- a/zz_MiscHelper/locale_enUS.lua +++ b/zz_MiscHelper/locale_enUS.lua @@ -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 \ No newline at end of file diff --git a/zz_MiscHelper/pack.xml b/zz_MiscHelper/pack.xml index 6561d66..f651caf 100644 --- a/zz_MiscHelper/pack.xml +++ b/zz_MiscHelper/pack.xml @@ -1,7 +1,9 @@