Skip to content

Commit

Permalink
v0.4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
d4kir92 committed Jan 4, 2024
1 parent 2a6d17a commit 718836b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DarkMode.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Interface-Wrath: 30403
## Interface: 100200

## Version: 0.4.11
## Version: 0.4.12
## Title: DarkMode by |cff3FC7EBD4KiR |T132115:16:16:0:0|t
## Notes: Improve Any Ui or Frame
## Author: D4KiR
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_TBC.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 20504
## Version: 0.4.11
## Version: 0.4.12
## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t
## Notes: Improve Any Ui or Frame
## Author: D4KiR
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 11500
## Version: 0.4.11
## Version: 0.4.12
## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t
## Notes: Improve Any Ui or Frame
## Author: D4KiR
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_Wrath.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 30403
## Version: 0.4.11
## Version: 0.4.12
## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t
## Notes: Improve Any Ui or Frame
## Author: D4KiR
Expand Down
24 changes: 20 additions & 4 deletions libs/D4Lib/D4Translations.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
function D4:Trans(key, value, lang)
function D4:Trans(key, lang, t1, t2, t3)
D4.trans = D4.trans or {}
if lang == nil then
lang = GetLocale()
end

D4.trans[lang] = D4.trans[lang] or {}
if D4.trans[lang][key] ~= nil then return D4.trans[lang][key] end
if value ~= nil then return value end
local result = nil
if D4.trans[lang][key] ~= nil then
result = D4.trans[lang][key]
elseif D4.trans["enUS"][key] ~= nil then
result = D4.trans["enUS"][key]
end

if t1 and t2 and t3 then
result = format(result, t1, t2, t3)
end

if t1 and t2 then
result = format(result, t1, t2)
end

if t1 then
result = format(result, t1)
end

return key
return result or key
end

function D4:AddTrans(lang, key, value)
Expand Down
32 changes: 16 additions & 16 deletions libs/D4Lib/D4Versions.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local AddonName, _ = ...
D4VersionTab = D4VersionTab or {}
D4.VersionTab = D4.VersionTab or {}
local pre = "D4PREFIX"
C_ChatInfo.RegisterAddonMessagePrefix(pre)
function D4:SetVersion(name, icon, ver)
Expand All @@ -21,28 +21,28 @@ function D4:SetVersion(name, icon, ver)
return false
end

if D4VersionTab[string.lower(name)] ~= nil then
if D4.VersionTab[string.lower(name)] ~= nil then
D4:msg("|cffff0000VERSION ALREADY SET", name)

return false
end

local index = string.lower(name)
D4VersionTab[index] = {}
D4VersionTab[index].name = name
D4VersionTab[index].version = ver
D4VersionTab[index].icon = icon
D4VersionTab[index].foundHigher = false
D4.VersionTab[index] = {}
D4.VersionTab[index].name = name
D4.VersionTab[index].version = ver
D4.VersionTab[index].icon = icon
D4.VersionTab[index].foundHigher = false
local nameOrder = {}
for k, v in pairs(D4VersionTab) do
for k, v in pairs(D4.VersionTab) do
tinsert(nameOrder, string.lower(k))
end

table.sort(nameOrder)
local id = 0
for i, v in pairs(nameOrder) do
id = id + 1
D4VersionTab[string.lower(v)].id = id
D4.VersionTab[string.lower(v)].id = id
end
end

Expand All @@ -53,7 +53,7 @@ function D4:GetVersion(name)
return false
end

if name and D4VersionTab[string.lower(name)] then return D4VersionTab[string.lower(name)].version end
if name and D4.VersionTab[string.lower(name)] then return D4.VersionTab[string.lower(name)].version end

return nil
end
Expand All @@ -65,7 +65,7 @@ function D4:FoundHigher(name)
return false
end

if name and D4VersionTab[string.lower(name)] then return D4VersionTab[string.lower(name)].foundHigher end
if name and D4.VersionTab[string.lower(name)] then return D4.VersionTab[string.lower(name)].foundHigher end

return false
end
Expand Down Expand Up @@ -94,9 +94,9 @@ function D4:CheckVersion(name, ver)
local ov1, ov2, ov3 = string.split(".", ver)
local cv1, cv2, cv3 = string.split(".", D4:GetVersion(name))
local higher = D4:IsHigherVersion(ov1, ov2, ov3, cv1, cv2, cv3)
if higher and name and D4VersionTab and D4VersionTab[string.lower(name)] then
D4VersionTab[string.lower(name)].foundHigher = true
D4:MSG(name, D4VersionTab[string.lower(name)].icon, format("New Version available (v%s -> v%s)", D4:GetVersion(name), ver))
if higher and name and D4.VersionTab and D4.VersionTab[string.lower(name)] then
D4.VersionTab[string.lower(name)].foundHigher = true
D4:MSG(name, D4.VersionTab[string.lower(name)].icon, format("New Version available (v%s -> v%s)", D4:GetVersion(name), ver))
end
end

Expand All @@ -108,8 +108,8 @@ f:SetScript(
C_Timer.After(
2,
function()
if D4VersionTab[string.lower(AddonName)] then
local id = D4VersionTab[string.lower(AddonName)].id or 0
if D4.VersionTab[string.lower(AddonName)] then
local id = D4.VersionTab[string.lower(AddonName)].id or 0
C_Timer.After(
id * 0.1,
function()
Expand Down
4 changes: 2 additions & 2 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ function DarkMode:InitDMSettings()
DMSettings:Hide()
end

D4:SetVersion(AddonName, 136122, "0.4.11")
DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.11"))
D4:SetVersion(AddonName, 136122, "0.4.12")
DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.12"))
DMSettings.CloseButton:SetScript(
"OnClick",
function()
Expand Down

0 comments on commit 718836b

Please sign in to comment.