|
| 1 | +local ALName, ALPrivate = ... |
| 2 | + |
| 3 | +local _G = getfenv(0) |
| 4 | +local AtlasLoot = _G.AtlasLoot |
| 5 | +local Addons = AtlasLoot.Addons |
| 6 | +local AL = AtlasLoot.Locales |
| 7 | +local News = Addons:RegisterNewAddon("News") |
| 8 | + |
| 9 | +local LibSharedMedia = LibStub("LibSharedMedia-3.0") |
| 10 | + |
| 11 | +function News.Init() |
| 12 | + AtlasLoot.SlashCommands:Add("news", News.Open, "/al news - News") |
| 13 | +end |
| 14 | +AtlasLoot:AddInitFunc(News.Init) |
| 15 | + |
| 16 | + |
| 17 | +--################################ |
| 18 | +-- GUI |
| 19 | +--################################ |
| 20 | +local function FrameOnDragStart(self, arg1) |
| 21 | + if arg1 == "LeftButton" then |
| 22 | + self:StartMoving() |
| 23 | + end |
| 24 | +end |
| 25 | + |
| 26 | +local function FrameOnDragStop(self) |
| 27 | + self:StopMovingOrSizing() |
| 28 | +end |
| 29 | + |
| 30 | +local function FrameOnShow(self) |
| 31 | + |
| 32 | +end |
| 33 | + |
| 34 | +local function News_LinkOnClick(self) |
| 35 | + -- TODO FIX |
| 36 | + News.GUI.linkButton:HighlightText() |
| 37 | +end |
| 38 | + |
| 39 | +local function News_HideCheckboxOnClick(self) |
| 40 | + -- TODO ADD FUNCTIONALITY |
| 41 | +end |
| 42 | + |
| 43 | +function News:Open() |
| 44 | + if not News.GUI then |
| 45 | + local frameName = "AtlasLoot_News-Frame" |
| 46 | + |
| 47 | + local frame = CreateFrame("Frame", frameName, UIParent, _G.BackdropTemplateMixin and "BackdropTemplate" or nil) |
| 48 | + frame:ClearAllPoints() |
| 49 | + frame:SetPoint("CENTER") |
| 50 | + frame:SetSize(400,300) |
| 51 | + frame:SetMovable(true) |
| 52 | + frame:EnableMouse(true) |
| 53 | + frame:RegisterForDrag("LeftButton") |
| 54 | + frame:RegisterForDrag("LeftButton", "RightButton") |
| 55 | + frame:SetScript("OnMouseDown", FrameOnDragStart) |
| 56 | + frame:SetScript("OnMouseUp", FrameOnDragStop) |
| 57 | + frame:SetScript("OnShow", FrameOnShow) |
| 58 | + frame:SetToplevel(true) |
| 59 | + frame:SetClampedToScreen(true) |
| 60 | + frame:SetBackdrop(ALPrivate.BOX_BACKDROP) |
| 61 | + frame:SetBackdropColor(0.45, 0.45, 0.45, 1) |
| 62 | + frame:SetScale(1) |
| 63 | + frame:Hide() |
| 64 | + --tinsert(UISpecialFrames, frameName) -- allow ESC close |
| 65 | + |
| 66 | + frame.CloseButton = CreateFrame("Button", frameName.."-CloseButton", frame, "UIPanelCloseButton") |
| 67 | + frame.CloseButton:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 3, 2) |
| 68 | + |
| 69 | + frame.titleFrame = AtlasLoot.GUI.CreateTextWithBg(frame, 0, 0) |
| 70 | + frame.titleFrame:SetPoint("TOPLEFT", frame, 5, -5) |
| 71 | + frame.titleFrame:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -27, -23) |
| 72 | + frame.titleFrame:SetBackdropColor(0.05, 0.05, 0.05, 1) |
| 73 | + frame.titleFrame:SetFont(LibSharedMedia:Fetch("font", "Friz Quadrata TT"), 12) |
| 74 | + frame.titleFrame.text:SetText(AL["AtlasLoot"].." "..C_AddOns.GetAddOnMetadata(ALName, "Version").." - "..AL["News"]) |
| 75 | + frame.titleFrame.text:SetTextColor(1, 1, 1, 1) |
| 76 | + |
| 77 | + frame.content = CreateFrame("Frame", nil, frame) |
| 78 | + frame.content:SetPoint("TOPLEFT", frame.titleFrame, "BOTTOMLEFT", 0, -5) |
| 79 | + frame.content:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -5, 5) |
| 80 | + |
| 81 | + local scrollFrame = CreateFrame("ScrollFrame", frameName.."-scroll", frame.content) |
| 82 | + scrollFrame:EnableMouse(true) |
| 83 | + scrollFrame:EnableMouseWheel(true) |
| 84 | + scrollFrame:SetPoint("TOPLEFT", frame.titleFrame, "BOTTOMLEFT", 2, -5) |
| 85 | + scrollFrame:SetPoint("BOTTOMRIGHT", frame.content, "BOTTOMRIGHT", -23, 20) |
| 86 | + --scrollFrame:SetScript("OnMouseWheel", NewsScroll_OnMouseWheel) |
| 87 | + frame.content.scrollFrame = scrollFrame |
| 88 | + |
| 89 | + scrollFrame.editBox = CreateFrame("EditBox", nil, scrollFrame) |
| 90 | + scrollFrame.editBox:SetMultiLine(true) |
| 91 | + scrollFrame.editBox:SetAutoFocus(false) |
| 92 | + scrollFrame.editBox:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0) |
| 93 | + scrollFrame.editBox:SetPoint("BOTTOMRIGHT", scrollFrame, "BOTTOMRIGHT", 0 ,0) |
| 94 | + scrollFrame.editBox:SetTextColor(1, 1, 1, 1) |
| 95 | + scrollFrame.editBox:SetFontObject("ChatFontNormal") |
| 96 | + scrollFrame.editBox:SetText("test\ntest\ntest\ntest\ntest\ntest\ntest\nmucho queso\nhellopp") |
| 97 | + scrollFrame.editBox:SetWidth(400) |
| 98 | + scrollFrame.editBox:SetHeight(300) |
| 99 | + scrollFrame:SetScrollChild(scrollFrame.editBox) |
| 100 | + --scrollFrame.editBox:Disable() |
| 101 | + scrollFrame.editBoxbg = scrollFrame.editBox:CreateTexture(nil, "BACKGROUND") |
| 102 | + scrollFrame.editBoxbg:SetAllPoints(scrollFrame.editBox) |
| 103 | + scrollFrame.editBoxbg:SetColorTexture(0, 0, 0, 0.5) |
| 104 | + |
| 105 | + scrollFrame.scrollbar = CreateFrame("Slider", frameName.."-scrollbar", scrollFrame, "UIPanelScrollBarTemplate") |
| 106 | + scrollFrame.scrollbar:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", 6, -16) |
| 107 | + scrollFrame.scrollbar:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", 6, 16) |
| 108 | + scrollFrame.scrollbar:SetValueStep(1) |
| 109 | + scrollFrame.scrollbar:SetValue(0) |
| 110 | + scrollFrame.scrollbar:SetWidth(16) |
| 111 | + scrollFrame.scrollbar.obj = scrollFrame |
| 112 | + |
| 113 | + scrollFrame.scrollbg = scrollFrame:CreateTexture(nil, "BACKGROUND") |
| 114 | + scrollFrame.scrollbg:SetAllPoints(scrollFrame.scrollbar) |
| 115 | + scrollFrame.scrollbg:SetColorTexture(0, 0, 0, 0.5) |
| 116 | + |
| 117 | + frame.content.option = AtlasLoot.GUI.CreateCheckBox() |
| 118 | + frame.content.option:SetParPoint("TOPLEFT", frame.content.scrollFrame, "BOTTOMRIGHT", -175, 0) |
| 119 | + frame.content.option:SetText(AL["Don't show again for this version."]) |
| 120 | + frame.content.option:SetOnClickFunc(News_HideCheckboxOnClick) |
| 121 | + frame.content.option:SetChecked(AtlasLoot:GetDb().activeList[2]) |
| 122 | + |
| 123 | + frame.linkButton = CreateFrame("EditBox", nil, frame.content) |
| 124 | + frame.linkButton:SetWidth(160) |
| 125 | + frame.linkButton:SetHeight(16) |
| 126 | + frame.linkButton:SetAutoFocus(false) |
| 127 | + frame.linkButton:SetJustifyH("CENTER") |
| 128 | + frame.linkButton:SetPoint("TOPLEFT", scrollFrame, "BOTTOMLEFT", 0, -3) |
| 129 | + frame.linkButton:SetTextColor(1, 1, 1, 1) |
| 130 | + frame.linkButton:SetFontObject("ChatFontSmall") |
| 131 | + frame.linkButton:SetText("buymeacoffee.com/snowflame0") |
| 132 | + frame.linkButton:SetScript("OnMouseDown", News_LinkOnClick) |
| 133 | + frame.linkbg = frame.linkButton:CreateTexture(nil, "BACKGROUND") |
| 134 | + frame.linkbg:SetAllPoints(frame.linkButton) |
| 135 | + frame.linkbg:SetColorTexture(0, 0, 0, 0.5) |
| 136 | + |
| 137 | + News.GUI = frame |
| 138 | + elseif News.GUI:IsShown() then |
| 139 | + News.GUI:Hide() |
| 140 | + return |
| 141 | + end |
| 142 | + |
| 143 | + News.GUI:Show() |
| 144 | +end |
0 commit comments