-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHiphamAlert.lua
214 lines (186 loc) · 7.99 KB
/
HiphamAlert.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
---@class Core: AceAddon, AceEvent-3.0, AceConsole-3.0, AceTimer-3.0
local Core = LibStub("AceAddon-3.0"):NewAddon("HiphamAlert", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0")
-- WOW Addon Life Cycle
function Core:OnInitialize()
Core:setupDB()
Core:migrationDB()
Core:setupMinimapIcon()
end
function Core:OnEnable()
Core:setupConfigs()
Core:updateMinimapIcon()
Core:RegisterEvent("PLAYER_ENTERING_WORLD")
Core:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
C_ChatInfo.RegisterAddonMessagePrefix("HiphamAlert")
end
function Core:OnDisable()
end
function Core:refreshConfigs()
Core:migrationDB()
Core:setupConfigs()
end
function Core:PLAYER_ENTERING_WORLD(event, isLogin, isReload)
Core:updateCurrentInstance()
end
function Core:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName,
destFlags, destFlags2, spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
if sourceGUID == UnitGUID("player") then
Core.Utils.debugPrint("-------------------------------------------")
Core.Utils.debugPrint(eventType, spellName, spellId)
local name, rank, icon, castTime, minRange, maxRange = C_Spell.GetSpellInfo(spellId)
Core.Utils.debugPrint(castTime)
local cooldownMS, gcdMS = GetSpellBaseCooldown(spellId)
Core.Utils.debugPrint(cooldownMS, gcdMS)
end
Core:processCombatLogForVoiceAlert(eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags,
spellId, spellName,
spellSchool)
end
-- Public function
function Core:setupDB()
Core.DB = LibStub("AceDB-3.0"):New("HiphamAlertDB", Core.DefaultDB, true)
Core.DB:RegisterDefaults(Core.DefaultDB)
Core.DB.RegisterCallback(Core, "OnProfileChanged", "refreshConfigs")
Core.DB.RegisterCallback(Core, "OnProfileCopied", "refreshConfigs")
Core.DB.RegisterCallback(Core, "OnProfileReset", "refreshConfigs")
end
function Core:migrationDB()
-- 프로필 DB 마이그레이션
if Core.DB.global.version == nil or Core.DB.global.version < Core.DefaultDB.global.version then
Core.DB:ResetDB()
end
-- 주문 DB 마이그레이션
local oldSpellDB = Core.DB.profile.spellDB
local newSpellDB = {}
for _, spell in pairs(Core.SpellDB) do
newSpellDB[spell.id] = spell
newSpellDB[spell.id].enabled = (oldSpellDB and oldSpellDB[spell.id] and oldSpellDB[spell.id].enabled) or {
none = true,
pvp = true,
arena = true,
party = true,
raid = true,
}
end
Core.DB.profile.spellDB = newSpellDB
end
function Core:setupMinimapIcon()
local minimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject("HiphamAlert", {
type = "data source",
text = Core.Utils.colorText("힙햄얼럿", Core.Assets.color.key),
icon = "Interface\\AddOns\\HiphamAlert\\Assets\\Images\\logo_hipham.blp",
OnClick = function()
Core:openConfigs()
end,
OnTooltipShow = function(tooltip)
tooltip:AddLine(Core.Utils.colorText("힙햄얼럿", Core.Assets.color.key))
tooltip:AddLine("클릭시 힙햄얼럿 옵션창을 불러옵니다.")
end
})
LibStub("LibDBIcon-1.0"):Register("HiphamAlert", minimapIcon, Core.DB.global.minimap)
end
function Core:updateMinimapIcon()
if Core.DB.global.minimap.hide then
LibStub("LibDBIcon-1.0"):Hide("HiphamAlert")
else
LibStub("LibDBIcon-1.0"):Show("HiphamAlert")
end
end
function Core:updateCurrentInstance()
local name, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceID,
instanceGroupSize, LfgDungeonID = GetInstanceInfo()
if instanceType == Core.Schemas.instanceTypes.none.id then
Core.State.currentInstance = Core.Schemas.instanceTypes.none
elseif instanceType == Core.Schemas.instanceTypes.pvp.id then
Core.State.currentInstance = Core.Schemas.instanceTypes.pvp
elseif instanceType == Core.Schemas.instanceTypes.arena.id then
Core.State.currentInstance = Core.Schemas.instanceTypes.arena
elseif instanceType == Core.Schemas.instanceTypes.party.id then
Core.State.currentInstance = Core.Schemas.instanceTypes.party
elseif instanceType == Core.Schemas.instanceTypes.raid.id then
Core.State.currentInstance = Core.Schemas.instanceTypes.raid
else
Core.State.currentInstance = Core.Schemas.instanceTypes.none
end
end
function Core:processCombatLogForVoiceAlert(eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags,
spellId, spellName, spellSchool)
-- 음성 알림 활성화 체크
if Core.DB.profile.voiceAlertEnabled == nil then return end
if Core.DB.profile.voiceAlertEnabled == false then return end
-- print("음성 알림 활성화 체크 완료")
-- 현재 인스턴스 체크
local currentInstance = Core.State.currentInstance
if currentInstance == nil then return end
-- print("현재 인스턴스 체크 완료")
-- 인스턴스별 음성 알림 활성화 체크
if Core.DB.profile.voiceAlertEnabledByInstance[currentInstance.id] == nil then return end
if Core.DB.profile.voiceAlertEnabledByInstance[currentInstance.id] == false then return end
-- print("인스턴스별 음성 알림 활성화 체크 완료")
-- 주문별 음성 알림 활성화 체크
local spell = Core.DB.profile.spellDB[spellId]
if spell == nil then return end
local isEnabled = spell.enabled[currentInstance.id]
if isEnabled == nil then return end
if isEnabled == false then return end
local combatLogVoiceMap = spell.combatLogVoiceMap[eventType]
if combatLogVoiceMap == nil then return end
-- print("주문별 음성 알림 활성화 체크 완료")
-- 대상별 음성 알림 활성화 체크
if Core.DB.profile.voiceAlertEnabledByTarget[currentInstance.id].mine then
if CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_ME) or
CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE) or
CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MY_PET) then
Core:playSpellSound(combatLogVoiceMap)
return
end
end
if Core.DB.profile.voiceAlertEnabledByTarget[currentInstance.id].alliesUnit then
if CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_FRIENDLY_UNITS) then
Core:playSpellSound(combatLogVoiceMap)
return
end
end
if Core.DB.profile.voiceAlertEnabledByTarget[currentInstance.id].enemyUnit then
if CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_HOSTILE_PLAYERS) or
CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_HOSTILE_UNITS) then
Core:playSpellSound(combatLogVoiceMap)
return
end
end
if Core.DB.profile.voiceAlertEnabledByTarget[currentInstance.id].targetUnit then
if CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_HOSTILE_PLAYERS) or
CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_HOSTILE_UNITS) then
local targetUnit = UnitGUID("target")
if targetUnit ~= nil then
if sourceGUID == targetUnit then
Core:playSpellSound(combatLogVoiceMap)
return
end
end
end
end
end
function Core:playSpellSound(path)
if path == nil then
return
end
Core.Utils.debugPrint("Interface\\Addons\\HiphamAlert\\Assets\\Sounds\\" .. path .. ".mp3")
PlaySoundFile("Interface\\Addons\\HiphamAlert\\Assets\\Sounds\\" .. path .. ".mp3", Core.DB.global.soundChannel)
end
SLASH_HIPHAMCMD1 = "/hipham"
SLASH_HIPHAMCMD2 = "/힙햄"
function SlashCmdList.HIPHAMCMD(message)
Core:openConfigs()
end
SLASH_DEBUGCMD1 = "/hiphamdebug"
SLASH_DEBUGCMD2 = "/힙햄디버그"
function SlashCmdList.DEBUGCMD(message)
Core.DB.global.debugMode = not Core.DB.global.debugMode
if Core.DB.global.debugMode == true then
print("힙햄얼럿: " .. Core.Utils.colorText("디버그 모드 켜짐", Core.Assets.color.green))
else
print("힙햄얼럿: " .. Core.Utils.colorText("디버그 모드 꺼짐", Core.Assets.color.red))
end
end