Code:
function Panel_Refresh(self, name)
local width = self:GetWidth();
local height = self:GetHeight();
-- time stamp header
local timeStampHeader = CreateFrame("FRAME", nil, self);
timeStampHeader:SetPoint("TOPLEFT", self, 10, -10);
timeStampHeader:SetWidth(100);
timeStampHeader:SetHeight(20);
timeStampHeader.text = timeStampHeader:CreateFontString();
timeStampHeader.text:SetPoint("CENTER");
timeStampHeader.text:SetSize(100, 20);
timeStampHeader.text:SetFont("Fonts\\FRIZQT__.ttf", 12, "OUTLINE");
timeStampHeader.text:SetText("Time/Date");
-- boss name headers
local headers = bosses[name];
local columnWidth = (width - 120) / #headers;
for i, v in ipairs(headers) do
local bossHeader = CreateFrame("FRAME", nil, self);
bossHeader:SetPoint("TOPLEFT", self, 110 + columnWidth * (i - 1), -10);
bossHeader:SetWidth(columnWidth);
bossHeader:SetHeight(20);
bossHeader.text = bossHeader:CreateFontString();
bossHeader.text:SetPoint("CENTER");
bossHeader.text:SetSize(columnWidth, 20);
bossHeader.text:SetFont("Fonts\\FRIZQT__.ttf", 12, "OUTLINE");
bossHeader.text:SetText(v);
end
-- parent scroll frame
local scrollParent = CreateFrame("Frame", nil, self);
scrollParent:SetSize(width - 24, height - 34);
scrollParent:SetPoint("TOPLEFT", self, 0, -30);
-- scroll frame
local scrollFrame = CreateFrame("ScrollFrame", nil, scrollParent);
scrollFrame:SetPoint("TOPLEFT");
scrollFrame:SetPoint("BOTTOMRIGHT");
scrollParent.scrollframe = scrollFrame;
-- scroll bar
local scrollBar = CreateFrame("Slider", nil, scrollFrame, "UIPanelScrollBarTemplate");
scrollBar:SetPoint("TOPLEFT", scrollParent, "TOPRIGHT", 4, -16);
scrollBar:SetPoint("BOTTOMLEFT", scrollParent, "BOTTOMRIGHT", 4, 16);
scrollBar:SetMinMaxValues(1, 200);
scrollBar:SetValueStep(1);
scrollBar.scrollStep = 1;
scrollBar:SetValue(0);
scrollBar:SetWidth(16);
scrollBar:SetScript("OnValueChanged", function (self, value) self:GetParent():SetVerticalScroll(value) end);
local scrollbg = scrollBar:CreateTexture(nil, "BACKGROUND");
scrollbg:SetAllPoints(scrollBar);
scrollbg:SetTexture(0, 0, 0, 0.4);
scrollParent.scrollbar = scrollBar;
-- content frame
local contentFrame = CreateFrame("Frame", nil, scrollFrame);
contentFrame:SetSize(width - 36, height);
scrollFrame.content = contentFrame;
scrollFrame:SetScrollChild(contentFrame);
-- runs
for k, run in ipairs(RUNS) do
if(name == run[3] and run[2] ~= {}) then
local timeStampFrame = CreateFrame("FRAME", nil, contentFrame);
timeStampFrame:SetPoint("TOPLEFT", contentFrame, 10, -(15 * (k - 1)));
timeStampFrame:SetWidth(100);
timeStampFrame:SetHeight(15);
timeStampFrame.text = timeStampFrame:CreateFontString();
timeStampFrame.text:SetPoint("CENTER");
timeStampFrame.text:SetSize(columnWidth, 15);
timeStampFrame.text:SetFont("Fonts\\FRIZQT__.ttf", 10, "OUTLINE");
timeStampFrame.text:SetText(run[1]);
for i, s in pairs(run[2]) do
local timer = Seconds_To_Timer(s);
local timerFrame = CreateFrame("FRAME", nil, contentFrame);
timerFrame:SetPoint("TOPLEFT", contentFrame, 110 + columnWidth * (i - 1), -(15 * (k - 1)));
timerFrame:SetWidth(columnWidth);
timerFrame:SetHeight(15);
timerFrame.text = timerFrame:CreateFontString();
timerFrame.text:SetPoint("CENTER");
timerFrame.text:SetSize(columnWidth, 15);
timerFrame.text:SetFont("Fonts\\FRIZQT__.ttf", 10, "OUTLINE");
timerFrame.text:SetText(timer);
end
end
end
end
Which is called here: