From 1da1e7bf9ff712d6288dfb2ccd1d9f3883aa4068 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 4 May 2025 15:09:34 +0200 Subject: [PATCH] Code format --- Heimdall.lua | 1344 ++++----- Meta | 2 +- Modules/AchievementSniffer.lua | 5 +- Modules/AgentTracker.lua | 29 +- Modules/BonkDetector.lua | 21 +- Modules/Bully.lua | 4 +- Modules/CLEUParser.lua | 573 ++-- Modules/CombatAlerter.lua | 35 +- Modules/Commander.lua | 115 +- Modules/Config.lua | 4632 ++++++++++++++++++-------------- Modules/Configurator.lua | 4 +- Modules/DeathReporter.lua | 119 +- Modules/Dueler.lua | 9 +- Modules/DumpTable.lua | 8 +- Modules/Echoer.lua | 4 +- Modules/Emoter.lua | 4 +- Modules/Inviter.lua | 45 +- Modules/Macroer.lua | 170 +- Modules/Messenger.lua | 40 +- Modules/MinimapTagger.lua | 124 +- Modules/Network.lua | 7 +- Modules/NetworkMessenger.lua | 20 +- Modules/Noter.lua | 37 +- Modules/ReactiveValue.lua | 1214 ++++----- Modules/Sniffer.lua | 15 +- Modules/Spotter.lua | 29 +- Modules/StinkyCache.lua | 43 +- Modules/StinkyTracker.lua | 51 +- Modules/Whoer.lua | 148 +- Weakauras/Config/init.lua | 10 +- 30 files changed, 4620 insertions(+), 4241 deletions(-) diff --git a/Heimdall.lua b/Heimdall.lua index df6522b..f215c0c 100644 --- a/Heimdall.lua +++ b/Heimdall.lua @@ -6,713 +6,739 @@ local VERSION = "3.10.1" shared.VERSION = VERSION local function init() - ---@class Heimdall_Data - ---@field config HeimdallConfig - if not Heimdall_Data then Heimdall_Data = {} end + ---@class Heimdall_Data + ---@field config HeimdallConfig + if not Heimdall_Data then Heimdall_Data = {} end - ---@class InitTable - ---@field Init fun(): nil + ---@class InitTable + ---@field Init fun(): nil - ---@class HeimdallShared - ---@field raceMap table - ---@field classColors table - ---@field messenger HeimdallMessengerData - ---@field who HeimdallWhoData - ---@field stinkyTracker HeimdallStinkyTrackerData - ---@field networkNodes string[] - ---@field network HeimdallNetworkData - ---@field networkMessenger HeimdallNetworkMessengerData - ---@field stinkyCache HeimdallStinkyCacheData - ---@field _L fun(key: string, locale: string): string - ---@field _Locale Localization - ---@field VERSION string - ---@field dumpTable fun(table: any, depth?: number): nil - ---@field utf8len fun(input: string): number - ---@field padString fun(input: string, targetLength: number, left?: boolean): string - ---@field GetOrDefault fun(table: table, keys: string[], default: any): any - ---@field Split fun(input: string, deliminer: string): string[] - ---@field IsStinky fun(name: string): boolean - ---@field Memoize fun(f: function): function - ---@field GetLocaleForChannel fun(channel: string): string - ---@field WhoQueryService WhoQueryService - ---@field Whoer InitTable|{ShouldNotifyForZone: fun(zone: string): boolean} - ---@field Messenger InitTable - ---@field Spotter InitTable - ---@field DeathReporter InitTable - ---@field Inviter InitTable - ---@field Dueler InitTable - ---@field Bully InitTable - ---@field AgentTracker InitTable - ---@field Emoter InitTable - ---@field Echoer InitTable - ---@field Macroer InitTable - ---@field Commander InitTable - ---@field StinkyTracker InitTable - ---@field CombatAlerter InitTable - ---@field Config InitTable - ---@field Sniffer InitTable - ---@field MinimapTagger InitTable - ---@field BonkDetector InitTable - ---@field Noter InitTable - ---@field Network InitTable - ---@field NetworkMessenger InitTable - ---@field StinkyCache InitTable - ---@field Configurator InitTable - ---@field AchievementSniffer InitTable + ---@class HeimdallShared + ---@field raceMap table + ---@field classColors table + ---@field messenger HeimdallMessengerData + ---@field who HeimdallWhoData + ---@field stinkyTracker HeimdallStinkyTrackerData + ---@field networkNodes string[] + ---@field network HeimdallNetworkData + ---@field networkMessenger HeimdallNetworkMessengerData + ---@field stinkyCache HeimdallStinkyCacheData + ---@field _L fun(key: string, locale: string): string + ---@field _Locale Localization + ---@field VERSION string + ---@field dumpTable fun(table: any, depth?: number): nil + ---@field utf8len fun(input: string): number + ---@field padString fun(input: string, targetLength: number, left?: boolean): string + ---@field GetOrDefault fun(table: table, keys: string[], default: any): any + ---@field Split fun(input: string, deliminer: string): string[] + ---@field IsStinky fun(name: string): boolean + ---@field Memoize fun(f: function): function + ---@field GetLocaleForChannel fun(channel: string): string + ---@field WhoQueryService WhoQueryService + ---@field Whoer InitTable|{ShouldNotifyForZone: fun(zone: string): boolean} + ---@field Messenger InitTable + ---@field Spotter InitTable + ---@field DeathReporter InitTable + ---@field Inviter InitTable + ---@field Dueler InitTable + ---@field Bully InitTable + ---@field AgentTracker InitTable + ---@field Emoter InitTable + ---@field Echoer InitTable + ---@field Macroer InitTable + ---@field Commander InitTable + ---@field StinkyTracker InitTable + ---@field CombatAlerter InitTable + ---@field Config InitTable + ---@field Sniffer InitTable + ---@field MinimapTagger InitTable + ---@field BonkDetector InitTable + ---@field Noter InitTable + ---@field Network InitTable + ---@field NetworkMessenger InitTable + ---@field StinkyCache InitTable + ---@field Configurator InitTable + ---@field AchievementSniffer InitTable - --- Config --- - ---@class HeimdallConfig - ---@field spotter HeimdallSpotterConfig - ---@field who HeimdallWhoConfig - ---@field messenger HeimdallMessengerConfig - ---@field deathReporter HeimdallDeathReporterConfig - ---@field inviter HeimdallInviterConfig - ---@field dueler HeimdallDuelerConfig - ---@field bully HeimdallBullyConfig - ---@field agentTracker HeimdallAgentTrackerConfig - ---@field emoter HeimdallEmoterConfig - ---@field echoer HeimdallEchoerConfig - ---@field macroer HeimdallMacroerConfig - ---@field commander HeimdallCommanderConfig - ---@field stinkyTracker HeimdallStinkyTrackerConfig - ---@field combatAlerter HeimdallCombatAlerterConfig - ---@field sniffer HeimdallSnifferConfig - ---@field bonkDetector HeimdallBonkDetectorConfig - ---@field noter HeimdallNoterConfig - ---@field network HeimdallNetworkConfig - ---@field networkMessenger HeimdallNetworkMessengerConfig - ---@field configurator HeimdallConfiguratorConfig - ---@field stinkyCache HeimdallStinkyCacheConfig - ---@field achievementSniffer HeimdallAchievementSnifferConfig - ---@field whisperNotify table - ---@field addonPrefix string - ---@field stinkies table - ---@field agents table - ---@field scale number - ---@field notes table - ---@field channelLocale table - ---@field locale string - ---@field debug boolean + --- Config --- + ---@class HeimdallConfig + ---@field spotter HeimdallSpotterConfig + ---@field who HeimdallWhoConfig + ---@field messenger HeimdallMessengerConfig + ---@field deathReporter HeimdallDeathReporterConfig + ---@field inviter HeimdallInviterConfig + ---@field dueler HeimdallDuelerConfig + ---@field bully HeimdallBullyConfig + ---@field agentTracker HeimdallAgentTrackerConfig + ---@field emoter HeimdallEmoterConfig + ---@field echoer HeimdallEchoerConfig + ---@field macroer HeimdallMacroerConfig + ---@field commander HeimdallCommanderConfig + ---@field stinkyTracker HeimdallStinkyTrackerConfig + ---@field combatAlerter HeimdallCombatAlerterConfig + ---@field sniffer HeimdallSnifferConfig + ---@field bonkDetector HeimdallBonkDetectorConfig + ---@field noter HeimdallNoterConfig + ---@field network HeimdallNetworkConfig + ---@field networkMessenger HeimdallNetworkMessengerConfig + ---@field configurator HeimdallConfiguratorConfig + ---@field stinkyCache HeimdallStinkyCacheConfig + ---@field achievementSniffer HeimdallAchievementSnifferConfig + ---@field whisperNotify table + ---@field addonPrefix string + ---@field stinkies table + ---@field agents table + ---@field scale number + ---@field notes table + ---@field channelLocale table + ---@field locale string + ---@field debug boolean - ---@class HeimdallSpotterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field everyone boolean - ---@field hostile boolean - ---@field alliance boolean - ---@field stinky boolean - ---@field channels string[] - ---@field zoneOverride string? - ---@field throttleTime number + ---@class HeimdallSpotterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field everyone boolean + ---@field hostile boolean + ---@field alliance boolean + ---@field stinky boolean + ---@field channels string[] + ---@field zoneOverride string? + ---@field throttleTime number - ---@class HeimdallWhoConfig - ---@field enabled boolean - ---@field debug boolean - ---@field ignored table - ---@field channels string[] - ---@field ttl number - ---@field doWhisper boolean - ---@field zoneNotifyFor table - ---@field queries string + ---@class HeimdallWhoConfig + ---@field enabled boolean + ---@field debug boolean + ---@field ignored table + ---@field channels string[] + ---@field ttl number + ---@field doWhisper boolean + ---@field zoneNotifyFor table + ---@field queries string - ---@class HeimdallMessengerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field interval number + ---@class HeimdallMessengerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field interval number - ---@class HeimdallDeathReporterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field throttle number - ---@field doWhisper boolean - ---@field channels string[] - ---@field zoneOverride string? - ---@field duelThrottle number + ---@class HeimdallDeathReporterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field throttle number + ---@field doWhisper boolean + ---@field channels string[] + ---@field zoneOverride string? + ---@field duelThrottle number - ---@class HeimdallInviterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field keyword string - ---@field allAssist boolean - ---@field agentsAssist boolean - ---@field throttle number - ---@field kickOffline boolean - ---@field cleanupInterval number - ---@field afkThreshold number + ---@class HeimdallInviterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field keyword string + ---@field allAssist boolean + ---@field agentsAssist boolean + ---@field throttle number + ---@field kickOffline boolean + ---@field cleanupInterval number + ---@field afkThreshold number - ---@class HeimdallDuelerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field declineOther boolean + ---@class HeimdallDuelerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field declineOther boolean - ---@class HeimdallBullyConfig - ---@field enabled boolean - ---@field debug boolean + ---@class HeimdallBullyConfig + ---@field enabled boolean + ---@field debug boolean - ---@class HeimdallAgentTrackerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] + ---@class HeimdallAgentTrackerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] - ---@class HeimdallEmoterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field prefix string + ---@class HeimdallEmoterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field prefix string - ---@class HeimdallEchoerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field prefix string + ---@class HeimdallEchoerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field prefix string - ---@class HeimdallMacroerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field priority string[] + ---@class HeimdallMacroerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field priority string[] - ---@class HeimdallCommanderConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field commander string - ---@field commands table + ---@class HeimdallCommanderConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field commander string + ---@field commands table - ---@class HeimdallStinkyTrackerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] + ---@class HeimdallStinkyTrackerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] - ---@class HeimdallCombatAlerterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] + ---@class HeimdallCombatAlerterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] - ---@class HeimdallSnifferConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field throttle number - ---@field zoneOverride string? - ---@field stinky boolean + ---@class HeimdallSnifferConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field throttle number + ---@field zoneOverride string? + ---@field stinky boolean - ---@class HeimdallMinimapTaggerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field throttle number - ---@field scale number - ---@field tagTTL number - ---@field tagSound boolean - ---@field tagSoundFile string - ---@field tagSoundThrottle number - ---@field tagTextureFile string - ---@field alertTTL number - ---@field alertSound boolean - ---@field alertSoundFile string - ---@field alertSoundThrottle number - ---@field alertTextureFile string - ---@field combatTTL number - ---@field combatSound boolean - ---@field combatSoundFile string - ---@field combatSoundThrottle number - ---@field combatTextureFile string - ---@field helpTTL number - ---@field helpSound boolean - ---@field helpSoundFile string - ---@field helpSoundThrottle number - ---@field helpTextureFile string + ---@class HeimdallMinimapTaggerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field throttle number + ---@field scale number + ---@field tagTTL number + ---@field tagSound boolean + ---@field tagSoundFile string + ---@field tagSoundThrottle number + ---@field tagTextureFile string + ---@field alertTTL number + ---@field alertSound boolean + ---@field alertSoundFile string + ---@field alertSoundThrottle number + ---@field alertTextureFile string + ---@field combatTTL number + ---@field combatSound boolean + ---@field combatSoundFile string + ---@field combatSoundThrottle number + ---@field combatTextureFile string + ---@field helpTTL number + ---@field helpSound boolean + ---@field helpSoundFile string + ---@field helpSoundThrottle number + ---@field helpTextureFile string - ---@class HeimdallBonkDetectorConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] - ---@field throttle number + ---@class HeimdallBonkDetectorConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] + ---@field throttle number - ---@class HeimdallNoterConfig - ---@field enabled boolean - ---@field debug boolean - ---@field channels string[] + ---@class HeimdallNoterConfig + ---@field enabled boolean + ---@field debug boolean + ---@field channels string[] - ---@class HeimdallNetworkConfig - ---@field enabled boolean - ---@field debug boolean - ---@field members string[] - ---@field updateInterval number + ---@class HeimdallNetworkConfig + ---@field enabled boolean + ---@field debug boolean + ---@field members string[] + ---@field updateInterval number - ---@class HeimdallNetworkMessengerConfig - ---@field enabled boolean - ---@field debug boolean - ---@field interval number + ---@class HeimdallNetworkMessengerConfig + ---@field enabled boolean + ---@field debug boolean + ---@field interval number - ---@class HeimdallConfiguratorConfig - ---@field enabled boolean - ---@field debug boolean + ---@class HeimdallConfiguratorConfig + ---@field enabled boolean + ---@field debug boolean - ---@class HeimdallStinkyCacheConfig - ---@field enabled boolean - ---@field debug boolean - ---@field commander string - ---@field ttl number + ---@class HeimdallStinkyCacheConfig + ---@field enabled boolean + ---@field debug boolean + ---@field commander string + ---@field ttl number - ---@class HeimdallAchievementSnifferConfig - ---@field enabled boolean - ---@field debug boolean - -----@field texture string - -----@field offsetX number - -----@field offsetY number - ---@field rescan boolean - ---@field scanInterval number - -----@field iconScale number + ---@class HeimdallAchievementSnifferConfig + ---@field enabled boolean + ---@field debug boolean + -----@field texture string + -----@field offsetX number + -----@field offsetY number + ---@field rescan boolean + ---@field scanInterval number + -----@field iconScale number - --- Data --- - ---@class HeimdallMessengerData - ---@field queue table - ---@field ticker number? + --- Data --- + ---@class HeimdallMessengerData + ---@field queue table + ---@field ticker number? - ---@class HeimdallNetworkMessengerData - ---@field queue table - ---@field ticker number? + ---@class HeimdallNetworkMessengerData + ---@field queue table + ---@field ticker number? - ---@class HeimdallWhoData - ---@field updateTicker number? - ---@field whoTicker number? - ---@field ignored table + ---@class HeimdallWhoData + ---@field updateTicker number? + ---@field whoTicker number? + ---@field ignored table - ---@class HeimdallStinkyTrackerData - ---@field stinkies ReactiveValue + ---@class HeimdallStinkyTrackerData + ---@field stinkies ReactiveValue - ---@class HeimdallNetworkData - ---@field ticker number? + ---@class HeimdallNetworkData + ---@field ticker number? - ---@class HeimdallStinkyCacheData - ---@field stinkies table + ---@class HeimdallStinkyCacheData + ---@field stinkies table - shared.GetOrDefault = function(table, keys, default) - local value = default - if not table then return value end - if not keys then return value end + shared.GetOrDefault = function(table, keys, default) + local value = default + if not table then return value end + if not keys then return value end - local traverse = table - for i = 1, #keys do - local key = keys[i] - if traverse[key] ~= nil then - traverse = traverse[key] - else - break - end + local traverse = table + for i = 1, #keys do + local key = keys[i] + if traverse[key] ~= nil then + traverse = traverse[key] + else + break + end - if i == #keys then - value = traverse - end - end - return value - end + if i == #keys then value = traverse end + end + return value + end - shared.messenger = { - queue = {} - } - shared.who = { - ignored = {}, - } + shared.messenger = { + queue = {}, + } + shared.who = { + ignored = {}, + } - --/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally" - Heimdall_Data.config = { - debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false), - spotter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false), - everyone = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "everyone" }, false), - hostile = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "hostile" }, true), - alliance = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "alliance" }, true), - stinky = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "stinky" }, true), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "channels" }, { "Agent" }), - zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "zoneOverride" }, nil), - throttleTime = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "throttleTime" }, 10) - }, - who = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "who", "debug" }, false), - ignored = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ignored" }, {}), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "who", "channels" }, { "Agent" }), - ttl = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ttl" }, 20), - doWhisper = shared.GetOrDefault(Heimdall_Data, { "config", "who", "doWhisper" }, true), - zoneNotifyFor = shared.GetOrDefault(Heimdall_Data, { "config", "who", "zoneNotifyFor" }, { - ["Orgrimmar"] = true, - ["Thunder Bluff"] = true, - ["Undercity"] = true, - ["Durotar"] = true, - ["Echo Isles"] = true, - ["Valley of Trials"] = true, - }), - queries = shared.GetOrDefault(Heimdall_Data, { "config", "who", "queries" }, ""), - }, - messenger = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "enabled" }, true), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "debug" }, false), - interval = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "interval" }, 0.2), - }, - deathReporter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "debug" }, false), - throttle = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "throttle" }, 10), - doWhisper = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "channels" }, { "Agent" }), - zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "zoneOverride" }, nil), - duelThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "duelThrottle" }, 5), - }, - inviter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "channels" }, { "Agent" }), - keyword = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "keyword" }, "+"), - allAssist = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "allAssist" }, false), - agentsAssist = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "agentsAssist" }, false), - throttle = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "throttle" }, 1), - kickOffline = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "kickOffline" }, false), - cleanupInterval = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "cleanupInterval" }, 10), - afkThreshold = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "afkThreshold" }, 300), - }, - dueler = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "debug" }, false), - declineOther = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "declineOther" }, false), - }, - bully = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "debug" }, false), - }, - agentTracker = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "channels" }, { "Agent" }), - }, - emoter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "channels" }, { "Agent" }), - prefix = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "prefix" }, ""), - }, - echoer = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "channels" }, { "Agent" }), - prefix = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "prefix" }, ""), - }, - macroer = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "debug" }, false), - priority = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "priority" }, {}), - }, - agents = shared.GetOrDefault(Heimdall_Data, { "config", "agents" }, {}), - commander = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "channels" }, { "Agent" }), - commander = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commander" }, "Heimdállr"), - commands = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commands" }, {}), - }, - stinkyTracker = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }), - }, - combatAlerter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "channels" }, { "Agent" }), - }, - messageDelegator = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "debug" }, false), - delegates = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "delegates" }, {}), - masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "masterChannel" }, "Agent"), - }, - sniffer = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "channels" }, { "Agent" }), - throttle = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "throttle" }, 10), - zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "zoneOverride" }, nil), - stinky = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "stinky" }, true), - }, - minimapTagger = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "channels" }, { "Agent" }), - throttle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "throttle" }, 10), - scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3), - tagTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTTL" }, 1), - tagSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSound" }, false), - tagSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundFile" }, - "MGSSpot.ogg"), - tagSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundThrottle" }, 0), - tagTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTextureFile" }, - "Aura4.tga"), - --- - alertTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTTL" }, 1), - alertSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSound" }, false), - alertSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSoundFile" }, - "OOF.ogg"), - alertSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSoundThrottle" }, - 0), - alertTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTextureFile" }, - "Aura27.tga"), - --- - combatTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTTL" }, 1), - combatSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSound" }, false), - combatSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSoundFile" }, - "StarScream.ogg"), - combatSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSoundThrottle" }, - 2), - combatTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTextureFile" }, - "Aura58.tga"), - --- - helpTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTTL" }, 1), - helpSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSound" }, false), - helpSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSoundFile" }, - "MedicGangsterParadise.ogg"), - helpSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSoundThrottle" }, 2), - helpTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTextureFile" }, - "Aura68.tga"), - }, - whisperNotify = shared.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {}), - stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}), - notes = shared.GetOrDefault(Heimdall_Data, { "config", "notes" }, {}), - scale = shared.GetOrDefault(Heimdall_Data, { "config", "scale" }, 1), - locale = shared.GetOrDefault(Heimdall_Data, { "config", "locale" }, "en"), - bonkDetector = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "channels" }, { "Agent" }), - throttle = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "throttle" }, 5), - }, - noter = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "debug" }, false), - channels = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "channels" }, { "Agent" }), - lastNotes = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "lastNotes" }, 5), - }, - network = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "network", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "network", "debug" }, false), - members = shared.GetOrDefault(Heimdall_Data, { "config", "network", "members" }, {}), - updateInterval = shared.GetOrDefault(Heimdall_Data, { "config", "network", "updateInterval" }, 10), - }, - networkMessenger = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "debug" }, false), - interval = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "interval" }, 0.01), - }, - configurator = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "configurator", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "configurator", "debug" }, false), - }, - stinkyCache = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "debug" }, false), - commander = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "commander" }, "Heimdállr"), - ttl = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "ttl" }, 10), - }, - achievementSniffer = { - enabled = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "enabled" }, false), - debug = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "debug" }, false), - --texture = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "texture" }, "Aura53.tga"), - --offsetX = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "offsetX" }, 0), - --offsetY = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "offsetY" }, 0), - rescan = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "rescan" }, false), - scanInterval = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "scanInterval" }, 1), - --iconScale = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "iconScale" }, 1), - }, - addonPrefix = shared.GetOrDefault(Heimdall_Data, { "config", "addonPrefix" }, "HEIMDALL"), - channelLocale = shared.GetOrDefault(Heimdall_Data, { "config", "channelLocale" }, {}), - } + --/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally" + Heimdall_Data.config = { + debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false), + spotter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false), + everyone = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "everyone" }, false), + hostile = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "hostile" }, true), + alliance = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "alliance" }, true), + stinky = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "stinky" }, true), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "channels" }, { "Agent" }), + zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "zoneOverride" }, nil), + throttleTime = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "throttleTime" }, 10), + }, + who = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "who", "debug" }, false), + ignored = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ignored" }, {}), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "who", "channels" }, { "Agent" }), + ttl = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ttl" }, 20), + doWhisper = shared.GetOrDefault(Heimdall_Data, { "config", "who", "doWhisper" }, true), + zoneNotifyFor = shared.GetOrDefault(Heimdall_Data, { "config", "who", "zoneNotifyFor" }, { + ["Orgrimmar"] = true, + ["Thunder Bluff"] = true, + ["Undercity"] = true, + ["Durotar"] = true, + ["Echo Isles"] = true, + ["Valley of Trials"] = true, + }), + queries = shared.GetOrDefault(Heimdall_Data, { "config", "who", "queries" }, ""), + }, + messenger = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "enabled" }, true), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "debug" }, false), + interval = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "interval" }, 0.2), + }, + deathReporter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "debug" }, false), + throttle = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "throttle" }, 10), + doWhisper = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "channels" }, { "Agent" }), + zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "zoneOverride" }, nil), + duelThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "duelThrottle" }, 5), + }, + inviter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "channels" }, { "Agent" }), + keyword = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "keyword" }, "+"), + allAssist = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "allAssist" }, false), + agentsAssist = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "agentsAssist" }, false), + throttle = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "throttle" }, 1), + kickOffline = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "kickOffline" }, false), + cleanupInterval = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "cleanupInterval" }, 10), + afkThreshold = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "afkThreshold" }, 300), + }, + dueler = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "debug" }, false), + declineOther = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "declineOther" }, false), + }, + bully = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "debug" }, false), + }, + agentTracker = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "channels" }, { "Agent" }), + }, + emoter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "channels" }, { "Agent" }), + prefix = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "prefix" }, ""), + }, + echoer = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "channels" }, { "Agent" }), + prefix = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "prefix" }, ""), + }, + macroer = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "debug" }, false), + priority = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "priority" }, {}), + }, + agents = shared.GetOrDefault(Heimdall_Data, { "config", "agents" }, {}), + commander = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "channels" }, { "Agent" }), + commander = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commander" }, "Heimdállr"), + commands = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commands" }, {}), + }, + stinkyTracker = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }), + }, + combatAlerter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "channels" }, { "Agent" }), + }, + messageDelegator = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "debug" }, false), + delegates = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "delegates" }, {}), + masterChannel = shared.GetOrDefault( + Heimdall_Data, + { "config", "messageDelegator", "masterChannel" }, + "Agent" + ), + }, + sniffer = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "channels" }, { "Agent" }), + throttle = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "throttle" }, 10), + zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "zoneOverride" }, nil), + stinky = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "stinky" }, true), + }, + minimapTagger = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "channels" }, { "Agent" }), + throttle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "throttle" }, 10), + scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3), + tagTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTTL" }, 1), + tagSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSound" }, false), + tagSoundFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "tagSoundFile" }, + "MGSSpot.ogg" + ), + tagSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundThrottle" }, 0), + tagTextureFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "tagTextureFile" }, + "Aura4.tga" + ), + --- + alertTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTTL" }, 1), + alertSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSound" }, false), + alertSoundFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "alertSoundFile" }, + "OOF.ogg" + ), + alertSoundThrottle = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "alertSoundThrottle" }, + 0 + ), + alertTextureFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "alertTextureFile" }, + "Aura27.tga" + ), + --- + combatTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTTL" }, 1), + combatSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSound" }, false), + combatSoundFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "combatSoundFile" }, + "StarScream.ogg" + ), + combatSoundThrottle = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "combatSoundThrottle" }, + 2 + ), + combatTextureFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "combatTextureFile" }, + "Aura58.tga" + ), + --- + helpTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTTL" }, 1), + helpSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSound" }, false), + helpSoundFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "helpSoundFile" }, + "MedicGangsterParadise.ogg" + ), + helpSoundThrottle = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "helpSoundThrottle" }, + 2 + ), + helpTextureFile = shared.GetOrDefault( + Heimdall_Data, + { "config", "minimapTagger", "helpTextureFile" }, + "Aura68.tga" + ), + }, + whisperNotify = shared.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {}), + stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}), + notes = shared.GetOrDefault(Heimdall_Data, { "config", "notes" }, {}), + scale = shared.GetOrDefault(Heimdall_Data, { "config", "scale" }, 1), + locale = shared.GetOrDefault(Heimdall_Data, { "config", "locale" }, "en"), + bonkDetector = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "channels" }, { "Agent" }), + throttle = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "throttle" }, 5), + }, + noter = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "debug" }, false), + channels = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "channels" }, { "Agent" }), + lastNotes = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "lastNotes" }, 5), + }, + network = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "network", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "network", "debug" }, false), + members = shared.GetOrDefault(Heimdall_Data, { "config", "network", "members" }, {}), + updateInterval = shared.GetOrDefault(Heimdall_Data, { "config", "network", "updateInterval" }, 10), + }, + networkMessenger = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "debug" }, false), + interval = shared.GetOrDefault(Heimdall_Data, { "config", "networkMessenger", "interval" }, 0.01), + }, + configurator = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "configurator", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "configurator", "debug" }, false), + }, + stinkyCache = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "debug" }, false), + commander = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "commander" }, "Heimdállr"), + ttl = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyCache", "ttl" }, 10), + }, + achievementSniffer = { + enabled = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "enabled" }, false), + debug = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "debug" }, false), + --texture = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "texture" }, "Aura53.tga"), + --offsetX = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "offsetX" }, 0), + --offsetY = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "offsetY" }, 0), + rescan = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "rescan" }, false), + scanInterval = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "scanInterval" }, 1), + --iconScale = shared.GetOrDefault(Heimdall_Data, { "config", "achievementSniffer", "iconScale" }, 1), + }, + addonPrefix = shared.GetOrDefault(Heimdall_Data, { "config", "addonPrefix" }, "HEIMDALL"), + channelLocale = shared.GetOrDefault(Heimdall_Data, { "config", "channelLocale" }, {}), + } - shared.raceMap = { - ["Orc"] = "Horde", - ["Undead"] = "Horde", - ["Tauren"] = "Horde", - ["Troll"] = "Horde", - ["Blood Elf"] = "Horde", - ["Goblin"] = "Horde", - ["Human"] = "Alliance", - ["Dwarf"] = "Alliance", - ["Night Elf"] = "Alliance", - ["Gnome"] = "Alliance", - ["Draenei"] = "Alliance", - ["Worgen"] = "Alliance", - ["Vulpera"] = "Horde", - ["Nightborne"] = "Horde", - ["Zandalari Troll"] = "Horde", - ["Kul Tiran"] = "Alliance", - ["Dark Iron Dwarf"] = "Alliance", - ["Void Elf"] = "Alliance", - ["Lightforged Draenei"] = "Alliance", - ["Mechagnome"] = "Alliance", - ["Mag'har Orc"] = "Horde" - } + shared.raceMap = { + ["Orc"] = "Horde", + ["Undead"] = "Horde", + ["Tauren"] = "Horde", + ["Troll"] = "Horde", + ["Blood Elf"] = "Horde", + ["Goblin"] = "Horde", + ["Human"] = "Alliance", + ["Dwarf"] = "Alliance", + ["Night Elf"] = "Alliance", + ["Gnome"] = "Alliance", + ["Draenei"] = "Alliance", + ["Worgen"] = "Alliance", + ["Vulpera"] = "Horde", + ["Nightborne"] = "Horde", + ["Zandalari Troll"] = "Horde", + ["Kul Tiran"] = "Alliance", + ["Dark Iron Dwarf"] = "Alliance", + ["Void Elf"] = "Alliance", + ["Lightforged Draenei"] = "Alliance", + ["Mechagnome"] = "Alliance", + ["Mag'har Orc"] = "Horde", + } - shared.classColors = { - ["Warrior"] = "C69B6D", - ["Paladin"] = "F48CBA", - ["Hunter"] = "AAD372", - ["Rogue"] = "FFF468", - ["Priest"] = "FFFFFF", - ["Death Knight"] = "C41E3A", - ["Shaman"] = "0070DD", - ["Mage"] = "3FC7EB", - ["Warlock"] = "8788EE", - ["Monk"] = "00FF98", - ["Druid"] = "FF7C0A", - ["Demon Hunter"] = "A330C9" - } + shared.classColors = { + ["Warrior"] = "C69B6D", + ["Paladin"] = "F48CBA", + ["Hunter"] = "AAD372", + ["Rogue"] = "FFF468", + ["Priest"] = "FFFFFF", + ["Death Knight"] = "C41E3A", + ["Shaman"] = "0070DD", + ["Mage"] = "3FC7EB", + ["Warlock"] = "8788EE", + ["Monk"] = "00FF98", + ["Druid"] = "FF7C0A", + ["Demon Hunter"] = "A330C9", + } - ---@param input string - ---@return number - shared.utf8len = function(input) - if not input then - return 0 - end - local len = 0 - local i = 1 - local n = #input - while i <= n do - local c = input:byte(i) - if c >= 0 and c <= 127 then - i = i + 1 - elseif c >= 194 and c <= 223 then - i = i + 2 - elseif c >= 224 and c <= 239 then - i = i + 3 - elseif c >= 240 and c <= 244 then - i = i + 4 - else - i = i + 1 - end - len = len + 1 - end - return len - end - ---@param input string - ---@param targetLength number - ---@param left boolean - ---@return string - shared.padString = function(input, targetLength, left) - left = left or false - local len = shared.utf8len(input) - if len < targetLength then - if left then - input = input .. string.rep(" ", targetLength - len) - else - input = string.rep(" ", targetLength - len) .. input - end - end - return input - end + ---@param input string + ---@return number + shared.utf8len = function(input) + if not input then return 0 end + local len = 0 + local i = 1 + local n = #input + while i <= n do + local c = input:byte(i) + if c >= 0 and c <= 127 then + i = i + 1 + elseif c >= 194 and c <= 223 then + i = i + 2 + elseif c >= 224 and c <= 239 then + i = i + 3 + elseif c >= 240 and c <= 244 then + i = i + 4 + else + i = i + 1 + end + len = len + 1 + end + return len + end + ---@param input string + ---@param targetLength number + ---@param left boolean + ---@return string + shared.padString = function(input, targetLength, left) + left = left or false + local len = shared.utf8len(input) + if len < targetLength then + if left then + input = input .. string.rep(" ", targetLength - len) + else + input = string.rep(" ", targetLength - len) .. input + end + end + return input + end - ---@param input string - ---@param deliminer string - ---@return table - shared.Split = function(input, deliminer) - if deliminer == nil then - deliminer = "%s" - end - local t = {} - for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do - table.insert(t, str) - end - return t - end - ---@param name string - ---@return boolean - shared.IsStinky = function(name) - return Heimdall_Data.config.stinkies[name] ~= nil or shared.StinkyCache[name] ~= nil - end + ---@param input string + ---@param deliminer string + ---@return table + shared.Split = function(input, deliminer) + if deliminer == nil then deliminer = "%s" end + local t = {} + for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do + table.insert(t, str) + end + return t + end + ---@param name string + ---@return boolean + shared.IsStinky = function(name) + return Heimdall_Data.config.stinkies[name] ~= nil or shared.StinkyCache[name] ~= nil + end - ---@param f function - ---@return function - shared.Memoize = function(f) - local mem = {} -- memoizing table - setmetatable(mem, { __mode = "kv" }) -- make it weak - return function(x) -- new version of ’f’, with memoizing - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Memoize %s", tostring(x))) - end - local r = mem[x] - if r == nil then -- no previous result? - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Memoize %s is nil, calling original function", tostring(x))) - end - r = f(x) -- calls original function - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Memoized result for %s: %s", tostring(x), tostring(r))) - end - mem[x] = r -- store result for reuse - end - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Memoize %s is %s", tostring(x), tostring(r))) - end - return r - end - end + ---@param f function + ---@return function + shared.Memoize = function(f) + local mem = {} -- memoizing table + setmetatable(mem, { __mode = "kv" }) -- make it weak + return function(x) -- new version of ’f’, with memoizing + if Heimdall_Data.config.debug then print(string.format("[Heimdall] Memoize %s", tostring(x))) end + local r = mem[x] + if r == nil then -- no previous result? + if Heimdall_Data.config.debug then + print(string.format("[Heimdall] Memoize %s is nil, calling original function", tostring(x))) + end + r = f(x) -- calls original function + if Heimdall_Data.config.debug then + print(string.format("[Heimdall] Memoized result for %s: %s", tostring(x), tostring(r))) + end + mem[x] = r -- store result for reuse + end + if Heimdall_Data.config.debug then + print(string.format("[Heimdall] Memoize %s is %s", tostring(x), tostring(r))) + end + return r + end + end - ---@param channel string - ---@return string - shared.GetLocaleForChannel = function(channel) - return Heimdall_Data.config.channelLocale[channel] or "en" - end + ---@param channel string + ---@return string + shared.GetLocaleForChannel = function(channel) return Heimdall_Data.config.channelLocale[channel] or "en" end - ---@param key string - ---@param locale string - ---@return string - shared._L = function(key, locale) - local locale = shared._Locale[locale] - if not locale then - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Locale %s not found", tostring(locale))) - end - return key - end - local value = locale[key] - if not value then - if Heimdall_Data.config.debug then - print(string.format("[Heimdall] Key %s not found in locale %s", tostring(key), tostring(locale))) - end - return key - end - return value - end + ---@param key string + ---@param locale string + ---@return string + shared._L = function(key, locale) + local locale = shared._Locale[locale] + if not locale then + if Heimdall_Data.config.debug then + print(string.format("[Heimdall] Locale %s not found", tostring(locale))) + end + return key + end + local value = locale[key] + if not value then + if Heimdall_Data.config.debug then + print(string.format("[Heimdall] Key %s not found in locale %s", tostring(key), tostring(locale))) + end + return key + end + return value + end - shared.Messenger.Init() - shared.StinkyTracker.Init() - shared.AgentTracker.Init() - shared.Whoer.Init() - shared.Spotter.Init() - shared.DeathReporter.Init() - shared.Inviter.Init() - shared.Dueler.Init() - shared.Bully.Init() - shared.Macroer.Init() - shared.Commander.Init() - shared.CombatAlerter.Init() - shared.Config.Init() - shared.MinimapTagger.Init() - shared.BonkDetector.Init() - shared.Sniffer.Init() - shared.Noter.Init() - shared.Network.Init() - shared.NetworkMessenger.Init() - shared.Configurator.Init() - shared.StinkyCache.Init() - shared.AchievementSniffer.Init() - print("Heimdall loaded!") + shared.Messenger.Init() + shared.StinkyTracker.Init() + shared.AgentTracker.Init() + shared.Whoer.Init() + shared.Spotter.Init() + shared.DeathReporter.Init() + shared.Inviter.Init() + shared.Dueler.Init() + shared.Bully.Init() + shared.Macroer.Init() + shared.Commander.Init() + shared.CombatAlerter.Init() + shared.Config.Init() + shared.MinimapTagger.Init() + shared.BonkDetector.Init() + shared.Sniffer.Init() + shared.Noter.Init() + shared.Network.Init() + shared.NetworkMessenger.Init() + shared.Configurator.Init() + shared.StinkyCache.Init() + shared.AchievementSniffer.Init() + print("Heimdall loaded!") end local loadedFrame = CreateFrame("Frame") loadedFrame:RegisterEvent("ADDON_LOADED") loadedFrame:SetScript("OnEvent", function(self, event, addonName) - if addonName == addonname then - init() - end + if addonName == addonname then init() end end) diff --git a/Meta b/Meta index 5fe685d..859955a 160000 --- a/Meta +++ b/Meta @@ -1 +1 @@ -Subproject commit 5fe685d4c6ef558a5021f98258e5b1016a81a122 +Subproject commit 859955aa366f3d42fb6344a68c95b4ddb4f4cd1c diff --git a/Modules/AchievementSniffer.lua b/Modules/AchievementSniffer.lua index 2274521..2544f64 100644 --- a/Modules/AchievementSniffer.lua +++ b/Modules/AchievementSniffer.lua @@ -248,9 +248,7 @@ function shared.AchievementSniffer.Init() if Heimdall_Data.config.achievementSniffer.debug then print(string.format("[%s] Event triggered: %s for unit: %s", ModuleName, event, unit)) end - if event == "NAME_PLATE_UNIT_ADDED" then - TryInspect(unit) - end + if event == "NAME_PLATE_UNIT_ADDED" then TryInspect(unit) end --UpdateFrames() end) @@ -271,7 +269,6 @@ function shared.AchievementSniffer.Init() Scan(name) end) - local function Tick() C_Timer.NewTimer(Heimdall_Data.config.achievementSniffer.scanInterval, Tick) if not Heimdall_Data.config.achievementSniffer.enabled then return end diff --git a/Modules/AgentTracker.lua b/Modules/AgentTracker.lua index 9338373..9fae27e 100644 --- a/Modules/AgentTracker.lua +++ b/Modules/AgentTracker.lua @@ -41,12 +41,16 @@ function shared.AgentTracker.Init() if name then local isNewAgent = not Heimdall_Data.config.agents[name] Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S") - if isNewAgent then - newAgents = newAgents + 1 - end + if isNewAgent then newAgents = newAgents + 1 end if Heimdall_Data.config.agentTracker.debug then - print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", - name)) + print( + string.format( + "[%s] %s agent: %s", + ModuleName, + isNewAgent and "Added new" or "Updated existing", + name + ) + ) end end end @@ -89,20 +93,27 @@ function shared.AgentTracker.Init() shared.dumpTable(Heimdall_Data.config.agentTracker) end - sender = string.match(sender, "^[^-]+") local isNewAgent = not Heimdall_Data.config.agents[sender] Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S") if Heimdall_Data.config.agentTracker.debug then - print(string.format("[%s] %s agent from message: %s", ModuleName, - isNewAgent and "Added new" or "Updated existing", sender)) + print( + string.format( + "[%s] %s agent from message: %s", + ModuleName, + isNewAgent and "Added new" or "Updated existing", + sender + ) + ) end end) if Heimdall_Data.config.agentTracker.debug then local count = 0 - for _ in pairs(Heimdall_Data.config.agents) do count = count + 1 end + for _ in pairs(Heimdall_Data.config.agents) do + count = count + 1 + end print(string.format("[%s] Module initialized - Tracking %d agents", ModuleName, count)) end print("[Heimdall] AgentTracker loaded") diff --git a/Modules/BonkDetector.lua b/Modules/BonkDetector.lua index 4b15884..d3a919f 100644 --- a/Modules/BonkDetector.lua +++ b/Modules/BonkDetector.lua @@ -73,8 +73,14 @@ function shared.BonkDetector.Init() if lastReportTime[source] and (currentTime - lastReportTime[source]) < throttle then if Heimdall_Data.config.bonkDetector.debug then local timeLeft = throttle - (currentTime - lastReportTime[source]) - print(string.format("[%s] Damage report throttled for %s (%.1f seconds remaining)", - ModuleName, source, timeLeft)) + print( + string.format( + "[%s] Damage report throttled for %s (%.1f seconds remaining)", + ModuleName, + source, + timeLeft + ) + ) end return end @@ -82,8 +88,15 @@ function shared.BonkDetector.Init() lastReportTime[source] = currentTime if Heimdall_Data.config.bonkDetector.debug then - print(string.format("[%s] Processing damage event - Source: %s, Target: %s, Type: %s", - ModuleName, source, destination, subevent)) + print( + string.format( + "[%s] Processing damage event - Source: %s, Target: %s, Type: %s", + ModuleName, + source, + destination, + subevent + ) + ) end for _, channel in pairs(Heimdall_Data.config.bonkDetector.channels) do diff --git a/Modules/Bully.lua b/Modules/Bully.lua index 918cd2d..941ece1 100644 --- a/Modules/Bully.lua +++ b/Modules/Bully.lua @@ -6,8 +6,6 @@ local ModuleName = "Bully" ---@diagnostic disable-next-line: missing-fields shared.Bully = {} function shared.Bully.Init() - if Heimdall_Data.config.bully.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.bully.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] Bully loaded") end diff --git a/Modules/CLEUParser.lua b/Modules/CLEUParser.lua index 144e85d..ecfc283 100644 --- a/Modules/CLEUParser.lua +++ b/Modules/CLEUParser.lua @@ -12,12 +12,12 @@ local function Init() ["destGUID"] = 8, ["destName"] = 9, ["destFlags"] = 10, - ["destRaidFlags"] = 11 + ["destRaidFlags"] = 11, }, ["GENERIC_SPELL"] = { ["spellId"] = 12, ["spellName"] = 13, - ["spellSchool"] = 14 + ["spellSchool"] = 14, }, ["GENERIC_DAMAGE"] = { ["amount"] = 15, @@ -29,19 +29,19 @@ local function Init() ["critical"] = 21, ["glancing"] = 22, ["crushing"] = 23, - ["isOffHand"] = 24 + ["isOffHand"] = 24, }, ["GENERIC_MISSED"] = { ["missType"] = 15, ["isOffHand"] = 16, ["amountMissed"] = 17, - ["critical"] = 18 + ["critical"] = 18, }, ["GENERIC_HEAL"] = { ["amount"] = 15, ["overhealing"] = 16, ["absorbed"] = 17, - ["critical"] = 18 + ["critical"] = 18, }, ["GENERIC_HEAL_ABSORBED"] = { ["extraGUID"] = 15, @@ -52,44 +52,44 @@ local function Init() ["extraSpellName"] = 20, ["extraSchool"] = 21, ["absorbedAmount"] = 22, - ["totalAmount"] = 23 + ["totalAmount"] = 23, }, ["GENERIC_ENERGIZE"] = { ["amount"] = 15, ["overEnergize"] = 16, - ["powerType"] = 17 + ["powerType"] = 17, }, ["GENERIC_DRAIN"] = { ["amount"] = 15, ["powerType"] = 16, - ["extraAmount"] = 17 + ["extraAmount"] = 17, }, ["GENERIC_LEECH"] = { ["amount"] = 15, ["powerType"] = 16, - ["extraAmount"] = 17 + ["extraAmount"] = 17, }, ["GENERIC_INTERRUPT"] = { ["extraSpellId"] = 15, ["extraSpellName"] = 16, - ["extraSchool"] = 17 + ["extraSchool"] = 17, }, ["GENERIC_DISPEL"] = { ["extraSpellId"] = 15, ["extraSpellName"] = 16, ["extraSchool"] = 17, - ["auraType"] = 18 + ["auraType"] = 18, }, ["GENERIC_DISPEL_FAILED"] = { ["extraSpellId"] = 15, ["extraSpellName"] = 16, - ["extraSchool"] = 17 + ["extraSchool"] = 17, }, ["GENERIC_STOLEN"] = { ["extraSpellId"] = 15, ["extraSpellName"] = 16, ["extraSchool"] = 17, - ["auraType"] = 18 + ["auraType"] = 18, }, ["GENERIC_EXTRA_ATTACKS"] = { ["amount"] = 15 }, ["GENERIC_AURA_APPLIED"] = { ["auraType"] = 15, ["amount"] = 16 }, @@ -102,38 +102,32 @@ local function Init() ["extraSpellId"] = 15, ["extraSpellName"] = 16, ["extraSchool"] = 17, - ["auraType"] = 18 + ["auraType"] = 18, }, ["GENERIC_CAST_START"] = {}, ["GENERIC_CAST_SUCCESS"] = {}, - ["GENERIC_CAST_FAILED"] = {} + ["GENERIC_CAST_FAILED"] = {}, } CLEUEventInfo["SWING_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SWING_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SWING_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] - CLEUEventInfo["SWING_HEAL_ABSORBED"] = - CLEUEventInfo["GENERIC_HEAL_ABSORBED"] + CLEUEventInfo["SWING_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SWING_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SWING_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SWING_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["SWING_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SWING_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] - CLEUEventInfo["SWING_DISPEL_FAILED"] = - CLEUEventInfo["GENERIC_DISPEL_FAILED"] + CLEUEventInfo["SWING_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SWING_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] - CLEUEventInfo["SWING_EXTRA_ATTACKS"] = - CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] + CLEUEventInfo["SWING_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["SWING_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["SWING_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] - CLEUEventInfo["SWING_AURA_APPLIED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] - CLEUEventInfo["SWING_AURA_REMOVED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] + CLEUEventInfo["SWING_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] + CLEUEventInfo["SWING_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["SWING_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["SWING_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] - CLEUEventInfo["SWING_AURA_BROKEN_SPELL"] = - CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] + CLEUEventInfo["SWING_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["SWING_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["SWING_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["SWING_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] @@ -141,28 +135,22 @@ local function Init() CLEUEventInfo["RANGE_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["RANGE_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["RANGE_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] - CLEUEventInfo["RANGE_HEAL_ABSORBED"] = - CLEUEventInfo["GENERIC_HEAL_ABSORBED"] + CLEUEventInfo["RANGE_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["RANGE_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["RANGE_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["RANGE_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["RANGE_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["RANGE_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] - CLEUEventInfo["RANGE_DISPEL_FAILED"] = - CLEUEventInfo["GENERIC_DISPEL_FAILED"] + CLEUEventInfo["RANGE_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["RANGE_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] - CLEUEventInfo["RANGE_EXTRA_ATTACKS"] = - CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] + CLEUEventInfo["RANGE_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["RANGE_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["RANGE_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] - CLEUEventInfo["RANGE_AURA_APPLIED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] - CLEUEventInfo["RANGE_AURA_REMOVED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] + CLEUEventInfo["RANGE_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] + CLEUEventInfo["RANGE_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["RANGE_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["RANGE_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] - CLEUEventInfo["RANGE_AURA_BROKEN_SPELL"] = - CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] + CLEUEventInfo["RANGE_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["RANGE_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["RANGE_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["RANGE_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] @@ -170,28 +158,22 @@ local function Init() CLEUEventInfo["SPELL_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SPELL_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SPELL_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] - CLEUEventInfo["SPELL_HEAL_ABSORBED"] = - CLEUEventInfo["GENERIC_HEAL_ABSORBED"] + CLEUEventInfo["SPELL_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SPELL_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SPELL_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SPELL_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["SPELL_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SPELL_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] - CLEUEventInfo["SPELL_DISPEL_FAILED"] = - CLEUEventInfo["GENERIC_DISPEL_FAILED"] + CLEUEventInfo["SPELL_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SPELL_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] - CLEUEventInfo["SPELL_EXTRA_ATTACKS"] = - CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] + CLEUEventInfo["SPELL_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["SPELL_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["SPELL_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] - CLEUEventInfo["SPELL_AURA_APPLIED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] - CLEUEventInfo["SPELL_AURA_REMOVED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] + CLEUEventInfo["SPELL_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] + CLEUEventInfo["SPELL_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["SPELL_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["SPELL_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] - CLEUEventInfo["SPELL_AURA_BROKEN_SPELL"] = - CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] + CLEUEventInfo["SPELL_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["SPELL_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["SPELL_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["SPELL_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] @@ -199,39 +181,25 @@ local function Init() CLEUEventInfo["SPELL_PERIODIC_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SPELL_PERIODIC_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SPELL_PERIODIC_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] - CLEUEventInfo["SPELL_PERIODIC_HEAL_ABSORBED"] = - CLEUEventInfo["GENERIC_HEAL_ABSORBED"] + CLEUEventInfo["SPELL_PERIODIC_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SPELL_PERIODIC_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SPELL_PERIODIC_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SPELL_PERIODIC_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] - CLEUEventInfo["SPELL_PERIODIC_INTERRUPT"] = - CLEUEventInfo["GENERIC_INTERRUPT"] + CLEUEventInfo["SPELL_PERIODIC_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SPELL_PERIODIC_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] - CLEUEventInfo["SPELL_PERIODIC_DISPEL_FAILED"] = - CLEUEventInfo["GENERIC_DISPEL_FAILED"] + CLEUEventInfo["SPELL_PERIODIC_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SPELL_PERIODIC_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] - CLEUEventInfo["SPELL_PERIODIC_EXTRA_ATTACKS"] = - CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] - CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED"] = - CLEUEventInfo["GENERIC_AURA_APPLIED"] - CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED"] = - CLEUEventInfo["GENERIC_AURA_REMOVED"] - CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] - CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = - CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] - CLEUEventInfo["SPELL_PERIODIC_AURA_REFRESH"] = - CLEUEventInfo["GENERIC_AURA_REFRESH"] - CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN"] = - CLEUEventInfo["GENERIC_AURA_BROKEN"] - CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN_SPELL"] = - CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] - CLEUEventInfo["SPELL_PERIODIC_CAST_START"] = - CLEUEventInfo["GENERIC_CAST_START"] - CLEUEventInfo["SPELL_PERIODIC_CAST_SUCCESS"] = - CLEUEventInfo["GENERIC_CAST_SUCCESS"] - CLEUEventInfo["SPELL_PERIODIC_CAST_FAILED"] = - CLEUEventInfo["GENERIC_CAST_FAILED"] + CLEUEventInfo["SPELL_PERIODIC_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] + CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] + CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] + CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] + CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] + CLEUEventInfo["SPELL_PERIODIC_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] + CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] + CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] + CLEUEventInfo["SPELL_PERIODIC_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] + CLEUEventInfo["SPELL_PERIODIC_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] + CLEUEventInfo["SPELL_PERIODIC_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] ---@class CLEUParser CLEUParser = { @@ -239,132 +207,88 @@ local function Init() ---@return number, nil|string GetTimestamp = function(...) local val = select(CLEUEventInfo["GENERIC"]["timestamp"], ...) - if val == nil then - return 0, "Timestamp is nil or missing" - end - if type(val) ~= "number" then - return 0, "Timestamp is not a number" - end + if val == nil then return 0, "Timestamp is nil or missing" end + if type(val) ~= "number" then return 0, "Timestamp is not a number" end return val, nil end, ---@param ... any ---@return string, nil|string GetSubevent = function(...) local val = select(CLEUEventInfo["GENERIC"]["subevent"], ...) - if val == nil then - return "", "Subevent is nil or missing" - end - if type(val) ~= "string" then - return "", "Subevent is not a string" - end + if val == nil then return "", "Subevent is nil or missing" end + if type(val) ~= "string" then return "", "Subevent is not a string" end return val, nil end, ---@param ... any ---@return boolean, nil|string GetHideCaster = function(...) local val = select(CLEUEventInfo["GENERIC"]["hideCaster"], ...) - if val == nil then - return false, "HideCaster is nil or missing" - end - if type(val) ~= "boolean" then - return false, "HideCaster is not a boolean" - end + if val == nil then return false, "HideCaster is nil or missing" end + if type(val) ~= "boolean" then return false, "HideCaster is not a boolean" end return val, nil end, ---@param ... any ---@return string, nil|string GetSourceGUID = function(...) local val = select(CLEUEventInfo["GENERIC"]["sourceGUID"], ...) - if val == nil then - return "", "SourceGUID is nil or missing" - end - if type(val) ~= "string" then - return "", "SourceGUID is not a string" - end + if val == nil then return "", "SourceGUID is nil or missing" end + if type(val) ~= "string" then return "", "SourceGUID is not a string" end return val, nil end, ---@param ... any ---@return string, nil|string GetSourceName = function(...) local val = select(CLEUEventInfo["GENERIC"]["sourceName"], ...) - if val == nil then - return "", "SourceName is nil or missing" - end - if type(val) ~= "string" then - return "", "SourceName is not a string" - end + if val == nil then return "", "SourceName is nil or missing" end + if type(val) ~= "string" then return "", "SourceName is not a string" end return val, nil end, ---@param ... any ---@return number, nil|string GetSourceFlags = function(...) local val = select(CLEUEventInfo["GENERIC"]["sourceFlags"], ...) - if val == nil then - return 0, "SourceFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "SourceFlags is not a number" - end + if val == nil then return 0, "SourceFlags is nil or missing" end + if type(val) ~= "number" then return 0, "SourceFlags is not a number" end return val, nil end, ---@param ... any ---@return number, nil|string GetSourceRaidFlags = function(...) local val = select(CLEUEventInfo["GENERIC"]["sourceRaidFlags"], ...) - if val == nil then - return 0, "SourceRaidFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "SourceRaidFlags is not a number" - end + if val == nil then return 0, "SourceRaidFlags is nil or missing" end + if type(val) ~= "number" then return 0, "SourceRaidFlags is not a number" end return val, nil end, ---@param ... any ---@return string, nil|string GetDestGUID = function(...) local val = select(CLEUEventInfo["GENERIC"]["destGUID"], ...) - if val == nil then - return "", "DestGUID is nil or missing" - end - if type(val) ~= "string" then - return "", "DestGUID is not a string" - end + if val == nil then return "", "DestGUID is nil or missing" end + if type(val) ~= "string" then return "", "DestGUID is not a string" end return val, nil end, ---@param ... any ---@return string, nil|string GetDestName = function(...) local val = select(CLEUEventInfo["GENERIC"]["destName"], ...) - if val == nil then - return "", "DestName is nil or missing" - end - if type(val) ~= "string" then - return "", "DestName is not a string" - end + if val == nil then return "", "DestName is nil or missing" end + if type(val) ~= "string" then return "", "DestName is not a string" end return val, nil end, ---@param ... any ---@return number, nil|string GetDestFlags = function(...) local val = select(CLEUEventInfo["GENERIC"]["destFlags"], ...) - if val == nil then - return 0, "DestFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "DestFlags is not a number" - end + if val == nil then return 0, "DestFlags is nil or missing" end + if type(val) ~= "number" then return 0, "DestFlags is not a number" end return val, nil end, ---@param ... any ---@return number, nil|string GetDestRaidFlags = function(...) local val = select(CLEUEventInfo["GENERIC"]["destRaidFlags"], ...) - if val == nil then - return 0, "DestRaidFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "DestRaidFlags is not a number" - end + if val == nil then return 0, "DestRaidFlags is nil or missing" end + if type(val) ~= "number" then return 0, "DestRaidFlags is not a number" end return val, nil end, @@ -380,9 +304,7 @@ local function Init() GetSpellId = function(...) local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellId"], ...) if val == nil then return 0, "SpellId is nil or missing" end - if type(val) ~= "number" then - return 0, "SpellId is not a number" - end + if type(val) ~= "number" then return 0, "SpellId is not a number" end return val, nil end, --- Specific to subevents prefixed by: @@ -396,12 +318,8 @@ local function Init() ---@return string, nil|string GetSpellName = function(...) local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellName"], ...) - if val == nil then - return "", "SpellName is nil or missing" - end - if type(val) ~= "string" then - return "", "SpellName is not a string" - end + if val == nil then return "", "SpellName is nil or missing" end + if type(val) ~= "string" then return "", "SpellName is not a string" end return val, nil end, --- Specific to subevents prefixed by: @@ -414,14 +332,9 @@ local function Init() ---@param ... any ---@return number, nil|string GetSpellSchool = function(...) - local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellSchool"], - ...) - if val == nil then - return 0, "SpellSchool is nil or missing" - end - if type(val) ~= "number" then - return 0, "SpellSchool is not a number" - end + local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellSchool"], ...) + if val == nil then return 0, "SpellSchool is nil or missing" end + if type(val) ~= "number" then return 0, "SpellSchool is not a number" end return val, nil end, @@ -451,15 +364,10 @@ local function Init() ---@return number, nil|string GetAmount = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["amount"], ...) if val == nil then return 0, "Amount is nil or missing" end - if type(val) ~= "number" then - return 0, "Amount is not a number" - end + if type(val) ~= "number" then return 0, "Amount is not a number" end return val, nil end, --- Specific to subevents prefixed by: @@ -479,21 +387,12 @@ local function Init() ---@return number, nil|string GetOverkill = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end - if not CLEUEventInfo[subevent] then - return 0, "Subevent is not a valid event" - end - if not CLEUEventInfo[subevent]["overkill"] then - return 0, "Overkill is nil or missing" - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end + if not CLEUEventInfo[subevent] then return 0, "Subevent is not a valid event" end + if not CLEUEventInfo[subevent]["overkill"] then return 0, "Overkill is nil or missing" end local val = select(CLEUEventInfo[subevent]["overkill"], ...) if val == nil then return 0, "Overkill is nil or missing" end - if type(val) ~= "number" then - return 0, "Overkill is not a number" - end + if type(val) ~= "number" then return 0, "Overkill is not a number" end return val, nil end, --- Specific to subevents prefixed by: @@ -513,15 +412,10 @@ local function Init() ---@return number, nil|string GetSchool = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["school"], ...) if val == nil then return 0, "School is nil or missing" end - if type(val) ~= "number" then - return 0, "School is not a number" - end + if type(val) ~= "number" then return 0, "School is not a number" end return val, nil end, --- Specific to subevents prefixed by: @@ -543,17 +437,10 @@ local function Init() ---@return boolean, nil|string GetResisted = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["resisted"], ...) - if val == nil then - return false, "Resisted is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Resisted is not a boolean" - end + if val == nil then return false, "Resisted is nil or missing" end + if type(val) ~= "boolean" then return false, "Resisted is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -575,17 +462,10 @@ local function Init() ---@return boolean, nil|string GetBlocked = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["blocked"], ...) - if val == nil then - return false, "Blocked is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Blocked is not a boolean" - end + if val == nil then return false, "Blocked is nil or missing" end + if type(val) ~= "boolean" then return false, "Blocked is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -608,17 +488,10 @@ local function Init() ---@return boolean, nil|string GetAbsorbed = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["absorbed"], ...) - if val == nil then - return false, "Absorbed is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Absorbed is not a boolean" - end + if val == nil then return false, "Absorbed is nil or missing" end + if type(val) ~= "boolean" then return false, "Absorbed is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -640,17 +513,10 @@ local function Init() ---@return boolean, nil|string GetCritical = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["critical"], ...) - if val == nil then - return false, "Critical is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Critical is not a boolean" - end + if val == nil then return false, "Critical is nil or missing" end + if type(val) ~= "boolean" then return false, "Critical is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -670,17 +536,10 @@ local function Init() ---@return boolean, nil|string GetGlancing = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["glancing"], ...) - if val == nil then - return false, "Glancing is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Glancing is not a boolean" - end + if val == nil then return false, "Glancing is nil or missing" end + if type(val) ~= "boolean" then return false, "Glancing is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -700,17 +559,10 @@ local function Init() ---@return boolean, nil|string GetCrushing = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["crushing"], ...) - if val == nil then - return false, "Crushing is nil or missing" - end - if type(val) ~= "boolean" then - return false, "Crushing is not a boolean" - end + if val == nil then return false, "Crushing is nil or missing" end + if type(val) ~= "boolean" then return false, "Crushing is not a boolean" end return val, nil end, --- Specific to subevents prefixed by: @@ -731,17 +583,10 @@ local function Init() ---@return boolean, nil|string GetIsOffHand = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return false, - string.format("Failed getting subevent due to: %s", err) - end + if err then return false, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["isOffHand"], ...) - if val == nil then - return false, "IsOffHand is nil or missing" - end - if type(val) ~= "boolean" then - return false, "IsOffHand is not a boolean" - end + if val == nil then return false, "IsOffHand is nil or missing" end + if type(val) ~= "boolean" then return false, "IsOffHand is not a boolean" end return val, nil end, @@ -764,17 +609,10 @@ local function Init() ---@return string, nil|string GetMissType = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return "", - string.format("Failed getting subevent due to: %s", err) - end + if err then return "", string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["missType"], ...) - if val == nil then - return "", "MissType is nil or missing" - end - if type(val) ~= "string" then - return "", "MissType is not a string" - end + if val == nil then return "", "MissType is nil or missing" end + if type(val) ~= "string" then return "", "MissType is not a string" end return val, nil end, @@ -797,17 +635,10 @@ local function Init() --- return type is unconfirmed! GetAmountMissed = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["amountMissed"], ...) - if val == nil then - return 0, "AmountMissed is nil or missing" - end - if type(val) ~= "number" then - return 0, "AmountMissed is not a number" - end + if val == nil then return 0, "AmountMissed is nil or missing" end + if type(val) ~= "number" then return 0, "AmountMissed is not a number" end return val, nil end, @@ -830,17 +661,10 @@ local function Init() ---@return number, nil|string GetOverhealing = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["overhealing"], ...) - if val == nil then - return 0, "Overhealing is nil or missing" - end - if type(val) ~= "number" then - return 0, "Overhealing is not a number" - end + if val == nil then return 0, "Overhealing is nil or missing" end + if type(val) ~= "number" then return 0, "Overhealing is not a number" end return val, nil end, @@ -861,17 +685,10 @@ local function Init() ---@return string, nil|string GetExtraGUID = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return "", - string.format("Failed getting subevent due to: %s", err) - end + if err then return "", string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraGUID"], ...) - if val == nil then - return "", "ExtraGUID is nil or missing" - end - if type(val) ~= "string" then - return "", "ExtraGUID is not a string" - end + if val == nil then return "", "ExtraGUID is nil or missing" end + if type(val) ~= "string" then return "", "ExtraGUID is not a string" end return val, nil end, @@ -892,17 +709,10 @@ local function Init() ---@return string, nil|string GetExtraName = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return "", - string.format("Failed getting subevent due to: %s", err) - end + if err then return "", string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraName"], ...) - if val == nil then - return "", "ExtraName is nil or missing" - end - if type(val) ~= "string" then - return "", "ExtraName is not a string" - end + if val == nil then return "", "ExtraName is nil or missing" end + if type(val) ~= "string" then return "", "ExtraName is not a string" end return val, nil end, @@ -923,17 +733,10 @@ local function Init() ---@return number, nil|string GetExtraFlags = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraFlags"], ...) - if val == nil then - return 0, "ExtraFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraFlags is not a number" - end + if val == nil then return 0, "ExtraFlags is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraFlags is not a number" end return val, nil end, @@ -954,17 +757,10 @@ local function Init() ---@return number, nil|string GetExtraRaidFlags = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraRaidFlags"], ...) - if val == nil then - return 0, "ExtraRaidFlags is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraRaidFlags is not a number" - end + if val == nil then return 0, "ExtraRaidFlags is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraRaidFlags is not a number" end return val, nil end, @@ -989,17 +785,10 @@ local function Init() ---@return number, nil|string GetExtraSpellID = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraSpellID"], ...) - if val == nil then - return 0, "ExtraSpellID is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraSpellID is not a number" - end + if val == nil then return 0, "ExtraSpellID is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraSpellID is not a number" end return val, nil end, @@ -1025,17 +814,10 @@ local function Init() ---@return string, nil|string GetExtraSpellName = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return "", - string.format("Failed getting subevent due to: %s", err) - end + if err then return "", string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraSpellName"], ...) - if val == nil then - return "", "extraSpellName is nil or missing" - end - if type(val) ~= "string" then - return "", "extraSpellName is not a string" - end + if val == nil then return "", "extraSpellName is nil or missing" end + if type(val) ~= "string" then return "", "extraSpellName is not a string" end return val, nil end, @@ -1061,17 +843,10 @@ local function Init() ---@return number, nil|string GetExtraSchool = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraSchool"], ...) - if val == nil then - return 0, "ExtraSchool is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraSchool is not a number" - end + if val == nil then return 0, "ExtraSchool is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraSchool is not a number" end return val, nil end, @@ -1092,17 +867,10 @@ local function Init() ---@return number, nil|string GetAbsorbedAmount = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["absorbedAmount"], ...) - if val == nil then - return 0, "AbsorbedAmount is nil or missing" - end - if type(val) ~= "number" then - return 0, "AbsorbedAmount is not a number" - end + if val == nil then return 0, "AbsorbedAmount is nil or missing" end + if type(val) ~= "number" then return 0, "AbsorbedAmount is not a number" end return val, nil end, @@ -1123,17 +891,10 @@ local function Init() ---@return number, nil|string GetOverEnergize = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["overEnergize"], ...) - if val == nil then - return 0, "OverEnergize is nil or missing" - end - if type(val) ~= "number" then - return 0, "OverEnergize is not a number" - end + if val == nil then return 0, "OverEnergize is nil or missing" end + if type(val) ~= "number" then return 0, "OverEnergize is not a number" end return val, nil end, @@ -1158,17 +919,10 @@ local function Init() ---@return number, nil|string GetPowerType = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["powerType"], ...) - if val == nil then - return 0, "PowerType is nil or missing" - end - if type(val) ~= "number" then - return 0, "PowerType is not a number" - end + if val == nil then return 0, "PowerType is nil or missing" end + if type(val) ~= "number" then return 0, "PowerType is not a number" end return val, nil end, @@ -1190,17 +944,10 @@ local function Init() ---@return number, nil|string GetExtraAmount = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraAmount"], ...) - if val == nil then - return 0, "ExtraAmount is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraAmount is not a number" - end + if val == nil then return 0, "ExtraAmount is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraAmount is not a number" end return val, nil end, @@ -1229,17 +976,10 @@ local function Init() ---@return number, nil|string GetExtraSpellId = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["extraSpellId"], ...) - if val == nil then - return 0, "ExtraSpellId is nil or missing" - end - if type(val) ~= "number" then - return 0, "ExtraSpellId is not a number" - end + if val == nil then return 0, "ExtraSpellId is nil or missing" end + if type(val) ~= "number" then return 0, "ExtraSpellId is not a number" end return val, nil end, @@ -1268,17 +1008,12 @@ local function Init() ---@return number, nil|string GetExtraAuraType = function(...) local subevent, err = CLEUParser.GetSubevent(...) - if err then - return 0, - string.format("Failed getting subevent due to: %s", err) - end + if err then return 0, string.format("Failed getting subevent due to: %s", err) end local val = select(CLEUEventInfo[subevent]["auraType"], ...) if val == nil then return 0, "AuraType is nil or missing" end - if type(val) ~= "number" then - return 0, "AuraType is not a number" - end + if type(val) ~= "number" then return 0, "AuraType is not a number" end return val, nil - end + end, } end @@ -1286,7 +1021,5 @@ local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:RegisterEvent("GUILD_ROSTER_UPDATE") -frame:SetScript("OnEvent", function(self, event, ...) - Init() -end) +frame:SetScript("OnEvent", function(self, event, ...) Init() end) Init() diff --git a/Modules/CombatAlerter.lua b/Modules/CombatAlerter.lua index 918dacd..8d955fe 100644 --- a/Modules/CombatAlerter.lua +++ b/Modules/CombatAlerter.lua @@ -53,8 +53,14 @@ function shared.CombatAlerter.Init() if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source, - tostring(alerted[source] or false))) + print( + string.format( + "[%s] Source is tracked stinky: %s (Already alerted: %s)", + ModuleName, + source, + tostring(alerted[source] or false) + ) + ) end if alerted[source] then return end @@ -63,8 +69,16 @@ function shared.CombatAlerter.Init() local zone, subZone = GetZoneText(), GetSubZoneText() if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100, - y * 100)) + print( + string.format( + "[%s] Player location: %s/%s at %.2f,%.2f", + ModuleName, + zone, + subZone, + x * 100, + y * 100 + ) + ) end SetMapToCurrentZone() @@ -73,11 +87,14 @@ function shared.CombatAlerter.Init() for _, channel in pairs(Heimdall_Data.config.combatAlerter.channels) do local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("combatAlerterInCombat", locale), + local text = string.format( + shared._L("combatAlerterInCombat", locale), source, - shared._L("zone", locale), shared._L("subZone", locale), + shared._L("zone", locale), + shared._L("subZone", locale), tostring(areaId), - x * 100, y * 100 + x * 100, + y * 100 ) ---@type Message local msg = { @@ -111,8 +128,6 @@ function shared.CombatAlerter.Init() alerted = {} end) - if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] CombatAlerter loaded") end diff --git a/Modules/Commander.lua b/Modules/Commander.lua index bf7eba6..4962821 100644 --- a/Modules/Commander.lua +++ b/Modules/Commander.lua @@ -29,7 +29,7 @@ local helpMessages = { "9) note i..j - lists notes from i to j for the character.", "10) note delete i - deletes the i-th note for the character.", "11) note delete i..j - deletes notes from i to j for the character.", - } + }, } ---@diagnostic disable-next-line: missing-fields @@ -51,16 +51,12 @@ function shared.Commander.Init() if #currentChunk + #word + 1 <= size then currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) else - if #currentChunk > 0 then - ret[#ret + 1] = currentChunk - end + if #currentChunk > 0 then ret[#ret + 1] = currentChunk end currentChunk = word end end - if #currentChunk > 0 then - ret[#ret + 1] = currentChunk - end + if #currentChunk > 0 then ret[#ret + 1] = currentChunk end return ret end @@ -69,9 +65,7 @@ function shared.Commander.Init() local function Count(arr) local ret = {} for _, player in pairs(arr) do - if shared.Whoer.ShouldNotifyForZone(player.zone) then - ret[player.zone] = (ret[player.zone] or 0) + 1 - end + if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end end local text = {} for zone, count in pairs(ret) do @@ -95,8 +89,13 @@ function shared.Commander.Init() local ret = {} for _, player in pairs(arr) do if shared.Whoer.ShouldNotifyForZone(player.zone) then - ret[#ret + 1] = string.format("%s/%s (%s) %s", player.name, player.class, player.zone, - player.stinky and "(!!!!)" or "") + ret[#ret + 1] = string.format( + "%s/%s (%s) %s", + player.name, + player.class, + player.zone, + player.stinky and "(!!!!)" or "" + ) end end if Heimdall_Data.config.commander.debug then @@ -119,9 +118,7 @@ function shared.Commander.Init() local function CountClass(arr) local ret = {} for _, player in pairs(arr) do - if shared.Whoer.ShouldNotifyForZone(player.zone) then - ret[player.class] = (ret[player.class] or 0) + 1 - end + if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.class] = (ret[player.class] or 0) + 1 end end local text = {} for class, count in pairs(ret) do @@ -144,36 +141,27 @@ function shared.Commander.Init() end local function CountClassPartitionedStinkies() if Heimdall_Data.config.commander.debug then - print(string.format("[%s] Executing: CountClassPartitionedStinkies", - ModuleName)) + print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) end local res = CountClassPartitioned(HeimdallStinkies) - if #res == 0 then - return { "No stinkies found" } - end + if #res == 0 then return { "No stinkies found" } end return res end local function WhoPartitionedStinkies() if Heimdall_Data.config.commander.debug then - print(string.format("[%s] Executing: WhoPartitionedStinkies", - ModuleName)) + print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) shared.dumpTable(HeimdallStinkies) end local res = WhoPartitioned(HeimdallStinkies) - if #res == 0 then - return { "No stinkies found" } - end + if #res == 0 then return { "No stinkies found" } end return res end local function CountPartitionedStinkies() if Heimdall_Data.config.commander.debug then - print(string.format("[%s] Executing: CountPartitionedStinkies", - ModuleName)) + print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) end local res = CountPartitioned(HeimdallStinkies) - if #res == 0 then - return { "No stinkies found" } - end + if #res == 0 then return { "No stinkies found" } end return res end local function HelpRu() @@ -190,26 +178,32 @@ function shared.Commander.Init() AcceptGroup() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") C_Timer.NewTimer(0.1, function() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] Click event triggered", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] Click event triggered", ModuleName)) + end _G["StaticPopup1Button1"]:Click() end, 1) end) local function JoinGroup() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] JoinGroup command received", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] JoinGroup command received", ModuleName)) + end groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST") - C_Timer.NewTimer(10, function() - groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") - end, 1) + C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1) return { "+" } end local function LeaveGroup() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] LeaveGroup command received", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] LeaveGroup command received", ModuleName)) + end LeaveParty() return {} end ---@param target string local function FollowTarget(target) - if Heimdall_Data.config.commander.debug then print(string.format("[%s] Following target: %s", ModuleName, target)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] Following target: %s", ModuleName, target)) + end if not target then return end FollowUnit(target) return {} @@ -218,14 +212,12 @@ function shared.Commander.Init() ---@param args string[] local function MacroTarget(args) if Heimdall_Data.config.commander.debug then - print(string.format("[%s] Macroing: %s", ModuleName, - strjoin(" ", unpack(args)))) + print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args)))) end if #args < 2 or #args % 2 ~= 0 then if #args < 2 or #args % 2 ~= 0 then if Heimdall_Data.config.commander.debug then - print(string.format( - "[%s] Invalid number of arguments for MacroTarget", ModuleName)) + print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName)) end return {} end @@ -243,7 +235,7 @@ function shared.Commander.Init() name = name, class = class or "unknown", seenAt = GetTime(), - hostile = true + hostile = true, } end return {} @@ -255,15 +247,15 @@ function shared.Commander.Init() ---@field callback fun(...: any): string[] local commands = { - { keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies }, - { keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies }, - { keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies }, - { keywordRe = "^help$", commanderOnly = false, callback = HelpRu }, - { keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn }, - { keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup }, + { keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies }, + { keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies }, + { keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies }, + { keywordRe = "^help$", commanderOnly = false, callback = HelpRu }, + { keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn }, + { keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup }, { keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup }, - { keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget }, - { keywordRe = "^macro", commanderOnly = false, callback = MacroTarget }, + { keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget }, + { keywordRe = "^macro", commanderOnly = false, callback = MacroTarget }, } local commanderChannelFrame = CreateFrame("Frame") @@ -290,8 +282,14 @@ function shared.Commander.Init() end if not ok then if Heimdall_Data.config.commander.debug then - print(string.format("[%s] Channel name '%s' does not match any of the channels '%s'", ModuleName, - channelname, table.concat(Heimdall_Data.config.commander.channels, ", "))) + print( + string.format( + "[%s] Channel name '%s' does not match any of the channels '%s'", + ModuleName, + channelname, + table.concat(Heimdall_Data.config.commander.channels, ", ") + ) + ) end return end @@ -307,10 +305,13 @@ function shared.Commander.Init() if Heimdall_Data.config.commander.debug then print(string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))) end - if enabled and - (not command.commanderOnly - or (command.commanderOnly - and sender == Heimdall_Data.config.commander.commander)) then + if + enabled + and ( + not command.commanderOnly + or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander) + ) + then if msg:match(command.keywordRe) then local messages = command.callback({ strsplit(",", msg) }) if Heimdall_Data.config.commander.debug then @@ -321,7 +322,7 @@ function shared.Commander.Init() local msg = { channel = "C", data = channelname, - message = message + message = message, } if Heimdall_Data.config.commander.debug then print(string.format("[%s] Queuing message", ModuleName)) diff --git a/Modules/Config.lua b/Modules/Config.lua index 0de1fe2..5958058 100644 --- a/Modules/Config.lua +++ b/Modules/Config.lua @@ -5,82 +5,76 @@ local addonname, shared = ... ---@param str string ---@return table local function StringToMap(str, deliminer) - if not str then return {} end - local map = {} - local parts = { strsplit(deliminer, str) } - for _, line in ipairs(parts) do - line = strtrim(line) - if line ~= "" then - map[line] = true - end - end - return map + if not str then return {} end + local map = {} + local parts = { strsplit(deliminer, str) } + for _, line in ipairs(parts) do + line = strtrim(line) + if line ~= "" then map[line] = true end + end + return map end ---@param str string ---@return string[] local function StringToArray(str, deliminer) - if not str then return {} end - local ret = {} - local array = { strsplit(deliminer, str) } - for i, line in ipairs(array) do - line = strtrim(line) - if line ~= "" then - ret[i] = line - end - end - return ret + if not str then return {} end + local ret = {} + local array = { strsplit(deliminer, str) } + for i, line in ipairs(array) do + line = strtrim(line) + if line ~= "" then ret[i] = line end + end + return ret end ---@param map table ---@param deliminer string ---@return string local function MapKeyToString(map, deliminer) - local str = "" - for k, _ in pairs(map) do - str = str .. k .. deliminer - end - return str + local str = "" + for k, _ in pairs(map) do + str = str .. k .. deliminer + end + return str end ---@param map table ---@param deliminer string ---@param terminator string ---@return string local function MapToString(map, deliminer, terminator) - local str = "" - for k, v in pairs(map) do - str = str .. k .. deliminer .. v .. terminator - end - return str + local str = "" + for k, v in pairs(map) do + str = str .. k .. deliminer .. v .. terminator + end + return str end ---@param str string ---@param deliminer string ---@param terminator string ---@return table local function MapFromString(str, deliminer, terminator) - local map = {} - local lines = shared.Split(str, terminator) - for _, line in ipairs(lines) do - local data = shared.Split(line, deliminer) - if #data == 2 then - map[data[1]] = data[2] - else - if Heimdall_Data.config.debug then - print("Invalid data in map:", line) - end - end - end - return map + local map = {} + local lines = shared.Split(str, terminator) + for _, line in ipairs(lines) do + local data = shared.Split(line, deliminer) + if #data == 2 then + map[data[1]] = data[2] + else + if Heimdall_Data.config.debug then print("Invalid data in map:", line) end + end + end + return map end ---@param map table ---@param deliminer string ---@return string local function MapValueToString(map, deliminer) - local str = "" - for _, v in pairs(map) do - str = str .. tostring(v) .. deliminer - end - return str + local str = "" + for _, v in pairs(map) do + str = str .. tostring(v) .. deliminer + end + return str end ---@class GridFrame:Frame @@ -91,121 +85,119 @@ end ---@field cellHeight number ---@field columnHeights table GridFrame = { - ---@param name string - ---@param parent Frame - ---@param columns number - ---@param cellHeight number - ---@param size {w: number, h:number}? - ---@return GridFrame - new = function(name, parent, columns, cellHeight, size) - local self = setmetatable({}, { - __index = GridFrame - }) - self.frame = CreateFrame("Frame", name, parent) - size = size or {} - if size.w then self.frame:SetWidth(size.w) end - if size.h then self.frame:SetHeight(size.h) end - self.allowOverflow = false - self.frame:SetPoint("CENTER", parent, "CENTER") - self.frame:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - tileSize = 64, - tile = true - }) - self.frame:SetBackdropColor(0, 0, 0, 0.8) - self.frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) + ---@param name string + ---@param parent Frame + ---@param columns number + ---@param cellHeight number + ---@param size {w: number, h:number}? + ---@return GridFrame + new = function(name, parent, columns, cellHeight, size) + local self = setmetatable({}, { + __index = GridFrame, + }) + self.frame = CreateFrame("Frame", name, parent) + size = size or {} + if size.w then self.frame:SetWidth(size.w) end + if size.h then self.frame:SetHeight(size.h) end + self.allowOverflow = false + self.frame:SetPoint("CENTER", parent, "CENTER") + self.frame:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + tileSize = 64, + tile = true, + }) + self.frame:SetBackdropColor(0, 0, 0, 0.8) + self.frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) - self.columns = columns - self.cellWidth = self.frame:GetWidth() / columns - self.cellHeight = cellHeight - self.columnHeights = {} - for i = 1, columns do - self.columnHeights[i] = 0 - end - return self - end, - ---@param self GridFrame - ---@param frame Frame - ---@param rowspan number - ---@param colspan number - Add = function(self, frame, rowspan, colspan) - colspan = math.min(colspan, self.columns) + self.columns = columns + self.cellWidth = self.frame:GetWidth() / columns + self.cellHeight = cellHeight + self.columnHeights = {} + for i = 1, columns do + self.columnHeights[i] = 0 + end + return self + end, + ---@param self GridFrame + ---@param frame Frame + ---@param rowspan number + ---@param colspan number + Add = function(self, frame, rowspan, colspan) + colspan = math.min(colspan, self.columns) - local bestColumn = nil - local bestRow = math.huge + local bestColumn = nil + local bestRow = math.huge - for startColumn = 1, self.columns - colspan + 1 do - local currentMaxY = 0 - for c = startColumn, startColumn + colspan - 1 do - currentMaxY = math.max(currentMaxY, self.columnHeights[c]) - end - if currentMaxY < bestRow then - bestRow = currentMaxY - bestColumn = startColumn - end - end + for startColumn = 1, self.columns - colspan + 1 do + local currentMaxY = 0 + for c = startColumn, startColumn + colspan - 1 do + currentMaxY = math.max(currentMaxY, self.columnHeights[c]) + end + if currentMaxY < bestRow then + bestRow = currentMaxY + bestColumn = startColumn + end + end - if bestColumn then - frame:SetParent(self.frame) - frame.gridData = { - row = bestRow, - column = bestColumn, - colspan = colspan, - rowspan = rowspan, - parent = self - } - frame.SetPos = function(self) - if not self.gridData then return end - local parent = self.gridData.parent - local x = (self.gridData.column - 1) * parent.cellWidth - local y = -(self.gridData.row * parent.cellHeight) - self:SetPoint("TOPLEFT", parent.frame, "TOPLEFT", x, y) - self:SetWidth(parent.cellWidth * self.gridData.colspan) - self:SetHeight(parent.cellHeight * self.gridData.rowspan) - end - frame.SetPos(frame) + if bestColumn then + frame:SetParent(self.frame) + frame.gridData = { + row = bestRow, + column = bestColumn, + colspan = colspan, + rowspan = rowspan, + parent = self, + } + frame.SetPos = function(self) + if not self.gridData then return end + local parent = self.gridData.parent + local x = (self.gridData.column - 1) * parent.cellWidth + local y = -(self.gridData.row * parent.cellHeight) + self:SetPoint("TOPLEFT", parent.frame, "TOPLEFT", x, y) + self:SetWidth(parent.cellWidth * self.gridData.colspan) + self:SetHeight(parent.cellHeight * self.gridData.rowspan) + end + frame.SetPos(frame) - for c = bestColumn, bestColumn + colspan - 1 do - self.columnHeights[c] = self.columnHeights[c] + rowspan - end - else - print("No available space in the grid.") - end - end, - Recalculate = function(self) - local children = { self.frame:GetChildren() } - for _, child in pairs(children) do - if child.gridData then - child:SetPos() - -- else - -- print("Child has no grid data", child) - end - end - end, - SetWidth = function(self, width) - self.frame:SetWidth(width) - self.cellWidth = width / self.columns - self:Recalculate() - end, - SetHeight = function(self, height) - self.frame:SetHeight(height) - local tallestRow = 0 - for _, height in pairs(self.columnHeights) do - tallestRow = math.max(tallestRow, height) - end - if tallestRow > 0 then - self.cellHeight = height / tallestRow - end - self:Recalculate() - end, - SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY) - self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY) - self:Recalculate() - end, - SetParent = function(self, parent) - self.frame:SetParent(parent) - self:Recalculate() - end + for c = bestColumn, bestColumn + colspan - 1 do + self.columnHeights[c] = self.columnHeights[c] + rowspan + end + else + print("No available space in the grid.") + end + end, + Recalculate = function(self) + local children = { self.frame:GetChildren() } + for _, child in pairs(children) do + if child.gridData then + child:SetPos() + -- else + -- print("Child has no grid data", child) + end + end + end, + SetWidth = function(self, width) + self.frame:SetWidth(width) + self.cellWidth = width / self.columns + self:Recalculate() + end, + SetHeight = function(self, height) + self.frame:SetHeight(height) + local tallestRow = 0 + for _, height in pairs(self.columnHeights) do + tallestRow = math.max(tallestRow, height) + end + if tallestRow > 0 then self.cellHeight = height / tallestRow end + self:Recalculate() + end, + SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY) + self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY) + self:Recalculate() + end, + SetParent = function(self, parent) + self.frame:SetParent(parent) + self:Recalculate() + end, } ---@class StaticGridFrame @@ -217,173 +209,160 @@ GridFrame = { ---@field cellHeight number ---@field occupancy table> StaticGridFrame = { - ---@param name string - ---@param parent Frame - ---@param rows number - ---@param columns number - ---@param size {w: number, h:number}? - ---@return StaticGridFrame - new = function(name, parent, rows, columns, size) - local self = setmetatable({}, { - __index = StaticGridFrame - }) - size = size or {} - self.frame = CreateFrame("Frame", name, parent) - self.frame:SetWidth(columns * 128) - self.frame:SetHeight(rows * 128) - self.frame:SetPoint("CENTER", UIParent, "CENTER") - self.frame:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - tileSize = 64, - tile = true - }) - self.frame:SetBackdropColor(0, 0, 0, 0.8) - self.frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) - if size.w then self.frame:SetWidth(size.w) end - if size.h then self.frame:SetHeight(size.h) end + ---@param name string + ---@param parent Frame + ---@param rows number + ---@param columns number + ---@param size {w: number, h:number}? + ---@return StaticGridFrame + new = function(name, parent, rows, columns, size) + local self = setmetatable({}, { + __index = StaticGridFrame, + }) + size = size or {} + self.frame = CreateFrame("Frame", name, parent) + self.frame:SetWidth(columns * 128) + self.frame:SetHeight(rows * 128) + self.frame:SetPoint("CENTER", UIParent, "CENTER") + self.frame:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + tileSize = 64, + tile = true, + }) + self.frame:SetBackdropColor(0, 0, 0, 0.8) + self.frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) + if size.w then self.frame:SetWidth(size.w) end + if size.h then self.frame:SetHeight(size.h) end - self.rows = rows - self.columns = columns - self.cellWidth = self.frame:GetWidth() / columns - self.cellHeight = self.frame:GetHeight() / rows - self.occupancy = {} - for row = 1, rows do - self.occupancy[row] = {} - for column = 1, columns do - self.occupancy[row][column] = false - end - end - return self - end, - ---@param self StaticGridFrame - ---@param frame Frame - ---@param rowspan number - ---@param colspan number - Add = function(self, frame, rowspan, colspan) - if rowspan > self.rows or colspan > self.columns then - print("Rowspan or colspan exceeds grid dimensions.") - return - end + self.rows = rows + self.columns = columns + self.cellWidth = self.frame:GetWidth() / columns + self.cellHeight = self.frame:GetHeight() / rows + self.occupancy = {} + for row = 1, rows do + self.occupancy[row] = {} + for column = 1, columns do + self.occupancy[row][column] = false + end + end + return self + end, + ---@param self StaticGridFrame + ---@param frame Frame + ---@param rowspan number + ---@param colspan number + Add = function(self, frame, rowspan, colspan) + if rowspan > self.rows or colspan > self.columns then + print("Rowspan or colspan exceeds grid dimensions.") + return + end - for row = 1, self.rows do - for col = 1, self.columns do - if not self.occupancy[row][col] then - local canPlace = true - for r = row, row + rowspan - 1 do - for c = col, col + colspan - 1 do - -- Check if r or c is out of bounds or if the cell is occupied - if r > self.rows or c > self.columns or self.occupancy[r][c] then - canPlace = false - break - end - end - if not canPlace then break end - end - if canPlace then - local x = (col - 1) * self.cellWidth - local y = -(row - 1) * self.cellHeight - frame.colspan = colspan - frame.rowspan = rowspan - frame:SetWidth(self.cellWidth * colspan) - frame:SetHeight(self.cellHeight * rowspan) - frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", x, y) - frame:SetParent(self.frame) - for r = row, row + rowspan - 1 do - for c = col, col + colspan - 1 do - self.occupancy[r][c] = true - end - end - return - end - end - end - end - print("No available space in the grid.") - end, - MakeMovable = function(self) - self.frame:SetMovable(true) - self.frame:EnableMouse(true) - self.frame:RegisterForDrag("LeftButton") - self.frame:SetScript("OnDragStart", function(self) - self:StartMoving() - end) - self.frame:SetScript("OnDragStop", function(self) - self:StopMovingOrSizing() - end) - end, - Recalculate = function(self) - for _, frame in pairs(self.frame:GetChildren()) do - if frame.colspan then - frame:SetWidth(self.cellWidth * frame.colspan) - end - if frame.rowspan then - frame:SetHeight(self.cellHeight * frame.rowspan) - end - end - end, - SetWidth = function(self, width) - self.frame:SetWidth(width) - self.cellWidth = width / self.columns - self:Recalculate() - end, - SetHeight = function(self, height) - self.frame:SetHeight(height) - self.cellHeight = height / self.rows - self:Recalculate() - end, - SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY) - self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY) - self:Recalculate() - end, - SetParent = function(self, parent) - self.frame:SetParent(parent) - self:Recalculate() - end + for row = 1, self.rows do + for col = 1, self.columns do + if not self.occupancy[row][col] then + local canPlace = true + for r = row, row + rowspan - 1 do + for c = col, col + colspan - 1 do + -- Check if r or c is out of bounds or if the cell is occupied + if r > self.rows or c > self.columns or self.occupancy[r][c] then + canPlace = false + break + end + end + if not canPlace then break end + end + if canPlace then + local x = (col - 1) * self.cellWidth + local y = -(row - 1) * self.cellHeight + frame.colspan = colspan + frame.rowspan = rowspan + frame:SetWidth(self.cellWidth * colspan) + frame:SetHeight(self.cellHeight * rowspan) + frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", x, y) + frame:SetParent(self.frame) + for r = row, row + rowspan - 1 do + for c = col, col + colspan - 1 do + self.occupancy[r][c] = true + end + end + return + end + end + end + end + print("No available space in the grid.") + end, + MakeMovable = function(self) + self.frame:SetMovable(true) + self.frame:EnableMouse(true) + self.frame:RegisterForDrag("LeftButton") + self.frame:SetScript("OnDragStart", function(self) self:StartMoving() end) + self.frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) + end, + Recalculate = function(self) + for _, frame in pairs(self.frame:GetChildren()) do + if frame.colspan then frame:SetWidth(self.cellWidth * frame.colspan) end + if frame.rowspan then frame:SetHeight(self.cellHeight * frame.rowspan) end + end + end, + SetWidth = function(self, width) + self.frame:SetWidth(width) + self.cellWidth = width / self.columns + self:Recalculate() + end, + SetHeight = function(self, height) + self.frame:SetHeight(height) + self.cellHeight = height / self.rows + self:Recalculate() + end, + SetPoint = function(self, point, relativeTo, relativePoint, offsetX, offsetY) + self.frame:SetPoint(point, relativeTo, relativePoint, offsetX, offsetY) + self:Recalculate() + end, + SetParent = function(self, parent) + self.frame:SetParent(parent) + self:Recalculate() + end, } --/run HeimdallConfig:ClearAllPoints(); HeimdallConfig:SetPoint("CENTER", UIParent, "CENTER", 0, 0) -local configFrame = StaticGridFrame.new("HeimdallConfig", - UIParent, - 120, 12, - { w = 1024 + 1024, h = 1024 + 512 }) +local configFrame = StaticGridFrame.new("HeimdallConfig", UIParent, 120, 12, { w = 1024 + 1024, h = 1024 + 512 }) configFrame:MakeMovable() configFrame.frame:SetScript("OnKeyUp", function(self, key) - if key == "ESCAPE" then - self:Hide() - end + if key == "ESCAPE" then self:Hide() end end) -local colorIndex = 1 -local colors = { - { 1, 0, 0, 1 }, -- Red - { 0, 1, 0, 1 }, -- Green - { 0, 0, 1, 1 }, -- Blue - { 1, 1, 0, 1 }, -- Yellow - { 1, 0, 1, 1 }, -- Magenta - { 0, 1, 1, 1 }, -- Cyan - { 1, 1, 1, 1 }, -- White - { 1, 0.5, 0, 1 }, -- Orange - { 0.5, 0, 1, 1 }, -- Purple - { 1, 0.5, 0.5, 1 }, -- Pink - { 0.6, 0.4, 0.2, 1 }, -- Brown - { 0.5, 1, 0.5, 1 }, -- Light Green - { 1, 0.8, 0, 1 }, -- Dark Orange - { 0.8, 0, 1, 1 }, -- Dark Purple - { 0.13, 0.55, 0.13, 1 }, -- Olive Green - { 0, 0, 0.5, 1 }, -- Navy Blue - { 1, 0.5, 0.3, 1 }, -- Coral - { 0, 0.5, 0.5, 1 }, -- Teal - { 0.9, 0.7, 1, 1 }, -- Lavender - { 0.5, 0, 0, 1 }, -- Maroon - { 1, 0.84, 0, 1 }, -- Gold - { 0.44, 0.52, 0.57, 1 }, -- Slate Gray - { 1, 0.41, 0.71, 1 }, -- Hot Pink - { 0.91, 0.48, 0.2, 1 } -- Burnt Sienna +local colorIndex = 1 +local colors = { + { 1, 0, 0, 1 }, -- Red + { 0, 1, 0, 1 }, -- Green + { 0, 0, 1, 1 }, -- Blue + { 1, 1, 0, 1 }, -- Yellow + { 1, 0, 1, 1 }, -- Magenta + { 0, 1, 1, 1 }, -- Cyan + { 1, 1, 1, 1 }, -- White + { 1, 0.5, 0, 1 }, -- Orange + { 0.5, 0, 1, 1 }, -- Purple + { 1, 0.5, 0.5, 1 }, -- Pink + { 0.6, 0.4, 0.2, 1 }, -- Brown + { 0.5, 1, 0.5, 1 }, -- Light Green + { 1, 0.8, 0, 1 }, -- Dark Orange + { 0.8, 0, 1, 1 }, -- Dark Purple + { 0.13, 0.55, 0.13, 1 }, -- Olive Green + { 0, 0, 0.5, 1 }, -- Navy Blue + { 1, 0.5, 0.3, 1 }, -- Coral + { 0, 0.5, 0.5, 1 }, -- Teal + { 0.9, 0.7, 1, 1 }, -- Lavender + { 0.5, 0, 0, 1 }, -- Maroon + { 1, 0.84, 0, 1 }, -- Gold + { 0.44, 0.52, 0.57, 1 }, -- Slate Gray + { 1, 0.41, 0.71, 1 }, -- Hot Pink + { 0.91, 0.48, 0.2, 1 }, -- Burnt Sienna } local GetNextColor = function() - local color = colors[colorIndex] - colorIndex = colorIndex + 1 - if colorIndex > #colors then colorIndex = 1 end - return unpack(color) + local color = colors[colorIndex] + colorIndex = colorIndex + 1 + if colorIndex > #colors then colorIndex = 1 end + return unpack(color) end --HeimdallTestFrame = GridFrame.new("HeimdallPartyFrame", UIParent, 12, 20, { w = 1024, h = 1024 }) @@ -403,1782 +382,2257 @@ end --configFrame:Add(HeimdallTestFrame, 20, 12) ---@diagnostic disable-next-line: missing-fields -shared.Config = {} +shared.Config = {} function shared.Config.Init() - configFrame.frame:SetScale(Heimdall_Data.config.scale) - - local buttonColors = { - enabled = { 0, 1, 0, 1 }, - disabled = { 1, 0, 0, 1 } - } - local function CreateFancyText(name, parent, text, color) - local r, g, b, a = unpack(color) - local textFrame = CreateFrame("Frame", name .. "TextFrame", parent) - local textElement = textFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal") - textElement:SetText(text) - textElement:SetTextColor(r, g, b, a) - textElement:SetPoint("CENTER", textFrame, "CENTER", 0, 0) - textFrame:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 2, - edgeSize = 12, - }) - textFrame:SetBackdropColor(r, g, b, 0.3) - textFrame:SetBackdropBorderColor(r, g, b, 0.5) - return textFrame - end - ---@param name string - ---@param parent Frame - ---@param onClick fun(): boolean - local function CreateBasicButton(name, parent, text, onClick) - local button = CreateFrame("Frame", name, parent) - button:SetScript("OnMouseDown", function() - local res = onClick() - local color = res and buttonColors.enabled or buttonColors.disabled - button:SetBackdropColor(unpack(color)) - end) - button:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 2, - edgeSize = 12, - insets = { - left = 2, - right = 2, - top = 2, - bottom = 2 - } - }) - button.UpdateColor = function(self, state) - local color = state and buttonColors.enabled or buttonColors.disabled - self:SetBackdropColor(unpack(color)) - end - --spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled) - local spotterEnableButtonLabel = button:CreateFontString(nil, "OVERLAY", "GameFontNormal") - spotterEnableButtonLabel:SetText(text or "") - spotterEnableButtonLabel:SetAllPoints(button) - return button - end - ---@param name string - ---@param parent Frame - ---@param text string - ---@param onDone fun(editBox: Frame) - local function CreateBasicSmallEditBox(name, parent, text, initialValue, onDone) - local container = GridFrame.new(name, parent, 1, 1) - local editBoxFrame = CreateFrame("Frame", name .. "EditBoxFrame", container.frame) - local editBox = CreateFrame("EditBox", name .. "EditBox", editBoxFrame) - local textFrame = CreateFrame("Frame", name .. "TextFrame", container.frame) - local textElement = textFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") - textElement:SetText(text) - - editBox:SetAutoFocus(false) - editBox:SetFontObject("GameFontNormal") - editBox:SetText(Heimdall_Data.config.spotter.throttleTime) - editBox:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 2, - edgeSize = 12, - insets = { - left = 2, - right = 2, - top = 2, - bottom = 2 - } - }) - editBox:SetBackdropColor(0.8, 0.8, 0.8, 1) - editBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) - editBox:SetTextInsets(6, 6, 0, 0) - editBox:SetScript("OnEnterPressed", function() editBox:ClearFocus() end) - editBox:SetScript("OnEscapePressed", function() editBox:ClearFocus() end) - editBox:SetScript("OnEditFocusLost", function() onDone(editBox) end) - editBox:SetText(initialValue or "") - container:Add(textFrame, 1, 1) - container:Add(editBox, 2, 1) - textElement:SetPoint("TOPLEFT", textFrame, "TOPLEFT", 2, -2) - return container - end - ---@param name string - ---@param parent Frame - ---@param text string - ---@param onDone fun(editBox: Frame) - local function CreateBasicBigEditBox(name, parent, text, initialValue, onDone) - local container = GridFrame.new(name, parent, 1, 100) - local editBoxFrame = CreateFrame("Frame", name .. "EditBoxFrame", container.frame) - local editBox = CreateFrame("EditBox", name .. "EditBox", editBoxFrame) - local textFrame = CreateFrame("Frame", name .. "TextFrame", container.frame) - local textElement = textFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") - textElement:SetText(text) - - editBoxFrame:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 2, - edgeSize = 12, - insets = { - left = 2, - right = 2, - top = 2, - bottom = 2 - } - }) - editBoxFrame:SetBackdropColor(0.8, 0.8, 0.8, 1) - editBoxFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) - - editBox:SetAllPoints(editBoxFrame) - editBox:SetAutoFocus(false) - editBox:SetFontObject("GameFontNormal") - editBox:SetText(initialValue or "") - editBox:SetTextInsets(6, 6, 6, 6) - editBox:SetMultiLine(true) - editBox:SetSize(280, 100) - editBox:SetMaxLetters(100000) - editBox:SetScript("OnEscapePressed", function() editBox:ClearFocus() end) - editBox:SetScript("OnEditFocusLost", function() onDone(editBox) end) - container:Add(textFrame, 1, 1) - container:Add(editBoxFrame, 7, 1) - textElement:SetPoint("TOPLEFT", textFrame, "TOPLEFT", 2, -2) - return container - end - - local scale = CreateBasicSmallEditBox("HeimdallConfigScale", configFrame.frame, "Scale", Heimdall_Data.config.scale, - function(self) - local text = self:GetText() - if string.match(text, "^%d+%.*%d*$") then - Heimdall_Data.config.scale = tonumber(text) - configFrame.frame:SetScale(Heimdall_Data.config.scale) - else - print(string.format("Invalid scale: %s, please use numbers", text)) - self:SetText(Heimdall_Data.config.scale) - end - end) - configFrame:Add(scale, 2, 2) - local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") - title:SetText(string.format("%s - v%s", shared._L("heimdallConfig", Heimdall_Data.config.locale), shared.VERSION)) - configFrame:Add(title, 2, 7) - - local debug = CreateBasicButton("HeimdallConfigDebug", configFrame.frame, - shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.debug = not Heimdall_Data.config.debug - return Heimdall_Data.config.debug - end) - debug:UpdateColor(Heimdall_Data.config.debug) - configFrame:Add(debug, 2, 1) - - local russian = nil - local english = CreateBasicButton("HeimdallConfigEnglish", configFrame.frame, - shared._L("english", Heimdall_Data.config.locale), function() - Heimdall_Data.config.locale = "en" - russian:UpdateColor(false) - return Heimdall_Data.config.locale == "en" - end) - english:UpdateColor(Heimdall_Data.config.locale == "en") - russian = CreateBasicButton("HeimdallConfigRussian", configFrame.frame, - shared._L("russian", Heimdall_Data.config.locale), function() - Heimdall_Data.config.locale = "ru" - english:UpdateColor(false) - return Heimdall_Data.config.locale == "ru" - end) - russian:UpdateColor(Heimdall_Data.config.locale == "ru") - configFrame:Add(english, 2, 1) - configFrame:Add(russian, 2, 1) - - -- Spotter - do - local r, g, b, a = GetNextColor() - local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig", - UIParent, 12, 20) - spotterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(spotterConfigFrame, 9, 3) - - local title = CreateFancyText("HeimdallSpotterConfigTitle", spotterConfigFrame.frame, - shared._L("spotter", Heimdall_Data.config.locale), { r, g, b, a }) - spotterConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallSpotterConfigDebugButton", - spotterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.debug = not Heimdall_Data.config.spotter.debug - return Heimdall_Data.config.spotter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.spotter.debug) - spotterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallSpotterConfigEnableButton", - spotterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.enabled = not Heimdall_Data.config.spotter.enabled - return Heimdall_Data.config.spotter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.spotter.enabled) - spotterConfigFrame:Add(enableButton, 1, 6) - - local everyoneButton = CreateBasicButton("HeimdallSpotterConfigEveryoneButton", - spotterConfigFrame.frame, shared._L("everyone", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.everyone = not Heimdall_Data.config.spotter.everyone - return Heimdall_Data.config.spotter.everyone - end) - everyoneButton:UpdateColor(Heimdall_Data.config.spotter.everyone) - spotterConfigFrame:Add(everyoneButton, 1, 6) - - local hostileButton = CreateBasicButton("HeimdallSpotterConfigHostileButton", - spotterConfigFrame.frame, shared._L("hostile", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.hostile = not Heimdall_Data.config.spotter.hostile - return Heimdall_Data.config.spotter.hostile - end) - hostileButton:UpdateColor(Heimdall_Data.config.spotter.hostile) - spotterConfigFrame:Add(hostileButton, 1, 4) - - local allianceButton = CreateBasicButton("HeimdallSpotterConfigAllianceButton", - spotterConfigFrame.frame, shared._L("alliance", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.alliance = not Heimdall_Data.config.spotter.alliance - return Heimdall_Data.config.spotter.alliance - end) - allianceButton:UpdateColor(Heimdall_Data.config.spotter.alliance) - spotterConfigFrame:Add(allianceButton, 1, 4) - - local stinkyButton = CreateBasicButton("HeimdallSpotterConfigStinkyButton", - spotterConfigFrame.frame, shared._L("stinky", Heimdall_Data.config.locale), function() - Heimdall_Data.config.spotter.stinky = not Heimdall_Data.config.spotter.stinky - return Heimdall_Data.config.spotter.stinky - end) - stinkyButton:UpdateColor(Heimdall_Data.config.spotter.stinky) - spotterConfigFrame:Add(stinkyButton, 1, 4) - - local channels = CreateBasicSmallEditBox("HeimdallSpotterConfigChannels", - spotterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.spotter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.spotter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.spotter.channels) - end) - spotterConfigFrame:Add(channels, 2, 4) - - local zoneOverride = CreateBasicSmallEditBox("HeimdallSpotterConfigZoneOverride", - spotterConfigFrame.frame, shared._L("zoneOverride", Heimdall_Data.config.locale), - Heimdall_Data.config.spotter.zoneOverride, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.spotter.zoneOverride = text - print("Zone override set to", tostring(text)) - else - print("Invalid zone override", tostring(text)) - self:SetText(Heimdall_Data.config.spotter.zoneOverride) - end - end) - spotterConfigFrame:Add(zoneOverride, 2, 4) - - local throttleTime = CreateBasicSmallEditBox("HeimdallSpotterConfigThrottleTime", - spotterConfigFrame.frame, shared._L("throttle", Heimdall_Data.config.locale), - Heimdall_Data.config.spotter.throttleTime, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.spotter.throttleTime = tonumber(text) - else - print("Invalid throttle time", tostring(text)) - self:SetText(Heimdall_Data.config.spotter.throttleTime) - end - end) - spotterConfigFrame:Add(throttleTime, 2, 4) - end - - -- Whoer - do - local r, g, b, a = GetNextColor() - local whoerConfigFrame = GridFrame.new("HeimdallWhoerConfig", - UIParent, 12, 20) - whoerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(whoerConfigFrame, 30, 6) - - local title = CreateFancyText("HeimdallWhoerConfigTitle", whoerConfigFrame.frame, - shared._L("whoer", Heimdall_Data.config.locale), { r, g, b, a }) - whoerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallWhoerConfigDebugButton", - whoerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.who.debug = not Heimdall_Data.config.who.debug - return Heimdall_Data.config.who.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.who.debug) - whoerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallWhoerConfigEnableButton", - whoerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.who.enabled = not Heimdall_Data.config.who.enabled - return Heimdall_Data.config.who.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.who.enabled) - whoerConfigFrame:Add(enableButton, 2, 3) - - local doWhisperButton = CreateBasicButton("HeimdallWhoerConfigDoWhisperButton", - whoerConfigFrame.frame, shared._L("doWhisper", Heimdall_Data.config.locale), function() - Heimdall_Data.config.who.doWhisper = not Heimdall_Data.config.who.doWhisper - return Heimdall_Data.config.who.doWhisper - end) - doWhisperButton:UpdateColor(Heimdall_Data.config.who.doWhisper) - whoerConfigFrame:Add(doWhisperButton, 2, 3) - - local channels = CreateBasicSmallEditBox("HeimdallWhoerConfigChannels", - whoerConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.who.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.who.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.who.channels) - end) - whoerConfigFrame:Add(channels, 2, 3) - - local ttl = CreateBasicSmallEditBox("HeimdallWhoerConfigTTL", - whoerConfigFrame.frame, shared._L("ttl", Heimdall_Data.config.locale), - Heimdall_Data.config.who.ttl, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.who.ttl = tonumber(text) - print("TTL set to", tostring(text)) - else - print("Invalid TTL", tostring(text)) - self:SetText(Heimdall_Data.config.who.ttl) - end - end) - whoerConfigFrame:Add(ttl, 2, 3) - - local ignored = CreateBasicBigEditBox("HeimdallWhoerConfigIgnored", - whoerConfigFrame.frame, shared._L("ignored", Heimdall_Data.config.locale), - MapKeyToString(Heimdall_Data.config.who.ignored or {}, ","), - function(self) - local ignored = StringToMap(self:GetText(), ",") - Heimdall_Data.config.who.ignored = ignored - end) - whoerConfigFrame:Add(ignored, 4, 6) - - local zoneNotifyFor = CreateBasicBigEditBox("HeimdallWhoerConfigZoneNotifyFor", - whoerConfigFrame.frame, shared._L("zoneNotifyFor", Heimdall_Data.config.locale), - MapKeyToString(Heimdall_Data.config.who.zoneNotifyFor or {}, "\n"), - function(self) - local zoneNotifyFor = StringToMap(self:GetText(), "\n") - Heimdall_Data.config.who.zoneNotifyFor = zoneNotifyFor - end) - whoerConfigFrame:Add(zoneNotifyFor, 4, 6) - - local whoQueries = CreateBasicBigEditBox("HeimdallWhoerConfigQueries", - whoerConfigFrame.frame, shared._L("queries", Heimdall_Data.config.locale), - shared.WhoQueryService.WhoQueriesToString(shared.WhoQueryService.queries or {}), - function(self) - Heimdall_Data.config.who.queries = self:GetText() - shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(self:GetText()) - end) - whoerConfigFrame:Add(whoQueries, 12, 12) - end - - -- Messenger - do - local r, g, b, a = GetNextColor() - local messengerConfigFrame = GridFrame.new("HeimdallMessengerConfig", - UIParent, 12, 20) - messengerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(messengerConfigFrame, 6, 3) - - local title = CreateFancyText("HeimdallMessengerConfigTitle", messengerConfigFrame.frame, - shared._L("messenger", Heimdall_Data.config.locale), - { r, g, b, a }) - messengerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallMessengerConfigDebugButton", - messengerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.messenger.debug = not Heimdall_Data.config.messenger.debug - return Heimdall_Data.config.messenger.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.messenger.debug) - messengerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallMessengerConfigEnableButton", - messengerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.messenger.enabled = not Heimdall_Data.config.messenger.enabled - return Heimdall_Data.config.messenger.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.messenger.enabled) - messengerConfigFrame:Add(enableButton, 2, 3) - - local interval = CreateBasicSmallEditBox("HeimdallMessengerConfigInterval", - messengerConfigFrame.frame, shared._L("interval", Heimdall_Data.config.locale), - Heimdall_Data.config.messenger.interval, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.messenger.interval = tonumber(text) - print("Interval set to", tostring(text)) - else - print("Invalid interval", tostring(text)) - self:SetText(Heimdall_Data.config.messenger.interval) - end - end) - messengerConfigFrame:Add(interval, 2, 3) - end - - -- Death Reporter - do - local r, g, b, a = GetNextColor() - local deathReporterConfigFrame = GridFrame.new("HeimdallDeathReporterConfig", - UIParent, 12, 20) - deathReporterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(deathReporterConfigFrame, 10, 3) - - local title = CreateFancyText("HeimdallDeathReporterConfigTitle", deathReporterConfigFrame.frame, - shared._L("deathReporter", Heimdall_Data.config.locale), - { r, g, b, a }) - deathReporterConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallDeathReporterConfigDebugButton", - deathReporterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.deathReporter.debug = not Heimdall_Data.config.deathReporter.debug - return Heimdall_Data.config.deathReporter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.deathReporter.debug) - deathReporterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallDeathReporterConfigEnableButton", - deathReporterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.deathReporter.enabled = not Heimdall_Data.config.deathReporter.enabled - return Heimdall_Data.config.deathReporter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.deathReporter.enabled) - deathReporterConfigFrame:Add(enableButton, 1, 6) - - local doWhisperButton = CreateBasicButton("HeimdallDeathReporterConfigDoWhisperButton", - deathReporterConfigFrame.frame, shared._L("doWhisper", Heimdall_Data.config.locale), function() - Heimdall_Data.config.deathReporter.doWhisper = not Heimdall_Data.config.deathReporter.doWhisper - return Heimdall_Data.config.deathReporter.doWhisper - end) - doWhisperButton:UpdateColor(Heimdall_Data.config.deathReporter.doWhisper) - deathReporterConfigFrame:Add(doWhisperButton, 1, 6) - - local throttleTime = CreateBasicSmallEditBox("HeimdallDeathReporterConfigThrottleTime", - deathReporterConfigFrame.frame, shared._L("throttle", Heimdall_Data.config.locale), - Heimdall_Data.config.deathReporter.throttle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.deathReporter.throttle = tonumber(text) - print("Throttle time set to", tostring(text)) - else - print("Invalid throttle time", tostring(text)) - self:SetText(Heimdall_Data.config.deathReporter.throttle) - end - end) - deathReporterConfigFrame:Add(throttleTime, 2, 6) - - local duelThrottle = CreateBasicSmallEditBox("HeimdallDeathReporterConfigDuelThrottle", - deathReporterConfigFrame.frame, shared._L("duelThrottle", Heimdall_Data.config.locale), - Heimdall_Data.config.deathReporter.duelThrottle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.deathReporter.duelThrottle = tonumber(text) - print("Duel throttle set to", tostring(text)) - else - print("Invalid duel throttle", tostring(text)) - self:SetText(Heimdall_Data.config.deathReporter.duelThrottle) - end - end) - deathReporterConfigFrame:Add(duelThrottle, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallDeathReporterConfigChannels", - deathReporterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.deathReporter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.deathReporter.channels) - end) - deathReporterConfigFrame:Add(channels, 2, 6) - - local zoneOverride = CreateBasicSmallEditBox("HeimdallDeathReporterConfigZoneOverride", - deathReporterConfigFrame.frame, shared._L("zoneOverride", Heimdall_Data.config.locale), - Heimdall_Data.config.deathReporter.zoneOverride, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.deathReporter.zoneOverride = text - print("Zone override set to", tostring(text)) - else - print("Invalid zone override", tostring(text)) - self:SetText(Heimdall_Data.config.deathReporter.zoneOverride) - end - end) - deathReporterConfigFrame:Add(zoneOverride, 2, 6) - end - - -- Inviter - do - local r, g, b, a = GetNextColor() - local inviterConfigFrame = GridFrame.new("HeimdallInviterConfig", - UIParent, 12, 20) - inviterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(inviterConfigFrame, 13, 3) - - local title = CreateFancyText("HeimdallInviterConfigTitle", inviterConfigFrame.frame, - shared._L("inviter", Heimdall_Data.config.locale), { r, g, b, a }) - inviterConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallInviterConfigDebugButton", - inviterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.inviter.debug = not Heimdall_Data.config.inviter.debug - return Heimdall_Data.config.inviter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.inviter.debug) - inviterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallInviterConfigEnableButton", - inviterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.inviter.enabled = not Heimdall_Data.config.inviter.enabled - return Heimdall_Data.config.inviter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.inviter.enabled) - inviterConfigFrame:Add(enableButton, 1, 3) - - local allAssistButton = CreateBasicButton("HeimdallInviterConfigAllAssistButton", - inviterConfigFrame.frame, shared._L("allAssist", Heimdall_Data.config.locale), function() - Heimdall_Data.config.inviter.allAssist = not Heimdall_Data.config.inviter.allAssist - return Heimdall_Data.config.inviter.allAssist - end) - allAssistButton:UpdateColor(Heimdall_Data.config.inviter.allAssist) - inviterConfigFrame:Add(allAssistButton, 1, 3) - - local agentsAssist = CreateBasicButton("HeimdallInviterConfigAgentsAssistButton", - inviterConfigFrame.frame, shared._L("agentsAssist", Heimdall_Data.config.locale), function() - Heimdall_Data.config.inviter.agentsAssist = not Heimdall_Data.config.inviter.agentsAssist - return Heimdall_Data.config.inviter.agentsAssist - end) - agentsAssist:UpdateColor(Heimdall_Data.config.inviter.agentsAssist) - inviterConfigFrame:Add(agentsAssist, 1, 3) - - local kickOffline = CreateBasicButton("HeimdallInviterConfigKickOfflineButton", - inviterConfigFrame.frame, shared._L("kickOffline", Heimdall_Data.config.locale), function() - Heimdall_Data.config.inviter.kickOffline = not Heimdall_Data.config.inviter.kickOffline - return Heimdall_Data.config.inviter.kickOffline - end) - kickOffline:UpdateColor(Heimdall_Data.config.inviter.kickOffline) - inviterConfigFrame:Add(kickOffline, 1, 3) - - local throttle = CreateBasicSmallEditBox("HeimdallInviterConfigThrottle", - inviterConfigFrame.frame, shared._L("throttle", Heimdall_Data.config.locale), - Heimdall_Data.config.inviter.throttle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.inviter.throttle = tonumber(text) - print("Throttle time set to", tostring(text)) - else - print("Invalid throttle time", tostring(text)) - self:SetText(Heimdall_Data.config.inviter.throttle) - end - end) - inviterConfigFrame:Add(throttle, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallInviterConfigChannels", - inviterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.inviter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.inviter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.inviter.channels) - end) - inviterConfigFrame:Add(channels, 2, 6) - - local keyword = CreateBasicSmallEditBox("HeimdallInviterConfigKeywords", - inviterConfigFrame.frame, shared._L("keyword", Heimdall_Data.config.locale), - Heimdall_Data.config.inviter.keyword, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.inviter.keyword = text - print("Keyword set to", tostring(text)) - else - print("Invalid keyword", tostring(text)) - self:SetText(Heimdall_Data.config.inviter.keyword) - end - end) - inviterConfigFrame:Add(keyword, 2, 6) - - local cleanupInterval = CreateBasicSmallEditBox("HeimdallInviterConfigCleanupInterval", - inviterConfigFrame.frame, shared._L("cleanupInterval", Heimdall_Data.config.locale), - Heimdall_Data.config.inviter.cleanupInterval, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.inviter.cleanupInterval = tonumber(text) - print("Cleanup interval set to", tostring(text)) - else - print("Invalid cleanup interval", tostring(text)) - self:SetText(Heimdall_Data.config.inviter.cleanupInterval) - end - end) - inviterConfigFrame:Add(cleanupInterval, 2, 6) - - local afkThreshold = CreateBasicSmallEditBox("HeimdallInviterConfigAfkThreshold", - inviterConfigFrame.frame, shared._L("afkThreshold", Heimdall_Data.config.locale), - Heimdall_Data.config.inviter.afkThreshold, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.inviter.afkThreshold = tonumber(text) - print("Afk threshold set to", tostring(text)) - end - end) - inviterConfigFrame:Add(afkThreshold, 2, 6) - end - - -- Dueler - do - local r, g, b, a = GetNextColor() - local duelerConfigFrame = GridFrame.new("HeimdallDuelerConfig", - UIParent, 12, 20) - duelerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(duelerConfigFrame, 4, 3) - - local title = CreateFancyText("HeimdallDuelerConfigTitle", duelerConfigFrame.frame, - shared._L("dueler", Heimdall_Data.config.locale), { r, g, b, a }) - duelerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallDuelerConfigDebugButton", - duelerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.dueler.debug = not Heimdall_Data.config.dueler.debug - return Heimdall_Data.config.dueler.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.dueler.debug) - duelerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallInviterConfigEnableButton", - duelerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.dueler.enabled = not Heimdall_Data.config.dueler.enabled - return Heimdall_Data.config.dueler.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.dueler.enabled) - duelerConfigFrame:Add(enableButton, 1, 6) - - local declineOther = CreateBasicButton("HeimdallDuelerConfigDeclineOtherButton", - duelerConfigFrame.frame, shared._L("declineOther", Heimdall_Data.config.locale), function() - Heimdall_Data.config.dueler.declineOther = not Heimdall_Data.config.dueler.declineOther - return Heimdall_Data.config.dueler.declineOther - end) - declineOther:UpdateColor(Heimdall_Data.config.dueler.declineOther) - duelerConfigFrame:Add(declineOther, 1, 6) - end - - -- Agent Tracker - do - local r, g, b, a = GetNextColor() - local agentTrackerConfigFrame = GridFrame.new("HeimdallAgentTrackerConfig", - UIParent, 12, 20) - agentTrackerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(agentTrackerConfigFrame, 5, 3) - - local title = CreateFancyText("HeimdallAgentTrackerConfigTitle", agentTrackerConfigFrame.frame, - shared._L("agentTracker", Heimdall_Data.config.locale), - { r, g, b, a }) - agentTrackerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallAgentTrackerConfigDebugButton", - agentTrackerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.agentTracker.debug = not Heimdall_Data.config.agentTracker.debug - return Heimdall_Data.config.agentTracker.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.agentTracker.debug) - agentTrackerConfigFrame:Add(debugButton, 1, 4) - - - local enableButton = CreateBasicButton("HeimdallAgentTrackerConfigEnableButton", - agentTrackerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.agentTracker.enabled = not Heimdall_Data.config.agentTracker.enabled - return Heimdall_Data.config.agentTracker.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.agentTracker.enabled) - agentTrackerConfigFrame:Add(enableButton, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallAgentTrackerConfigChannels", - agentTrackerConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.agentTracker.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.agentTracker.channels) - end) - agentTrackerConfigFrame:Add(channels, 2, 6) - end - - -- Stinky Tracker - do - local r, g, b, a = GetNextColor() - local stinkyTrackerConfigFrame = GridFrame.new("HeimdallStinkyTrackerConfig", - UIParent, 12, 20) - stinkyTrackerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(stinkyTrackerConfigFrame, 5, 3) - - local title = CreateFancyText("HeimdallStinkyTrackerConfigTitle", stinkyTrackerConfigFrame.frame, - shared._L("stinkyTracker", Heimdall_Data.config.locale), { r, g, b, a }) - stinkyTrackerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallStinkyTrackerConfigDebugButton", - stinkyTrackerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.stinkyTracker.debug = not Heimdall_Data.config.stinkyTracker.debug - return Heimdall_Data.config.stinkyTracker.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.stinkyTracker.debug) - stinkyTrackerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallStinkyTrackerConfigEnableButton", - stinkyTrackerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.stinkyTracker.enabled = not Heimdall_Data.config.stinkyTracker.enabled - return Heimdall_Data.config.stinkyTracker.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.stinkyTracker.enabled) - stinkyTrackerConfigFrame:Add(enableButton, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallStinkyTrackerConfigChannels", - stinkyTrackerConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.stinkyTracker.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.stinkyTracker.channels) - end) - stinkyTrackerConfigFrame:Add(channels, 2, 6) - end - - -- Emoter - do - local r, g, b, a = GetNextColor() - local emoterConfigFrame = GridFrame.new("HeimdallEmoterConfig", - UIParent, 12, 20) - emoterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(emoterConfigFrame, 7, 3) - - local title = CreateFancyText("HeimdallEmoterConfigTitle", emoterConfigFrame.frame, - shared._L("emoter", Heimdall_Data.config.locale), - { r, g, b, a }) - emoterConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallEmoterConfigDebugButton", - emoterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.emoter.debug = not Heimdall_Data.config.emoter.debug - return Heimdall_Data.config.emoter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.emoter.debug) - emoterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallEmoterConfigEnableButton", - emoterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.emoter.enabled = not Heimdall_Data.config.emoter.enabled - return Heimdall_Data.config.emoter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.emoter.enabled) - emoterConfigFrame:Add(enableButton, 1, 12) - - local channels = CreateBasicSmallEditBox("HeimdallEmoterConfigChannels", - emoterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.emoter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.emoter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.emoter.channels) - end) - emoterConfigFrame:Add(channels, 2, 6) - - local prefix = CreateBasicSmallEditBox("HeimdallEmoterConfigPrefix", - emoterConfigFrame.frame, shared._L("prefix", Heimdall_Data.config.locale), - Heimdall_Data.config.emoter.prefix, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.emoter.prefix = text - print("Prefix set to", tostring(text)) - else - print("Invalid prefix", tostring(text)) - self:SetText(Heimdall_Data.config.emoter.prefix) - end - end) - emoterConfigFrame:Add(prefix, 2, 6) - end - - -- Echoer - do - local r, g, b, a = GetNextColor() - local echoerConfigFrame = GridFrame.new("HeimdallEchoerConfig", - UIParent, 12, 20) - echoerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(echoerConfigFrame, 7, 3) - - local title = CreateFancyText("HeimdallEchoerConfigTitle", echoerConfigFrame.frame, - shared._L("echoer", Heimdall_Data.config.locale), - { r, g, b, a }) - echoerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallEchoerConfigDebugButton", - echoerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.echoer.debug = not Heimdall_Data.config.echoer.debug - return Heimdall_Data.config.echoer.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.echoer.debug) - echoerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallEmoterConfigEnableButton", - echoerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.echoer.enabled = not Heimdall_Data.config.echoer.enabled - return Heimdall_Data.config.echoer.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.echoer.enabled) - echoerConfigFrame:Add(enableButton, 1, 12) - - local channels = CreateBasicSmallEditBox("HeimdallEmoterConfigChannels", - echoerConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.echoer.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.echoer.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.echoer.channels) - end) - echoerConfigFrame:Add(channels, 2, 6) - - local prefix = CreateBasicSmallEditBox("HeimdallEmoterConfigPrefix", - echoerConfigFrame.frame, shared._L("prefix", Heimdall_Data.config.locale), - Heimdall_Data.config.echoer.prefix, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.echoer.prefix = text - print("Prefix set to", tostring(text)) - else - print("Invalid prefix", tostring(text)) - self:SetText(Heimdall_Data.config.echoer.prefix) - end - end) - echoerConfigFrame:Add(prefix, 2, 6) - end - - -- Commander - do - local r, g, b, a = GetNextColor() - local commanderConfigFrame = GridFrame.new("HeimdallCommanderConfig", - UIParent, 12, 20) - commanderConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(commanderConfigFrame, 10, 3) - - local title = CreateFancyText("HeimdallCommanderConfigTitle", commanderConfigFrame.frame, - shared._L("commander", Heimdall_Data.config.locale), - { r, g, b, a }) - commanderConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallCommanderConfigDebugButton", - commanderConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.commander.debug = not Heimdall_Data.config.commander.debug - return Heimdall_Data.config.commander.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.commander.debug) - commanderConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallCommanderConfigEnableButton", - commanderConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.commander.enabled = not Heimdall_Data.config.commander.enabled - return Heimdall_Data.config.commander.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.commander.enabled) - commanderConfigFrame:Add(enableButton, 1, 12) - - local channels = CreateBasicSmallEditBox("HeimdallCommanderConfigChannels", - commanderConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.commander.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.commander.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.commander.channels) - end) - commanderConfigFrame:Add(channels, 2, 6) - - local commander = CreateBasicSmallEditBox("HeimdallCommanderConfigCommander", - commanderConfigFrame.frame, shared._L("commander", Heimdall_Data.config.locale), - Heimdall_Data.config.commander.commander, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.commander.commander = text - print("Commander set to", tostring(text)) - else - print("Invalid commander", tostring(text)) - self:SetText(Heimdall_Data.config.commander.commander) - end - end) - commanderConfigFrame:Add(commander, 2, 6) - - local commands = CreateBasicSmallEditBox("HeimdallCommanderConfigCommands", - commanderConfigFrame.frame, shared._L("commands", Heimdall_Data.config.locale), - MapKeyToString(Heimdall_Data.config.commander.commands, ", "), - function(self) - local text = self:GetText() - Heimdall_Data.config.commander.commands = StringToMap(text, ",") - end) - commanderConfigFrame:Add(commands, 2, 12) - end - - -- Macroer - do - local r, g, b, a = GetNextColor() - local macroerConfigFrame = GridFrame.new("HeimdallMacroerConfig", - UIParent, 12, 20) - macroerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(macroerConfigFrame, 6, 3) - - local title = CreateFancyText("HeimdallMacroerConfigTitle", macroerConfigFrame.frame, - shared._L("macroer", Heimdall_Data.config.locale), - { r, g, b, a }) - macroerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallMacroerConfigDebugButton", - macroerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.macroer.debug = not Heimdall_Data.config.macroer.debug - return Heimdall_Data.config.macroer.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.macroer.debug) - macroerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallCommanderConfigEnableButton", - macroerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.macroer.enabled = not Heimdall_Data.config.macroer.enabled - return Heimdall_Data.config.macroer.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.macroer.enabled) - macroerConfigFrame:Add(enableButton, 1, 12) - - local priority = CreateBasicSmallEditBox("HeimdallMacroerConfigPriority", - macroerConfigFrame.frame, shared._L("priority", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.macroer.priority, ", "), - function(self) - local text = self:GetText() - Heimdall_Data.config.macroer.priority = StringToArray(text, ",") - end) - macroerConfigFrame:Add(priority, 2, 12) - end - - -- Combat Alerter - do - local r, g, b, a = GetNextColor() - local combatAlerterConfigFrame = GridFrame.new("HeimdallCombatAlerterConfig", - UIParent, 12, 20) - combatAlerterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(combatAlerterConfigFrame, 5, 3) - - local title = CreateFancyText("HeimdallCombatAlerterConfigTitle", combatAlerterConfigFrame.frame, - shared._L("combatAlerter", Heimdall_Data.config.locale), - { r, g, b, a }) - combatAlerterConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallCombatAlerterConfigDebugButton", - combatAlerterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.combatAlerter.debug = not Heimdall_Data.config.combatAlerter.debug - return Heimdall_Data.config.combatAlerter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.combatAlerter.debug) - combatAlerterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallCombatAlerterConfigEnableButton", - combatAlerterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.combatAlerter.enabled = not Heimdall_Data.config.combatAlerter.enabled - return Heimdall_Data.config.combatAlerter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.combatAlerter.enabled) - combatAlerterConfigFrame:Add(enableButton, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallCombatAlerterConfigChannels", - combatAlerterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.combatAlerter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.combatAlerter.channels) - end) - combatAlerterConfigFrame:Add(channels, 2, 6) - end - - -- Sniffer - do - local r, g, b, a = GetNextColor() - local snifferConfigFrame = GridFrame.new("HeimdallSnifferConfig", - UIParent, 12, 20) - snifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(snifferConfigFrame, 8, 3) - - local title = CreateFancyText("HeimdallSnifferConfigTitle", snifferConfigFrame.frame, - shared._L("sniffer", Heimdall_Data.config.locale), - { r, g, b, a }) - snifferConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallSnifferConfigDebugButton", - snifferConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.sniffer.debug = not Heimdall_Data.config.sniffer.debug - return Heimdall_Data.config.sniffer.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.sniffer.debug) - snifferConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallSnifferConfigEnableButton", - snifferConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.sniffer.enabled = not Heimdall_Data.config.sniffer.enabled - return Heimdall_Data.config.sniffer.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.sniffer.enabled) - snifferConfigFrame:Add(enableButton, 2, 3) - - local stinkyButton = CreateBasicButton("HeimdallSnifferConfigStinkyButton", - snifferConfigFrame.frame, shared._L("stinky", Heimdall_Data.config.locale), function() - Heimdall_Data.config.sniffer.stinky = not Heimdall_Data.config.sniffer.stinky - return Heimdall_Data.config.sniffer.stinky - end) - stinkyButton:UpdateColor(Heimdall_Data.config.sniffer.stinky) - snifferConfigFrame:Add(stinkyButton, 2, 3) - - local channels = CreateBasicSmallEditBox("HeimdallSnifferConfigChannels", - snifferConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.sniffer.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.sniffer.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.sniffer.channels) - end) - snifferConfigFrame:Add(channels, 2, 6) - - local throttle = CreateBasicSmallEditBox("HeimdallSnifferConfigThrottle", - snifferConfigFrame.frame, shared._L("throttle", Heimdall_Data.config.locale), - Heimdall_Data.config.sniffer.throttle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.sniffer.throttle = tonumber(text) - print("Throttle set to", tostring(text)) - else - print("Invalid throttle", tostring(text)) - self:SetText(Heimdall_Data.config.sniffer.throttle) - end - end) - snifferConfigFrame:Add(throttle, 2, 6) - - local zoneOverride = CreateBasicSmallEditBox("HeimdallSnifferConfigZoneOverride", - snifferConfigFrame.frame, shared._L("zoneOverride", Heimdall_Data.config.locale), - Heimdall_Data.config.sniffer.zoneOverride, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.sniffer.zoneOverride = text - print("Zone override set to", tostring(text)) - else - print("Invalid zone override", tostring(text)) - self:SetText(Heimdall_Data.config.sniffer.zoneOverride) - end - end) - snifferConfigFrame:Add(zoneOverride, 2, 6) - end - - -- BonkDetector - do - local r, g, b, a = GetNextColor() - local bonkDetectorConfigFrame = GridFrame.new("HeimdallBonkDetectorConfig", - UIParent, 12, 20) - bonkDetectorConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(bonkDetectorConfigFrame, 7, 3) - - local title = CreateFancyText("HeimdallBonkDetectorConfigTitle", bonkDetectorConfigFrame.frame, - shared._L("bonkDetector", Heimdall_Data.config.locale), - { r, g, b, a }) - bonkDetectorConfigFrame:Add(title, 1, 8) - - local debugButton = CreateBasicButton("HeimdallBonkDetectorConfigDebugButton", - bonkDetectorConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.bonkDetector.debug = not Heimdall_Data.config.bonkDetector.debug - return Heimdall_Data.config.bonkDetector.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.bonkDetector.debug) - bonkDetectorConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallBonkDetectorConfigEnableButton", - bonkDetectorConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.bonkDetector.enabled = not Heimdall_Data.config.bonkDetector.enabled - return Heimdall_Data.config.bonkDetector.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.bonkDetector.enabled) - bonkDetectorConfigFrame:Add(enableButton, 1, 12) - - local channels = CreateBasicSmallEditBox("HeimdallBonkDetectorConfigChannels", - bonkDetectorConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.bonkDetector.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.bonkDetector.channels) - end) - bonkDetectorConfigFrame:Add(channels, 2, 6) - - local throttle = CreateBasicSmallEditBox("HeimdallBonkDetectorConfigThrottle", - bonkDetectorConfigFrame.frame, shared._L("throttle", Heimdall_Data.config.locale), - Heimdall_Data.config.bonkDetector.throttle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.bonkDetector.throttle = tonumber(text) - print("Throttle set to", tostring(text)) - else - print("Invalid throttle", tostring(text)) - self:SetText(Heimdall_Data.config.bonkDetector.throttle) - end - end) - bonkDetectorConfigFrame:Add(throttle, 2, 6) - end - - -- Minimap Tagger - do - local r, g, b, a = GetNextColor() - local minimapTaggerConfigFrame = GridFrame.new("HeimdallMinimapTaggerConfig", - UIParent, 12, 20) - minimapTaggerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(minimapTaggerConfigFrame, 18, 6) - - local title = CreateFancyText("HeimdallMinimapTaggerConfigTitle", minimapTaggerConfigFrame.frame, - shared._L("minimapTagger", Heimdall_Data.config.locale), - { r, g, b, a }) - minimapTaggerConfigFrame:Add(title, 1, 8) - local debugButton = CreateBasicButton("HeimdallMinimapTaggerConfigDebugButton", - minimapTaggerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.debug = not Heimdall_Data.config.minimapTagger.debug - return Heimdall_Data.config.minimapTagger.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.minimapTagger.debug) - minimapTaggerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallMinimapTaggerConfigEnableButton", - minimapTaggerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.enabled = not Heimdall_Data.config.minimapTagger.enabled - return Heimdall_Data.config.minimapTagger.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.minimapTagger.enabled) - minimapTaggerConfigFrame:Add(enableButton, 2, 6) - - local channels = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigChannels", - minimapTaggerConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.minimapTagger.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.minimapTagger.channels) - end) - minimapTaggerConfigFrame:Add(channels, 2, 3) - - local scale = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigScale", - minimapTaggerConfigFrame.frame, shared._L("scale", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.scale, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.scale = tonumber(text) - print("Scale set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(scale, 2, 3) - - --region Tag - local tagSound = CreateBasicButton("HeimdallMinimapTaggerConfigTagSound", - minimapTaggerConfigFrame.frame, shared._L("tagSound", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.tagSound = not Heimdall_Data.config.minimapTagger.tagSound - return Heimdall_Data.config.minimapTagger.tagSound - end) - tagSound:UpdateColor(Heimdall_Data.config.minimapTagger.tagSound) - minimapTaggerConfigFrame:Add(tagSound, 2, 1) - - local tagTTL = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigTagTTL", - minimapTaggerConfigFrame.frame, shared._L("ttl", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.tagTTL, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.tagTTL = tonumber(text) - print("Tag TTL set to", tostring(text)) - else - print("Invalid tag TTL", tostring(text)) - self:SetText(Heimdall_Data.config.minimapTagger.tagTTL) - end - end) - minimapTaggerConfigFrame:Add(tagTTL, 2, 1) - - local tagSoundThrottle = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigTagSoundThrottle", - minimapTaggerConfigFrame.frame, shared._L("soundThrottle", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.tagSoundThrottle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.tagSoundThrottle = tonumber(text) - print("Tag sound throttle set to", tostring(text)) - else - print("Invalid tag sound throttle", tostring(text)) - self:SetText(Heimdall_Data.config.minimapTagger.tagSoundThrottle) - end - end) - minimapTaggerConfigFrame:Add(tagSoundThrottle, 2, 2) - - local tagSoundFile = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigTagSoundFile", - minimapTaggerConfigFrame.frame, shared._L("soundFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.tagSoundFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.tagSoundFile = text - print("Tag sound file set to", tostring(text)) - else - print("Invalid tag sound file", tostring(text)) - self:SetText(Heimdall_Data.config.minimapTagger.tagSoundFile) - end - end) - minimapTaggerConfigFrame:Add(tagSoundFile, 2, 4) - - local tagTexture = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigTagTexture", - minimapTaggerConfigFrame.frame, shared._L("textureFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.tagTextureFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.tagTextureFile = text - print("Tag texture file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(tagTexture, 2, 4) - --endregion - --region Alert - local alertSound = CreateBasicButton("HeimdallMinimapTaggerConfigAlertSound", - minimapTaggerConfigFrame.frame, shared._L("alertSound", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.alertSound = not Heimdall_Data.config.minimapTagger.alertSound - return Heimdall_Data.config.minimapTagger.alertSound - end) - alertSound:UpdateColor(Heimdall_Data.config.minimapTagger.alertSound) - minimapTaggerConfigFrame:Add(alertSound, 2, 1) - - local alertTTL = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigAlertTTL", - minimapTaggerConfigFrame.frame, shared._L("ttl", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.alertTTL, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.alertTTL = tonumber(text) - print("Alert TTL set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(alertTTL, 2, 1) - - local alertSoundThrottle = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigAlertSoundThrottle", - minimapTaggerConfigFrame.frame, shared._L("soundThrottle", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.alertSoundThrottle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.alertSoundThrottle = tonumber(text) - print("Alert sound throttle set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(alertSoundThrottle, 2, 2) - - local alertSoundFile = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigAlertSoundFile", - minimapTaggerConfigFrame.frame, shared._L("soundFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.alertSoundFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.alertSoundFile = text - print("Alert sound file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(alertSoundFile, 2, 4) - - local alertTexture = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigAlertTexture", - minimapTaggerConfigFrame.frame, shared._L("textureFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.alertTextureFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.alertTextureFile = text - print("Alert texture file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(alertTexture, 2, 4) - --endregion - --region Combat - local combatSound = CreateBasicButton("HeimdallMinimapTaggerConfigCombatSound", - minimapTaggerConfigFrame.frame, shared._L("combatSound", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.combatSound = not Heimdall_Data.config.minimapTagger.combatSound - return Heimdall_Data.config.minimapTagger.combatSound - end) - combatSound:UpdateColor(Heimdall_Data.config.minimapTagger.combatSound) - minimapTaggerConfigFrame:Add(combatSound, 2, 1) - - local combatTTL = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigCombatTTL", - minimapTaggerConfigFrame.frame, shared._L("ttl", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.combatTTL, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.combatTTL = tonumber(text) - print("Combat TTL set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(combatTTL, 2, 1) - - local combatSoundThrottle = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigCombatSoundThrottle", - minimapTaggerConfigFrame.frame, shared._L("soundThrottle", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.combatSoundThrottle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.combatSoundThrottle = tonumber(text) - print("Combat sound throttle set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(combatSoundThrottle, 2, 2) - - - local combatSoundFile = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigCombatSoundFile", - minimapTaggerConfigFrame.frame, shared._L("soundFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.combatSoundFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.combatSoundFile = text - print("Combat sound file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(combatSoundFile, 2, 4) - local combatTexture = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigCombatTexture", - minimapTaggerConfigFrame.frame, shared._L("textureFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.combatTextureFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.combatTextureFile = text - print("Combat texture file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(combatTexture, 2, 4) - --endregion - --region Help - local helpSound = CreateBasicButton("HeimdallMinimapTaggerConfigHelpSound", - minimapTaggerConfigFrame.frame, shared._L("helpSound", Heimdall_Data.config.locale), function() - Heimdall_Data.config.minimapTagger.helpSound = not Heimdall_Data.config.minimapTagger.helpSound - return Heimdall_Data.config.minimapTagger.helpSound - end) - helpSound:UpdateColor(Heimdall_Data.config.minimapTagger.helpSound) - minimapTaggerConfigFrame:Add(helpSound, 2, 1) - - local helpTTL = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigHelpTTL", - minimapTaggerConfigFrame.frame, shared._L("ttl", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.helpTTL, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.helpTTL = tonumber(text) - print("Help TTL set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(helpTTL, 2, 1) - - local helpSoundThrottle = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigHelpSoundThrottle", - minimapTaggerConfigFrame.frame, shared._L("soundThrottle", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.helpSoundThrottle, - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.minimapTagger.helpSoundThrottle = tonumber(text) - print("Help sound throttle set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(helpSoundThrottle, 2, 2) - - - local helpSoundFile = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigHelpSoundFile", - minimapTaggerConfigFrame.frame, shared._L("soundFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.helpSoundFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.helpSoundFile = text - print("Help sound file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(helpSoundFile, 2, 4) - local helpTexture = CreateBasicSmallEditBox("HeimdallMinimapTaggerConfigHelpTexture", - minimapTaggerConfigFrame.frame, shared._L("textureFile", Heimdall_Data.config.locale), - Heimdall_Data.config.minimapTagger.helpTextureFile, - function(self) - local text = self:GetText() - if string.match(text, "%S+") then - Heimdall_Data.config.minimapTagger.helpTextureFile = text - print("Help texture file set to", tostring(text)) - end - end) - minimapTaggerConfigFrame:Add(helpTexture, 2, 4) - --endregion - end - - -- Noter - do - local r, g, b, a = GetNextColor() - local noterConfigFrame = GridFrame.new("HeimdallNoterConfig", - UIParent, 12, 20) - noterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(noterConfigFrame, 7, 3) - - local title = CreateFancyText("HeimdallNoterConfigTitle", noterConfigFrame.frame, - shared._L("noter", Heimdall_Data.config.locale), - { r, g, b, a }) - noterConfigFrame:Add(title, 1, 8) - - local debugButton = CreateBasicButton("HeimdallNoterConfigDebugButton", - noterConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.noter.debug = not Heimdall_Data.config.noter.debug - return Heimdall_Data.config.noter.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.noter.debug) - noterConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallNoterConfigEnableButton", - noterConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.noter.enabled = not Heimdall_Data.config.noter.enabled - return Heimdall_Data.config.noter.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.noter.enabled) - noterConfigFrame:Add(enableButton, 1, 12) - - local channels = CreateBasicSmallEditBox("HeimdallNoterConfigChannels", - noterConfigFrame.frame, shared._L("channels", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.noter.channels or {}, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.noter.channels = StringToArray(text, ",") - print("Channels set to") - shared.dumpTable(Heimdall_Data.config.noter.channels) - end) - noterConfigFrame:Add(channels, 2, 6) - - local lastNotes = CreateBasicSmallEditBox("HeimdallNoterConfigLastNotes", - noterConfigFrame.frame, shared._L("lastNotes", Heimdall_Data.config.locale), - tostring(Heimdall_Data.config.noter.lastNotes), - function(self) - local text = self:GetText() - local value = tonumber(text) - if value and value > 0 then - Heimdall_Data.config.noter.lastNotes = value - print("Last notes set to", value) - else - print("Invalid number of last notes", text) - self:SetText(tostring(Heimdall_Data.config.noter.lastNotes)) - end - end) - noterConfigFrame:Add(lastNotes, 2, 6) - end - - -- Network - do - local r, g, b, a = GetNextColor() - local networkConfigFrame = GridFrame.new("HeimdallNetworkConfig", - UIParent, 12, 20) - networkConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(networkConfigFrame, 11, 3) - - local title = CreateFancyText("HeimdallNetworkConfigTitle", networkConfigFrame.frame, - shared._L("network", Heimdall_Data.config.locale), - { r, g, b, a }) - networkConfigFrame:Add(title, 1, 8) - - local debugButton = CreateBasicButton("HeimdallNetworkConfigDebugButton", - networkConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.network.debug = not Heimdall_Data.config.network.debug - return Heimdall_Data.config.network.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.network.debug) - networkConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallNetworkConfigEnableButton", - networkConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.network.enabled = not Heimdall_Data.config.network.enabled - return Heimdall_Data.config.network.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.network.enabled) - networkConfigFrame:Add(enableButton, 1, 12) - - local members = CreateBasicBigEditBox("HeimdallNetworkConfigMembers", - networkConfigFrame.frame, shared._L("members", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.network.members, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.network.members = StringToArray(text, ",") - print("Members set to", table.concat(Heimdall_Data.config.network.members, ",")) - self:SetText(table.concat(Heimdall_Data.config.network.members, ",")) - end) - networkConfigFrame:Add(members, 5, 6) - - local updateInterval = CreateBasicSmallEditBox("HeimdallNetworkConfigUpdateInterval", - networkConfigFrame.frame, shared._L("updateInterval", Heimdall_Data.config.locale), - tostring(Heimdall_Data.config.network.updateInterval), - function(self) - local text = self:GetText() - if string.match(text, "%d+") then - Heimdall_Data.config.network.updateInterval = tonumber(text) - print("Update interval set to", tostring(text)) - else - print("Invalid update interval", text) - self:SetText(tostring(Heimdall_Data.config.network.updateInterval)) - end - end) - networkConfigFrame:Add(updateInterval, 2, 6) - end - - -- NetworkMessenger - do - local r, g, b, a = GetNextColor() - local networkMessengerConfigFrame = GridFrame.new("HeimdallNetworkMessengerConfig", - UIParent, 12, 20) - networkMessengerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(networkMessengerConfigFrame, 5, 3) - - local title = CreateFancyText("HeimdallNetworkMessengerConfigTitle", networkMessengerConfigFrame.frame, - shared._L("networkMessenger", Heimdall_Data.config.locale), - { r, g, b, a }) - networkMessengerConfigFrame:Add(title, 1, 8) - - local debugButton = CreateBasicButton("HeimdallNetworkMessengerConfigDebugButton", - networkMessengerConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.networkMessenger.debug = not Heimdall_Data.config.networkMessenger.debug - return Heimdall_Data.config.networkMessenger.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.networkMessenger.debug) - networkMessengerConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallNetworkMessengerConfigEnableButton", - networkMessengerConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.networkMessenger.enabled = not Heimdall_Data.config.networkMessenger.enabled - return Heimdall_Data.config.networkMessenger.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.networkMessenger.enabled) - networkMessengerConfigFrame:Add(enableButton, 2, 6) - - local interval = CreateBasicSmallEditBox("HeimdallNetworkMessengerConfigInterval", - networkMessengerConfigFrame.frame, shared._L("interval", Heimdall_Data.config.locale), - tostring(Heimdall_Data.config.networkMessenger.interval), - function(self) - local text = self:GetText() - if string.match(text, "^%d+%.?%d*$") then - Heimdall_Data.config.networkMessenger.interval = tonumber(text) - print("Interval set to", tostring(text)) - else - print("Invalid interval", text) - self:SetText(tostring(Heimdall_Data.config.networkMessenger.interval)) - end - end) - networkMessengerConfigFrame:Add(interval, 2, 6) - end - - -- AchievementSniffer - do - local r, g, b, a = GetNextColor() - local achievementSnifferConfigFrame = GridFrame.new("HeimdallAchievementSnifferConfig", - UIParent, 12, 20) - achievementSnifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(achievementSnifferConfigFrame, 14, 3) - - local title = CreateFancyText("HeimdallAchievementSnifferConfigTitle", achievementSnifferConfigFrame.frame, - shared._L("achievementSniffer", Heimdall_Data.config.locale), - { r, g, b, a }) - achievementSnifferConfigFrame:Add(title, 1, 8) - - local debugButton = CreateBasicButton("HeimdallAchievementSnifferConfigDebugButton", - achievementSnifferConfigFrame.frame, shared._L("debug", Heimdall_Data.config.locale), function() - Heimdall_Data.config.achievementSniffer.debug = not Heimdall_Data.config.achievementSniffer.debug - return Heimdall_Data.config.achievementSniffer.debug - end) - debugButton:UpdateColor(Heimdall_Data.config.achievementSniffer.debug) - achievementSnifferConfigFrame:Add(debugButton, 1, 4) - - local enableButton = CreateBasicButton("HeimdallAchievementSnifferConfigEnableButton", - achievementSnifferConfigFrame.frame, shared._L("enabled", Heimdall_Data.config.locale), function() - Heimdall_Data.config.achievementSniffer.enabled = not Heimdall_Data.config.achievementSniffer.enabled - return Heimdall_Data.config.achievementSniffer.enabled - end) - enableButton:UpdateColor(Heimdall_Data.config.achievementSniffer.enabled) - achievementSnifferConfigFrame:Add(enableButton, 2, 3) - - --local texture = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigTexture", - -- achievementSnifferConfigFrame.frame, shared._L("texture", Heimdall_Data.config.locale), - -- Heimdall_Data.config.achievementSniffer.texture, - -- function(self) - -- local text = self:GetText() - -- Heimdall_Data.config.achievementSniffer.texture = text - -- end) - --achievementSnifferConfigFrame:Add(texture, 2, 3) - - --local offsetX = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigOffsetX", - -- achievementSnifferConfigFrame.frame, shared._L("offsetX", Heimdall_Data.config.locale), - -- tostring(Heimdall_Data.config.achievementSniffer.offsetX), - -- function(self) - -- local text = self:GetText() - -- if string.match(text, "%d+") then - -- Heimdall_Data.config.achievementSniffer.offsetX = tonumber(text) - -- print("Offset X set to", tostring(text)) - -- else - -- print("Invalid offset X", text) - -- self:SetText(tostring(Heimdall_Data.config.achievementSniffer.offsetX)) - -- end - -- end) - --achievementSnifferConfigFrame:Add(offsetX, 2, 3) - - --local offsetY = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigOffsetY", - -- achievementSnifferConfigFrame.frame, shared._L("offsetY", Heimdall_Data.config.locale), - -- tostring(Heimdall_Data.config.achievementSniffer.offsetY), - -- function(self) - -- local text = self:GetText() - -- if string.match(text, "%d+") then - -- Heimdall_Data.config.achievementSniffer.offsetY = tonumber(text) - -- print("Offset Y set to", tostring(text)) - -- else - -- print("Invalid offset Y", text) - -- self:SetText(tostring(Heimdall_Data.config.achievementSniffer.offsetY)) - -- end - -- end) - --achievementSnifferConfigFrame:Add(offsetY, 2, 3) - - local rescan = CreateBasicButton("HeimdallAchievementSnifferConfigRescanButton", - achievementSnifferConfigFrame.frame, shared._L("rescan", Heimdall_Data.config.locale), function() - Heimdall_Data.config.achievementSniffer.rescan = not Heimdall_Data.config.achievementSniffer.rescan - return Heimdall_Data.config.achievementSniffer.rescan - end) - rescan:UpdateColor(Heimdall_Data.config.achievementSniffer.rescan) - achievementSnifferConfigFrame:Add(rescan, 2, 3) - - local scanInterval = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigScanInterval", - achievementSnifferConfigFrame.frame, shared._L("scanInterval", Heimdall_Data.config.locale), - tostring(Heimdall_Data.config.achievementSniffer.scanInterval), - function(self) - local text = self:GetText() - Heimdall_Data.config.achievementSniffer.scanInterval = tonumber(text) - end) - achievementSnifferConfigFrame:Add(scanInterval, 2, 3) - - --local iconScale = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigIconScale", - -- achievementSnifferConfigFrame.frame, shared._L("iconScale", Heimdall_Data.config.locale), - -- tostring(Heimdall_Data.config.achievementSniffer.iconScale), - -- function(self) - -- local text = self:GetText() - -- Heimdall_Data.config.achievementSniffer.iconScale = tonumber(text) - -- end) - --achievementSnifferConfigFrame:Add(iconScale, 2, 3) - end - - -- Addon prefix - do - local r, g, b, a = GetNextColor() - local addonPrefixConfigFrame = GridFrame.new("HeimdallAddonPrefixConfig", - UIParent, 12, 20) - addonPrefixConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(addonPrefixConfigFrame, 5, 1) - - local title = CreateFancyText("HeimdallAddonPrefixConfigTitle", addonPrefixConfigFrame.frame, - shared._L("addonPrefix", Heimdall_Data.config.locale), - { r, g, b, a }) - addonPrefixConfigFrame:Add(title, 1, 12) - - local addonPrefix = CreateBasicSmallEditBox("HeimdallAddonPrefixConfigAddonPrefix", - addonPrefixConfigFrame.frame, shared._L("addonPrefix", Heimdall_Data.config.locale), - Heimdall_Data.config.addonPrefix, - function(self) - local text = self:GetText() - Heimdall_Data.config.addonPrefix = text - end) - addonPrefixConfigFrame:Add(addonPrefix, 2, 12) - end - - -- Whisper Notify - do - local r, g, b, a = GetNextColor() - local whisperNotifyConfigFrame = GridFrame.new("HeimdallWhisperNotifyConfig", - UIParent, 12, 20) - whisperNotifyConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(whisperNotifyConfigFrame, 14, 1) - - local title = CreateFancyText("HeimdallWhisperNotifyConfigTitle", whisperNotifyConfigFrame.frame, - shared._L("whisperNotify", Heimdall_Data.config.locale), - { r, g, b, a }) - whisperNotifyConfigFrame:Add(title, 1, 12) - - local whisperNotify = CreateBasicBigEditBox("HeimdallWhisperNotifyConfigWhisperNotify", - whisperNotifyConfigFrame.frame, shared._L("whisperNotify", Heimdall_Data.config.locale), - table.concat(Heimdall_Data.config.whisperNotify, "\n"), - function(self) - local text = self:GetText() - Heimdall_Data.config.whisperNotify = StringToArray(text, "\n") - end) - whisperNotifyConfigFrame:Add(whisperNotify, 8, 12) - end - - -- Stinkies - do - local r, g, b, a = GetNextColor() - local stinkiesConfigFrame = GridFrame.new("HeimdallStinkiesConfig", - UIParent, 12, 20) - stinkiesConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(stinkiesConfigFrame, 28, 6) - -- Why do 17 rows of content fit into a frame that is 14 rows? - -- I don't know, at this point I can't be fucked to fix it, the display is minimally functional - - local title = CreateFancyText("HeimdallStinkiesConfigTitle", stinkiesConfigFrame.frame, - shared._L("stinkies", Heimdall_Data.config.locale), - { r, g, b, a }) - stinkiesConfigFrame:Add(title, 1, 12) - - local stinkies = CreateBasicBigEditBox("HeimdallStinkiesConfigStinkies", - stinkiesConfigFrame.frame, shared._L("stinkies", Heimdall_Data.config.locale), - MapKeyToString(Heimdall_Data.config.stinkies, ","), - function(self) - local text = self:GetText() - Heimdall_Data.config.stinkies = StringToMap(text, ",") - end) - stinkiesConfigFrame:Add(stinkies, 16, 12) - end - - -- Channel locale - do - local r, g, b, a = GetNextColor() - local channelLocaleConfigFrame = GridFrame.new("HeimdallChannelLocaleConfig", - UIParent, 12, 20) - channelLocaleConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) - configFrame:Add(channelLocaleConfigFrame, 14, 1) - - local title = CreateFancyText("HeimdallChannelLocaleConfigTitle", channelLocaleConfigFrame.frame, - shared._L("channelLocale", Heimdall_Data.config.locale), - { r, g, b, a }) - channelLocaleConfigFrame:Add(title, 1, 12) - - local channelLocale = CreateBasicBigEditBox("HeimdallChannelLocaleConfigChannelLocale", - channelLocaleConfigFrame.frame, shared._L("channelLocale", Heimdall_Data.config.locale), - MapToString(Heimdall_Data.config.channelLocale, ":", "\n"), - function(self) - local text = self:GetText() - Heimdall_Data.config.channelLocale = MapFromString(text, ":", "\n") - end) - channelLocaleConfigFrame:Add(channelLocale, 8, 12) - end - - --configFrame.frame:Hide() - print("[Heimdall] Config loaded") + configFrame.frame:SetScale(Heimdall_Data.config.scale) + + local buttonColors = { + enabled = { 0, 1, 0, 1 }, + disabled = { 1, 0, 0, 1 }, + } + local function CreateFancyText(name, parent, text, color) + local r, g, b, a = unpack(color) + local textFrame = CreateFrame("Frame", name .. "TextFrame", parent) + local textElement = textFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal") + textElement:SetText(text) + textElement:SetTextColor(r, g, b, a) + textElement:SetPoint("CENTER", textFrame, "CENTER", 0, 0) + textFrame:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 2, + edgeSize = 12, + }) + textFrame:SetBackdropColor(r, g, b, 0.3) + textFrame:SetBackdropBorderColor(r, g, b, 0.5) + return textFrame + end + ---@param name string + ---@param parent Frame + ---@param onClick fun(): boolean + local function CreateBasicButton(name, parent, text, onClick) + local button = CreateFrame("Frame", name, parent) + button:SetScript("OnMouseDown", function() + local res = onClick() + local color = res and buttonColors.enabled or buttonColors.disabled + button:SetBackdropColor(unpack(color)) + end) + button:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 2, + edgeSize = 12, + insets = { + left = 2, + right = 2, + top = 2, + bottom = 2, + }, + }) + button.UpdateColor = function(self, state) + local color = state and buttonColors.enabled or buttonColors.disabled + self:SetBackdropColor(unpack(color)) + end + --spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled) + local spotterEnableButtonLabel = button:CreateFontString(nil, "OVERLAY", "GameFontNormal") + spotterEnableButtonLabel:SetText(text or "") + spotterEnableButtonLabel:SetAllPoints(button) + return button + end + ---@param name string + ---@param parent Frame + ---@param text string + ---@param onDone fun(editBox: Frame) + local function CreateBasicSmallEditBox(name, parent, text, initialValue, onDone) + local container = GridFrame.new(name, parent, 1, 1) + local editBoxFrame = CreateFrame("Frame", name .. "EditBoxFrame", container.frame) + local editBox = CreateFrame("EditBox", name .. "EditBox", editBoxFrame) + local textFrame = CreateFrame("Frame", name .. "TextFrame", container.frame) + local textElement = textFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") + textElement:SetText(text) + + editBox:SetAutoFocus(false) + editBox:SetFontObject("GameFontNormal") + editBox:SetText(Heimdall_Data.config.spotter.throttleTime) + editBox:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 2, + edgeSize = 12, + insets = { + left = 2, + right = 2, + top = 2, + bottom = 2, + }, + }) + editBox:SetBackdropColor(0.8, 0.8, 0.8, 1) + editBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) + editBox:SetTextInsets(6, 6, 0, 0) + editBox:SetScript("OnEnterPressed", function() editBox:ClearFocus() end) + editBox:SetScript("OnEscapePressed", function() editBox:ClearFocus() end) + editBox:SetScript("OnEditFocusLost", function() onDone(editBox) end) + editBox:SetText(initialValue or "") + container:Add(textFrame, 1, 1) + container:Add(editBox, 2, 1) + textElement:SetPoint("TOPLEFT", textFrame, "TOPLEFT", 2, -2) + return container + end + ---@param name string + ---@param parent Frame + ---@param text string + ---@param onDone fun(editBox: Frame) + local function CreateBasicBigEditBox(name, parent, text, initialValue, onDone) + local container = GridFrame.new(name, parent, 1, 100) + local editBoxFrame = CreateFrame("Frame", name .. "EditBoxFrame", container.frame) + local editBox = CreateFrame("EditBox", name .. "EditBox", editBoxFrame) + local textFrame = CreateFrame("Frame", name .. "TextFrame", container.frame) + local textElement = textFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") + textElement:SetText(text) + + editBoxFrame:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 2, + edgeSize = 12, + insets = { + left = 2, + right = 2, + top = 2, + bottom = 2, + }, + }) + editBoxFrame:SetBackdropColor(0.8, 0.8, 0.8, 1) + editBoxFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) + + editBox:SetAllPoints(editBoxFrame) + editBox:SetAutoFocus(false) + editBox:SetFontObject("GameFontNormal") + editBox:SetText(initialValue or "") + editBox:SetTextInsets(6, 6, 6, 6) + editBox:SetMultiLine(true) + editBox:SetSize(280, 100) + editBox:SetMaxLetters(100000) + editBox:SetScript("OnEscapePressed", function() editBox:ClearFocus() end) + editBox:SetScript("OnEditFocusLost", function() onDone(editBox) end) + container:Add(textFrame, 1, 1) + container:Add(editBoxFrame, 7, 1) + textElement:SetPoint("TOPLEFT", textFrame, "TOPLEFT", 2, -2) + return container + end + + local scale = CreateBasicSmallEditBox( + "HeimdallConfigScale", + configFrame.frame, + "Scale", + Heimdall_Data.config.scale, + function(self) + local text = self:GetText() + if string.match(text, "^%d+%.*%d*$") then + Heimdall_Data.config.scale = tonumber(text) + configFrame.frame:SetScale(Heimdall_Data.config.scale) + else + print(string.format("Invalid scale: %s, please use numbers", text)) + self:SetText(Heimdall_Data.config.scale) + end + end + ) + configFrame:Add(scale, 2, 2) + local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") + title:SetText(string.format("%s - v%s", shared._L("heimdallConfig", Heimdall_Data.config.locale), shared.VERSION)) + configFrame:Add(title, 2, 7) + + local debug = CreateBasicButton( + "HeimdallConfigDebug", + configFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.debug = not Heimdall_Data.config.debug + return Heimdall_Data.config.debug + end + ) + debug:UpdateColor(Heimdall_Data.config.debug) + configFrame:Add(debug, 2, 1) + + local russian = nil + local english = CreateBasicButton( + "HeimdallConfigEnglish", + configFrame.frame, + shared._L("english", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.locale = "en" + russian:UpdateColor(false) + return Heimdall_Data.config.locale == "en" + end + ) + english:UpdateColor(Heimdall_Data.config.locale == "en") + russian = CreateBasicButton( + "HeimdallConfigRussian", + configFrame.frame, + shared._L("russian", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.locale = "ru" + english:UpdateColor(false) + return Heimdall_Data.config.locale == "ru" + end + ) + russian:UpdateColor(Heimdall_Data.config.locale == "ru") + configFrame:Add(english, 2, 1) + configFrame:Add(russian, 2, 1) + + -- Spotter + do + local r, g, b, a = GetNextColor() + local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig", UIParent, 12, 20) + spotterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(spotterConfigFrame, 9, 3) + + local title = CreateFancyText( + "HeimdallSpotterConfigTitle", + spotterConfigFrame.frame, + shared._L("spotter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + spotterConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallSpotterConfigDebugButton", + spotterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.debug = not Heimdall_Data.config.spotter.debug + return Heimdall_Data.config.spotter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.spotter.debug) + spotterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallSpotterConfigEnableButton", + spotterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.enabled = not Heimdall_Data.config.spotter.enabled + return Heimdall_Data.config.spotter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.spotter.enabled) + spotterConfigFrame:Add(enableButton, 1, 6) + + local everyoneButton = CreateBasicButton( + "HeimdallSpotterConfigEveryoneButton", + spotterConfigFrame.frame, + shared._L("everyone", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.everyone = not Heimdall_Data.config.spotter.everyone + return Heimdall_Data.config.spotter.everyone + end + ) + everyoneButton:UpdateColor(Heimdall_Data.config.spotter.everyone) + spotterConfigFrame:Add(everyoneButton, 1, 6) + + local hostileButton = CreateBasicButton( + "HeimdallSpotterConfigHostileButton", + spotterConfigFrame.frame, + shared._L("hostile", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.hostile = not Heimdall_Data.config.spotter.hostile + return Heimdall_Data.config.spotter.hostile + end + ) + hostileButton:UpdateColor(Heimdall_Data.config.spotter.hostile) + spotterConfigFrame:Add(hostileButton, 1, 4) + + local allianceButton = CreateBasicButton( + "HeimdallSpotterConfigAllianceButton", + spotterConfigFrame.frame, + shared._L("alliance", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.alliance = not Heimdall_Data.config.spotter.alliance + return Heimdall_Data.config.spotter.alliance + end + ) + allianceButton:UpdateColor(Heimdall_Data.config.spotter.alliance) + spotterConfigFrame:Add(allianceButton, 1, 4) + + local stinkyButton = CreateBasicButton( + "HeimdallSpotterConfigStinkyButton", + spotterConfigFrame.frame, + shared._L("stinky", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.spotter.stinky = not Heimdall_Data.config.spotter.stinky + return Heimdall_Data.config.spotter.stinky + end + ) + stinkyButton:UpdateColor(Heimdall_Data.config.spotter.stinky) + spotterConfigFrame:Add(stinkyButton, 1, 4) + + local channels = CreateBasicSmallEditBox( + "HeimdallSpotterConfigChannels", + spotterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.spotter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.spotter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.spotter.channels) + end + ) + spotterConfigFrame:Add(channels, 2, 4) + + local zoneOverride = CreateBasicSmallEditBox( + "HeimdallSpotterConfigZoneOverride", + spotterConfigFrame.frame, + shared._L("zoneOverride", Heimdall_Data.config.locale), + Heimdall_Data.config.spotter.zoneOverride, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.spotter.zoneOverride = text + print("Zone override set to", tostring(text)) + else + print("Invalid zone override", tostring(text)) + self:SetText(Heimdall_Data.config.spotter.zoneOverride) + end + end + ) + spotterConfigFrame:Add(zoneOverride, 2, 4) + + local throttleTime = CreateBasicSmallEditBox( + "HeimdallSpotterConfigThrottleTime", + spotterConfigFrame.frame, + shared._L("throttle", Heimdall_Data.config.locale), + Heimdall_Data.config.spotter.throttleTime, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.spotter.throttleTime = tonumber(text) + else + print("Invalid throttle time", tostring(text)) + self:SetText(Heimdall_Data.config.spotter.throttleTime) + end + end + ) + spotterConfigFrame:Add(throttleTime, 2, 4) + end + + -- Whoer + do + local r, g, b, a = GetNextColor() + local whoerConfigFrame = GridFrame.new("HeimdallWhoerConfig", UIParent, 12, 20) + whoerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(whoerConfigFrame, 30, 6) + + local title = CreateFancyText( + "HeimdallWhoerConfigTitle", + whoerConfigFrame.frame, + shared._L("whoer", Heimdall_Data.config.locale), + { r, g, b, a } + ) + whoerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallWhoerConfigDebugButton", + whoerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.who.debug = not Heimdall_Data.config.who.debug + return Heimdall_Data.config.who.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.who.debug) + whoerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallWhoerConfigEnableButton", + whoerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.who.enabled = not Heimdall_Data.config.who.enabled + return Heimdall_Data.config.who.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.who.enabled) + whoerConfigFrame:Add(enableButton, 2, 3) + + local doWhisperButton = CreateBasicButton( + "HeimdallWhoerConfigDoWhisperButton", + whoerConfigFrame.frame, + shared._L("doWhisper", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.who.doWhisper = not Heimdall_Data.config.who.doWhisper + return Heimdall_Data.config.who.doWhisper + end + ) + doWhisperButton:UpdateColor(Heimdall_Data.config.who.doWhisper) + whoerConfigFrame:Add(doWhisperButton, 2, 3) + + local channels = CreateBasicSmallEditBox( + "HeimdallWhoerConfigChannels", + whoerConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.who.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.who.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.who.channels) + end + ) + whoerConfigFrame:Add(channels, 2, 3) + + local ttl = CreateBasicSmallEditBox( + "HeimdallWhoerConfigTTL", + whoerConfigFrame.frame, + shared._L("ttl", Heimdall_Data.config.locale), + Heimdall_Data.config.who.ttl, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.who.ttl = tonumber(text) + print("TTL set to", tostring(text)) + else + print("Invalid TTL", tostring(text)) + self:SetText(Heimdall_Data.config.who.ttl) + end + end + ) + whoerConfigFrame:Add(ttl, 2, 3) + + local ignored = CreateBasicBigEditBox( + "HeimdallWhoerConfigIgnored", + whoerConfigFrame.frame, + shared._L("ignored", Heimdall_Data.config.locale), + MapKeyToString(Heimdall_Data.config.who.ignored or {}, ","), + function(self) + local ignored = StringToMap(self:GetText(), ",") + Heimdall_Data.config.who.ignored = ignored + end + ) + whoerConfigFrame:Add(ignored, 4, 6) + + local zoneNotifyFor = CreateBasicBigEditBox( + "HeimdallWhoerConfigZoneNotifyFor", + whoerConfigFrame.frame, + shared._L("zoneNotifyFor", Heimdall_Data.config.locale), + MapKeyToString(Heimdall_Data.config.who.zoneNotifyFor or {}, "\n"), + function(self) + local zoneNotifyFor = StringToMap(self:GetText(), "\n") + Heimdall_Data.config.who.zoneNotifyFor = zoneNotifyFor + end + ) + whoerConfigFrame:Add(zoneNotifyFor, 4, 6) + + local whoQueries = CreateBasicBigEditBox( + "HeimdallWhoerConfigQueries", + whoerConfigFrame.frame, + shared._L("queries", Heimdall_Data.config.locale), + shared.WhoQueryService.WhoQueriesToString(shared.WhoQueryService.queries or {}), + function(self) + Heimdall_Data.config.who.queries = self:GetText() + shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(self:GetText()) + end + ) + whoerConfigFrame:Add(whoQueries, 12, 12) + end + + -- Messenger + do + local r, g, b, a = GetNextColor() + local messengerConfigFrame = GridFrame.new("HeimdallMessengerConfig", UIParent, 12, 20) + messengerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(messengerConfigFrame, 6, 3) + + local title = CreateFancyText( + "HeimdallMessengerConfigTitle", + messengerConfigFrame.frame, + shared._L("messenger", Heimdall_Data.config.locale), + { r, g, b, a } + ) + messengerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallMessengerConfigDebugButton", + messengerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.messenger.debug = not Heimdall_Data.config.messenger.debug + return Heimdall_Data.config.messenger.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.messenger.debug) + messengerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallMessengerConfigEnableButton", + messengerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.messenger.enabled = not Heimdall_Data.config.messenger.enabled + return Heimdall_Data.config.messenger.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.messenger.enabled) + messengerConfigFrame:Add(enableButton, 2, 3) + + local interval = CreateBasicSmallEditBox( + "HeimdallMessengerConfigInterval", + messengerConfigFrame.frame, + shared._L("interval", Heimdall_Data.config.locale), + Heimdall_Data.config.messenger.interval, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.messenger.interval = tonumber(text) + print("Interval set to", tostring(text)) + else + print("Invalid interval", tostring(text)) + self:SetText(Heimdall_Data.config.messenger.interval) + end + end + ) + messengerConfigFrame:Add(interval, 2, 3) + end + + -- Death Reporter + do + local r, g, b, a = GetNextColor() + local deathReporterConfigFrame = GridFrame.new("HeimdallDeathReporterConfig", UIParent, 12, 20) + deathReporterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(deathReporterConfigFrame, 10, 3) + + local title = CreateFancyText( + "HeimdallDeathReporterConfigTitle", + deathReporterConfigFrame.frame, + shared._L("deathReporter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + deathReporterConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallDeathReporterConfigDebugButton", + deathReporterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.deathReporter.debug = not Heimdall_Data.config.deathReporter.debug + return Heimdall_Data.config.deathReporter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.deathReporter.debug) + deathReporterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallDeathReporterConfigEnableButton", + deathReporterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.deathReporter.enabled = not Heimdall_Data.config.deathReporter.enabled + return Heimdall_Data.config.deathReporter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.deathReporter.enabled) + deathReporterConfigFrame:Add(enableButton, 1, 6) + + local doWhisperButton = CreateBasicButton( + "HeimdallDeathReporterConfigDoWhisperButton", + deathReporterConfigFrame.frame, + shared._L("doWhisper", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.deathReporter.doWhisper = not Heimdall_Data.config.deathReporter.doWhisper + return Heimdall_Data.config.deathReporter.doWhisper + end + ) + doWhisperButton:UpdateColor(Heimdall_Data.config.deathReporter.doWhisper) + deathReporterConfigFrame:Add(doWhisperButton, 1, 6) + + local throttleTime = CreateBasicSmallEditBox( + "HeimdallDeathReporterConfigThrottleTime", + deathReporterConfigFrame.frame, + shared._L("throttle", Heimdall_Data.config.locale), + Heimdall_Data.config.deathReporter.throttle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.deathReporter.throttle = tonumber(text) + print("Throttle time set to", tostring(text)) + else + print("Invalid throttle time", tostring(text)) + self:SetText(Heimdall_Data.config.deathReporter.throttle) + end + end + ) + deathReporterConfigFrame:Add(throttleTime, 2, 6) + + local duelThrottle = CreateBasicSmallEditBox( + "HeimdallDeathReporterConfigDuelThrottle", + deathReporterConfigFrame.frame, + shared._L("duelThrottle", Heimdall_Data.config.locale), + Heimdall_Data.config.deathReporter.duelThrottle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.deathReporter.duelThrottle = tonumber(text) + print("Duel throttle set to", tostring(text)) + else + print("Invalid duel throttle", tostring(text)) + self:SetText(Heimdall_Data.config.deathReporter.duelThrottle) + end + end + ) + deathReporterConfigFrame:Add(duelThrottle, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallDeathReporterConfigChannels", + deathReporterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.deathReporter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.deathReporter.channels) + end + ) + deathReporterConfigFrame:Add(channels, 2, 6) + + local zoneOverride = CreateBasicSmallEditBox( + "HeimdallDeathReporterConfigZoneOverride", + deathReporterConfigFrame.frame, + shared._L("zoneOverride", Heimdall_Data.config.locale), + Heimdall_Data.config.deathReporter.zoneOverride, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.deathReporter.zoneOverride = text + print("Zone override set to", tostring(text)) + else + print("Invalid zone override", tostring(text)) + self:SetText(Heimdall_Data.config.deathReporter.zoneOverride) + end + end + ) + deathReporterConfigFrame:Add(zoneOverride, 2, 6) + end + + -- Inviter + do + local r, g, b, a = GetNextColor() + local inviterConfigFrame = GridFrame.new("HeimdallInviterConfig", UIParent, 12, 20) + inviterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(inviterConfigFrame, 13, 3) + + local title = CreateFancyText( + "HeimdallInviterConfigTitle", + inviterConfigFrame.frame, + shared._L("inviter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + inviterConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallInviterConfigDebugButton", + inviterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.inviter.debug = not Heimdall_Data.config.inviter.debug + return Heimdall_Data.config.inviter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.inviter.debug) + inviterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallInviterConfigEnableButton", + inviterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.inviter.enabled = not Heimdall_Data.config.inviter.enabled + return Heimdall_Data.config.inviter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.inviter.enabled) + inviterConfigFrame:Add(enableButton, 1, 3) + + local allAssistButton = CreateBasicButton( + "HeimdallInviterConfigAllAssistButton", + inviterConfigFrame.frame, + shared._L("allAssist", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.inviter.allAssist = not Heimdall_Data.config.inviter.allAssist + return Heimdall_Data.config.inviter.allAssist + end + ) + allAssistButton:UpdateColor(Heimdall_Data.config.inviter.allAssist) + inviterConfigFrame:Add(allAssistButton, 1, 3) + + local agentsAssist = CreateBasicButton( + "HeimdallInviterConfigAgentsAssistButton", + inviterConfigFrame.frame, + shared._L("agentsAssist", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.inviter.agentsAssist = not Heimdall_Data.config.inviter.agentsAssist + return Heimdall_Data.config.inviter.agentsAssist + end + ) + agentsAssist:UpdateColor(Heimdall_Data.config.inviter.agentsAssist) + inviterConfigFrame:Add(agentsAssist, 1, 3) + + local kickOffline = CreateBasicButton( + "HeimdallInviterConfigKickOfflineButton", + inviterConfigFrame.frame, + shared._L("kickOffline", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.inviter.kickOffline = not Heimdall_Data.config.inviter.kickOffline + return Heimdall_Data.config.inviter.kickOffline + end + ) + kickOffline:UpdateColor(Heimdall_Data.config.inviter.kickOffline) + inviterConfigFrame:Add(kickOffline, 1, 3) + + local throttle = CreateBasicSmallEditBox( + "HeimdallInviterConfigThrottle", + inviterConfigFrame.frame, + shared._L("throttle", Heimdall_Data.config.locale), + Heimdall_Data.config.inviter.throttle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.inviter.throttle = tonumber(text) + print("Throttle time set to", tostring(text)) + else + print("Invalid throttle time", tostring(text)) + self:SetText(Heimdall_Data.config.inviter.throttle) + end + end + ) + inviterConfigFrame:Add(throttle, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallInviterConfigChannels", + inviterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.inviter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.inviter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.inviter.channels) + end + ) + inviterConfigFrame:Add(channels, 2, 6) + + local keyword = CreateBasicSmallEditBox( + "HeimdallInviterConfigKeywords", + inviterConfigFrame.frame, + shared._L("keyword", Heimdall_Data.config.locale), + Heimdall_Data.config.inviter.keyword, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.inviter.keyword = text + print("Keyword set to", tostring(text)) + else + print("Invalid keyword", tostring(text)) + self:SetText(Heimdall_Data.config.inviter.keyword) + end + end + ) + inviterConfigFrame:Add(keyword, 2, 6) + + local cleanupInterval = CreateBasicSmallEditBox( + "HeimdallInviterConfigCleanupInterval", + inviterConfigFrame.frame, + shared._L("cleanupInterval", Heimdall_Data.config.locale), + Heimdall_Data.config.inviter.cleanupInterval, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.inviter.cleanupInterval = tonumber(text) + print("Cleanup interval set to", tostring(text)) + else + print("Invalid cleanup interval", tostring(text)) + self:SetText(Heimdall_Data.config.inviter.cleanupInterval) + end + end + ) + inviterConfigFrame:Add(cleanupInterval, 2, 6) + + local afkThreshold = CreateBasicSmallEditBox( + "HeimdallInviterConfigAfkThreshold", + inviterConfigFrame.frame, + shared._L("afkThreshold", Heimdall_Data.config.locale), + Heimdall_Data.config.inviter.afkThreshold, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.inviter.afkThreshold = tonumber(text) + print("Afk threshold set to", tostring(text)) + end + end + ) + inviterConfigFrame:Add(afkThreshold, 2, 6) + end + + -- Dueler + do + local r, g, b, a = GetNextColor() + local duelerConfigFrame = GridFrame.new("HeimdallDuelerConfig", UIParent, 12, 20) + duelerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(duelerConfigFrame, 4, 3) + + local title = CreateFancyText( + "HeimdallDuelerConfigTitle", + duelerConfigFrame.frame, + shared._L("dueler", Heimdall_Data.config.locale), + { r, g, b, a } + ) + duelerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallDuelerConfigDebugButton", + duelerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.dueler.debug = not Heimdall_Data.config.dueler.debug + return Heimdall_Data.config.dueler.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.dueler.debug) + duelerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallInviterConfigEnableButton", + duelerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.dueler.enabled = not Heimdall_Data.config.dueler.enabled + return Heimdall_Data.config.dueler.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.dueler.enabled) + duelerConfigFrame:Add(enableButton, 1, 6) + + local declineOther = CreateBasicButton( + "HeimdallDuelerConfigDeclineOtherButton", + duelerConfigFrame.frame, + shared._L("declineOther", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.dueler.declineOther = not Heimdall_Data.config.dueler.declineOther + return Heimdall_Data.config.dueler.declineOther + end + ) + declineOther:UpdateColor(Heimdall_Data.config.dueler.declineOther) + duelerConfigFrame:Add(declineOther, 1, 6) + end + + -- Agent Tracker + do + local r, g, b, a = GetNextColor() + local agentTrackerConfigFrame = GridFrame.new("HeimdallAgentTrackerConfig", UIParent, 12, 20) + agentTrackerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(agentTrackerConfigFrame, 5, 3) + + local title = CreateFancyText( + "HeimdallAgentTrackerConfigTitle", + agentTrackerConfigFrame.frame, + shared._L("agentTracker", Heimdall_Data.config.locale), + { r, g, b, a } + ) + agentTrackerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallAgentTrackerConfigDebugButton", + agentTrackerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.agentTracker.debug = not Heimdall_Data.config.agentTracker.debug + return Heimdall_Data.config.agentTracker.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.agentTracker.debug) + agentTrackerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallAgentTrackerConfigEnableButton", + agentTrackerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.agentTracker.enabled = not Heimdall_Data.config.agentTracker.enabled + return Heimdall_Data.config.agentTracker.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.agentTracker.enabled) + agentTrackerConfigFrame:Add(enableButton, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallAgentTrackerConfigChannels", + agentTrackerConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.agentTracker.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.agentTracker.channels) + end + ) + agentTrackerConfigFrame:Add(channels, 2, 6) + end + + -- Stinky Tracker + do + local r, g, b, a = GetNextColor() + local stinkyTrackerConfigFrame = GridFrame.new("HeimdallStinkyTrackerConfig", UIParent, 12, 20) + stinkyTrackerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(stinkyTrackerConfigFrame, 5, 3) + + local title = CreateFancyText( + "HeimdallStinkyTrackerConfigTitle", + stinkyTrackerConfigFrame.frame, + shared._L("stinkyTracker", Heimdall_Data.config.locale), + { r, g, b, a } + ) + stinkyTrackerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallStinkyTrackerConfigDebugButton", + stinkyTrackerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.stinkyTracker.debug = not Heimdall_Data.config.stinkyTracker.debug + return Heimdall_Data.config.stinkyTracker.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.stinkyTracker.debug) + stinkyTrackerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallStinkyTrackerConfigEnableButton", + stinkyTrackerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.stinkyTracker.enabled = not Heimdall_Data.config.stinkyTracker.enabled + return Heimdall_Data.config.stinkyTracker.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.stinkyTracker.enabled) + stinkyTrackerConfigFrame:Add(enableButton, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallStinkyTrackerConfigChannels", + stinkyTrackerConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.stinkyTracker.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.stinkyTracker.channels) + end + ) + stinkyTrackerConfigFrame:Add(channels, 2, 6) + end + + -- Emoter + do + local r, g, b, a = GetNextColor() + local emoterConfigFrame = GridFrame.new("HeimdallEmoterConfig", UIParent, 12, 20) + emoterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(emoterConfigFrame, 7, 3) + + local title = CreateFancyText( + "HeimdallEmoterConfigTitle", + emoterConfigFrame.frame, + shared._L("emoter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + emoterConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallEmoterConfigDebugButton", + emoterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.emoter.debug = not Heimdall_Data.config.emoter.debug + return Heimdall_Data.config.emoter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.emoter.debug) + emoterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallEmoterConfigEnableButton", + emoterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.emoter.enabled = not Heimdall_Data.config.emoter.enabled + return Heimdall_Data.config.emoter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.emoter.enabled) + emoterConfigFrame:Add(enableButton, 1, 12) + + local channels = CreateBasicSmallEditBox( + "HeimdallEmoterConfigChannels", + emoterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.emoter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.emoter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.emoter.channels) + end + ) + emoterConfigFrame:Add(channels, 2, 6) + + local prefix = CreateBasicSmallEditBox( + "HeimdallEmoterConfigPrefix", + emoterConfigFrame.frame, + shared._L("prefix", Heimdall_Data.config.locale), + Heimdall_Data.config.emoter.prefix, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.emoter.prefix = text + print("Prefix set to", tostring(text)) + else + print("Invalid prefix", tostring(text)) + self:SetText(Heimdall_Data.config.emoter.prefix) + end + end + ) + emoterConfigFrame:Add(prefix, 2, 6) + end + + -- Echoer + do + local r, g, b, a = GetNextColor() + local echoerConfigFrame = GridFrame.new("HeimdallEchoerConfig", UIParent, 12, 20) + echoerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(echoerConfigFrame, 7, 3) + + local title = CreateFancyText( + "HeimdallEchoerConfigTitle", + echoerConfigFrame.frame, + shared._L("echoer", Heimdall_Data.config.locale), + { r, g, b, a } + ) + echoerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallEchoerConfigDebugButton", + echoerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.echoer.debug = not Heimdall_Data.config.echoer.debug + return Heimdall_Data.config.echoer.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.echoer.debug) + echoerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallEmoterConfigEnableButton", + echoerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.echoer.enabled = not Heimdall_Data.config.echoer.enabled + return Heimdall_Data.config.echoer.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.echoer.enabled) + echoerConfigFrame:Add(enableButton, 1, 12) + + local channels = CreateBasicSmallEditBox( + "HeimdallEmoterConfigChannels", + echoerConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.echoer.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.echoer.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.echoer.channels) + end + ) + echoerConfigFrame:Add(channels, 2, 6) + + local prefix = CreateBasicSmallEditBox( + "HeimdallEmoterConfigPrefix", + echoerConfigFrame.frame, + shared._L("prefix", Heimdall_Data.config.locale), + Heimdall_Data.config.echoer.prefix, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.echoer.prefix = text + print("Prefix set to", tostring(text)) + else + print("Invalid prefix", tostring(text)) + self:SetText(Heimdall_Data.config.echoer.prefix) + end + end + ) + echoerConfigFrame:Add(prefix, 2, 6) + end + + -- Commander + do + local r, g, b, a = GetNextColor() + local commanderConfigFrame = GridFrame.new("HeimdallCommanderConfig", UIParent, 12, 20) + commanderConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(commanderConfigFrame, 10, 3) + + local title = CreateFancyText( + "HeimdallCommanderConfigTitle", + commanderConfigFrame.frame, + shared._L("commander", Heimdall_Data.config.locale), + { r, g, b, a } + ) + commanderConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallCommanderConfigDebugButton", + commanderConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.commander.debug = not Heimdall_Data.config.commander.debug + return Heimdall_Data.config.commander.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.commander.debug) + commanderConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallCommanderConfigEnableButton", + commanderConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.commander.enabled = not Heimdall_Data.config.commander.enabled + return Heimdall_Data.config.commander.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.commander.enabled) + commanderConfigFrame:Add(enableButton, 1, 12) + + local channels = CreateBasicSmallEditBox( + "HeimdallCommanderConfigChannels", + commanderConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.commander.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.commander.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.commander.channels) + end + ) + commanderConfigFrame:Add(channels, 2, 6) + + local commander = CreateBasicSmallEditBox( + "HeimdallCommanderConfigCommander", + commanderConfigFrame.frame, + shared._L("commander", Heimdall_Data.config.locale), + Heimdall_Data.config.commander.commander, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.commander.commander = text + print("Commander set to", tostring(text)) + else + print("Invalid commander", tostring(text)) + self:SetText(Heimdall_Data.config.commander.commander) + end + end + ) + commanderConfigFrame:Add(commander, 2, 6) + + local commands = CreateBasicSmallEditBox( + "HeimdallCommanderConfigCommands", + commanderConfigFrame.frame, + shared._L("commands", Heimdall_Data.config.locale), + MapKeyToString(Heimdall_Data.config.commander.commands, ", "), + function(self) + local text = self:GetText() + Heimdall_Data.config.commander.commands = StringToMap(text, ",") + end + ) + commanderConfigFrame:Add(commands, 2, 12) + end + + -- Macroer + do + local r, g, b, a = GetNextColor() + local macroerConfigFrame = GridFrame.new("HeimdallMacroerConfig", UIParent, 12, 20) + macroerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(macroerConfigFrame, 6, 3) + + local title = CreateFancyText( + "HeimdallMacroerConfigTitle", + macroerConfigFrame.frame, + shared._L("macroer", Heimdall_Data.config.locale), + { r, g, b, a } + ) + macroerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallMacroerConfigDebugButton", + macroerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.macroer.debug = not Heimdall_Data.config.macroer.debug + return Heimdall_Data.config.macroer.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.macroer.debug) + macroerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallCommanderConfigEnableButton", + macroerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.macroer.enabled = not Heimdall_Data.config.macroer.enabled + return Heimdall_Data.config.macroer.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.macroer.enabled) + macroerConfigFrame:Add(enableButton, 1, 12) + + local priority = CreateBasicSmallEditBox( + "HeimdallMacroerConfigPriority", + macroerConfigFrame.frame, + shared._L("priority", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.macroer.priority, ", "), + function(self) + local text = self:GetText() + Heimdall_Data.config.macroer.priority = StringToArray(text, ",") + end + ) + macroerConfigFrame:Add(priority, 2, 12) + end + + -- Combat Alerter + do + local r, g, b, a = GetNextColor() + local combatAlerterConfigFrame = GridFrame.new("HeimdallCombatAlerterConfig", UIParent, 12, 20) + combatAlerterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(combatAlerterConfigFrame, 5, 3) + + local title = CreateFancyText( + "HeimdallCombatAlerterConfigTitle", + combatAlerterConfigFrame.frame, + shared._L("combatAlerter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + combatAlerterConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallCombatAlerterConfigDebugButton", + combatAlerterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.combatAlerter.debug = not Heimdall_Data.config.combatAlerter.debug + return Heimdall_Data.config.combatAlerter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.combatAlerter.debug) + combatAlerterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallCombatAlerterConfigEnableButton", + combatAlerterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.combatAlerter.enabled = not Heimdall_Data.config.combatAlerter.enabled + return Heimdall_Data.config.combatAlerter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.combatAlerter.enabled) + combatAlerterConfigFrame:Add(enableButton, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallCombatAlerterConfigChannels", + combatAlerterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.combatAlerter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.combatAlerter.channels) + end + ) + combatAlerterConfigFrame:Add(channels, 2, 6) + end + + -- Sniffer + do + local r, g, b, a = GetNextColor() + local snifferConfigFrame = GridFrame.new("HeimdallSnifferConfig", UIParent, 12, 20) + snifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(snifferConfigFrame, 8, 3) + + local title = CreateFancyText( + "HeimdallSnifferConfigTitle", + snifferConfigFrame.frame, + shared._L("sniffer", Heimdall_Data.config.locale), + { r, g, b, a } + ) + snifferConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallSnifferConfigDebugButton", + snifferConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.sniffer.debug = not Heimdall_Data.config.sniffer.debug + return Heimdall_Data.config.sniffer.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.sniffer.debug) + snifferConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallSnifferConfigEnableButton", + snifferConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.sniffer.enabled = not Heimdall_Data.config.sniffer.enabled + return Heimdall_Data.config.sniffer.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.sniffer.enabled) + snifferConfigFrame:Add(enableButton, 2, 3) + + local stinkyButton = CreateBasicButton( + "HeimdallSnifferConfigStinkyButton", + snifferConfigFrame.frame, + shared._L("stinky", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.sniffer.stinky = not Heimdall_Data.config.sniffer.stinky + return Heimdall_Data.config.sniffer.stinky + end + ) + stinkyButton:UpdateColor(Heimdall_Data.config.sniffer.stinky) + snifferConfigFrame:Add(stinkyButton, 2, 3) + + local channels = CreateBasicSmallEditBox( + "HeimdallSnifferConfigChannels", + snifferConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.sniffer.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.sniffer.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.sniffer.channels) + end + ) + snifferConfigFrame:Add(channels, 2, 6) + + local throttle = CreateBasicSmallEditBox( + "HeimdallSnifferConfigThrottle", + snifferConfigFrame.frame, + shared._L("throttle", Heimdall_Data.config.locale), + Heimdall_Data.config.sniffer.throttle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.sniffer.throttle = tonumber(text) + print("Throttle set to", tostring(text)) + else + print("Invalid throttle", tostring(text)) + self:SetText(Heimdall_Data.config.sniffer.throttle) + end + end + ) + snifferConfigFrame:Add(throttle, 2, 6) + + local zoneOverride = CreateBasicSmallEditBox( + "HeimdallSnifferConfigZoneOverride", + snifferConfigFrame.frame, + shared._L("zoneOverride", Heimdall_Data.config.locale), + Heimdall_Data.config.sniffer.zoneOverride, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.sniffer.zoneOverride = text + print("Zone override set to", tostring(text)) + else + print("Invalid zone override", tostring(text)) + self:SetText(Heimdall_Data.config.sniffer.zoneOverride) + end + end + ) + snifferConfigFrame:Add(zoneOverride, 2, 6) + end + + -- BonkDetector + do + local r, g, b, a = GetNextColor() + local bonkDetectorConfigFrame = GridFrame.new("HeimdallBonkDetectorConfig", UIParent, 12, 20) + bonkDetectorConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(bonkDetectorConfigFrame, 7, 3) + + local title = CreateFancyText( + "HeimdallBonkDetectorConfigTitle", + bonkDetectorConfigFrame.frame, + shared._L("bonkDetector", Heimdall_Data.config.locale), + { r, g, b, a } + ) + bonkDetectorConfigFrame:Add(title, 1, 8) + + local debugButton = CreateBasicButton( + "HeimdallBonkDetectorConfigDebugButton", + bonkDetectorConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.bonkDetector.debug = not Heimdall_Data.config.bonkDetector.debug + return Heimdall_Data.config.bonkDetector.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.bonkDetector.debug) + bonkDetectorConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallBonkDetectorConfigEnableButton", + bonkDetectorConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.bonkDetector.enabled = not Heimdall_Data.config.bonkDetector.enabled + return Heimdall_Data.config.bonkDetector.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.bonkDetector.enabled) + bonkDetectorConfigFrame:Add(enableButton, 1, 12) + + local channels = CreateBasicSmallEditBox( + "HeimdallBonkDetectorConfigChannels", + bonkDetectorConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.bonkDetector.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.bonkDetector.channels) + end + ) + bonkDetectorConfigFrame:Add(channels, 2, 6) + + local throttle = CreateBasicSmallEditBox( + "HeimdallBonkDetectorConfigThrottle", + bonkDetectorConfigFrame.frame, + shared._L("throttle", Heimdall_Data.config.locale), + Heimdall_Data.config.bonkDetector.throttle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.bonkDetector.throttle = tonumber(text) + print("Throttle set to", tostring(text)) + else + print("Invalid throttle", tostring(text)) + self:SetText(Heimdall_Data.config.bonkDetector.throttle) + end + end + ) + bonkDetectorConfigFrame:Add(throttle, 2, 6) + end + + -- Minimap Tagger + do + local r, g, b, a = GetNextColor() + local minimapTaggerConfigFrame = GridFrame.new("HeimdallMinimapTaggerConfig", UIParent, 12, 20) + minimapTaggerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(minimapTaggerConfigFrame, 18, 6) + + local title = CreateFancyText( + "HeimdallMinimapTaggerConfigTitle", + minimapTaggerConfigFrame.frame, + shared._L("minimapTagger", Heimdall_Data.config.locale), + { r, g, b, a } + ) + minimapTaggerConfigFrame:Add(title, 1, 8) + local debugButton = CreateBasicButton( + "HeimdallMinimapTaggerConfigDebugButton", + minimapTaggerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.debug = not Heimdall_Data.config.minimapTagger.debug + return Heimdall_Data.config.minimapTagger.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.minimapTagger.debug) + minimapTaggerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallMinimapTaggerConfigEnableButton", + minimapTaggerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.enabled = not Heimdall_Data.config.minimapTagger.enabled + return Heimdall_Data.config.minimapTagger.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.minimapTagger.enabled) + minimapTaggerConfigFrame:Add(enableButton, 2, 6) + + local channels = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigChannels", + minimapTaggerConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.minimapTagger.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.minimapTagger.channels) + end + ) + minimapTaggerConfigFrame:Add(channels, 2, 3) + + local scale = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigScale", + minimapTaggerConfigFrame.frame, + shared._L("scale", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.scale, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.scale = tonumber(text) + print("Scale set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(scale, 2, 3) + + --region Tag + local tagSound = CreateBasicButton( + "HeimdallMinimapTaggerConfigTagSound", + minimapTaggerConfigFrame.frame, + shared._L("tagSound", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.tagSound = not Heimdall_Data.config.minimapTagger.tagSound + return Heimdall_Data.config.minimapTagger.tagSound + end + ) + tagSound:UpdateColor(Heimdall_Data.config.minimapTagger.tagSound) + minimapTaggerConfigFrame:Add(tagSound, 2, 1) + + local tagTTL = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigTagTTL", + minimapTaggerConfigFrame.frame, + shared._L("ttl", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.tagTTL, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.tagTTL = tonumber(text) + print("Tag TTL set to", tostring(text)) + else + print("Invalid tag TTL", tostring(text)) + self:SetText(Heimdall_Data.config.minimapTagger.tagTTL) + end + end + ) + minimapTaggerConfigFrame:Add(tagTTL, 2, 1) + + local tagSoundThrottle = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigTagSoundThrottle", + minimapTaggerConfigFrame.frame, + shared._L("soundThrottle", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.tagSoundThrottle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.tagSoundThrottle = tonumber(text) + print("Tag sound throttle set to", tostring(text)) + else + print("Invalid tag sound throttle", tostring(text)) + self:SetText(Heimdall_Data.config.minimapTagger.tagSoundThrottle) + end + end + ) + minimapTaggerConfigFrame:Add(tagSoundThrottle, 2, 2) + + local tagSoundFile = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigTagSoundFile", + minimapTaggerConfigFrame.frame, + shared._L("soundFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.tagSoundFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.tagSoundFile = text + print("Tag sound file set to", tostring(text)) + else + print("Invalid tag sound file", tostring(text)) + self:SetText(Heimdall_Data.config.minimapTagger.tagSoundFile) + end + end + ) + minimapTaggerConfigFrame:Add(tagSoundFile, 2, 4) + + local tagTexture = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigTagTexture", + minimapTaggerConfigFrame.frame, + shared._L("textureFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.tagTextureFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.tagTextureFile = text + print("Tag texture file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(tagTexture, 2, 4) + --endregion + --region Alert + local alertSound = CreateBasicButton( + "HeimdallMinimapTaggerConfigAlertSound", + minimapTaggerConfigFrame.frame, + shared._L("alertSound", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.alertSound = not Heimdall_Data.config.minimapTagger.alertSound + return Heimdall_Data.config.minimapTagger.alertSound + end + ) + alertSound:UpdateColor(Heimdall_Data.config.minimapTagger.alertSound) + minimapTaggerConfigFrame:Add(alertSound, 2, 1) + + local alertTTL = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigAlertTTL", + minimapTaggerConfigFrame.frame, + shared._L("ttl", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.alertTTL, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.alertTTL = tonumber(text) + print("Alert TTL set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(alertTTL, 2, 1) + + local alertSoundThrottle = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigAlertSoundThrottle", + minimapTaggerConfigFrame.frame, + shared._L("soundThrottle", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.alertSoundThrottle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.alertSoundThrottle = tonumber(text) + print("Alert sound throttle set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(alertSoundThrottle, 2, 2) + + local alertSoundFile = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigAlertSoundFile", + minimapTaggerConfigFrame.frame, + shared._L("soundFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.alertSoundFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.alertSoundFile = text + print("Alert sound file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(alertSoundFile, 2, 4) + + local alertTexture = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigAlertTexture", + minimapTaggerConfigFrame.frame, + shared._L("textureFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.alertTextureFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.alertTextureFile = text + print("Alert texture file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(alertTexture, 2, 4) + --endregion + --region Combat + local combatSound = CreateBasicButton( + "HeimdallMinimapTaggerConfigCombatSound", + minimapTaggerConfigFrame.frame, + shared._L("combatSound", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.combatSound = not Heimdall_Data.config.minimapTagger.combatSound + return Heimdall_Data.config.minimapTagger.combatSound + end + ) + combatSound:UpdateColor(Heimdall_Data.config.minimapTagger.combatSound) + minimapTaggerConfigFrame:Add(combatSound, 2, 1) + + local combatTTL = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigCombatTTL", + minimapTaggerConfigFrame.frame, + shared._L("ttl", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.combatTTL, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.combatTTL = tonumber(text) + print("Combat TTL set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(combatTTL, 2, 1) + + local combatSoundThrottle = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigCombatSoundThrottle", + minimapTaggerConfigFrame.frame, + shared._L("soundThrottle", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.combatSoundThrottle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.combatSoundThrottle = tonumber(text) + print("Combat sound throttle set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(combatSoundThrottle, 2, 2) + + local combatSoundFile = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigCombatSoundFile", + minimapTaggerConfigFrame.frame, + shared._L("soundFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.combatSoundFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.combatSoundFile = text + print("Combat sound file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(combatSoundFile, 2, 4) + local combatTexture = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigCombatTexture", + minimapTaggerConfigFrame.frame, + shared._L("textureFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.combatTextureFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.combatTextureFile = text + print("Combat texture file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(combatTexture, 2, 4) + --endregion + --region Help + local helpSound = CreateBasicButton( + "HeimdallMinimapTaggerConfigHelpSound", + minimapTaggerConfigFrame.frame, + shared._L("helpSound", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.minimapTagger.helpSound = not Heimdall_Data.config.minimapTagger.helpSound + return Heimdall_Data.config.minimapTagger.helpSound + end + ) + helpSound:UpdateColor(Heimdall_Data.config.minimapTagger.helpSound) + minimapTaggerConfigFrame:Add(helpSound, 2, 1) + + local helpTTL = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigHelpTTL", + minimapTaggerConfigFrame.frame, + shared._L("ttl", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.helpTTL, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.helpTTL = tonumber(text) + print("Help TTL set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(helpTTL, 2, 1) + + local helpSoundThrottle = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigHelpSoundThrottle", + minimapTaggerConfigFrame.frame, + shared._L("soundThrottle", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.helpSoundThrottle, + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.minimapTagger.helpSoundThrottle = tonumber(text) + print("Help sound throttle set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(helpSoundThrottle, 2, 2) + + local helpSoundFile = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigHelpSoundFile", + minimapTaggerConfigFrame.frame, + shared._L("soundFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.helpSoundFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.helpSoundFile = text + print("Help sound file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(helpSoundFile, 2, 4) + local helpTexture = CreateBasicSmallEditBox( + "HeimdallMinimapTaggerConfigHelpTexture", + minimapTaggerConfigFrame.frame, + shared._L("textureFile", Heimdall_Data.config.locale), + Heimdall_Data.config.minimapTagger.helpTextureFile, + function(self) + local text = self:GetText() + if string.match(text, "%S+") then + Heimdall_Data.config.minimapTagger.helpTextureFile = text + print("Help texture file set to", tostring(text)) + end + end + ) + minimapTaggerConfigFrame:Add(helpTexture, 2, 4) + --endregion + end + + -- Noter + do + local r, g, b, a = GetNextColor() + local noterConfigFrame = GridFrame.new("HeimdallNoterConfig", UIParent, 12, 20) + noterConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(noterConfigFrame, 7, 3) + + local title = CreateFancyText( + "HeimdallNoterConfigTitle", + noterConfigFrame.frame, + shared._L("noter", Heimdall_Data.config.locale), + { r, g, b, a } + ) + noterConfigFrame:Add(title, 1, 8) + + local debugButton = CreateBasicButton( + "HeimdallNoterConfigDebugButton", + noterConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.noter.debug = not Heimdall_Data.config.noter.debug + return Heimdall_Data.config.noter.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.noter.debug) + noterConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallNoterConfigEnableButton", + noterConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.noter.enabled = not Heimdall_Data.config.noter.enabled + return Heimdall_Data.config.noter.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.noter.enabled) + noterConfigFrame:Add(enableButton, 1, 12) + + local channels = CreateBasicSmallEditBox( + "HeimdallNoterConfigChannels", + noterConfigFrame.frame, + shared._L("channels", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.noter.channels or {}, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.noter.channels = StringToArray(text, ",") + print("Channels set to") + shared.dumpTable(Heimdall_Data.config.noter.channels) + end + ) + noterConfigFrame:Add(channels, 2, 6) + + local lastNotes = CreateBasicSmallEditBox( + "HeimdallNoterConfigLastNotes", + noterConfigFrame.frame, + shared._L("lastNotes", Heimdall_Data.config.locale), + tostring(Heimdall_Data.config.noter.lastNotes), + function(self) + local text = self:GetText() + local value = tonumber(text) + if value and value > 0 then + Heimdall_Data.config.noter.lastNotes = value + print("Last notes set to", value) + else + print("Invalid number of last notes", text) + self:SetText(tostring(Heimdall_Data.config.noter.lastNotes)) + end + end + ) + noterConfigFrame:Add(lastNotes, 2, 6) + end + + -- Network + do + local r, g, b, a = GetNextColor() + local networkConfigFrame = GridFrame.new("HeimdallNetworkConfig", UIParent, 12, 20) + networkConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(networkConfigFrame, 11, 3) + + local title = CreateFancyText( + "HeimdallNetworkConfigTitle", + networkConfigFrame.frame, + shared._L("network", Heimdall_Data.config.locale), + { r, g, b, a } + ) + networkConfigFrame:Add(title, 1, 8) + + local debugButton = CreateBasicButton( + "HeimdallNetworkConfigDebugButton", + networkConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.network.debug = not Heimdall_Data.config.network.debug + return Heimdall_Data.config.network.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.network.debug) + networkConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallNetworkConfigEnableButton", + networkConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.network.enabled = not Heimdall_Data.config.network.enabled + return Heimdall_Data.config.network.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.network.enabled) + networkConfigFrame:Add(enableButton, 1, 12) + + local members = CreateBasicBigEditBox( + "HeimdallNetworkConfigMembers", + networkConfigFrame.frame, + shared._L("members", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.network.members, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.network.members = StringToArray(text, ",") + print("Members set to", table.concat(Heimdall_Data.config.network.members, ",")) + self:SetText(table.concat(Heimdall_Data.config.network.members, ",")) + end + ) + networkConfigFrame:Add(members, 5, 6) + + local updateInterval = CreateBasicSmallEditBox( + "HeimdallNetworkConfigUpdateInterval", + networkConfigFrame.frame, + shared._L("updateInterval", Heimdall_Data.config.locale), + tostring(Heimdall_Data.config.network.updateInterval), + function(self) + local text = self:GetText() + if string.match(text, "%d+") then + Heimdall_Data.config.network.updateInterval = tonumber(text) + print("Update interval set to", tostring(text)) + else + print("Invalid update interval", text) + self:SetText(tostring(Heimdall_Data.config.network.updateInterval)) + end + end + ) + networkConfigFrame:Add(updateInterval, 2, 6) + end + + -- NetworkMessenger + do + local r, g, b, a = GetNextColor() + local networkMessengerConfigFrame = GridFrame.new("HeimdallNetworkMessengerConfig", UIParent, 12, 20) + networkMessengerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(networkMessengerConfigFrame, 5, 3) + + local title = CreateFancyText( + "HeimdallNetworkMessengerConfigTitle", + networkMessengerConfigFrame.frame, + shared._L("networkMessenger", Heimdall_Data.config.locale), + { r, g, b, a } + ) + networkMessengerConfigFrame:Add(title, 1, 8) + + local debugButton = CreateBasicButton( + "HeimdallNetworkMessengerConfigDebugButton", + networkMessengerConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.networkMessenger.debug = not Heimdall_Data.config.networkMessenger.debug + return Heimdall_Data.config.networkMessenger.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.networkMessenger.debug) + networkMessengerConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallNetworkMessengerConfigEnableButton", + networkMessengerConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.networkMessenger.enabled = not Heimdall_Data.config.networkMessenger.enabled + return Heimdall_Data.config.networkMessenger.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.networkMessenger.enabled) + networkMessengerConfigFrame:Add(enableButton, 2, 6) + + local interval = CreateBasicSmallEditBox( + "HeimdallNetworkMessengerConfigInterval", + networkMessengerConfigFrame.frame, + shared._L("interval", Heimdall_Data.config.locale), + tostring(Heimdall_Data.config.networkMessenger.interval), + function(self) + local text = self:GetText() + if string.match(text, "^%d+%.?%d*$") then + Heimdall_Data.config.networkMessenger.interval = tonumber(text) + print("Interval set to", tostring(text)) + else + print("Invalid interval", text) + self:SetText(tostring(Heimdall_Data.config.networkMessenger.interval)) + end + end + ) + networkMessengerConfigFrame:Add(interval, 2, 6) + end + + -- AchievementSniffer + do + local r, g, b, a = GetNextColor() + local achievementSnifferConfigFrame = GridFrame.new("HeimdallAchievementSnifferConfig", UIParent, 12, 20) + achievementSnifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(achievementSnifferConfigFrame, 14, 3) + + local title = CreateFancyText( + "HeimdallAchievementSnifferConfigTitle", + achievementSnifferConfigFrame.frame, + shared._L("achievementSniffer", Heimdall_Data.config.locale), + { r, g, b, a } + ) + achievementSnifferConfigFrame:Add(title, 1, 8) + + local debugButton = CreateBasicButton( + "HeimdallAchievementSnifferConfigDebugButton", + achievementSnifferConfigFrame.frame, + shared._L("debug", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.achievementSniffer.debug = not Heimdall_Data.config.achievementSniffer.debug + return Heimdall_Data.config.achievementSniffer.debug + end + ) + debugButton:UpdateColor(Heimdall_Data.config.achievementSniffer.debug) + achievementSnifferConfigFrame:Add(debugButton, 1, 4) + + local enableButton = CreateBasicButton( + "HeimdallAchievementSnifferConfigEnableButton", + achievementSnifferConfigFrame.frame, + shared._L("enabled", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.achievementSniffer.enabled = not Heimdall_Data.config.achievementSniffer.enabled + return Heimdall_Data.config.achievementSniffer.enabled + end + ) + enableButton:UpdateColor(Heimdall_Data.config.achievementSniffer.enabled) + achievementSnifferConfigFrame:Add(enableButton, 2, 3) + + --local texture = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigTexture", + -- achievementSnifferConfigFrame.frame, shared._L("texture", Heimdall_Data.config.locale), + -- Heimdall_Data.config.achievementSniffer.texture, + -- function(self) + -- local text = self:GetText() + -- Heimdall_Data.config.achievementSniffer.texture = text + -- end) + --achievementSnifferConfigFrame:Add(texture, 2, 3) + + --local offsetX = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigOffsetX", + -- achievementSnifferConfigFrame.frame, shared._L("offsetX", Heimdall_Data.config.locale), + -- tostring(Heimdall_Data.config.achievementSniffer.offsetX), + -- function(self) + -- local text = self:GetText() + -- if string.match(text, "%d+") then + -- Heimdall_Data.config.achievementSniffer.offsetX = tonumber(text) + -- print("Offset X set to", tostring(text)) + -- else + -- print("Invalid offset X", text) + -- self:SetText(tostring(Heimdall_Data.config.achievementSniffer.offsetX)) + -- end + -- end) + --achievementSnifferConfigFrame:Add(offsetX, 2, 3) + + --local offsetY = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigOffsetY", + -- achievementSnifferConfigFrame.frame, shared._L("offsetY", Heimdall_Data.config.locale), + -- tostring(Heimdall_Data.config.achievementSniffer.offsetY), + -- function(self) + -- local text = self:GetText() + -- if string.match(text, "%d+") then + -- Heimdall_Data.config.achievementSniffer.offsetY = tonumber(text) + -- print("Offset Y set to", tostring(text)) + -- else + -- print("Invalid offset Y", text) + -- self:SetText(tostring(Heimdall_Data.config.achievementSniffer.offsetY)) + -- end + -- end) + --achievementSnifferConfigFrame:Add(offsetY, 2, 3) + + local rescan = CreateBasicButton( + "HeimdallAchievementSnifferConfigRescanButton", + achievementSnifferConfigFrame.frame, + shared._L("rescan", Heimdall_Data.config.locale), + function() + Heimdall_Data.config.achievementSniffer.rescan = not Heimdall_Data.config.achievementSniffer.rescan + return Heimdall_Data.config.achievementSniffer.rescan + end + ) + rescan:UpdateColor(Heimdall_Data.config.achievementSniffer.rescan) + achievementSnifferConfigFrame:Add(rescan, 2, 3) + + local scanInterval = CreateBasicSmallEditBox( + "HeimdallAchievementSnifferConfigScanInterval", + achievementSnifferConfigFrame.frame, + shared._L("scanInterval", Heimdall_Data.config.locale), + tostring(Heimdall_Data.config.achievementSniffer.scanInterval), + function(self) + local text = self:GetText() + Heimdall_Data.config.achievementSniffer.scanInterval = tonumber(text) + end + ) + achievementSnifferConfigFrame:Add(scanInterval, 2, 3) + + --local iconScale = CreateBasicSmallEditBox("HeimdallAchievementSnifferConfigIconScale", + -- achievementSnifferConfigFrame.frame, shared._L("iconScale", Heimdall_Data.config.locale), + -- tostring(Heimdall_Data.config.achievementSniffer.iconScale), + -- function(self) + -- local text = self:GetText() + -- Heimdall_Data.config.achievementSniffer.iconScale = tonumber(text) + -- end) + --achievementSnifferConfigFrame:Add(iconScale, 2, 3) + end + + -- Addon prefix + do + local r, g, b, a = GetNextColor() + local addonPrefixConfigFrame = GridFrame.new("HeimdallAddonPrefixConfig", UIParent, 12, 20) + addonPrefixConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(addonPrefixConfigFrame, 5, 1) + + local title = CreateFancyText( + "HeimdallAddonPrefixConfigTitle", + addonPrefixConfigFrame.frame, + shared._L("addonPrefix", Heimdall_Data.config.locale), + { r, g, b, a } + ) + addonPrefixConfigFrame:Add(title, 1, 12) + + local addonPrefix = CreateBasicSmallEditBox( + "HeimdallAddonPrefixConfigAddonPrefix", + addonPrefixConfigFrame.frame, + shared._L("addonPrefix", Heimdall_Data.config.locale), + Heimdall_Data.config.addonPrefix, + function(self) + local text = self:GetText() + Heimdall_Data.config.addonPrefix = text + end + ) + addonPrefixConfigFrame:Add(addonPrefix, 2, 12) + end + + -- Whisper Notify + do + local r, g, b, a = GetNextColor() + local whisperNotifyConfigFrame = GridFrame.new("HeimdallWhisperNotifyConfig", UIParent, 12, 20) + whisperNotifyConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(whisperNotifyConfigFrame, 14, 1) + + local title = CreateFancyText( + "HeimdallWhisperNotifyConfigTitle", + whisperNotifyConfigFrame.frame, + shared._L("whisperNotify", Heimdall_Data.config.locale), + { r, g, b, a } + ) + whisperNotifyConfigFrame:Add(title, 1, 12) + + local whisperNotify = CreateBasicBigEditBox( + "HeimdallWhisperNotifyConfigWhisperNotify", + whisperNotifyConfigFrame.frame, + shared._L("whisperNotify", Heimdall_Data.config.locale), + table.concat(Heimdall_Data.config.whisperNotify, "\n"), + function(self) + local text = self:GetText() + Heimdall_Data.config.whisperNotify = StringToArray(text, "\n") + end + ) + whisperNotifyConfigFrame:Add(whisperNotify, 8, 12) + end + + -- Stinkies + do + local r, g, b, a = GetNextColor() + local stinkiesConfigFrame = GridFrame.new("HeimdallStinkiesConfig", UIParent, 12, 20) + stinkiesConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(stinkiesConfigFrame, 28, 6) + -- Why do 17 rows of content fit into a frame that is 14 rows? + -- I don't know, at this point I can't be fucked to fix it, the display is minimally functional + + local title = CreateFancyText( + "HeimdallStinkiesConfigTitle", + stinkiesConfigFrame.frame, + shared._L("stinkies", Heimdall_Data.config.locale), + { r, g, b, a } + ) + stinkiesConfigFrame:Add(title, 1, 12) + + local stinkies = CreateBasicBigEditBox( + "HeimdallStinkiesConfigStinkies", + stinkiesConfigFrame.frame, + shared._L("stinkies", Heimdall_Data.config.locale), + MapKeyToString(Heimdall_Data.config.stinkies, ","), + function(self) + local text = self:GetText() + Heimdall_Data.config.stinkies = StringToMap(text, ",") + end + ) + stinkiesConfigFrame:Add(stinkies, 16, 12) + end + + -- Channel locale + do + local r, g, b, a = GetNextColor() + local channelLocaleConfigFrame = GridFrame.new("HeimdallChannelLocaleConfig", UIParent, 12, 20) + channelLocaleConfigFrame.frame:SetBackdropColor(r, g, b, 0.3) + configFrame:Add(channelLocaleConfigFrame, 14, 1) + + local title = CreateFancyText( + "HeimdallChannelLocaleConfigTitle", + channelLocaleConfigFrame.frame, + shared._L("channelLocale", Heimdall_Data.config.locale), + { r, g, b, a } + ) + channelLocaleConfigFrame:Add(title, 1, 12) + + local channelLocale = CreateBasicBigEditBox( + "HeimdallChannelLocaleConfigChannelLocale", + channelLocaleConfigFrame.frame, + shared._L("channelLocale", Heimdall_Data.config.locale), + MapToString(Heimdall_Data.config.channelLocale, ":", "\n"), + function(self) + local text = self:GetText() + Heimdall_Data.config.channelLocale = MapFromString(text, ":", "\n") + end + ) + channelLocaleConfigFrame:Add(channelLocale, 8, 12) + end + + --configFrame.frame:Hide() + print("[Heimdall] Config loaded") end -SlashCmdList["HEIMDALL_CONFIG"] = function() - configFrame.frame:Show() -end +SlashCmdList["HEIMDALL_CONFIG"] = function() configFrame.frame:Show() end SLASH_HEIMDALL_CONFIG1 = "/heimdall_config" SLASH_HEIMDALL_CONFIG2 = "/hc" diff --git a/Modules/Configurator.lua b/Modules/Configurator.lua index fa0a6e9..0473e4a 100644 --- a/Modules/Configurator.lua +++ b/Modules/Configurator.lua @@ -5,6 +5,4 @@ local ModuleName = "Configurator" ---@diagnostic disable-next-line: missing-fields shared.Configurator = {} -function shared.Configurator.Init() - print("[Heimdall] Configurator module loaded") -end +function shared.Configurator.Init() print("[Heimdall] Configurator module loaded") end diff --git a/Modules/DeathReporter.lua b/Modules/DeathReporter.lua index 6820a06..6fc1121 100644 --- a/Modules/DeathReporter.lua +++ b/Modules/DeathReporter.lua @@ -16,8 +16,15 @@ function shared.DeathReporter.Init() ---@param spellName string local function RegisterDeath(source, destination, spellName) if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s", - ModuleName, source, destination, spellName)) + print( + string.format( + "[%s] Processing death event - Source: %s, Target: %s, Spell: %s", + ModuleName, + source, + destination, + spellName + ) + ) end if not Heimdall_Data.config.deathReporter.enabled then @@ -27,27 +34,52 @@ function shared.DeathReporter.Init() return end - if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then + if + recentDeaths[destination] + and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle + then if Heimdall_Data.config.deathReporter.debug then local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination]) - print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)", - ModuleName, destination, timeLeft)) + print( + string.format( + "[%s] Death report throttled for %s (%.1f seconds remaining)", + ModuleName, + destination, + timeLeft + ) + ) end return end - if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then + if + recentDuels[destination] + and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle + then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName, - destination)) + print( + string.format( + "[%s] Ignoring death report - Recent duel detected for target: %s", + ModuleName, + destination + ) + ) end return end - if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then + if + recentDuels[source] + and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle + then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName, - source)) + print( + string.format( + "[%s] Ignoring death report - Recent duel detected for source: %s", + ModuleName, + source + ) + ) end return end @@ -58,25 +90,48 @@ function shared.DeathReporter.Init() recentDeaths[destination] = GetTime() C_Timer.NewTimer(3, function() - if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then + if + recentDuels[destination] + and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle + then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, - destination)) + print( + string.format( + "[%s] Cancelling delayed death report - Recent duel detected for: %s", + ModuleName, + destination + ) + ) end return end - if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then + if + recentDuels[source] + and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle + then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, - source)) + print( + string.format( + "[%s] Cancelling delayed death report - Recent duel detected for: %s", + ModuleName, + source + ) + ) end return end if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Sending death report - %s killed %s with %s", - ModuleName, source, destination, spellName)) + print( + string.format( + "[%s] Sending death report - %s killed %s with %s", + ModuleName, + source, + destination, + spellName + ) + ) end local zone, subzone = GetZoneText() or "Unknown", GetSubZoneText() or "Unknown" @@ -95,18 +150,22 @@ function shared.DeathReporter.Init() for _, channel in pairs(Heimdall_Data.config.deathReporter.channels) do local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("killed", locale), + local text = string.format( + shared._L("killed", locale), source, destination, shared._L(spellName, locale), - shared._L(zone, locale), shared._L(subzone, locale), + shared._L(zone, locale), + shared._L(subzone, locale), zoneId, - x * 100, y * 100) + x * 100, + y * 100 + ) ---@type Message local msg = { channel = "C", data = channel, - message = text + message = text, } if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Queuing death report message", ModuleName)) @@ -162,7 +221,9 @@ function shared.DeathReporter.Init() local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel") if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Received system message: %s", ModuleName, msg)) - print(string.format("[%s] Source: %s, Destination: %s", ModuleName, tostring(source), tostring(destination))) + print( + string.format("[%s] Source: %s, Destination: %s", ModuleName, tostring(source), tostring(destination)) + ) end if not source or not destination then return end source = string.match(source, "([^-]+)") @@ -178,8 +239,14 @@ function shared.DeathReporter.Init() end) if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs", - ModuleName, Heimdall_Data.config.deathReporter.throttle, Heimdall_Data.config.deathReporter.duelThrottle)) + print( + string.format( + "[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs", + ModuleName, + Heimdall_Data.config.deathReporter.throttle, + Heimdall_Data.config.deathReporter.duelThrottle + ) + ) end print("[Heimdall] DeathReporter loaded") end diff --git a/Modules/Dueler.lua b/Modules/Dueler.lua index e15c275..43387ee 100644 --- a/Modules/Dueler.lua +++ b/Modules/Dueler.lua @@ -44,8 +44,13 @@ function shared.Dueler.Init() end) if Heimdall_Data.config.dueler.debug then - print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName, - tostring(Heimdall_Data.config.dueler.declineOther))) + print( + string.format( + "[%s] Module initialized with auto-decline: %s", + ModuleName, + tostring(Heimdall_Data.config.dueler.declineOther) + ) + ) end print("[Heimdall] Dueler loaded") end diff --git a/Modules/DumpTable.lua b/Modules/DumpTable.lua index 58781dc..d5142b9 100644 --- a/Modules/DumpTable.lua +++ b/Modules/DumpTable.lua @@ -10,15 +10,13 @@ if not shared.dumpTable then print(tostring(table)) return end - if depth == nil then - depth = 0 - end - if (depth > 200) then + if depth == nil then depth = 0 end + if depth > 200 then print("Error: Depth > 200 in dumpTable()") return end for k, v in pairs(table) do - if (type(v) == "table") then + if type(v) == "table" then print(string.rep(" ", depth) .. k .. ":") shared.dumpTable(v, depth + 1) else diff --git a/Modules/Echoer.lua b/Modules/Echoer.lua index ab837e0..29972c7 100644 --- a/Modules/Echoer.lua +++ b/Modules/Echoer.lua @@ -54,8 +54,6 @@ function shared.Echoer.Init() end end) - if Heimdall_Data.config.echoer.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] Echoer loaded") end diff --git a/Modules/Emoter.lua b/Modules/Emoter.lua index ac020ff..73bc659 100644 --- a/Modules/Emoter.lua +++ b/Modules/Emoter.lua @@ -55,8 +55,6 @@ function shared.Emoter.Init() end end) - if Heimdall_Data.config.emoter.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] Emoter loaded") end diff --git a/Modules/Inviter.lua b/Modules/Inviter.lua index 73ba81d..cd4fa0a 100644 --- a/Modules/Inviter.lua +++ b/Modules/Inviter.lua @@ -8,7 +8,7 @@ shared.Inviter = {} function shared.Inviter.Init() if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then Heimdall_Data.config.inviter.listeningChannel = { - [Heimdall_Data.config.inviter.listeningChannel] = true + [Heimdall_Data.config.inviter.listeningChannel] = true, } end ---@type Timer @@ -36,7 +36,9 @@ function shared.Inviter.Init() if Heimdall_Data.config.inviter.agentsAssist then if Heimdall_Data.config.inviter.debug then local agentCount = 0 - for _ in pairs(Heimdall_Data.config.agents) do agentCount = agentCount + 1 end + for _ in pairs(Heimdall_Data.config.agents) do + agentCount = agentCount + 1 + end print(string.format("[%s] Processing %d agents for assistant promotion", ModuleName, agentCount)) end @@ -100,8 +102,11 @@ function shared.Inviter.Init() local frame = FindPlayerRaidFrame(name) if frame then playerButtons[name] = frame - local button = framePool[frame.unit] or CreateFrame("Button", - string.format("HeimdallKickButton%s", frame.unit, frame, "SecureActionButtonTemplate")) + local button = framePool[frame.unit] + or CreateFrame( + "Button", + string.format("HeimdallKickButton%s", frame.unit, frame, "SecureActionButtonTemplate") + ) framePool[frame.unit] = button button:SetSize(frame.UNIT_WIDTH / 2, frame.UNIT_HEIGHT / 2) @@ -142,9 +147,7 @@ function shared.Inviter.Init() groupMembers[name] = now else local online = UnitIsConnected(unit) - if online then - groupMembers[name] = now - end + if online then groupMembers[name] = now end end end end @@ -221,9 +224,7 @@ function shared.Inviter.Init() return end if msg == Heimdall_Data.config.inviter.keyword then - if Heimdall_Data.config.inviter.debug then - print(string.format("[%s] Inviting %s", ModuleName, sender)) - end + if Heimdall_Data.config.inviter.debug then print(string.format("[%s] Inviting %s", ModuleName, sender)) end InviteUnit(sender) else if Heimdall_Data.config.inviter.debug then @@ -233,17 +234,25 @@ function shared.Inviter.Init() end) if Heimdall_Data.config.inviter.debug then - print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s", - ModuleName, - tostring(Heimdall_Data.config.inviter.allAssist), - tostring(Heimdall_Data.config.inviter.agentsAssist))) + print( + string.format( + "[%s] Module initialized - All assist: %s, Agents assist: %s", + ModuleName, + tostring(Heimdall_Data.config.inviter.allAssist), + tostring(Heimdall_Data.config.inviter.agentsAssist) + ) + ) end if Heimdall_Data.config.inviter.debug then - print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s", - ModuleName, - tostring(Heimdall_Data.config.inviter.allAssist), - tostring(Heimdall_Data.config.inviter.agentsAssist))) + print( + string.format( + "[%s] Module initialized - All assist: %s, Agents assist: %s", + ModuleName, + tostring(Heimdall_Data.config.inviter.allAssist), + tostring(Heimdall_Data.config.inviter.agentsAssist) + ) + ) end print("[Heimdall] Inviter loaded") end diff --git a/Modules/Macroer.lua b/Modules/Macroer.lua index f0d3071..bb982fe 100644 --- a/Modules/Macroer.lua +++ b/Modules/Macroer.lua @@ -6,102 +6,96 @@ local ModuleName = "Macroer" ---@diagnostic disable-next-line: missing-fields shared.Macroer = {} function shared.Macroer.Init() - ---@class stinky - ---@field name string - ---@field class string - ---@field seenAt number - ---@field hostile boolean + ---@class stinky + ---@field name string + ---@field class string + ---@field seenAt number + ---@field hostile boolean - local function FindOrCreateMacro(macroName) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName)) - end - local idx = GetMacroIndexByName(macroName) - if idx == 0 then - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Creating new macro: %s", ModuleName, macroName)) - end - CreateMacro(macroName, "INV_Misc_QuestionMark", "") - end - idx = GetMacroIndexByName(macroName) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Macro index: %d", ModuleName, idx)) - end - return idx - end + local function FindOrCreateMacro(macroName) + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName)) + end + local idx = GetMacroIndexByName(macroName) + if idx == 0 then + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Creating new macro: %s", ModuleName, macroName)) + end + CreateMacro(macroName, "INV_Misc_QuestionMark", "") + end + idx = GetMacroIndexByName(macroName) + if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Macro index: %d", ModuleName, idx)) end + return idx + end - ---@param stinkies table - local function FixMacro(stinkies) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies)) - end - if not Heimdall_Data.config.macroer.enabled then - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Module disabled, skipping macro update", ModuleName)) - end - return - end - if InCombatLockdown() then - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] In combat, skipping macro update", ModuleName)) - end - return - end + ---@param stinkies table + local function FixMacro(stinkies) + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies)) + end + if not Heimdall_Data.config.macroer.enabled then + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Module disabled, skipping macro update", ModuleName)) + end + return + end + if InCombatLockdown() then + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] In combat, skipping macro update", ModuleName)) + end + return + end - local priorityMap = {} - for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do - priorityMap[className] = priority - end - local minPriority = #Heimdall_Data.config.macroer.priority + 1 + local priorityMap = {} + for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do + priorityMap[className] = priority + end + local minPriority = #Heimdall_Data.config.macroer.priority + 1 - local sortedStinkies = {} - for _, stinky in pairs(stinkies) do - if not Heimdall_Data.config.agents[stinky.name] then - sortedStinkies[#sortedStinkies + 1] = stinky - end - end + local sortedStinkies = {} + for _, stinky in pairs(stinkies) do + if not Heimdall_Data.config.agents[stinky.name] then sortedStinkies[#sortedStinkies + 1] = stinky end + end - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Processing %d non-agent stinkies", ModuleName, #sortedStinkies)) - end + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Processing %d non-agent stinkies", ModuleName, #sortedStinkies)) + end - table.sort(sortedStinkies, function(a, b) - local aPriority = priorityMap[a.class] or minPriority - local bPriority = priorityMap[b.class] or minPriority - return aPriority > bPriority - end) + table.sort(sortedStinkies, function(a, b) + local aPriority = priorityMap[a.class] or minPriority + local bPriority = priorityMap[b.class] or minPriority + return aPriority > bPriority + end) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies)) - shared.dumpTable(sortedStinkies) - end - local lines = { "/targetenemy" } - for _, stinky in pairs(sortedStinkies) do - if stinky.seenAt > GetTime() - 600 then - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Adding target macro for: %s", ModuleName, stinky.name)) - end - lines[#lines + 1] = string.format("/tar %s", stinky.name) - end - end + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies)) + shared.dumpTable(sortedStinkies) + end + local lines = { "/targetenemy" } + for _, stinky in pairs(sortedStinkies) do + if stinky.seenAt > GetTime() - 600 then + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Adding target macro for: %s", ModuleName, stinky.name)) + end + lines[#lines + 1] = string.format("/tar %s", stinky.name) + end + end - local idx = FindOrCreateMacro("HeimdallTarget") - local body = strjoin("\n", unpack(lines)) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines)) - end - EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) - end + local idx = FindOrCreateMacro("HeimdallTarget") + local body = strjoin("\n", unpack(lines)) + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines)) + end + EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) + end - shared.stinkyTracker.stinkies:onChange(function(value) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Stinkies changed, updating macro", ModuleName)) - end - FixMacro(value) - end) + shared.stinkyTracker.stinkies:onChange(function(value) + if Heimdall_Data.config.macroer.debug then + print(string.format("[%s] Stinkies changed, updating macro", ModuleName)) + end + FixMacro(value) + end) - if Heimdall_Data.config.macroer.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end - print("[Heimdall] Macroer loaded") + if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end + print("[Heimdall] Macroer loaded") end diff --git a/Modules/Messenger.lua b/Modules/Messenger.lua index b7de41c..13915d1 100644 --- a/Modules/Messenger.lua +++ b/Modules/Messenger.lua @@ -56,8 +56,14 @@ function shared.Messenger.Init() end if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Processing message - Channel: %s, Data: %s", ModuleName, - message.channel or "nil", message.data or "nil")) + print( + string.format( + "[%s] Processing message - Channel: %s, Data: %s", + ModuleName, + message.channel or "nil", + message.data or "nil" + ) + ) print(string.format("[%s] Message content: %s", ModuleName, message.message or "nil")) end @@ -89,8 +95,14 @@ function shared.Messenger.Init() if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, - message.data)) + print( + string.format( + "[%s] Processing channel message: '%s' to '%s'", + ModuleName, + message.message, + message.data + ) + ) end local channelId = GetChannelName(message.data) if channelId == 0 then @@ -126,8 +138,15 @@ function shared.Messenger.Init() end if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel, - message.data)) + print( + string.format( + "[%s] Sending message: '%s' to %s:%s", + ModuleName, + message.message, + message.channel, + message.data + ) + ) end if string.len(message.message) > 255 then print(string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)) @@ -146,8 +165,13 @@ function shared.Messenger.Init() end if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Module initialized with interval: %s", ModuleName, - Heimdall_Data.config.messenger.interval)) + print( + string.format( + "[%s] Module initialized with interval: %s", + ModuleName, + Heimdall_Data.config.messenger.interval + ) + ) end print("[Heimdall] Messenger loaded") end diff --git a/Modules/MinimapTagger.lua b/Modules/MinimapTagger.lua index 4a14bee..accb55b 100644 --- a/Modules/MinimapTagger.lua +++ b/Modules/MinimapTagger.lua @@ -110,8 +110,13 @@ function shared.MinimapTagger.Init() end if Heimdall_Data.config.minimapTagger.alertSound then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Playing alert sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.alertSoundFile)) + print( + string.format( + "[%s] Playing alert sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.alertSoundFile + ) + ) end if muteAlertUntil > GetTime() then if Heimdall_Data.config.minimapTagger.debug then @@ -121,14 +126,17 @@ function shared.MinimapTagger.Init() muteAlertUntil = GetTime() + Heimdall_Data.config.minimapTagger.alertSoundThrottle local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.alertSoundFile, "Master") if not ok and Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Failed to play alert sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.alertSoundFile)) + print( + string.format( + "[%s] Failed to play alert sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.alertSoundFile + ) + ) end end end - if doTag then - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL) - end + if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL) end end --endregion @@ -166,8 +174,13 @@ function shared.MinimapTagger.Init() end if Heimdall_Data.config.minimapTagger.tagSound then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Playing tag sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.tagSoundFile)) + print( + string.format( + "[%s] Playing tag sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.tagSoundFile + ) + ) end if muteTagUntil > GetTime() then if Heimdall_Data.config.minimapTagger.debug then @@ -177,14 +190,17 @@ function shared.MinimapTagger.Init() muteTagUntil = GetTime() + Heimdall_Data.config.minimapTagger.tagSoundThrottle local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.tagSoundFile, "Master") if not ok and Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Failed to play tag sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.tagSoundFile)) + print( + string.format( + "[%s] Failed to play tag sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.tagSoundFile + ) + ) end end end - if doTag then - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL) - end + if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL) end end --endregion @@ -222,8 +238,13 @@ function shared.MinimapTagger.Init() end if Heimdall_Data.config.minimapTagger.combatSound then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Playing combat sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.combatSoundFile)) + print( + string.format( + "[%s] Playing combat sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.combatSoundFile + ) + ) end if muteCombatUntil > GetTime() then if Heimdall_Data.config.minimapTagger.debug then @@ -233,14 +254,17 @@ function shared.MinimapTagger.Init() muteCombatUntil = GetTime() + Heimdall_Data.config.minimapTagger.combatSoundThrottle local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.combatSoundFile, "Master") if not ok and Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Failed to play combat sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.combatSoundFile)) + print( + string.format( + "[%s] Failed to play combat sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.combatSoundFile + ) + ) end end end - if doTag then - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL) - end + if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL) end end --endregion @@ -278,8 +302,13 @@ function shared.MinimapTagger.Init() end if Heimdall_Data.config.minimapTagger.helpSound then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Playing help sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.helpSoundFile)) + print( + string.format( + "[%s] Playing help sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.helpSoundFile + ) + ) end if muteHelpUntil > GetTime() then if Heimdall_Data.config.minimapTagger.debug then @@ -289,14 +318,17 @@ function shared.MinimapTagger.Init() muteHelpUntil = GetTime() + Heimdall_Data.config.minimapTagger.helpSoundThrottle local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.helpSoundFile, "Master") if not ok and Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Failed to play help sound: %s", ModuleName, - Heimdall_Data.config.minimapTagger.helpSoundFile)) + print( + string.format( + "[%s] Failed to play help sound: %s", + ModuleName, + Heimdall_Data.config.minimapTagger.helpSoundFile + ) + ) end end end - if doTag then - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL) - end + if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL) end end --endregion @@ -370,8 +402,14 @@ function shared.MinimapTagger.Init() if not ok then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Ignoring message from non-master channel: %s, need %s", ModuleName, channelname, - Heimdall_Data.config.minimapTagger.masterChannel)) + print( + string.format( + "[%s] Ignoring message from non-master channel: %s, need %s", + ModuleName, + channelname, + Heimdall_Data.config.minimapTagger.masterChannel + ) + ) end return end @@ -387,8 +425,14 @@ function shared.MinimapTagger.Init() local currentMapId = GetCurrentMapAreaID() if currentMapId ~= messageMapId then if Heimdall_Data.config.minimapTagger.debug then - print(string.format("[%s] Current map ID (%d) does not match message map ID (%d), ignoring message", - ModuleName, currentMapId, messageMapId)) + print( + string.format( + "[%s] Current map ID (%d) does not match message map ID (%d), ignoring message", + ModuleName, + currentMapId, + messageMapId + ) + ) end doTag = false end @@ -405,9 +449,7 @@ function shared.MinimapTagger.Init() if Heimdall_Data.config.minimapTagger.debug then print(string.format("[%s] Found alert position: %s, %s", ModuleName, tostring(x), tostring(y))) end - if x and y then - PlantTag(tonumber(x), tonumber(y), 2, doTag) - end + if x and y then PlantTag(tonumber(x), tonumber(y), 2, doTag) end end --endregion --region Combat @@ -425,9 +467,7 @@ function shared.MinimapTagger.Init() if Heimdall_Data.config.minimapTagger.debug then print(string.format("[%s] Found combat position: %s, %s", ModuleName, tostring(x), tostring(y))) end - if x and y then - PlantCombat(tonumber(x), tonumber(y), 2, doTag) - end + if x and y then PlantCombat(tonumber(x), tonumber(y), 2, doTag) end end --endregion --region Death @@ -445,9 +485,7 @@ function shared.MinimapTagger.Init() if Heimdall_Data.config.minimapTagger.debug then print(string.format("[%s] Found death position: %s, %s", ModuleName, tostring(x), tostring(y))) end - if x and y then - PlantAlert(tonumber(x), tonumber(y), 2, doTag) - end + if x and y then PlantAlert(tonumber(x), tonumber(y), 2, doTag) end end --endregion --region Help @@ -497,7 +535,5 @@ function shared.MinimapTagger.Init() print("[Heimdall] MinimapTagger loaded") end -SlashCmdList["HEIMDALL_MINIMAPTAGGER"] = function(args) - shared.MinimapTagger.Init() -end +SlashCmdList["HEIMDALL_MINIMAPTAGGER"] = function(args) shared.MinimapTagger.Init() end SLASH_HEIMDALL_MINIMAPTAGGER1 = "/mf" diff --git a/Modules/Network.lua b/Modules/Network.lua index c14b675..a1ee335 100644 --- a/Modules/Network.lua +++ b/Modules/Network.lua @@ -56,13 +56,10 @@ function shared.Network.Init() local friendsFrame = CreateFrame("Frame") friendsFrame:RegisterEvent("FRIENDLIST_UPDATE") - friendsFrame:SetScript("OnEvent", function(self, event, ...) - end) + friendsFrame:SetScript("OnEvent", function(self, event, ...) end) local function NetworkTick() - if Heimdall_Data.config.network.debug then - print("Network module is updating.") - end + if Heimdall_Data.config.network.debug then print("Network module is updating.") end ShowFriends() updatePending = true C_Timer.After(1, function() diff --git a/Modules/NetworkMessenger.lua b/Modules/NetworkMessenger.lua index a905992..551d169 100644 --- a/Modules/NetworkMessenger.lua +++ b/Modules/NetworkMessenger.lua @@ -63,9 +63,15 @@ function shared.NetworkMessenger.Init() end if Heimdall_Data.config.networkMessenger.debug then - print(string.format("[%s] Sending network message: '%s' to %s:%s", ModuleName, message.message, - message.channel, - message.data)) + print( + string.format( + "[%s] Sending network message: '%s' to %s:%s", + ModuleName, + message.message, + message.channel, + message.data + ) + ) end local payload = string.format("dmessage|%s|%s|%s", message.message, message.channel, message.data) if Heimdall_Data.config.networkMessenger.debug then @@ -140,7 +146,7 @@ function shared.NetworkMessenger.Init() local msg = { channel = channel, message = message, - data = target + data = target, } table.insert(shared.messenger.queue, msg) elseif command == "dmessage" then @@ -150,9 +156,7 @@ function shared.NetworkMessenger.Init() parts[1] = "message" local message = table.concat(parts, "|") - if nextIdx > #shared.networkNodes then - nextIdx = 1 - end + if nextIdx > #shared.networkNodes then nextIdx = 1 end local recipient = shared.networkNodes[nextIdx] nextIdx = nextIdx + 1 if Heimdall_Data.config.networkMessenger.debug then @@ -167,7 +171,7 @@ function shared.NetworkMessenger.Init() local testmsg = { channel = "W", message = "Hi, mom!", - data = "Secundus" + data = "Secundus", } for i = 1, 36 do table.insert(shared.networkMessenger.queue, testmsg) diff --git a/Modules/Noter.lua b/Modules/Noter.lua index 58c9bfe..4096825 100644 --- a/Modules/Noter.lua +++ b/Modules/Noter.lua @@ -29,16 +29,12 @@ function shared.Noter.Init() if #currentChunk + #word + 1 <= size then currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) else - if #currentChunk > 0 then - ret[#ret + 1] = currentChunk - end + if #currentChunk > 0 then ret[#ret + 1] = currentChunk end currentChunk = word end end - if #currentChunk > 0 then - ret[#ret + 1] = currentChunk - end + if #currentChunk > 0 then ret[#ret + 1] = currentChunk end return ret end @@ -65,8 +61,7 @@ function shared.Noter.Init() end local indices = shared.Split(range, "..") if Heimdall_Data.config.noter.debug then - print(string.format("[%s] Indices for range deletion: %s", ModuleName, - table.concat(indices, ", "))) + print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", "))) shared.dumpTable(indices) end local start = tonumber(indices[1]) @@ -74,8 +69,7 @@ function shared.Noter.Init() if not start then if Heimdall_Data.config.noter.debug then - print(string.format("[%s] Invalid start range for delete note: %s", ModuleName, - tostring(start))) + print(string.format("[%s] Invalid start range for delete note: %s", ModuleName, tostring(start))) end return end @@ -118,7 +112,7 @@ function shared.Noter.Init() local msg = { channel = "C", data = channel, - message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note) + message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note), } --table.insert(shared.messenger.queue, msg) table.insert(shared.networkMessenger.queue, msg) @@ -132,8 +126,13 @@ function shared.Noter.Init() local range = args[3] if not range then if Heimdall_Data.config.noter.debug then - print(string.format("[%s] No range specified for print note, defaulting to last %d notes", ModuleName, - Heimdall_Data.config.noter.lastNotes)) + print( + string.format( + "[%s] No range specified for print note, defaulting to last %d notes", + ModuleName, + Heimdall_Data.config.noter.lastNotes + ) + ) end local notes = Heimdall_Data.config.notes[name] or {} local start = math.max(1, #notes - Heimdall_Data.config.noter.lastNotes + 1) @@ -152,8 +151,7 @@ function shared.Noter.Init() end local indices = shared.Split(range, "..") if Heimdall_Data.config.noter.debug then - print(string.format("[%s] Indices for range printing: %s", ModuleName, - table.concat(indices, ", "))) + print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", "))) shared.dumpTable(indices) end local start = tonumber(indices[1]) @@ -161,8 +159,7 @@ function shared.Noter.Init() if not start then if Heimdall_Data.config.noter.debug then - print(string.format("[%s] Invalid start range for print note: %s", ModuleName, - tostring(start))) + print(string.format("[%s] Invalid start range for print note: %s", ModuleName, tostring(start))) end return end @@ -212,7 +209,7 @@ function shared.Noter.Init() local note = { source = sender, date = date("%Y-%m-%dT%H:%M:%S"), - note = msg + note = msg, } if Heimdall_Data.config.noter.debug then @@ -284,9 +281,7 @@ function shared.Noter.Init() print(string.format("[%s] Note command received for: %s", ModuleName, name)) end local note = strtrim(args[3] or "") - if Heimdall_Data.config.noter.debug then - print(string.format("[%s] Note: %s", ModuleName, note)) - end + if Heimdall_Data.config.noter.debug then print(string.format("[%s] Note: %s", ModuleName, note)) end if note == "delete" then DeleteNotes(name, args) elseif string.find(note, "^[%d%.]*$") then diff --git a/Modules/ReactiveValue.lua b/Modules/ReactiveValue.lua index 40ca42b..c05605d 100644 --- a/Modules/ReactiveValue.lua +++ b/Modules/ReactiveValue.lua @@ -1,667 +1,609 @@ local function Init() - local metadata = { - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __add = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value + other._value - end - if otherType == "string" and self._type == otherType then - return self._value .. other - end - if otherType == "number" and self._type == otherType then - return self._value + other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __mul = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value * other._value - end - if otherType == "number" and self._type == otherType then - return self._value * other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __sub = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value - other._value - end - if otherType == "number" and self._type == otherType then - return self._value - other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __div = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value / other._value - end - if otherType == "number" and self._type == otherType then - return self._value / other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __mod = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value % other._value - end - if otherType == "number" and self._type == otherType then - return self._value % other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return ReactiveValue|nil - __pow = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value ^ other._value - end - if otherType == "number" and self._type == otherType then - return self._value ^ other - end - return nil - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return boolean - __eq = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value == other._value - end - return self._value == other - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return boolean - __lt = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value < other._value - end - return self._value < other - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return boolean - __le = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value <= other._value - end - return self._value <= other - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return boolean - __gt = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value > other._value - end - return self._value > other - end, - ---@param self ReactiveValue - ---@param other ReactiveValue - ---@return boolean - __ge = function(self, other) - local otherType = type(other) - if otherType == "table" and other._type and other._type == self._type and other._value then - return self._value >= other._value - end - return self._value >= other - end, - ---@param self ReactiveValue - ---@return number - __len = function(self) - if self._type == "table" then - return #self._value - end - if self._type == "string" then - return string.len(self._value) - end - return 0 - end, - ---@param self ReactiveValue - ---@return string - __tostring = function(self) - return tostring(self._value) - end, - ---@param self ReactiveValue - ---@param key string - ---@param value any - ---@return nil - __newindex = function(self, key, value) - local setupComplete = rawget(self, "_setupComplete") - if setupComplete == nil or setupComplete == false then - rawset(self, key, value) - return - end - if self._type ~= "table" then - rawset(self, key, value) - return - end + local metadata = { + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __add = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value + other._value + end + if otherType == "string" and self._type == otherType then return self._value .. other end + if otherType == "number" and self._type == otherType then return self._value + other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __mul = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value * other._value + end + if otherType == "number" and self._type == otherType then return self._value * other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __sub = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value - other._value + end + if otherType == "number" and self._type == otherType then return self._value - other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __div = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value / other._value + end + if otherType == "number" and self._type == otherType then return self._value / other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __mod = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value % other._value + end + if otherType == "number" and self._type == otherType then return self._value % other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return ReactiveValue|nil + __pow = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value ^ other._value + end + if otherType == "number" and self._type == otherType then return self._value ^ other end + return nil + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return boolean + __eq = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value == other._value + end + return self._value == other + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return boolean + __lt = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value < other._value + end + return self._value < other + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return boolean + __le = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value <= other._value + end + return self._value <= other + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return boolean + __gt = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value > other._value + end + return self._value > other + end, + ---@param self ReactiveValue + ---@param other ReactiveValue + ---@return boolean + __ge = function(self, other) + local otherType = type(other) + if otherType == "table" and other._type and other._type == self._type and other._value then + return self._value >= other._value + end + return self._value >= other + end, + ---@param self ReactiveValue + ---@return number + __len = function(self) + if self._type == "table" then return #self._value end + if self._type == "string" then return string.len(self._value) end + return 0 + end, + ---@param self ReactiveValue + ---@return string + __tostring = function(self) return tostring(self._value) end, + ---@param self ReactiveValue + ---@param key string + ---@param value any + ---@return nil + __newindex = function(self, key, value) + local setupComplete = rawget(self, "_setupComplete") + if setupComplete == nil or setupComplete == false then + rawset(self, key, value) + return + end + if self._type ~= "table" then + rawset(self, key, value) + return + end - self._value[key] = value - local ChangedKey = { key } + self._value[key] = value + local ChangedKey = { key } - -- If the value being assigned is a ReactiveValue - -- Then listen to changes on it as well - -- And propagate those changes upwards - if self._recursive and getmetatable(value) == getmetatable(self) then - self:_setupListeners(key, value) - end + -- If the value being assigned is a ReactiveValue + -- Then listen to changes on it as well + -- And propagate those changes upwards + if self._recursive and getmetatable(value) == getmetatable(self) then self:_setupListeners(key, value) end - self:_notify() - self:_notifyFieldChanged(ChangedKey) - self:_notifyAnyFieldChanged(ChangedKey) - end, - ---@param self ReactiveValue - ---@param key string - ---@return any|nil - __index = function(self, key) - local value = rawget(self, key) - if value ~= nil then - return value - end - if rawget(self, "_type") ~= "table" then - return nil - end - local innerTable = rawget(self, "_value") - if innerTable ~= nil then - return rawget(innerTable, key) - end - return nil - end - -- __index = ReactiveValue - } + self:_notify() + self:_notifyFieldChanged(ChangedKey) + self:_notifyAnyFieldChanged(ChangedKey) + end, + ---@param self ReactiveValue + ---@param key string + ---@return any|nil + __index = function(self, key) + local value = rawget(self, key) + if value ~= nil then return value end + if rawget(self, "_type") ~= "table" then return nil end + local innerTable = rawget(self, "_value") + if innerTable ~= nil then return rawget(innerTable, key) end + return nil + end, + -- __index = ReactiveValue + } - --- Sadly I could not get @generic to play nice with this class - --- I think it's not ready yet, there are issues on github describing similar problems and it is marked as WIP... - --- Guess I'll have to live without it for now and specify type of a RV in #type + --- Sadly I could not get @generic to play nice with this class + --- I think it's not ready yet, there are issues on github describing similar problems and it is marked as WIP... + --- Guess I'll have to live without it for now and specify type of a RV in #type - ---## A type safe value that can be listened to for changes - ---### **Always use RV:set() for setting primitive values** - --- Supports primitive values and tables
- --- Tables can be listened to for changes on any field or a specific field
- ---### Example usage (value):
- --- ```lua - --- local test = ReactiveValue.new(1) - --- test:onChange(function(value) - --- print("test changed to " .. value) - --- end) - --- test:set(2) - --- test:set(test + 3) - --- ``` - ---### Example usage (table):
- --- ```lua - --- local test = ReactiveValue.new({1, 2, 3}) - --- test:onAnyFieldChange(function(field, value) - --- print(string.format("test.%s changed to %s", table.concat(field, "."), value)) - --- end) - --- test[1] = 4 -- test.1 changed to 4 - --- test[4] = {1, 2, 3} -- test.4 changed to - --- test[4][1] = 14 -- No log(!!) because test[4] is a table and not a ReactiveValue - --- ``` - ---### To trigger a callback for `test[4][1]` in the previous example do:
- --- ```lua - --- local test = ReactiveValue.new({1, 2, 3}, true) - --- test:onAnyFieldChange(function(field, value) - --- print(string.format("test.%s changed to %s", table.concat(field, "."), value)) - --- end) - --- test[1] = 4 -- test.1 changed to 4 - --- test[4] = {1, 2, 3} -- test.4 changed to
- --- test[4][1] = 14 -- test.4.1 changed to 14 - --- ``` - ---### To listen to a specific field of a table do:
- --- ```lua - --- local test = ReactiveValue.new({1, 2, 3}, true) - --- test:onFieldChange("1", function(value) - --- print("test.1 changed to " .. value) - --- end) - --- test[1] = 4 -- test.1 changed to 4 - --- test[4] = {1, 2, 3} -- Does not trigger callback - -- ``` - ---@class ReactiveValue - ---@field _listeners table - ---@field _fieldListeners table> - ---@field _anyFieldListeners table> - ---@field _oneTimeListeners table - ---@field _value any - ---@field _type string - ---@field _recursive boolean? - ReactiveValue = { - ---#### Get the underlying value of a ReactiveValue - ---@param self ReactiveValue - ---@return any - get = function(self) end, + ---## A type safe value that can be listened to for changes + ---### **Always use RV:set() for setting primitive values** + --- Supports primitive values and tables
+ --- Tables can be listened to for changes on any field or a specific field
+ ---### Example usage (value):
+ --- ```lua + --- local test = ReactiveValue.new(1) + --- test:onChange(function(value) + --- print("test changed to " .. value) + --- end) + --- test:set(2) + --- test:set(test + 3) + --- ``` + ---### Example usage (table):
+ --- ```lua + --- local test = ReactiveValue.new({1, 2, 3}) + --- test:onAnyFieldChange(function(field, value) + --- print(string.format("test.%s changed to %s", table.concat(field, "."), value)) + --- end) + --- test[1] = 4 -- test.1 changed to 4 + --- test[4] = {1, 2, 3} -- test.4 changed to
+ --- test[4][1] = 14 -- No log(!!) because test[4] is a table and not a ReactiveValue + --- ``` + ---### To trigger a callback for `test[4][1]` in the previous example do:
+ --- ```lua + --- local test = ReactiveValue.new({1, 2, 3}, true) + --- test:onAnyFieldChange(function(field, value) + --- print(string.format("test.%s changed to %s", table.concat(field, "."), value)) + --- end) + --- test[1] = 4 -- test.1 changed to 4 + --- test[4] = {1, 2, 3} -- test.4 changed to
+ --- test[4][1] = 14 -- test.4.1 changed to 14 + --- ``` + ---### To listen to a specific field of a table do:
+ --- ```lua + --- local test = ReactiveValue.new({1, 2, 3}, true) + --- test:onFieldChange("1", function(value) + --- print("test.1 changed to " .. value) + --- end) + --- test[1] = 4 -- test.1 changed to 4 + --- test[4] = {1, 2, 3} -- Does not trigger callback + -- ``` + ---@class ReactiveValue + ---@field _listeners table + ---@field _fieldListeners table> + ---@field _anyFieldListeners table> + ---@field _oneTimeListeners table + ---@field _value any + ---@field _type string + ---@field _recursive boolean? + ReactiveValue = { + ---#### Get the underlying value of a ReactiveValue + ---@param self ReactiveValue + ---@return any + get = function(self) end, - ---### Set the underlying value of a ReactiveValue triggering listener callbacks - ---@param self ReactiveValue - ---@param newValue any - set = function(self, newValue) end, + ---### Set the underlying value of a ReactiveValue triggering listener callbacks + ---@param self ReactiveValue + ---@param newValue any + set = function(self, newValue) end, - ---## EVENT - ---### Register a listener that is triggered whenever the underlying value changes - --- Returns a function that can be called to undo the callback - ---@param self ReactiveValue - ---@param callback fun(value: any, type: string) - ---@return fun(): nil - onChange = function(self, callback) end, + ---## EVENT + ---### Register a listener that is triggered whenever the underlying value changes + --- Returns a function that can be called to undo the callback + ---@param self ReactiveValue + ---@param callback fun(value: any, type: string) + ---@return fun(): nil + onChange = function(self, callback) end, - ---## EVENT - ---### Register a listener that is triggered whenever a specific field of a table changes - --- Returns a function that can be called to undo the callback - ---@param self ReactiveValue - ---@param field string - ---@param callback fun(field: string[], value: any, type: string) - ---@return fun(): nil - onFieldChange = function(self, field, callback) end, + ---## EVENT + ---### Register a listener that is triggered whenever a specific field of a table changes + --- Returns a function that can be called to undo the callback + ---@param self ReactiveValue + ---@param field string + ---@param callback fun(field: string[], value: any, type: string) + ---@return fun(): nil + onFieldChange = function(self, field, callback) end, - ---## EVENT - ---### Register a listener that is triggered whenever any field of a table changes - --- Returns a function that can be called to undo the callback - ---@param self ReactiveValue - ---@param callback fun(field: string[], value: any, type: string) - ---@param depth number? How deep to listen for changes - ---@return fun(): nil - onAnyFieldChange = function(self, callback, depth) end, + ---## EVENT + ---### Register a listener that is triggered whenever any field of a table changes + --- Returns a function that can be called to undo the callback + ---@param self ReactiveValue + ---@param callback fun(field: string[], value: any, type: string) + ---@param depth number? How deep to listen for changes + ---@return fun(): nil + onAnyFieldChange = function(self, callback, depth) end, - ---## EVENT - ---### Register a listener that is triggered ONCE whenever the underlying value changes - --- Returns a function that can be called to undo the callback - ---@param self ReactiveValue - ---@param callback fun(value: any, type: string) - ---@return fun(): nil - once = function(self, callback) end, - ---### Setup listeners for all fields of a table recursively - --- This is used to ensure that listeners are notified recursively + ---## EVENT + ---### Register a listener that is triggered ONCE whenever the underlying value changes + --- Returns a function that can be called to undo the callback + ---@param self ReactiveValue + ---@param callback fun(value: any, type: string) + ---@return fun(): nil + once = function(self, callback) end, + ---### Setup listeners for all fields of a table recursively + --- This is used to ensure that listeners are notified recursively - ---@param self ReactiveValue - _setupAllListenersRecursively = function(self) end, - ---### Setup listeners for a specific field of a table recursively - --- This is used to ensure that listeners are notified recursively + ---@param self ReactiveValue + _setupAllListenersRecursively = function(self) end, + ---### Setup listeners for a specific field of a table recursively + --- This is used to ensure that listeners are notified recursively - ---@param self ReactiveValue - _setupListeners = function(self, key, value, recursive) end, + ---@param self ReactiveValue + _setupListeners = function(self, key, value, recursive) end, - ---### Notify listeners that the underlying value has changed - ---@param self ReactiveValue - ---@return nil - ---#### Event contains: - --- 2. value: any - The new value of the changed field - --- 3. type: string - The type of the new value of the changed field - _notify = function(self) end, + ---### Notify listeners that the underlying value has changed + ---@param self ReactiveValue + ---@return nil + ---#### Event contains: + --- 2. value: any - The new value of the changed field + --- 3. type: string - The type of the new value of the changed field + _notify = function(self) end, - ---### Notify listeners that a specific field of the underlying value has changed - ---#### Event contains: - --- 1. field: table - A list of keys that lead to the changed field - --- 2. value: any - The new value of the changed field - --- 3. type: string - The type of the new value of the changed field - ---@param self ReactiveValue - _notifyFieldChanged = function(self, field) end, + ---### Notify listeners that a specific field of the underlying value has changed + ---#### Event contains: + --- 1. field: table - A list of keys that lead to the changed field + --- 2. value: any - The new value of the changed field + --- 3. type: string - The type of the new value of the changed field + ---@param self ReactiveValue + _notifyFieldChanged = function(self, field) end, - ---### Notify listeners that any field of the underlying value has changed - ---#### Event contains: - --- 1. field: table - A list of keys that lead to the changed field - --- 2. value: any - The new value of the changed field - --- 3. type: string - The type of the new value of the changed field - _notifyAnyFieldChanged = function(self, field) end, - } - ---### Constructor - ---@param initialValue any - ---@param recursive boolean? - ---@return ReactiveValue - ReactiveValue.new = function(initialValue, recursive) - local self = setmetatable({}, metadata) - self._listeners = {} - self._fieldListeners = {} - self._anyFieldListeners = {} - self._oneTimeListeners = {} - self._value = initialValue - self._type = type(initialValue) - self._recursive = recursive or false + ---### Notify listeners that any field of the underlying value has changed + ---#### Event contains: + --- 1. field: table - A list of keys that lead to the changed field + --- 2. value: any - The new value of the changed field + --- 3. type: string - The type of the new value of the changed field + _notifyAnyFieldChanged = function(self, field) end, + } + ---### Constructor + ---@param initialValue any + ---@param recursive boolean? + ---@return ReactiveValue + ReactiveValue.new = function(initialValue, recursive) + local self = setmetatable({}, metadata) + self._listeners = {} + self._fieldListeners = {} + self._anyFieldListeners = {} + self._oneTimeListeners = {} + self._value = initialValue + self._type = type(initialValue) + self._recursive = recursive or false - ---@return any - self.get = function(self) - return self._value - end - ---@param newValue any - self.set = function(self, newValue) - if self._value == newValue then - return - end - if type(newValue) ~= self._type then - error("Expected " .. self._type .. ", got " .. type(newValue)) - return - end - self._value = newValue - self:_notify() - end - self.onChange = function(self, callback) - if type(callback) ~= "function" then - error("Expected function, got " .. type(callback)) - return function() end - end - self._listeners[callback] = true - return function() - self._listeners[callback] = nil - end - end - self.onFieldChange = function(self, field, callback) - if type(callback) ~= "function" then - error("Expected function, got " .. type(callback)) - return function() end - end - if self._fieldListeners[field] == nil then - self._fieldListeners[field] = {} - end - self._fieldListeners[field][callback] = true - return function() - self._fieldListeners[field][callback] = nil - end - end - self.onAnyFieldChange = function(self, callback, depth) - depth = depth or 99999 - if type(callback) ~= "function" then - error("Expected function, got " .. type(callback)) - return function() end - end - if self._anyFieldListeners[depth] == nil then - self._anyFieldListeners[depth] = {} - end - self._anyFieldListeners[depth][callback] = true - return function() - self._anyFieldListeners[depth][callback] = nil - end - end - self.once = function(self, callback) - if type(callback) ~= "function" then - error("Expected function, got " .. type(callback)) - return function() end - end - self._oneTimeListeners[callback] = true - return function() - self._oneTimeListeners[callback] = nil - end - end + ---@return any + self.get = function(self) return self._value end + ---@param newValue any + self.set = function(self, newValue) + if self._value == newValue then return end + if type(newValue) ~= self._type then + error("Expected " .. self._type .. ", got " .. type(newValue)) + return + end + self._value = newValue + self:_notify() + end + self.onChange = function(self, callback) + if type(callback) ~= "function" then + error("Expected function, got " .. type(callback)) + return function() end + end + self._listeners[callback] = true + return function() self._listeners[callback] = nil end + end + self.onFieldChange = function(self, field, callback) + if type(callback) ~= "function" then + error("Expected function, got " .. type(callback)) + return function() end + end + if self._fieldListeners[field] == nil then self._fieldListeners[field] = {} end + self._fieldListeners[field][callback] = true + return function() self._fieldListeners[field][callback] = nil end + end + self.onAnyFieldChange = function(self, callback, depth) + depth = depth or 99999 + if type(callback) ~= "function" then + error("Expected function, got " .. type(callback)) + return function() end + end + if self._anyFieldListeners[depth] == nil then self._anyFieldListeners[depth] = {} end + self._anyFieldListeners[depth][callback] = true + return function() self._anyFieldListeners[depth][callback] = nil end + end + self.once = function(self, callback) + if type(callback) ~= "function" then + error("Expected function, got " .. type(callback)) + return function() end + end + self._oneTimeListeners[callback] = true + return function() self._oneTimeListeners[callback] = nil end + end - self._setupAllListenersRecursively = function(self) - if self._type ~= "table" then - return - end - for key, value in pairs(self._value) do - self:_setupListeners(key, value, true) - end - end - ---@param key string - ---@param value any - ---@param recursive boolean? - self._setupListeners = function(self, key, value, recursive) - recursive = recursive or false - if self._type ~= "table" then - return - end - if getmetatable(value) ~= getmetatable(self) then - return - end - value._recursive = true - if value._type == "table" then - value:onAnyFieldChange(function(key2) - ChangedKey = { key, table.unpack(key2) } - self:_notifyFieldChanged(ChangedKey) - self:_notifyAnyFieldChanged(ChangedKey) - end) - else - value:onChange(function(newVal) - ChangedKey = { key } - self:_notifyFieldChanged(ChangedKey) - self:_notifyAnyFieldChanged(ChangedKey) - end) - end + self._setupAllListenersRecursively = function(self) + if self._type ~= "table" then return end + for key, value in pairs(self._value) do + self:_setupListeners(key, value, true) + end + end + ---@param key string + ---@param value any + ---@param recursive boolean? + self._setupListeners = function(self, key, value, recursive) + recursive = recursive or false + if self._type ~= "table" then return end + if getmetatable(value) ~= getmetatable(self) then return end + value._recursive = true + if value._type == "table" then + value:onAnyFieldChange(function(key2) + ChangedKey = { key, table.unpack(key2) } + self:_notifyFieldChanged(ChangedKey) + self:_notifyAnyFieldChanged(ChangedKey) + end) + else + value:onChange(function(newVal) + ChangedKey = { key } + self:_notifyFieldChanged(ChangedKey) + self:_notifyAnyFieldChanged(ChangedKey) + end) + end - if recursive then - value:_setupAllListenersRecursively() - end - end + if recursive then value:_setupAllListenersRecursively() end + end - if recursive then - self:_setupAllListenersRecursively() - end + if recursive then self:_setupAllListenersRecursively() end - self._notify = function(self) - for listener, _ in pairs(self._oneTimeListeners) do - -- task.spawn(listener, self._value, self._type) - listener(self._value, self._type) - self._oneTimeListeners[listener] = nil - end - for listener, _ in pairs(self._listeners) do - -- task.spawn(listener, self._value, self._type) - listener(self._value, self._type) - end - end - -- TODO: Maybe implement some sort of regex here or something... - -- Such as listening to *.field1 or something - -- But this (having to loop over listeners and evaluate some condition) would tank performance - -- Compared to a simple lookup - -- So I'm not going to do anything about it for now, until I figure out a better way - ---@param field table A list of keys that lead to the changed field - ---@return nil - self._notifyFieldChanged = function(self, field) - local value = self._value - for _, key in ipairs(field) do - value = value[key] - end + self._notify = function(self) + for listener, _ in pairs(self._oneTimeListeners) do + -- task.spawn(listener, self._value, self._type) + listener(self._value, self._type) + self._oneTimeListeners[listener] = nil + end + for listener, _ in pairs(self._listeners) do + -- task.spawn(listener, self._value, self._type) + listener(self._value, self._type) + end + end + -- TODO: Maybe implement some sort of regex here or something... + -- Such as listening to *.field1 or something + -- But this (having to loop over listeners and evaluate some condition) would tank performance + -- Compared to a simple lookup + -- So I'm not going to do anything about it for now, until I figure out a better way + ---@param field table A list of keys that lead to the changed field + ---@return nil + self._notifyFieldChanged = function(self, field) + local value = self._value + for _, key in ipairs(field) do + value = value[key] + end - local strfield = table.concat(field, ".") - if self._fieldListeners[strfield] == nil then - return - end - for listener, _ in pairs(self._fieldListeners[strfield]) do - -- task.spawn(listener, value, type(value)) - listener(value, type(value)) - end - end - ---@param self ReactiveValue - ---@param field table A list of keys that lead to the changed field - ---@return nil - self._notifyAnyFieldChanged = function(self, field) - local value = self._value - for _, key in ipairs(field) do - value = value[key] - end - local keyDepth = #field - for listenerDepth, listeners in pairs(self._anyFieldListeners) do - if listenerDepth >= keyDepth then - for listener, _ in pairs(listeners) do - -- The reason this also returns type(value) is so that clients don't have to compute type(value) - -- I assume some of them might want to do it so computing it once is probably better than having every client compute it for themselves - -- task.spawn(listener, field, value, type(value)) - listener(field, value, type(value)) - end - end - end - end + local strfield = table.concat(field, ".") + if self._fieldListeners[strfield] == nil then return end + for listener, _ in pairs(self._fieldListeners[strfield]) do + -- task.spawn(listener, value, type(value)) + listener(value, type(value)) + end + end + ---@param self ReactiveValue + ---@param field table A list of keys that lead to the changed field + ---@return nil + self._notifyAnyFieldChanged = function(self, field) + local value = self._value + for _, key in ipairs(field) do + value = value[key] + end + local keyDepth = #field + for listenerDepth, listeners in pairs(self._anyFieldListeners) do + if listenerDepth >= keyDepth then + for listener, _ in pairs(listeners) do + -- The reason this also returns type(value) is so that clients don't have to compute type(value) + -- I assume some of them might want to do it so computing it once is probably better than having every client compute it for themselves + -- task.spawn(listener, field, value, type(value)) + listener(field, value, type(value)) + end + end + end + end - self._setupComplete = true - return self - end + self._setupComplete = true + return self + end - -- S -- begintest - -- S local invocations = 0 - -- S -- Integer example - -- S local test = ReactiveValue.new(1) - -- S test:onChange(function(value) - -- S invocations = invocations + 1 - -- S print("test changed to " .. value) - -- S end) - -- S test:set(2) - -- S assert(invocations == 1) - -- S - -- S invocations = 0 - -- String example - -- S test = ReactiveValue.new("test") - -- S test:onChange(function(value) - -- S invocations = invocations + 1 - -- S print("test changed to " .. value) - -- S end) - -- S test:set("test2") - -- S assert(invocations == 1) - -- S - -- S -- Type safety example - -- S local res, err = pcall(test.set, test, 1) - -- S assert(res == false) - -- S assert(err:find("Expected string, got number")) - -- S - -- S -- Table example - -- S invocations = 0 - -- S test = ReactiveValue.new({1, 2, 3}) - -- S local clbk = test:onChange(function(value) - -- S invocations = invocations + 1 - -- S print("test changed to") - -- S dumpTable(value, 0) - -- S end) - -- S test:set({1, 2, 3, 4}) - -- S assert(invocations == 1) - -- S - -- S -- Callback removal example - -- S clbk() - -- S - -- S invocations = 0 - -- S -- Any field change example - -- S clbk = test:onAnyFieldChange(function(field, value) - -- S invocations = invocations + 1 - -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) - -- S end) - -- S test.Pero = 1 - -- S test.Pero = nil - -- S assert(invocations == 2) - -- S clbk() - -- S - -- S invocations = 0 - -- S -- Field change example - -- S test:onFieldChange("Pero", function(value) - -- S invocations = invocations + 1 - -- S print("test.Pero changed to " .. value) - -- S end) - -- S test.Pero = 2 - -- S assert(invocations == 1) - -- S - -- S invocations = 0 - -- S -- One time listener example - -- S test:once(function(value) - -- S invocations = invocations + 1 - -- S print("test changed to") - -- S dumpTable(value, 0) - -- S end) - -- S test:set({3, 2, 1}) - -- S assert(invocations == 1) - -- S - -- S invocations = 0 - -- S -- Table push example - -- S test = ReactiveValue.new({}) - -- S test:onChange(function(value) - -- S invocations = invocations + 1 - -- S print("test changed to") - -- S dumpTable(value, 0) - -- S end) - -- S test:onAnyFieldChange(function(field, value) - -- S invocations = invocations + 1 - -- S print("test." .. table.concat(field, ".") .. " changed to " .. value) - -- S end) - -- S test[#test + 1] = 4 - -- S assert(invocations == 2) - -- S - -- S invocations = 0 - -- S test = ReactiveValue.new({ - -- S name = "pero", - -- S coins = ReactiveValue.new(1) - -- S }) - -- S test.coins:onChange(function(value) - -- S invocations = invocations + 1 - -- S print("test.coins changed to " .. value) - -- S end) - -- S test.coins:set(2) - -- S assert(invocations == 1) - -- S - -- S invocations = 0 - -- S test = ReactiveValue.new({ - -- S name = "pero", - -- S coins = ReactiveValue.new(1) - -- S }, true) - -- S test:onAnyFieldChange(function(field, value) - -- S invocations = invocations + 1 - -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) - -- S end) - -- S test.coins:set(2) - -- S test.pero2 = ReactiveValue.new({}) - -- S test.pero2.coins = ReactiveValue.new(1) - -- S test.pero2.coins:set(2) - -- S assert(invocations == 4) - -- S - -- S invocations = 0 - -- S test = ReactiveValue.new({ - -- S name = "pero", - -- S coins = ReactiveValue.new({ - -- S value = ReactiveValue.new(1) - -- S }) - -- S }, true) - -- S test:onAnyFieldChange(function(field, value) - -- S invocations = invocations + 1 - -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) - -- S end) - -- S test.coins.value:set(2) - -- S assert(invocations == 1) - -- S - -- S invocations = 0 - -- S test = ReactiveValue.new({}, true) - -- S test.coins = ReactiveValue.new({}) - -- S test.coins.value = ReactiveValue.new(1) - -- S test:onAnyFieldChange(function(field, value) - -- S invocations = invocations + 1 - -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) - -- S end) - -- S test.coins.value:set(3) - -- S assert(invocations == 1) - --S - --S invocations = 0 - --S test = ReactiveValue.new({}, true) - --S test:onAnyFieldChange(function(field, value) - --S invocations = invocations + 1 - --S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) - --S end, 1) - --S test.test2 = ReactiveValue.new({}, true) - --S test.test2.test3 = ReactiveValue.new(1) - --S assert(invocations == 1) - --S - -- S -- endtest + -- S -- begintest + -- S local invocations = 0 + -- S -- Integer example + -- S local test = ReactiveValue.new(1) + -- S test:onChange(function(value) + -- S invocations = invocations + 1 + -- S print("test changed to " .. value) + -- S end) + -- S test:set(2) + -- S assert(invocations == 1) + -- S + -- S invocations = 0 + -- String example + -- S test = ReactiveValue.new("test") + -- S test:onChange(function(value) + -- S invocations = invocations + 1 + -- S print("test changed to " .. value) + -- S end) + -- S test:set("test2") + -- S assert(invocations == 1) + -- S + -- S -- Type safety example + -- S local res, err = pcall(test.set, test, 1) + -- S assert(res == false) + -- S assert(err:find("Expected string, got number")) + -- S + -- S -- Table example + -- S invocations = 0 + -- S test = ReactiveValue.new({1, 2, 3}) + -- S local clbk = test:onChange(function(value) + -- S invocations = invocations + 1 + -- S print("test changed to") + -- S dumpTable(value, 0) + -- S end) + -- S test:set({1, 2, 3, 4}) + -- S assert(invocations == 1) + -- S + -- S -- Callback removal example + -- S clbk() + -- S + -- S invocations = 0 + -- S -- Any field change example + -- S clbk = test:onAnyFieldChange(function(field, value) + -- S invocations = invocations + 1 + -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) + -- S end) + -- S test.Pero = 1 + -- S test.Pero = nil + -- S assert(invocations == 2) + -- S clbk() + -- S + -- S invocations = 0 + -- S -- Field change example + -- S test:onFieldChange("Pero", function(value) + -- S invocations = invocations + 1 + -- S print("test.Pero changed to " .. value) + -- S end) + -- S test.Pero = 2 + -- S assert(invocations == 1) + -- S + -- S invocations = 0 + -- S -- One time listener example + -- S test:once(function(value) + -- S invocations = invocations + 1 + -- S print("test changed to") + -- S dumpTable(value, 0) + -- S end) + -- S test:set({3, 2, 1}) + -- S assert(invocations == 1) + -- S + -- S invocations = 0 + -- S -- Table push example + -- S test = ReactiveValue.new({}) + -- S test:onChange(function(value) + -- S invocations = invocations + 1 + -- S print("test changed to") + -- S dumpTable(value, 0) + -- S end) + -- S test:onAnyFieldChange(function(field, value) + -- S invocations = invocations + 1 + -- S print("test." .. table.concat(field, ".") .. " changed to " .. value) + -- S end) + -- S test[#test + 1] = 4 + -- S assert(invocations == 2) + -- S + -- S invocations = 0 + -- S test = ReactiveValue.new({ + -- S name = "pero", + -- S coins = ReactiveValue.new(1) + -- S }) + -- S test.coins:onChange(function(value) + -- S invocations = invocations + 1 + -- S print("test.coins changed to " .. value) + -- S end) + -- S test.coins:set(2) + -- S assert(invocations == 1) + -- S + -- S invocations = 0 + -- S test = ReactiveValue.new({ + -- S name = "pero", + -- S coins = ReactiveValue.new(1) + -- S }, true) + -- S test:onAnyFieldChange(function(field, value) + -- S invocations = invocations + 1 + -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) + -- S end) + -- S test.coins:set(2) + -- S test.pero2 = ReactiveValue.new({}) + -- S test.pero2.coins = ReactiveValue.new(1) + -- S test.pero2.coins:set(2) + -- S assert(invocations == 4) + -- S + -- S invocations = 0 + -- S test = ReactiveValue.new({ + -- S name = "pero", + -- S coins = ReactiveValue.new({ + -- S value = ReactiveValue.new(1) + -- S }) + -- S }, true) + -- S test:onAnyFieldChange(function(field, value) + -- S invocations = invocations + 1 + -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) + -- S end) + -- S test.coins.value:set(2) + -- S assert(invocations == 1) + -- S + -- S invocations = 0 + -- S test = ReactiveValue.new({}, true) + -- S test.coins = ReactiveValue.new({}) + -- S test.coins.value = ReactiveValue.new(1) + -- S test:onAnyFieldChange(function(field, value) + -- S invocations = invocations + 1 + -- S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) + -- S end) + -- S test.coins.value:set(3) + -- S assert(invocations == 1) + --S + --S invocations = 0 + --S test = ReactiveValue.new({}, true) + --S test:onAnyFieldChange(function(field, value) + --S invocations = invocations + 1 + --S print("test." .. table.concat(field, ".") .. " changed to " .. tostring(value)) + --S end, 1) + --S test.test2 = ReactiveValue.new({}, true) + --S test.test2.test3 = ReactiveValue.new(1) + --S assert(invocations == 1) + --S + -- S -- endtest end local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:RegisterEvent("GUILD_ROSTER_UPDATE") -frame:SetScript("OnEvent", function(self, event, ...) - Init() -end) +frame:SetScript("OnEvent", function(self, event, ...) Init() end) Init() diff --git a/Modules/Sniffer.lua b/Modules/Sniffer.lua index e60941c..501e743 100644 --- a/Modules/Sniffer.lua +++ b/Modules/Sniffer.lua @@ -6,9 +6,7 @@ local ModuleName = "Sniffer" ---@diagnostic disable-next-line: missing-fields shared.Sniffer = {} function shared.Sniffer.Init() - if Heimdall_Data.config.sniffer.debug then - print(string.format("[%s] Module initializing", ModuleName)) - end + if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end local smellThrottle = {} local SmellStinky = function(stinky) if Heimdall_Data.config.sniffer.debug then @@ -16,17 +14,14 @@ function shared.Sniffer.Init() shared.dumpTable(Heimdall_Data.config.sniffer) end if not Heimdall_Data.config.sniffer.enabled then return end - if Heimdall_Data.config.sniffer.stinky and - not shared.IsStinky(stinky) then + if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Stinky not found in config", ModuleName)) end return end if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttleTime then - if Heimdall_Data.config.sniffer.debug then - print(string.format("%s: Throttled", ModuleName)) - end + if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end return end smellThrottle[stinky] = GetTime() @@ -83,8 +78,6 @@ function shared.Sniffer.Init() end SmellStinky(destination) end) - if Heimdall_Data.config.sniffer.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] Sniffer loaded") end diff --git a/Modules/Spotter.lua b/Modules/Spotter.lua index 1a7e76f..ef5e01b 100644 --- a/Modules/Spotter.lua +++ b/Modules/Spotter.lua @@ -67,8 +67,13 @@ function shared.Spotter.Init() end if Heimdall_Data.config.spotter.debug then - print(string.format("[%s] Using everyone setting: %s", ModuleName, - tostring(Heimdall_Data.config.spotter.everyone))) + print( + string.format( + "[%s] Using everyone setting: %s", + ModuleName, + tostring(Heimdall_Data.config.spotter.everyone) + ) + ) end return Heimdall_Data.config.spotter.everyone end @@ -158,7 +163,8 @@ function shared.Spotter.Init() print(string.format("[%s] Processing channel: %s", ModuleName, channel)) end local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("spotterSpotted", locale), + local text = string.format( + shared._L("spotterSpotted", locale), hostile and shared._L("hostile", locale) or shared._L("friendly", locale), name, shared._L(class, locale), @@ -168,15 +174,18 @@ function shared.Spotter.Init() pvpOn and shared._L("pvpOn", locale) or shared._L("pvpOff", locale), string.gsub(FormatHP(hp), "M", "kk"), string.gsub(FormatHP(maxHp), "M", "kk"), - shared._L(zone, locale), shared._L(subzone, locale), + shared._L(zone, locale), + shared._L(subzone, locale), areaId, - x * 100, y * 100) + x * 100, + y * 100 + ) ---@type Message local msg = { channel = "C", data = channel, - message = text + message = text, } if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Queuing spotter message", ModuleName)) @@ -201,9 +210,7 @@ function shared.Spotter.Init() return end - if event == "UNIT_TARGET" then - unit = "target" - end + if event == "UNIT_TARGET" then unit = "target" end local err = NotifySpotted(unit) if err then @@ -213,8 +220,6 @@ function shared.Spotter.Init() end end) - if Heimdall_Data.config.spotter.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] Spotter loaded") end diff --git a/Modules/StinkyCache.lua b/Modules/StinkyCache.lua index 97030e8..f2d50a7 100644 --- a/Modules/StinkyCache.lua +++ b/Modules/StinkyCache.lua @@ -13,14 +13,23 @@ function shared.StinkyCache.Init() ---@param name string local function AskCommander(name) if Heimdall_Data.config.stinkyCache.debug then - print(string.format("[%s] Asking commander %s about %s", ModuleName, - Heimdall_Data.config.stinkyCache.commander, name)) + print( + string.format( + "[%s] Asking commander %s about %s", + ModuleName, + Heimdall_Data.config.stinkyCache.commander, + name + ) + ) end local messageParts = { "isstinky", name } local message = table.concat(messageParts, "|") - SendAddonMessage(Heimdall_Data.config.addonPrefix, - message, "WHISPER", - Heimdall_Data.config.stinkyCache.commander) + SendAddonMessage( + Heimdall_Data.config.addonPrefix, + message, + "WHISPER", + Heimdall_Data.config.stinkyCache.commander + ) return end @@ -29,20 +38,24 @@ function shared.StinkyCache.Init() addonMessageFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) if sender == Heimdall_Data.config.stinkyCache.commander then if Heimdall_Data.config.stinkyCache.debug then - print(string.format("[%s] Received stinky from commander %s: %s", ModuleName, - Heimdall_Data.config.stinkyCache.commander, msg)) + print( + string.format( + "[%s] Received stinky from commander %s: %s", + ModuleName, + Heimdall_Data.config.stinkyCache.commander, + msg + ) + ) end - local name, value = {strsplit("|", msg)} + local name, value = { strsplit("|", msg) } shared.stinkyCache.stinkies[name] = { value = value, timestamp = time() } else if Heimdall_Data.config.stinkyCache.debug then print(string.format("[%s] Received stinky from non-commander %s: %s", ModuleName, sender, msg)) end - local parts = {strsplit("|", msg)} + local parts = { strsplit("|", msg) } local command, name = parts[1], parts[2] - if parts[1] == "isstinky" then - local res = Heimdall_Data.config.stinkies[parts[2]] - end + if parts[1] == "isstinky" then local res = Heimdall_Data.config.stinkies[parts[2]] end end end) @@ -50,11 +63,9 @@ function shared.StinkyCache.Init() __index = function(self, key) local value = rawget(self, key) local now = GetTime() - if value == nil or now - value.timestamp > Heimdall_Data.config.stinkyCache.ttl then - AskCommander(key) - end + if value == nil or now - value.timestamp > Heimdall_Data.config.stinkyCache.ttl then AskCommander(key) end return rawget(self, key) - end + end, }) print("[Heimdall] StinkyCache module loaded") end diff --git a/Modules/StinkyTracker.lua b/Modules/StinkyTracker.lua index 54f4852..92e9572 100644 --- a/Modules/StinkyTracker.lua +++ b/Modules/StinkyTracker.lua @@ -7,7 +7,7 @@ local ModuleName = "StinkyTracker" shared.StinkyTracker = {} function shared.StinkyTracker.Init() shared.stinkyTracker = { - stinkies = ReactiveValue.new({}) + stinkies = ReactiveValue.new({}), } local whoRegex = "([^ -/]+)-?%w*/(%w+)" @@ -23,11 +23,18 @@ function shared.StinkyTracker.Init() name = name, class = class, seenAt = GetTime(), - hostile = true + hostile = true, } if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class, - date("%H:%M:%S", time()))) + print( + string.format( + "[%s] Found hostile player: %s (%s) at %s", + ModuleName, + name, + class, + date("%H:%M:%S", time()) + ) + ) shared.dumpTable(stinkies) end end @@ -53,12 +60,20 @@ function shared.StinkyTracker.Init() name = name, class = class, seenAt = GetTime(), - hostile = aggression == "hostile" + hostile = aggression == "hostile", } stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression, - date("%H:%M:%S", time()))) + print( + string.format( + "[%s] Found stinky in SEE: %s (%s) - %s at %s", + ModuleName, + name, + class, + aggression, + date("%H:%M:%S", time()) + ) + ) shared.dumpTable(stinkies) end return stinkies @@ -87,7 +102,7 @@ function shared.StinkyTracker.Init() name = name, class = class, seenAt = GetTime(), - hostile = true + hostile = true, } stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then @@ -141,8 +156,9 @@ function shared.StinkyTracker.Init() if stinky.hostile then shared.stinkyTracker.stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky - .class)) + print( + string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky.class) + ) end end end @@ -159,8 +175,9 @@ function shared.StinkyTracker.Init() if stinky.hostile then shared.stinkyTracker.stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky - .class)) + print( + string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky.class) + ) end end if not stinky.hostile then @@ -190,7 +207,9 @@ function shared.StinkyTracker.Init() -- Log total stinky count after processing if Heimdall_Data.config.stinkyTracker.debug then local count = 0 - for _ in pairs(shared.stinkyTracker.stinkies:get()) do count = count + 1 end + for _ in pairs(shared.stinkyTracker.stinkies:get()) do + count = count + 1 + end print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count)) end @@ -236,7 +255,7 @@ function shared.StinkyTracker.Init() name = name, class = UnitClass(unit), seenAt = GetTime(), - hostile = true + hostile = true, } return end @@ -254,8 +273,6 @@ function shared.StinkyTracker.Init() shared.stinkyTracker.stinkies[name] = nil end) - if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Module initialized", ModuleName)) - end + if Heimdall_Data.config.stinkyTracker.debug then print(string.format("[%s] Module initialized", ModuleName)) end print("[Heimdall] StinkyTracker loaded") end diff --git a/Modules/Whoer.lua b/Modules/Whoer.lua index c840ec0..0b35951 100644 --- a/Modules/Whoer.lua +++ b/Modules/Whoer.lua @@ -32,7 +32,7 @@ function shared.Whoer.Init() ---@return Player new = function(name, guild, race, class, zone) local self = setmetatable({}, { - __index = Player + __index = Player, }) self.name = name self.guild = guild @@ -47,13 +47,15 @@ function shared.Whoer.Init() end, ---@return string ToString = function(self) - local out = string.format("%s %s %s\nFirst: %s Last: %s Seen: %3d", + local out = string.format( + "%s %s %s\nFirst: %s Last: %s Seen: %3d", shared.padString(self.name, 16, true), shared.padString(self.guild, 26, false), shared.padString(self.zone, 26, false), shared.padString(self.firstSeen, 10, true), shared.padString(self.lastSeen, 10, true), - self.seenCount) + self.seenCount + ) return string.format("|cFF%s%s|r", shared.classColors[self.class], out) end, } @@ -67,12 +69,12 @@ function shared.Whoer.Init() ---@return WHOQuery new = function(query, filters) local self = setmetatable({}, { - __index = WHOQuery + __index = WHOQuery, }) self.query = query self.filters = filters return self - end + end, } ---@class WHOFilter @@ -81,12 +83,10 @@ function shared.Whoer.Init() ---@type WHOFilter local NotSiegeOfOrgrimmarFilter = { Run = function(name, guild, level, race, class, zone) - if not zone then - return false - end + if not zone then return false end return zone ~= "Siege of Orgrimmar" end, - key = "notsoo" + key = "notsoo", } ---@type WHOFilter local AllianceFilter = { @@ -95,7 +95,7 @@ function shared.Whoer.Init() if not shared.raceMap[race] then return false end return shared.raceMap[race] == "Alliance" end, - key = "ally" + key = "ally", } ---@class WhoQueryService @@ -110,15 +110,13 @@ function shared.Whoer.Init() queries = {}, filters = { NotSiegeOfOrgrimmarFilter, - AllianceFilter + AllianceFilter, }, ---@param key string ---@return WHOFilter? getFilter = function(key) for _, filter in pairs(shared.WhoQueryService.filters) do - if filter.key == key then - return filter - end + if filter.key == key then return filter end end return nil end, @@ -176,7 +174,7 @@ function shared.Whoer.Init() table.insert(ret, shared.WhoQueryService.WhoQueryFromString(query)) end return ret - end + end, } shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries) @@ -187,15 +185,13 @@ function shared.Whoer.Init() print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone)) end for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do - if Heimdall_Data.config.who.debug then - print(string.format("[%s] Checking zone %s", ModuleName, zone)) - end - if zone == "*" then - return true - end + if Heimdall_Data.config.who.debug then print(string.format("[%s] Checking zone %s", ModuleName, zone)) end + if zone == "*" then return true end if string.find(inputZone, zone) then if not Heimdall_Data.config.who.debug then - print(string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone)) + print( + string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone) + ) end return true end @@ -235,10 +231,25 @@ function shared.Whoer.Init() local function Notify(player) if Heimdall_Data.config.who.debug then print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name)) - print(string.format("[%s] Player details - Guild: %s, Race: %s, Class: %s, Zone: %s", ModuleName, - player.guild, player.race, player.class, player.zone)) - print(string.format("[%s] Player history - First seen: %s, Last seen: %s, Seen count: %d", ModuleName, - player.firstSeen, player.lastSeen, player.seenCount)) + print( + string.format( + "[%s] Player details - Guild: %s, Race: %s, Class: %s, Zone: %s", + ModuleName, + player.guild, + player.race, + player.class, + player.zone + ) + ) + print( + string.format( + "[%s] Player history - First seen: %s, Last seen: %s, Seen count: %d", + ModuleName, + player.firstSeen, + player.lastSeen, + player.seenCount + ) + ) end if not Heimdall_Data.config.who.enabled then @@ -258,26 +269,30 @@ function shared.Whoer.Init() if not shared.Whoer.ShouldNotifyForZone(player.zone) then --if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone)) + print( + string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone) + ) end return string.format("Not notifying for zone %s", tostring(player.zone)) end for _, channel in pairs(Heimdall_Data.config.who.channels) do local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("whoerNew", locale), + local text = string.format( + shared._L("whoerNew", locale), player.name, player.stinky and "(!!!!)" or "", shared._L(player.class, locale), --shared._L(player.race, locale), shared._L(shared.raceMap[player.race] or "unknown", locale), player.guild, - shared._L(player.zone, locale)) + shared._L(player.zone, locale) + ) ---@type Message local msg = { channel = "C", data = channel, - message = text + message = text, } if Heimdall_Data.config.who.debug then print(string.format("[%s] Queuing channel notification", ModuleName)) @@ -321,20 +336,22 @@ function shared.Whoer.Init() end for _, channel in pairs(Heimdall_Data.config.who.channels) do local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("whoerMoved", locale), + local text = string.format( + shared._L("whoerMoved", locale), player.name, player.stinky and "(!!!!)" or "", shared._L(player.class, locale), --shared._L(player.race, locale), shared._L(shared.raceMap[player.race] or "unknown", locale), player.guild, - shared._L(zone, locale)) + shared._L(zone, locale) + ) ---@type Message local msg = { channel = "C", data = channel, - message = text + message = text, } if Heimdall_Data.config.who.debug then print(string.format("[%s] Queuing channel notification", ModuleName)) @@ -370,20 +387,22 @@ function shared.Whoer.Init() for _, channel in pairs(Heimdall_Data.config.who.channels) do local locale = shared.GetLocaleForChannel(channel) - local text = string.format(shared._L("whoerGone", locale), + local text = string.format( + shared._L("whoerGone", locale), player.name, player.stinky and "(!!!!)" or "", shared._L(player.class, locale), --shared._L(player.race, locale), shared._L(shared.raceMap[player.race] or "unknown", locale), player.guild, - shared._L(player.zone, locale)) + shared._L(player.zone, locale) + ) ---@type Message local msg = { channel = "C", data = channel, - message = text + message = text, } if Heimdall_Data.config.who.debug then print(string.format("[%s] Queuing channel notification", ModuleName)) @@ -441,7 +460,9 @@ function shared.Whoer.Init() for i = 1, results do local name, guild, level, race, class, zone = GetWhoInfo(i) if Heimdall_Data.config.who.debug then - print(string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone)) + print( + string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone) + ) end local continue = false @@ -449,11 +470,15 @@ function shared.Whoer.Init() local filters = query.filters for _, filter in pairs(filters) do if Heimdall_Data.config.who.debug then - print(string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone)) + print( + string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone) + ) end if not filter.Run(name, guild, level, race, class, zone) then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key)) + print( + string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key) + ) end continue = true break @@ -488,8 +513,15 @@ function shared.Whoer.Init() if existing then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Found existing data for %s - Last seen: %s, Count: %d", - ModuleName, name, existing.lastSeen or "never", existing.seenCount or 0)) + print( + string.format( + "[%s] Found existing data for %s - Last seen: %s, Count: %d", + ModuleName, + name, + existing.lastSeen or "never", + existing.seenCount or 0 + ) + ) end player.lastSeen = existing.lastSeen or "never" player.firstSeen = existing.firstSeen or "never" @@ -516,7 +548,9 @@ function shared.Whoer.Init() local err = Notify(player) if err then - print(string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err))) + print( + string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err)) + ) end player.lastSeen = timestamp @@ -527,13 +561,18 @@ function shared.Whoer.Init() player.lastSeenInternal = GetTime() if player.zone ~= zone then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Player %s zone changed from %s to %s", ModuleName, name, player.zone, - zone)) + print( + string.format( + "[%s] Player %s zone changed from %s to %s", + ModuleName, + name, + player.zone, + zone + ) + ) end local err = NotifyZoneChanged(player, zone) - if err then - print(string.format("Error notifying for %s: %s", tostring(name), tostring(err))) - end + if err then print(string.format("Error notifying for %s: %s", tostring(name), tostring(err))) end end player.zone = zone player.lastSeen = timestamp @@ -578,17 +617,22 @@ function shared.Whoer.Init() end if Heimdall_Data.config.who.debug then - print(string.format("[%s] Running WHO query %d/%d: %s", ModuleName, whoQueryIdx, - #shared.WhoQueryService.queries, query.query)) + print( + string.format( + "[%s] Running WHO query %d/%d: %s", + ModuleName, + whoQueryIdx, + #shared.WhoQueryService.queries, + query.query + ) + ) print(string.format("[%s] Query has %d filters", ModuleName, #query.filters)) for i, filter in ipairs(query.filters) do print(string.format("[%s] Filter %d: %s", ModuleName, i, filter.key)) end end whoQueryIdx = whoQueryIdx + 1 - if whoQueryIdx > #shared.WhoQueryService.queries then - whoQueryIdx = 1 - end + if whoQueryIdx > #shared.WhoQueryService.queries then whoQueryIdx = 1 end lastQuery = query ---@diagnostic disable-next-line: param-type-mismatch SetWhoToUI(1) diff --git a/Weakauras/Config/init.lua b/Weakauras/Config/init.lua index 0ba77e3..0e0b59c 100644 --- a/Weakauras/Config/init.lua +++ b/Weakauras/Config/init.lua @@ -6,9 +6,7 @@ local function StringToMap(str, deliminer) local parts = { strsplit(deliminer, str) } for _, line in ipairs(parts) do line = strtrim(line) - if line ~= "" then - map[line] = true - end + if line ~= "" then map[line] = true end end return map end @@ -21,9 +19,7 @@ local function StringToArray(str, deliminer) local array = { strsplit(deliminer, str) } for i, line in ipairs(array) do line = strtrim(line) - if line ~= "" then - ret[i] = line - end + if line ~= "" then ret[i] = line end end return ret end @@ -39,7 +35,7 @@ local config = { stinky = aura_env.config.spotter.stinky, notifyChannel = aura_env.config.spotter.notifyChannel, zoneOverride = aura_env.config.spotter.zoneOverride, - throttleTime = aura_env.config.spotter.throttleTime + throttleTime = aura_env.config.spotter.throttleTime, }, who = { enabled = aura_env.config.who.enabled,