-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKorthiaQuests.lua
132 lines (112 loc) · 6.11 KB
/
KorthiaQuests.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
if AZP == nil then AZP = {} end
if AZP.VersionControl == nil then AZP.VersionControl = {} end
if AZP.ZoneQuests.Korthia == nil then AZP.ZoneQuests.Korthia = {} end
if AZP.ZoneQuests.Korthia.Events == nil then AZP.ZoneQuests.Korthia.Events = {} end
if AZPKQFrameLocation == nil then AZPKQFrameLocation = {"CENTER", 0, 0} end
local EventFrame, AZPKQSelfFrame = nil, nil
local TomTomLoaded = false
function AZP.ZoneQuests.Korthia:OnLoadSelf()
EventFrame = CreateFrame("Frame", nil)
EventFrame:RegisterEvent("VARIABLES_LOADED")
EventFrame:RegisterEvent("QUEST_FINISHED")
EventFrame:RegisterEvent("ADDON_LOADED")
EventFrame:SetScript("OnEvent", function(...) AZP.ZoneQuests.Korthia:OnEvent(...) end)
end
function AZP.ZoneQuests.Korthia:CreateUserFrame()
AZPKQSelfFrame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
AZPKQSelfFrame:SetPoint("CENTER", 0, 250)
AZPKQSelfFrame:SetSize(375, 385)
AZPKQSelfFrame:EnableMouse(true)
AZPKQSelfFrame:SetMovable(true)
AZPKQSelfFrame:RegisterForDrag("LeftButton")
AZPKQSelfFrame:SetScript("OnDragStart", AZPKQSelfFrame.StartMoving)
AZPKQSelfFrame:SetScript("OnDragStop", function() AZPKQSelfFrame:StopMovingOrSizing() AZP.ZoneQuests.Korthia:SaveLocation() end)
AZPKQSelfFrame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
edgeSize = 12,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
AZPKQSelfFrame:SetBackdropColor(0.25, 0.25, 0.25, 0.80)
AZPKQSelfFrame.Header = AZPKQSelfFrame:CreateFontString("AZPKQSelfFrame", "ARTWORK", "GameFontNormalHuge")
AZPKQSelfFrame.Header:SetPoint("TOP", 0, -10)
AZPKQSelfFrame.Header:SetText("|cFF00FFFFAzerPUG's Korthia Quests|r")
AZPKQSelfFrame.CloseButton = CreateFrame("Button", nil, AZPKQSelfFrame, "UIPanelCloseButton")
AZPKQSelfFrame.CloseButton:SetSize(25, 25)
AZPKQSelfFrame.CloseButton:SetPoint("TOPRIGHT", AZPKQSelfFrame, "TOPRIGHT", 2, 2)
AZPKQSelfFrame.CloseButton:SetScript("OnClick", function() AZPKQSelfFrame:Hide() end )
if AZPKQSelfFrame.QuestIDLabels == nil then AZPKQSelfFrame.QuestIDLabels = {} end
if AZPKQSelfFrame.QuestNameLabels == nil then AZPKQSelfFrame.QuestNameLabels = {} end
if AZPKQSelfFrame.QuestLocationLabels == nil then AZPKQSelfFrame.QuestLocationLabels = {} end
local Quests = AZP.ZoneQuests.Quests.Korthia
for i = 1, #Quests.IDs do
AZPKQSelfFrame.QuestIDLabels[i] = AZPKQSelfFrame:CreateFontString("AZPKQSelfFrame", "ARTWORK", "GameFontNormal")
AZPKQSelfFrame.QuestIDLabels[i]:SetPoint("TOPLEFT", 10, -20 * i -20)
AZPKQSelfFrame.QuestNameLabels[i] = AZPKQSelfFrame:CreateFontString("AZPKQSelfFrame", "ARTWORK", "GameFontNormal")
AZPKQSelfFrame.QuestNameLabels[i]:SetPoint("TOP", 0, -20 * i -20)
AZPKQSelfFrame.QuestLocationLabels[i] = CreateFrame("Frame", nil, AZPKQSelfFrame)
AZPKQSelfFrame.QuestLocationLabels[i]:SetSize(60, 16)
AZPKQSelfFrame.QuestLocationLabels[i]:SetPoint("TOPRIGHT", -10, -20 * i -20)
AZPKQSelfFrame.QuestLocationLabels[i]:SetScript("OnMouseDown",
function()
if i ~= 2 then
if TomTomLoaded == true then
local curID = Quests.IDs[i]
local curX = Quests[curID].Location.xVal
local curY = Quests[curID].Location.yVal
local curName = Quests[curID].Name
TomTom:AddWaypoint(1961, curX/100, curY/100, {title = curName, persistent = false, source = "Added by AzerPUG's Korthia Quests."})
end
end
end)
AZPKQSelfFrame.QuestLocationLabels[i].text = AZPKQSelfFrame.QuestLocationLabels[i]:CreateFontString("AZPKQSelfFrame", "ARTWORK", "GameFontNormal")
AZPKQSelfFrame.QuestLocationLabels[i].text:SetPoint("CENTER", 0, 0)
end
AZP.ZoneQuests.Korthia.Events:QuestFinished()
AZP.ZoneQuests.ZoneFrames.Korthia = AZPKQSelfFrame
AZPKQSelfFrame:Hide()
end
function AZP.ZoneQuests.Korthia:SaveLocation()
local temp = {}
temp[1], temp[2], temp[3], temp[4], temp[5] = AZPKQSelfFrame:GetPoint()
AZPKQFrameLocation = temp
end
function AZP.ZoneQuests.Korthia:LoadLocation()
AZPKQSelfFrame:SetPoint(AZPKQFrameLocation[1], AZPKQFrameLocation[4], AZPKQFrameLocation[5])
end
function AZP.ZoneQuests.Korthia.Events:QuestFinished()
local Quests = AZP.ZoneQuests.Quests.Korthia
local ColorEnd = "|r"
for i = 1, #Quests.IDs do
local curID = Quests.IDs[i]
local QColor = ""
if C_QuestLog.IsQuestFlaggedCompleted(curID) == true then
QColor = "|cFF00FF00"
elseif C_QuestLog.IsOnQuest(curID) == true then
QColor = "|cFFFFFF00"
elseif C_QuestLog.IsQuestFlaggedCompleted(curID) == false then
QColor = "|cFFFF0000"
end
AZPKQSelfFrame.QuestIDLabels[i]:SetText(string.format("%s%d%s", QColor, curID, ColorEnd))
AZPKQSelfFrame.QuestNameLabels[i]:SetText(string.format("%s%s%s", QColor, Quests[curID].Name, ColorEnd))
if Quests[curID].Location.xVal == nil or Quests[curID].Location.yVal == nil then
AZPKQSelfFrame.QuestLocationLabels[i].text:SetText(string.format("%s%s%s", QColor, "Treassures", ColorEnd))
else
AZPKQSelfFrame.QuestLocationLabels[i].text:SetText(string.format("%s%.1f - %.1f%s", QColor, Quests[curID].Location.xVal, Quests[curID].Location.yVal, ColorEnd))
end
end
end
function AZP.ZoneQuests.Korthia:OnEvent(self, event, ...)
if event == "VARIABLES_LOADED" then
AZP.ZoneQuests.Korthia.Events:VariablesLoaded()
elseif event == "QUEST_FINISHED" then
C_Timer.NewTimer(5, function() AZP.ZoneQuests.Korthia.Events:QuestFinished() end)
elseif event == "ADDON_LOADED" then
local AddOnName = ...
if AddOnName == "TomTom" then TomTomLoaded = true end
end
end
function AZP.ZoneQuests.Korthia.Events:VariablesLoaded()
C_Timer.NewTimer(5, function() AZP.ZoneQuests.Korthia:CreateUserFrame() AZP.ZoneQuests.Korthia:LoadLocation() end)
end
AZP.ZoneQuests.Korthia:OnLoadSelf()