File: ctrlpanel.lua

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (44 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local ctrlPanel = {}

local function ParseCtrlPanelTXT(filename)
  local f,it,isFile = nil,nil,false
  f  = io.open(filename,'r')
  if f then
    it = f:lines()
    isFile = true
  else
    f  = VFS.LoadFile(filename)
    it = f:gmatch("%a+.-\n")
  end

  local wp = '%s*([^%s]+)'           -- word pattern
  local wp2 = '%s+([^%s]+)'           -- word pattern
  local cp = '^'..wp..wp2..wp2..wp2..wp2 -- color pattern
  local sp = '^'..wp..wp2             -- single value pattern like queuedLineWidth

  for line in it do
    local _, _, n, r, g, b, a = line:lower():find(cp)

    r = tonumber(r or 1.0)
    g = tonumber(g or 1.0)
    b = tonumber(b or 1.0)
    a = tonumber(a or 1.0)

    if n then
      ctrlPanel[n]= { r,g,b,a }
    else
      _, _, n, r = line:lower():find(sp)
      if n then
        ctrlPanel[n]= r
      end
    end
  end

  if isFile then f:close() end
  f,it,wp,cp,sp=nil,nil,nil,nil,nil
end

ParseCtrlPanelTXT('ctrlpanel.txt')
ParseCtrlPanelTXT('LuaUI/ctrlpanel.txt')

return ctrlPanel