Implement toggling stinkiness and integrate stinkies with spotter

This commit is contained in:
2024-12-12 17:43:57 +01:00
parent e5151bc688
commit 33538be9f5
3 changed files with 25 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ local addonname, data = ...
local function init() local function init()
---@class Heimdall_Data ---@class Heimdall_Data
---@field who { data: table<string, Player> } ---@field who { data: table<string, Player> }
---@field stinkies table<string, boolean>
if not Heimdall_Data then Heimdall_Data = {} end if not Heimdall_Data then Heimdall_Data = {} end
if not Heimdall_Data.config then Heimdall_Data.config = {} end if not Heimdall_Data.config then Heimdall_Data.config = {} end
@@ -16,7 +17,6 @@ local function init()
---@field config HeimdallConfig ---@field config HeimdallConfig
---@field raceMap table<string, string> ---@field raceMap table<string, string>
---@field classColors table<string, string> ---@field classColors table<string, string>
---@field stinkies table<string, Player>
---@field messenger HeimdallMessengerData ---@field messenger HeimdallMessengerData
---@field who HeimdallWhoData ---@field who HeimdallWhoData
---@field dumpTable fun(table: any, depth?: number): nil ---@field dumpTable fun(table: any, depth?: number): nil
@@ -35,6 +35,7 @@ local function init()
---@field messenger HeimdallMessengerConfig ---@field messenger HeimdallMessengerConfig
---@field deathReporter HeimdallDeathReporterConfig ---@field deathReporter HeimdallDeathReporterConfig
---@field whisperNotify table<string, string> ---@field whisperNotify table<string, string>
---@field stinkies table<string, boolean>
---@class HeimdallSpotterConfig ---@class HeimdallSpotterConfig
---@field enabled boolean ---@field enabled boolean
@@ -154,6 +155,7 @@ local function init()
"Shootleta", "Shootleta",
"Stableta" "Stableta"
}), }),
stinkies = data.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}),
} }
data.raceMap = { data.raceMap = {
@@ -195,8 +197,6 @@ local function init()
["Demon Hunter"] = "A330C9" ["Demon Hunter"] = "A330C9"
} }
data.stinkies = {}
---@param input string ---@param input string
---@return number ---@return number
data.utf8len = function(input) data.utf8len = function(input)
@@ -253,3 +253,20 @@ loadedFrame:SetScript("OnEvent", function(self, event, addonName)
init() init()
end end
end) end)
local logoutFrame = CreateFrame("Frame")
logoutFrame:RegisterEvent("PLAYER_LOGOUT")
logoutFrame:SetScript("OnEvent", function(self, event)
Heimdall_Data.config.stinkies = data.config.stinkies
end)
SlashCmdList["HEIMDALL_TOGGLE_STINKY"] = function(input)
print("Toggling stinky: " .. tostring(input))
if data.config.stinkies[input] then
data.config.stinkies[input] = nil
else
data.config.stinkies[input] = true
end
print(data.config.stinkies[input])
end
SLASH_HEIMDALL_TOGGLE_STINKY1 = "/has"

View File

@@ -28,7 +28,7 @@ function data.Spotter.Init()
---@return string? error ---@return string? error
local function ShouldNotify(unit, name, faction, hostile) local function ShouldNotify(unit, name, faction, hostile)
if data.config.spotter.stinky then if data.config.spotter.stinky then
if data.stinkies[name] then return true end if data.config.stinkies[name] then return true end
end end
if data.config.spotter.alliance then if data.config.spotter.alliance then
if faction == "Alliance" then return true end if faction == "Alliance" then return true end
@@ -78,8 +78,10 @@ function data.Spotter.Init()
location = string.format("%s (%s)", zone, subzone) location = string.format("%s (%s)", zone, subzone)
end end
local text = string.format("I see (%s) %s of race %s (%s) with health %s/%s at %s", local stinky = data.config.stinkies[name] or false
local text = string.format("I see (%s) %s %s of race %s (%s) with health %s/%s at %s",
hostile and "Hostile" or "Friendly", hostile and "Hostile" or "Friendly",
stinky and string.format("(%s)", "!!!!") or "",
name, name,
race, race,
faction, faction,

View File

@@ -278,7 +278,7 @@ function data.Whoer.Init()
player.firstSeen = timestamp player.firstSeen = timestamp
end end
local stinky = data.stinkies[name] local stinky = data.config.stinkies[name]
if stinky then if stinky then
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master") PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
else else