View Single Post
05-08-15, 11:34 AM   #11
Yukyuk
A Chromatic Dragonspawn
 
Yukyuk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 179
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:
  1. function addon:Levels()
  2.     -- log(format("Historia levels"))
  3.     --  Define the container frame for the level frames (MC  = Middle container)
  4.     local Historia_Level_MC = CreateFrame("FRAME", "Historia_Level_MC", Historia_UI_Level);
  5.     Historia_Level_MC:SetPoint("TOP" ,"Historia_Level_Header1", 0, -48)
  6.     Historia_Level_MC:SetPoint("BOTTOM" ,"Historia_UI_Level", 0, 32)
  7.     Historia_Level_MC:SetPoint("LEFT" ,"Historia_UI_Level", 32, 0)
  8.     Historia_Level_MC:SetPoint("RIGHT" ,"Historia_UI_Level", -32, 0)
  9.     Historia_Level_MC:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
  10.                    edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  11.                    tile = true, tileSize = 32, edgeSize = 16,
  12.                    insets = { left = 0, right = 0, top = 5, bottom = 5 }});
  13.  
  14.     --  Define the frame for the first group of levels (ML1 = Middle Level one)            
  15.     local Historia_Level_ML1 = CreateFrame("FRAME", "Historia_Level_ML1", Historia_Level_MC);
  16.     Historia_Level_ML1:SetPoint("TOP" ,"Historia_Level_MC", 0, -0)
  17.     Historia_Level_ML1:SetPoint("BOTTOM" ,"Historia_Level_MC", 0, 0)
  18.     Historia_Level_ML1:SetPoint("LEFT" ,"Historia_Level_MC", 0, 0)
  19.     Historia_Level_ML1:SetPoint("RIGHT" ,"Historia_Level_MC", "LEFT", 40, 0)
  20.     Historia_Level_ML1:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
  21.                    edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  22.                    tile = true, tileSize = 32, edgeSize = 16,
  23.                    insets = { left = 0, right = 0, top = 5, bottom = 5 }});
  24.                    
  25.     --  Define the frame for the first group of dates (MD1 = Middle Date one)              
  26.     local Historia_Level_MD1 = CreateFrame("FRAME", "Historia_Level_MD1", Historia_Level_MC);
  27.     Historia_Level_MD1:SetPoint("TOP" ,"Historia_Level_MC", 0, -0)
  28.     Historia_Level_MD1:SetPoint("BOTTOM" ,"Historia_Level_MC", 0, 0)
  29.     Historia_Level_MD1:SetPoint("LEFT" ,"Historia_Level_MC", 36, 0)
  30.     Historia_Level_MD1:SetPoint("RIGHT" ,"Historia_Level_MC", "LEFT", 200, 0)
  31.     Historia_Level_MD1:SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
  32.                    edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  33.                    tile = true, tileSize = 32, edgeSize = 16,
  34.                    insets = { left = 0, right = 0, top = 5, bottom = 5 }});                    
  35.                    
  36.     --  Define the header fontstring for the first group of levels (HLML1 = Historia Level ML1)
  37.     local HLML1 = Historia_Level_ML1:CreateFontString("HLML1", "ARTWORK", "GameFontWhite")
  38.     HLML1:SetPoint("TOP" ,"Historia_Level_ML1", 0, -10)
  39.     HLML1:SetText(L['Level'])
  40.     --  Define the header fontstring for the first group of dates (HLML1 = Historia Date ML1)
  41.     local HLMD1 = Historia_Level_MD1:CreateFontString("HLMD1", "ARTWORK", "GameFontWhite")
  42.     HLMD1:SetPoint("TOP" ,"Historia_Level_MD1", 0, -10)
  43.     HLMD1:SetText(L['Date'])   
  44.     --  Set the levels and the date in the UI
  45.     for i = 1, #HistoriaLocalDb.Level do
  46.         local HLML1L1 = Historia_Level_ML1:CreateFontString("HLML1L1", "ARTWORK", "GameFontWhite")
  47.             HLML1L1:SetPoint("TOP", "Historia_Level_ML1", 0, -((i+1)*12))
  48.             HLML1L1:SetText(tostring(HistoriaLocalDb.Level[i].level))
  49.         local HLML1D1 = Historia_Level_MD1:CreateFontString("HLML1D1", "ARTWORK", "GameFontNormal")
  50.             HLML1D1:SetPoint("TOP" ,"Historia_Level_MD1", "TOP", 0, -((i+1)*12))
  51.             HLML1D1:SetText(format(date("%a, %b %d %Y %H:%M", HistoriaLocalDb.Level[i].time))) 
  52.     end
  53. end
  Reply With Quote