core: move expansion checks into module header

This commit is contained in:
shagu
2021-10-10 12:14:46 +02:00
parent 81efaea6a9
commit ebe5d91a3a
27 changed files with 52 additions and 52 deletions
+12 -1
View File
@@ -78,6 +78,7 @@ end)
settings.load = function(self)
settings.entries = settings.entries or {}
local expansion = ShaguTweaks:GetExpansion()
local entry = 1
for title, module in pairs(ShaguTweaks.mods) do
@@ -113,7 +114,16 @@ settings.load = function(self)
end)
text:SetText(title)
entry = entry + 1
if module.expansions[expansion] then
entry = entry + 1
button:Enable()
text:SetTextColor(1,.8,0,1)
elseif ShaguTweaks.debug then
entry = entry + 1
button:SetChecked(nil)
button:Disable()
text:SetTextColor(.5,.5,.5,.5)
end
end
settings:SetHeight(80 + math.floor(entry/2)*30)
@@ -124,6 +134,7 @@ settings.defaults = function()
for title, mod in pairs(ShaguTweaks.mods) do
current_config[title] = mod.enabled and 1 or 0
end
settings:load()
end
+4 -2
View File
@@ -18,9 +18,11 @@ ShaguTweaks.mods = {}
-- load translation tables
ShaguTweaks.L = (ShaguTweaks_locale[GetLocale()] or ShaguTweaks_locale["enUS"])
ShaguTweaks:RegisterEvent("VARIABLES_LOADED")
ShaguTweaks:SetScript("OnEvent", function()
-- load current expansion
local expansion = ShaguTweaks:GetExpansion()
-- initialize empty config
if not ShaguTweaks_config then ShaguTweaks_config = {} end
@@ -32,7 +34,7 @@ ShaguTweaks:SetScript("OnEvent", function()
end
-- load enabled mods
if ShaguTweaks_config[title] == 1 then
if mod.expansions[expansion] and ShaguTweaks_config[title] == 1 then
mod:enable()
end
end
+1 -4
View File
@@ -1,12 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
-- This is already part of the default options in TBC
if GetExpansion() == "tbc" then return end
local module = ShaguTweaks:register({
title = "Auto Dismount",
description = "Automatically dismounts whenever a spell is casted.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = nil,
})
+1 -4
View File
@@ -1,13 +1,10 @@
local _G = _G or getfenv(0)
local strsplit = ShaguTweaks.strsplit
local GetExpansion = ShaguTweaks.GetExpansion
-- It's not possible to achieve it like that in TBC
if GetExpansion() == "tbc" then return end
local module = ShaguTweaks:register({
title = "Auto Stance",
description = "Automatically switch to the required warrior or druid stance on spell cast.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = nil,
})
+1 -3
View File
@@ -1,12 +1,10 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
-- shaman class color is already blue in TBC
if GetExpansion() == "tbc" then return end
local module = ShaguTweaks:register({
title = "Blue Shaman Class Colors",
description = "Changes the class color code of shamans to blue, as known from TBC+.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = true,
})
+1
View File
@@ -10,6 +10,7 @@ local strsplit = ShaguTweaks.strsplit
local module = ShaguTweaks:register({
title = "Chat Hyperlinks",
description = "Copy website URLs from the chat, transforms CLINKs into real items and handles quest links.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
+1
View File
@@ -4,6 +4,7 @@ local scrollspeed = 1
local module = ShaguTweaks:register({
title = "Chat Tweaks",
description = "Allows to scroll using the mouse wheel, enables sticky chat channels and repeats message on arrow up.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
+1
View File
@@ -6,6 +6,7 @@ local AddBorder = ShaguTweaks.AddBorder
local module = ShaguTweaks:register({
title = "Darkened UI",
description = "Turns the entire interface into darker colors.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
color = { r = .3, g = .3, b = .3, a = .9}
})
+1 -4
View File
@@ -1,12 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
-- already part of the game
if GetExpansion() ~= "vanilla" then return end
local module = ShaguTweaks:register({
title = "Equip Compare",
description = "Shows currently equipped items on tooltips while the shift key is pressed.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = true,
})
+1
View File
@@ -6,6 +6,7 @@ local vanilla = ShaguTweaks.GetExpansion() == "vanilla" or nil
local module = ShaguTweaks:register({
title = "Real Health Numbers",
description = "Estimates health numbers, and shows numbers on player, pet and target unit frames.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
+1
View File
@@ -3,6 +3,7 @@ local _G = _G or getfenv(0)
local module = ShaguTweaks:register({
title = "Hide Errors",
description = "Hides and ignores all Lua errors produced by broken addons.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1
View File
@@ -6,6 +6,7 @@ local HookAddonOrVariable = ShaguTweaks.HookAddonOrVariable
local module = ShaguTweaks:register({
title = "Item Rarity Borders",
description = "Show item rarity as the border color on bags, bank, character and inspect frames.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
+1 -4
View File
@@ -1,12 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
-- tbc already has a clock
if GetExpansion() ~= "vanilla" then return end
local module = ShaguTweaks:register({
title = "MiniMap Clock",
description = "Adds a small 24h clock to the mini map.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = nil,
})
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "MiniMap Square",
description = "Draw the mini map in a squared shape instead of a round one.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "MiniMap Tweaks",
description = "Hides unnecessary mini map buttons and allows to zoom using the mouse wheel.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1
View File
@@ -3,6 +3,7 @@ local _G = _G or getfenv(0)
local module = ShaguTweaks:register({
title = "Movable Unit Frames",
description = "Player and Target unit frames can be moved while <Shift> and <Ctrl> are pressed together.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1
View File
@@ -4,6 +4,7 @@ local GetUnitData = ShaguTweaks.GetUnitData
local module = ShaguTweaks:register({
title = "Nameplate Class Colors",
description = "Changes the nameplate health bar color to the class color.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1 -4
View File
@@ -1,12 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
-- tbc does not allow to rescale nameplates (secure_frames)
if GetExpansion() == "tbc" then return end
local module = ShaguTweaks:register({
title = "Nameplate Scale",
description = "Makes all nameplates honor the UI-Scale setting.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = true,
})
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "Sell Junk",
description = "Adds a “Sell Junk” button to every merchant window, that sells all grey items.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
+1
View File
@@ -12,6 +12,7 @@ local friendinfo = gsub(gsub(FRIENDS_LEVEL_TEMPLATE,"%%s","%%s %%s"),"%%d","%%s"
local module = ShaguTweaks:register({
title = "Social Colors",
description = "Show class colors in Who, Guild, Friends and Chat.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1 -5
View File
@@ -3,14 +3,10 @@ local GetExpansion = ShaguTweaks.GetExpansion
local UnitCastingInfo = ShaguTweaks.UnitCastingInfo
local UnitChannelInfo = ShaguTweaks.UnitChannelInfo
local GetExpansion = ShaguTweaks.GetExpansion
-- TBC already has casting bars
if GetExpansion() ~= "vanilla" then return end
local module = ShaguTweaks:register({
title = "Enemy Castbars",
description = "Shows an enemy castbar on target unit frame.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = true,
})
+3 -6
View File
@@ -1,17 +1,14 @@
local _G = _G or getfenv(0)
local libdebuff = ShaguTweaks.libdebuff
local GetExpansion = ShaguTweaks.GetExpansion
-- there are already debuff timers in tbc+
if GetExpansion() ~= "vanilla" then return end
local module = ShaguTweaks:register({
title = "Debuff Timer",
description = "Show debuff durations on the target unit frame.",
expansions = { ["vanilla"] = true, ["tbc"] = nil },
enabled = true,
})
local UnitDebuff = ShaguTweaks.libdebuff.UnitDebuff
local libdebuff = ShaguTweaks.libdebuff
local UnitDebuff = libdebuff and libdebuff.UnitDebuff
local function TimeConvert(remaining)
local color = "|cffffffff"
+1
View File
@@ -6,6 +6,7 @@ local Abbreviate = ShaguTweaks.Abbreviate
local module = ShaguTweaks:register({
title = "Tooltip Details",
description = "Display health, class color, guild name, guild rank and current target on unit tooltips.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "Unit Frame Class Colors",
description = "Adds class colors to the player, target and party unit frames.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+10 -9
View File
@@ -1,3 +1,13 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "Vendor Values",
description = "Shows the vendor sell values on all item tooltips.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})
local data = {
[25]=7, [35]=9, [36]=7, [37]=7, [38]=1, [39]=1,
[40]=1, [43]=1, [44]=1, [45]=1, [47]=1, [48]=1,
@@ -3735,15 +3745,6 @@ local data_tbc = {
[38506]=25500, [38518]=37, [38576]=0, [38626]=2, [38628]=100000
}
local module = ShaguTweaks:register({
title = "Vendor Values",
description = "Shows the vendor sell values on all item tooltips.",
enabled = true,
})
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
if GetExpansion() == "tbc" then
for k,v in pairs(data_tbc) do data[k] = v end
end
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "WorldMap Coordinates",
description = "Adds coordinates to the bottom of the World Map.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
+1 -1
View File
@@ -1,9 +1,9 @@
local _G = _G or getfenv(0)
local GetExpansion = ShaguTweaks.GetExpansion
local module = ShaguTweaks:register({
title = "WorldMap Window",
description = "Turns the world map into a movable window. The map can be scaled with <Ctrl> + Mousewheel.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = true,
})