Took myrroddin's advice and coded part of my addon in lua instead of XML.
Would like to get the opinion of this community of how well I did.
There is problably room for improvement
This is the result of the coding (its part of a larger frame that is defined in XML).
And this is the code:
Lua Code:
function addon:Levels()
-- log(format("Historia levels"))
-- Define the container frame for the level frames (MC = Middle container)
local Historia_Level_MC = CreateFrame("FRAME", "Historia_Level_MC", Historia_UI_Level);
Historia_Level_MC:SetPoint("TOP" ,"Historia_Level_Header1", 0, -48)
Historia_Level_MC:SetPoint("BOTTOM" ,"Historia_UI_Level", 0, 32)
Historia_Level_MC:SetPoint("LEFT" ,"Historia_UI_Level", 32, 0)
Historia_Level_MC:SetPoint("RIGHT" ,"Historia_UI_Level", -32, 0)
Historia_Level_MC:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 32, edgeSize = 16,
insets = { left = 0, right = 0, top = 5, bottom = 5 }});
-- Define the frame for the first group of levels (ML1 = Middle Level one)
local Historia_Level_ML1 = CreateFrame("FRAME", "Historia_Level_ML1", Historia_Level_MC);
Historia_Level_ML1:SetPoint("TOP" ,"Historia_Level_MC", 0, -0)
Historia_Level_ML1:SetPoint("BOTTOM" ,"Historia_Level_MC", 0, 0)
Historia_Level_ML1:SetPoint("LEFT" ,"Historia_Level_MC", 0, 0)
Historia_Level_ML1:SetPoint("RIGHT" ,"Historia_Level_MC", "LEFT", 40, 0)
Historia_Level_ML1:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 32, edgeSize = 16,
insets = { left = 0, right = 0, top = 5, bottom = 5 }});
-- Define the frame for the first group of dates (MD1 = Middle Date one)
local Historia_Level_MD1 = CreateFrame("FRAME", "Historia_Level_MD1", Historia_Level_MC);
Historia_Level_MD1:SetPoint("TOP" ,"Historia_Level_MC", 0, -0)
Historia_Level_MD1:SetPoint("BOTTOM" ,"Historia_Level_MC", 0, 0)
Historia_Level_MD1:SetPoint("LEFT" ,"Historia_Level_MC", 36, 0)
Historia_Level_MD1:SetPoint("RIGHT" ,"Historia_Level_MC", "LEFT", 200, 0)
Historia_Level_MD1:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 32, edgeSize = 16,
insets = { left = 0, right = 0, top = 5, bottom = 5 }});
-- Define the header fontstring for the first group of levels (HLML1 = Historia Level ML1)
local HLML1 = Historia_Level_ML1:CreateFontString("HLML1", "ARTWORK", "GameFontWhite")
HLML1:SetPoint("TOP" ,"Historia_Level_ML1", 0, -10)
HLML1:SetText(L['Level'])
-- Define the header fontstring for the first group of dates (HLML1 = Historia Date ML1)
local HLMD1 = Historia_Level_MD1:CreateFontString("HLMD1", "ARTWORK", "GameFontWhite")
HLMD1:SetPoint("TOP" ,"Historia_Level_MD1", 0, -10)
HLMD1:SetText(L['Date'])
-- Set the levels and the date in the UI
for i = 1, #HistoriaLocalDb.Level do
local HLML1L1 = Historia_Level_ML1:CreateFontString("HLML1L1", "ARTWORK", "GameFontWhite")
HLML1L1:SetPoint("TOP", "Historia_Level_ML1", 0, -((i+1)*12))
HLML1L1:SetText(tostring(HistoriaLocalDb.Level[i].level))
local HLML1D1 = Historia_Level_MD1:CreateFontString("HLML1D1", "ARTWORK", "GameFontNormal")
HLML1D1:SetPoint("TOP" ,"Historia_Level_MD1", "TOP", 0, -((i+1)*12))
HLML1D1:SetText(format(date("%a, %b %d %Y %H:%M", HistoriaLocalDb.Level[i].time)))
end
end