Files

179 lines
8.6 KiB
Python

"""Qualified menu, popup and chat edits to the signed 6838 enUS UI."""
from hashlib import sha256
ADDONS = "interface/addons/"
# The shared Glue dialogs are a declared dependency of both GlueParent and GlueXML.
OCTO_GLUE = r'''OctoGlueWebLinks = {};
function OctoGlueWebLinks.IsProjectAddress(link)
if type(link) ~= "string" or link:find("[%c%s\\<>\"']") then return false; end
local host = link:lower():match("^https?://([^/?#]+)");
if not host then return false; end
host = host:match("^([^:]+):%d+$") or host;
return host == "octowow.st" or (host:match("^[a-z0-9][a-z0-9%.%-]*%.octowow%.st$") ~= nil);
end
function OctoGlueWebLinks.Open(link)
if OctoGlueWebLinks.IsProjectAddress(link) then LaunchURL(link); end
end
function OctoGlueWebLinks.DisplayHTML(text)
if type(text) ~= "string" then return text; end
return (text:gsub("<[aA](%s+[^>]*)>(.-)</[aA]%s*>", function(attributes, label)
local url;
while attributes:find("%S") do
local name, quote, value, rest = attributes:match("^%s*([%w_:%-]+)%s*=%s*([\"'])(.-)%2(.*)$");
if not name then return label; end
if name:lower() == "href" then
if url then return label; end
url = value;
end
attributes = rest;
end
if OctoGlueWebLinks.IsProjectAddress(url) then
return '<a href="' .. url .. '">' .. label .. '</a>';
end
return label;
end));
end
'''
# Coordinates are one-based, inclusive, on SHA-qualified parent bytes. Edits
# splice only these lines so mixed CRLF/LF files preserve untouched bytes.
EDITS = {
"blizzard_gamemenu/shared/gamemenuframe.lua": [
(7, 7, '\ttext = "The external event is unavailable.",'),
(13, 15, ""),
(55, 56, ""),
(116, 124, ""),
(173, 182, ""),
],
"blizzard_staticpopup_game/gamedialogdefs.lua": [
(2997, 3003, '''};
StaticPopup_AddShowCondition(function(info)
return info ~= StaticPopupDialogs["CONFIRM_LAUNCH_URL"];
end);'''),
(3246, 3251, '''\ttext = BACKPACK_AUTHENTICATOR_DIALOG_DESCRIPTION:match("^(.-)|n|n") or BACKPACK_AUTHENTICATOR_DIALOG_DESCRIPTION,
\tbutton1 = CLOSE,'''),
(3259, 3264, '''\ttext = GROUP_FINDER_AUTHENTICATOR_POPUP_DESC:match("^(.-)|n|n") or GROUP_FINDER_AUTHENTICATOR_POPUP_DESC,
\tbutton1 = CLOSE,'''),
],
"blizzard_staticpopup_glue/gluedialogdefs.lua": [
(1, 0, OCTO_GLUE),
(127, 127, '\ttext = "Your account agreement requires review. You will be disconnected.",'),
(132, 132, '\t\tOctoGlueWebLinks.Open(C_Login.GetAgreementLink());'),
],
"blizzard_staticpopup_glue/gluedialog.lua": [
(373, 373, '\tself.Container.HtmlText:SetText(OctoGlueWebLinks.DisplayHTML(self.Container.HtmlText.text));'),
],
"blizzard_staticpopup_glue/gluedialog.xml": [
(70, 70, '\t\t\t\t\t\t\t\t\tOctoGlueWebLinks.Open(link);'),
],
"blizzard_gluexml/serveralert.lua": [
(11, 11, '\tself.ScrollFrame.Text:SetText(OctoGlueWebLinks.DisplayHTML(text));'),
],
"blizzard_gluexml/serveralert.xml": [
(26, 26, '\t\t\t\t\t\t\t\tOctoGlueWebLinks.Open(link);'),
],
"blizzard_loginwarningdialogs/blizzard_loginwarningdialogs.xml": [
(27, 27, '\t\t\t\t\t<Button hyperlinksEnabled="false">'),
(59, 61, '''\t\t\t\t\t\t\t<OnLoad>
for _, label in ipairs({self.HealthyGamingText, self.AgeAppropriatenessText}) do
label:SetText((label:GetText():gsub("|H[^|]*|h(.-)|h", "%1")));
end
</OnLoad>'''),
],
"blizzard_uipanels_game/shared/itemrefhandlersshared.lua": [
(285, 286, '\treturn LinkProcessorResponse.Handled;'),
],
"blizzard_uipanels_game/mainline/itemrefhandlers.lua": [
(161, 161, '\t\telseif C_StorePublic.DoesGroupHavePurchaseableProducts(WOW_GAMES_CATEGORY_ID) then'),
(163, 163, '\t\telse\n\t\t\treturn LinkProcessorResponse.Handled;\n\t\tend'),
(173, 173, '''\t\tif StoreInterfaceUtil.HasSubscriptionProduct() then
\t\t\tStoreInterfaceUtil.OpenToSubscriptionProduct();
\t\telse
\t\t\treturn LinkProcessorResponse.Handled;
\t\tend'''),
],
"blizzard_chatframebase/shared/chatframe.lua": [
(295, 295, ''' if type(issecretvalue) == "function" and issecretvalue(message) then
return originalSecureAddMessage(self, message, ...);
end
if IsLoginConductReminder(message) then return end
if type(message) == "string" then
message = message:gsub("|H[uU][rR][lL][iI][nN][dD][eE][xX]:[^|]*|h(.-)|h", "%1");
end'''),
],
"blizzard_glueparent/mainline/glueparent.lua": [
(1244, 1244, '''\t\tif StoreInterfaceUtil.HasSubscriptionProduct() then
\t\t\tStoreInterfaceUtil.OpenToSubscriptionProduct();
\t\tend'''),
],
"blizzard_gluexml/mainline/characterselect.lua": [
(1131, 1131, '''\tif IsTrialAccount() then
\t\tif not StoreInterfaceUtil.HasSubscriptionProduct() then return nil, false; end'''),
],
"blizzard_gluexml/startereditionpopup.xml": [
(132, 132, '''\t\t\t<OnShow>
StarterEditionPopUp_OnShow(self);
StarterEditionPopUpUpgradeButton:SetShown(not IsTrialAccount() or StoreInterfaceUtil.HasSubscriptionProduct());
</OnShow>'''),
],
"blizzard_gluexml/shared/accountreactivate.lua": [
(2, 2, '''\tif StoreInterfaceUtil.HasSubscriptionProduct() then
\t\tStoreInterfaceUtil.OpenToSubscriptionProduct();
\tend'''),
(277, 277, ''' local hasSubscription = StoreInterfaceUtil.HasSubscriptionProduct();
self.Accept:SetShown(hasSubscription);
self.Reactivate:ClearAllPoints();
if hasSubscription then
self.Reactivate:SetPoint("TOP", self.ButtonDivider, "BOTTOM", 0, -4);
else
self.ButtonDivider:Hide();
self.Reactivate:SetPoint("TOP", self.Text, "BOTTOM", 0, -16);
local controls = self.Reactivate:IsShown() and self.Reactivate:GetHeight() + 16 or 0;
self:SetHeight(self.Text:GetHeight() + controls + 50);
end'''),
],
}
def transform(files):
changed = {}
for suffix, edits in EDITS.items():
path = ADDONS + suffix
original = files[path]
if sha256(original).hexdigest() != PARENTS[suffix]:
raise ValueError("Unexpected release parent for " + path)
lines = original.splitlines(keepends=True)
for first, last, replacement in reversed(edits):
line = lines[first - 1]
newline = b"\r\n" if line.endswith(b"\r\n") else b"\n"
block = [part.encode("utf-8") + newline for part in replacement.splitlines()]
lines[first - 1:last] = block
result = b"".join(lines)
if result == original:
raise ValueError("Expected a changed release member: " + path)
changed[path] = result
return changed
PARENTS = {
"blizzard_gamemenu/shared/gamemenuframe.lua": "a5c01a27b5d7b39e6703bce17b9a89891f187a5dd936b7a7024e9cb67e18d6e0",
"blizzard_staticpopup_game/gamedialogdefs.lua": "a5995e9a75c1e5db6812167a0d8aad3375ca604837a97d3e7184a64ce2aa5807",
"blizzard_staticpopup_glue/gluedialogdefs.lua": "82dbcd742afe0cde020326b2596d42fb1bd0b7b6f7f90750a24204e51b9c3f61",
"blizzard_staticpopup_glue/gluedialog.lua": "3fff23a97e267ce02285c6d646c8b6f1a823e0562f01740ec27efab40681f0de",
"blizzard_staticpopup_glue/gluedialog.xml": "e9b5769cc374b73d95e785331f7ca4bea08d3f949818882cea36ff5c62bdc2e3",
"blizzard_gluexml/serveralert.lua": "1547fd65f514fd72e3a2ab95314101dee6b4fa45bc15a3477522cc5a8b64d086",
"blizzard_gluexml/serveralert.xml": "e327821bc55a8b52b5f5822b2ca90a99a31ce99fa03aeb74eaa538f0701beab0",
"blizzard_loginwarningdialogs/blizzard_loginwarningdialogs.xml": "1232a1c8b7b8f4f6bedde056e1215dc7ccf3171339cf13e3bb149f8c7ffbe1b8",
"blizzard_uipanels_game/shared/itemrefhandlersshared.lua": "42a99fe942403d6259957ec49aca712daab8f6e63d25297a6aa7a9be9438c342",
"blizzard_uipanels_game/mainline/itemrefhandlers.lua": "895b783e01dadea688f0b7b983123a3c9c0ea28abd350c556fcfb6dc550a9801",
"blizzard_chatframebase/shared/chatframe.lua": "382c6ba2967d175d7ea6a21a546136b7757365ffc66401e0a3a94767e2fd5328",
"blizzard_glueparent/mainline/glueparent.lua": "26eaa64926c5d6f5e9b6a72bfed7b94ec8470c7e2e672a3cb01dba5905b7d0b1",
"blizzard_gluexml/mainline/characterselect.lua": "33f29651a6a0b8706158c2306df2b54573157791a9dc28e2bc937072fac8e749",
"blizzard_gluexml/startereditionpopup.xml": "642a9aafd3913ec633078e268f479bb23abfe2e7f8cb862466d557e78aa05fe2",
"blizzard_gluexml/shared/accountreactivate.lua": "b62960144c1dab4958494de20695411f0d2727db57cf64b8490ae6c99497a3f2",
}