Advertisement
alestane

transparent tables

Apr 10th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. local function scoreRowRender(event)
  2.     event.background.alpha, event.line.alpha = 0, 0
  3.     local scoreInfo = history:TopScore(event.parent.Source, event.index - 1)
  4.     if not scoreInfo then return end
  5.     local happened = scoreInfo.happened do
  6.         local YYyy, mm, dd, hh, MM, SS = happened:match("(%d%d%d%d)%-(%d%d)%-(%d%d) (%d%d)%:(%d%d)%:(%d%d)")
  7.         happened = os.date("%I:%M%p, %m/%d",
  8.             os.time{year = YYyy, month = mm, day = dd, hour = hh, min = MM, sec = SS}
  9.         )
  10.     end
  11.     local date = display.newEmbossedText(event.view, happened, 0, 0, fonts.crisp, event.target.height * 0.75)
  12.         event.view:insert(date)
  13.         date:setTextColor(colors.wood())
  14.         date:setReferencePoint(display.CenterLeft)
  15.     event.row.Score = display.newEmbossedText(event.view, tostring(scoreInfo.Score), 0, 0, fonts.crisp, event.target.height * 0.75) do local score = event.row.Score
  16.         event.view:insert(score)
  17.         score:setTextColor(colors.wood())
  18.         score:setReferencePoint(display.CenterRightReferencePoint)
  19.         score.x = event.view.width
  20.     end
  21.     event.row.Days = display.newEmbossedText(event.view, tostring(scoreInfo.Days).." days", 0, 0, fonts.crisp, event.target.height * 0.75) do local days = event.row.Days
  22.         event.view:insert(days)
  23.         days:setTextColor(colors.wood())
  24.         days:setReferencePoint(display.CenterRightReferencePoint)
  25.         days.x = event.view.width
  26.         days.isVisible = false
  27.     end
  28.     event.row.Links = display.newEmbossedText(event.view, tostring(scoreInfo.CircuitLength).." links", 0, 0, fonts.crisp, event.target.height * 0.75) do local links = event.row.Links
  29.         event.view:insert(links)
  30.         links:setTextColor(colors.wood())
  31.         links:setReferencePoint(display.CenterRightReferencePoint)
  32.         links.x = event.view.width
  33.         links.isVisible = false
  34.     end
  35. end
  36.  
  37. local function scoreRowTouch(event)
  38.     if event.phase == "release" then
  39.         if event.row.Score.isVisible then
  40.             event.row.Score.isVisible = false
  41.             event.row.Days.isVisible = true
  42.         elseif event.row.Days.isVisible then
  43.             event.row.Days.isVisible = false
  44.             event.row.Links.isVisible = true
  45.         elseif event.row.Links.isVisible then
  46.             event.row.Links.isVisible = false
  47.             event.row.Score.isVisible = true
  48.         end
  49.     end
  50.     return true
  51. end
  52.  
  53. local function blank(event)
  54.     event.background.alpha, event.line.alpha = 0, 0    
  55. end
  56.  
  57. local function list(parent, source, top)
  58.     local self = widget.newTableView{
  59.         bgColor = {0, 0, 0, 0},
  60.         left = display.contentWidth * 0.15,
  61.         width = display.contentWidth * 0.7,
  62.         top = display.contentHeight * top,
  63.         height = display.contentHeight * 0.225,
  64.         maskFile = "tableMask.png"
  65.     }
  66.     parent:insert(self)
  67.     self.maskScaleX = display.contentWidth / 640
  68.     self.maskScaleY = self.maskScaleX
  69.     self.Source = source
  70.  
  71.     self:insertRow{
  72.         height = display.contentHeight * 0.005,
  73.         onRender = blank
  74.     }
  75.     for i=1,15 do
  76.         self:insertRow{
  77.             height = typesize,
  78.             onRender = scoreRowRender,
  79.             onEvent = scoreRowTouch,
  80.         }
  81.     end
  82.     self:insertRow{
  83.         height = display.contentHeight * 0.005,
  84.         onRender = blank
  85.     }
  86.     self:addEventListener('touch', function(...) return true end)
  87.     return self
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement