-
Notifications
You must be signed in to change notification settings - Fork 9
/
ResetWarning.lua
108 lines (94 loc) · 3.62 KB
/
ResetWarning.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
WritCreater = WritCreater or {}
local function dailyReset()
local till = {}
local stamp = GetTimeUntilNextDailyLoginRewardClaimS()
till["hour"] = math.floor(stamp/3600)
stamp = stamp%3600
till["minute"] = math.floor(stamp/60)
stamp = stamp%60
return till["hour"], till["minute"]
end
WritCreater.dailyReset = dailyReset
-- local msg = {}
-- msg.GetCategory = function () return CSA_CATEGORY_LARGE_TEXT end--CSA_CATEGORY_MAJOR_TEXT, CSA_CATEGORY_RAID_COMPLETE_TEXT
-- msg.key = ""
local colour = "FFFF33"
local warningText = ""
local testingText = ""
function showAnnouncement(msgText, sound)
local secondText
local split = string.find(msgText, "\n")
if split then secondText = "|c"..colour..string.sub(msgText, split + 1) msgText = string.sub(msgText, 1,split).."|r" end
sound = sound or SOUNDS.CHAMPION_POINT_GAINED
local msg = CENTER_SCREEN_ANNOUNCE:CreateMessageParams(CSA_CATEGORY_LARGE_TEXT, sound)
msg:SetText(msgText, secondText)
msg:SetCSAType(CENTER_SCREEN_ANNOUNCE_TYPE_CHAMPION_POINT_GAINED)
msg:MarkSuppressIconFrame()
CENTER_SCREEN_ANNOUNCE:DisplayMessage(msg)
end
local function showAlert(msgText)
ZO_Alert(nil,nil,msgText)
end
local function chatWarning(msgText)
CHAT_SYSTEM:AddMessage(msgText)
end
local needsReset = false
local function windowWarning(msgText)
DolgubonsLazyWritResetWarnerBackdropOutput:SetText(msgText)
DolgubonsLazyWritResetWarner:SetHidden(false)
DolgubonsLazyWritResetWarnerBackdropClose:SetText("Close")
DolgubonsLazyWritResetWarnerBackdropClose:ClearAnchors()
DolgubonsLazyWritResetWarnerBackdropClose:SetAnchor(BOTTOM,DolgubonsLazyWritResetWarnerBackdrop, BOTTOM, 0, -15 )
DolgubonsLazyWritResetWarnerBackdropButton2:SetHidden(true)
end
local warningFunctions =
{
["alert"] = showAlert,
["chat"] = chatWarning,
["announcement"] = showAnnouncement,
["window"] = windowWarning,
["none"] = function() end,
}
local function showWarnings(isExample)
EVENT_MANAGER:UnregisterForUpdate(WritCreater.name.."DailyResetWarning")
local hour, minute = dailyReset()
local msgText = zo_strformat(warningText, hour, minute)
if isExample=="Example" then
msgText = "|c"..colour..WritCreater.strings['resetWarningExampleText'].."|r"
end
local warningType = WritCreater:GetSettings().dailyResetWarnType
if warningType == "all" then
for k, v in pairs(warningFunctions) do
v(msgText)
end
else
if not warningFunctions[warningType] then return end
warningFunctions[warningType](msgText)
end
end
WritCreater.showDailyResetWarnings = showWarnings
function WritCreater.refreshWarning()
local warnTime = WritCreater:GetSettings().dailyResetWarnTime
local hour, minute = dailyReset()
local timeToWarning = hour*3600 + minute*60 - warnTime*60
if timeToWarning < 0 then
EVENT_MANAGER:RegisterForUpdate(WritCreater.name.."DailyResetWarning", 5000, showWarnings)
else
EVENT_MANAGER:RegisterForUpdate(WritCreater.name.."DailyResetWarning", timeToWarning*1000, showWarnings)
end
end
function WritCreater.initializeResetWarnings()
warningText = "|c"..colour..WritCreater.strings.resetWarningMessageText.."|r"
-- windowWarning(warningText)
WritCreater.refreshWarning()
end
function WritCreater.showSettingsChoice(question)
DolgubonsLazyWritResetWarnerBackdropOutput:SetText(question)
DolgubonsLazyWritResetWarner:SetHidden(false)
-- DolgubonsLazyWritResetWarnerBackdropClose:SetText("On")
-- DolgubonsLazyWritResetWarnerBackdropButton2:SetText("Off")
-- DolgubonsLazyWritResetWarnerBackdropClose:ClearAnchors()
-- DolgubonsLazyWritResetWarnerBackdropClose:SetAnchor(BOTTOM,DolgubonsLazyWritResetWarnerBackdrop, BOTTOM, -100, -15 )
-- DolgubonsLazyWritResetWarnerBackdropButton2:SetHidden(false)
needsReset = true
end