Included some failsafes in case of Gold datatext enabled
Darthpred [08-12-16 - 18:55]
Included some failsafes in case of Gold datatext enabled
diff --git a/ElvUI_SLE/locales/english.lua b/ElvUI_SLE/locales/english.lua
index 20ac05a..a0f55fc 100644
--- a/ElvUI_SLE/locales/english.lua
+++ b/ElvUI_SLE/locales/english.lua
@@ -402,6 +402,7 @@ L["Remove selected character from the stored gold values"] = true
L["Are you sure you want to remove |cff1784d1%s|r from currency datatexts?"] = true
L["Hide panel background"] = true
L["Don't show this panel, only datatexts assinged to it"] = true
+L["SLE_DT_CURRENCY_WARNING_GOLD"] = [[Your datapanel %s has ElvUI's "Gold" datatext active while "S&L Currency" datatext is selected elsewhere. To ensure the correct functioning of "S&L Currency" datatext we are disabling some functions of "Gold" datatext. To avoid this conflict you need to replace one of conflicting datatexts.]]
--Enhnced Shadows
L["Enhanced Shadows"] = true
diff --git a/ElvUI_SLE/locales/russian.lua b/ElvUI_SLE/locales/russian.lua
index 4b547e2..8d5391b 100644
--- a/ElvUI_SLE/locales/russian.lua
+++ b/ElvUI_SLE/locales/russian.lua
@@ -399,6 +399,7 @@ L["Time Played"] = "Времени в игре"
L["Account Time Played"] = "Время в игре на аккаунте"
L["Hide panel background"] = "Скрыть фон"
L["Don't show this panel, only datatexts assinged to it"] = "Не показывать фон панели, а только назначенные инфо-тексты."
+L["SLE_DT_CURRENCY_WARNING_GOLD"] = [[На вашей панели %s включен инфо-текст "Gold" при активном инфо-тексте "S&L Currency". Для корректной работы "S&L Currency" мы отключаем некоторые функции инфо-текста "Gold". Для избежания данного конфликта вам необходимо заменить один из конфликтующих инфо-текстов.]]
--Enhnced Shadows
L["Enhanced Shadows"] = "Улучшенные тени"
diff --git a/ElvUI_SLE/modules/datatexts.lua b/ElvUI_SLE/modules/datatexts.lua
index 74e9794..defc6f4 100644
--- a/ElvUI_SLE/modules/datatexts.lua
+++ b/ElvUI_SLE/modules/datatexts.lua
@@ -1,6 +1,6 @@
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local DTP = SLE:NewModule('Datatexts', 'AceHook-3.0', 'AceEvent-3.0');
-local DT = E:GetModule('DataTexts');
+local DT, MM = SLE:GetElvModules("DataTexts", "Minimap");
--GLOBALS: ElvDB, hooksecurefunc
local _G = _G
local CreateFrame = CreateFrame
@@ -17,6 +17,7 @@ DTP.values = {
[8] = {"BOTTOM", ((E.eyefinity or E.screenwidth)/6 - 15), 3},
}
DTP.Names = {}
+DTP.GoldCache = {}
local function Bar_OnEnter(self)
if DTP.db["panel"..self.Num].mouseover then
@@ -44,6 +45,49 @@ local function Button_OnLeave(self)
end
end
+local OnLoadThrottle = true
+function DTP:LoadDTHook()
+ local SLE_Cur_Selected = false
+ T.twipe(DTP.GoldCache)
+ for panelName, panel in T.pairs(DT.RegisteredPanels) do
+ for i=1, panel.numPoints do
+ local pointIndex = DT.PointLocation[i]
+ if DTP.Names[panelName] then
+ panel.dataPanels[pointIndex]:HookScript("OnEnter", Button_OnEnter)
+ panel.dataPanels[pointIndex]:HookScript("OnLeave", Button_OnLeave)
+ end
+ for option, value in T.pairs(DT.db.panels) do
+ if value and type(value) == 'table' then
+ if option == panelName and DT.db.panels[option][pointIndex] and DT.db.panels[option][pointIndex] == "Gold" then
+ DTP.GoldCache[panelName] = panel.dataPanels[pointIndex]
+ elseif option == panelName and DT.db.panels[option][pointIndex] and DT.db.panels[option][pointIndex] == "S&L Currency" then
+ SLE_Cur_Selected = true
+ end
+ elseif value and type(value) == 'string' and value == "Gold" then
+ if DT.db.panels[option] == "Gold" and option == panelName then
+ DTP.GoldCache[panelName] = panel.dataPanels[pointIndex]
+ end
+ elseif value and type(value) == 'string' and value == "S&L Currency" then
+ if DT.db.panels[option] == "Gold" and option == panelName then
+ SLE_Cur_Selected = true
+ end
+ end
+ end
+ end
+ end
+ if OnLoadThrottle then
+ OnLoadThrottle = false
+ if SLE_Cur_Selected then
+ for k, v in T.pairs(DTP.GoldCache) do
+ local message = T.format(L["SLE_DT_CURRENCY_WARNING_GOLD"], "|cff1784d1"..L[k].."|r")
+ SLE:ErrorPrint(message)
+ if v then v:UnregisterAllEvents() end
+ end
+ end
+ E:Delay(1, function() OnLoadThrottle = true end)
+ end
+end
+
function DTP:MouseoverHook()
for panelName, panel in T.pairs(DT.RegisteredPanels) do
for i=1, panel.numPoints do
@@ -177,7 +221,11 @@ function DTP:Initialize()
local popup = E.PopupDialogs['SLE_CONFIRM_DELETE_CURRENCY_CHARACTER']
popup.OnAccept = DTP.DeleteCurrencyEntry,
- hooksecurefunc(DT, "LoadDataTexts", DTP.MouseoverHook)
+ -- hooksecurefunc(DT, "LoadDataTexts", DTP.MouseoverHook)
+ hooksecurefunc(DT, "LoadDataTexts", DTP.LoadDTHook)
+ -- :UpdateSettings()
+ hooksecurefunc(MM, "UpdateSettings", DTP.LoadDTHook)
+ DTP:LoadDTHook()
end
SLE:RegisterModule(DTP:GetName())
\ No newline at end of file