-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathChangeLog.lua
210 lines (177 loc) · 6.93 KB
/
ChangeLog.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
--[[
This change log was meant to be viewed in game.
You may do so by typing: /wim changelog
]]
local currentRevision = tonumber(("$Revision$"):match("(%d+)"));
local log = {};
local beta_log = {};
local t_insert = table.insert;
local function addEntry(version, rdate, description, transmitted)
t_insert(log, {v = version, r = rdate, d = description, t=transmitted and true});
end
local function addBetaEntry(version, rdate, description, transmitted)
t_insert(log, {v = version, r = rdate, d = description, t=transmitted and true});
end
-- ChangeLog Entries.
addEntry("3.9.0", "03/31/2021", [[
*TOC update for 9.0.5
*Compatible with TBC Beta
]]);
local function entryExists(version)
for i=1, #log do
if(log[i].v == version) then
return true;
end
end
return false;
end
local freshLoad = true;
local function formatEntry(txt)
local out = "";
for line in txt:gmatch("([^\n]+)\n") do
line = line:gsub("^%s*(%+)", " |cff69ccf0+ ");
line = line:gsub("^%s*(%*)", " |cffc79c6e* ");
line = line:gsub("^%s*(%-)", " |cffc41f3b- ");
out = out..line.."|r\n";
end
return out;
end
local function getEntryText(index)
local entry = log[index];
if(not entry) then return ""; end
local revision = entry.v == WIM.version and " - Revision "..WIM.GetRevision() or "";
revision = entry.t and " - |cffff0000"..WIM.L["Available For Download!"].."|r" or revision;
local txt = "Version "..entry.v.." ("..entry.r..")"..revision.."\n";
txt = txt..formatEntry(entry.d);
freshLoad = false;
return txt.."\n\n";
end
local function logSort(a, b)
if(WIM.CompareVersion(a.v, b.v) > 0) then
return true;
else
return false;
end
end
local changeLogWindow;
local function createChangeLogWindow()
-- create frame object - changes for Patch 9.0.1 - Shadowlands, retail and classic
local win = CreateFrame("Frame", "WIM3_ChangeLog", _G.UIParent, WIM.isShadowlands and "BackdropTemplate");
win:Hide(); -- hide initially, scripts aren't loaded yet.
table.insert(UISpecialFrames, "WIM3_ChangeLog");
-- set size and position
win:SetWidth(700);
win:SetHeight(500);
win:SetPoint("CENTER");
-- set backdrop - changes for Patch 9.0.1 - Shadowlands, retail and classic
win.backdropInfo = {bgFile = "Interface\\AddOns\\"..WIM.addonTocName.."\\Sources\\Options\\Textures\\Frame_Background",
edgeFile = "Interface\\AddOns\\"..WIM.addonTocName.."\\Sources\\Options\\Textures\\Frame",
tile = true, tileSize = 64, edgeSize = 64,
insets = { left = 64, right = 64, top = 64, bottom = 64 }};
if not WIM.isShadowlands then
win:SetBackdrop(win.backdropInfo);
else
win:ApplyBackdrop();
end
-- set basic frame properties
win:SetClampedToScreen(true);
win:SetFrameStrata("DIALOG");
win:SetMovable(true);
win:SetToplevel(true);
win:EnableMouse(true);
win:RegisterForDrag("LeftButton");
-- set script events
win:SetScript("OnShow", function(self) _G.PlaySound(850); self:update(); end);
win:SetScript("OnHide", function(self) _G.PlaySound(851); end);
win:SetScript("OnDragStart", function(self) self:StartMoving(); end);
win:SetScript("OnDragStop", function(self) self:StopMovingOrSizing(); end);
-- create and set title bar text
win.title = win:CreateFontString(win:GetName().."Title", "OVERLAY", "ChatFontNormal");
win.title:SetPoint("TOPLEFT", 50 , -20);
local font = win.title:GetFont();
win.title:SetFont(font, 16, "");
win.title:SetText(WIM.L["WIM (WoW Instant Messenger)"].." v"..WIM.version.." - "..WIM.L["Change Log"]);
-- create close button
win.close = CreateFrame("Button", win:GetName().."Close", win);
win.close:SetWidth(18); win.close:SetHeight(18);
win.close:SetPoint("TOPRIGHT", -24, -20);
win.close:SetNormalTexture("Interface\\AddOns\\"..WIM.addonTocName.."\\Sources\\Options\\Textures\\blipRed");
win.close:SetHighlightTexture("Interface\\AddOns\\"..WIM.addonTocName.."\\Sources\\Options\\Textures\\close", "BLEND");
win.close:SetScript("OnClick", function(self)
self:GetParent():Hide();
end);
win.textFrame = CreateFrame("ScrollFrame", "WIM3_ChangeLogTextFrame", win, "UIPanelScrollFrameTemplate");
win.textFrame:SetPoint("TOPLEFT", 25, -50);
win.textFrame:SetPoint("BOTTOMRIGHT", -42, 20);
win.textFrame.text = CreateFrame("SimpleHTML", "WIM3_ChangeLogTextFrameText", win.textFrame);
win.textFrame.text:SetWidth(win.textFrame:GetWidth());
win.textFrame.text:SetHeight(200);
win.textFrame:SetScrollChild(win.textFrame.text);
win.update = function(self)
local tmp = "";
freshLoad = true;
table.sort(log, logSort);
for i=1, #beta_log do
tmp = tmp..getEntryText(i);
end
for i=1, #log do
tmp = tmp..getEntryText(i);
end
self.textFrame.text:SetFontObject(ChatFontNormal);
self.textFrame.text:SetText(tmp);
self.textFrame:UpdateScrollChildRect();
end
return win;
end
local function getEntryString(index)
local entry = log[index];
if(entry) then
local out = entry.v.."\003\003"..entry.r.."\003\003"..entry.d;
return out;
else
return;
end
end
WIM.RegisterAddonMessageHandler("CHANGELOG", function(from, data)
local v, r, d = string.match(data, "^(.+)\003\003(.+)\003\003(.+)$");
WIM.AddChangeLogEntry(v, r, d);
end);
WIM.RegisterAddonMessageHandler("GETCHANGELOG", function(from, data)
for i=1, #log do
if(WIM.CompareVersion(log[i].v, data) > 0) then
local vd = getEntryString(i);
if(vd) then
--DEFAULT_CHAT_FRAME:AddMessage(vd);
WIM.SendData("WHISPER", from, "CHANGELOG", vd);
end
end
end
end);
WIM.RegisterAddonMessageHandler("NEGOTIATE", function(from, data)
local v, isBeta = string.match(data, "^(.+):(%d)");
local diff = WIM.CompareVersion(v);
if(diff > 0 and tonumber(isBeta) == 0 and not entryExists(v)) then
WIM.SendData("WHISPER", from, "GETCHANGELOG", WIM.version);
end
end);
function WIM.ShowChangeLog()
changeLogWindow = changeLogWindow or createChangeLogWindow();
changeLogWindow:Show();
end
function WIM.GetRevision()
return currentRevision;
end
local transmissionReceived = false;
function WIM.AddChangeLogEntry(version, releaseDate, desc)
if(type(version) == "string" and type(releaseDate) == "string" and type(desc) == "string" and not entryExists(version)) then
addEntry(version, releaseDate, desc, true);
transmissionReceived = true;
if(changeLogWindow and changeLogWindow:IsShown()) then
changeLogWindow:update();
end
end
end
function WIM.ChangeLogUpdated()
return transmissionReceived;
end
WIM.RegisterSlashCommand("changelog", WIM.ShowChangeLog, WIM.L["View WIM's change log."]);