Advertisement
draugath

Untitled

Jan 19th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. declare('PluginManager', {})
  2.  
  3. local _, _, list3 = dofile('templates.lua')
  4.  
  5. local examples = {
  6.     {
  7.         name = 'Example 1',
  8.         author = 'Pseudonym 1',
  9.         description = 'It does nothing.',
  10.         version = '1.0',
  11.     },
  12.     {
  13.         name = 'Example 2',
  14.         author = 'Pseudonym 2',
  15.         description = 'It does nothing.',
  16.         version = '1.2',
  17.     },
  18.     {
  19.         name = 'Example 3',
  20.         author = 'Pseudonym 3',
  21.         description = 'It does nothing.',
  22.         version = '0.34',
  23.     },
  24. }
  25.  
  26. local function InitializePluginList()
  27. end
  28.  
  29.  
  30. local function CreateManagerUI()
  31.     local toggle_size = 15
  32.     local list_item_gap = 10
  33.    
  34.     local pluginlist = list3{size = '500x500'}
  35.     function pluginlist:setup_list()
  36.         self:SetCreateItemFunc(
  37.             function(item)
  38.                 printtable(item)
  39.                 return iup.hbox{
  40.                     iup.stationtoggle{size = toggle_size},
  41.                     iup.label{title = item.name or 'Unnamed plugin'},
  42.                     iup.label{title = item.author or ''},
  43.                     iup.label{title = item.description or ''},
  44.                     iup.label{title = item.version or ''},
  45.                     gap = list_item_gap,
  46.                 }
  47.             end
  48.         )
  49.        
  50.         self:SetColors{'30 55 78 96', '42 74 96 96', [0] = '65 100 127 255'}
  51.         self:AddItems(examples)
  52.         self:PopulateList()
  53.     end
  54.    
  55.     local closebutton = iup.stationbutton{title = 'Close', action = function(self) HideDialog(iup.GetDialog(self)) end}
  56.    
  57.     local listheaders = {
  58.         name = iup.label{title = 'Name'},
  59.         author = iup.label{title = 'Author'},
  60.         description = iup.label{title = 'Description'},
  61.         version = iup.label{title = 'Version'},
  62.     }
  63.    
  64.     local body = iup.vbox{
  65.         iup.hbox{
  66.             iup.fill{size = toggle_size},
  67.             listheaders.name,
  68.             listheaders.author,
  69.             listheaders.description,
  70.             listheaders.version,
  71.             gap = list_item_gap,
  72.         },
  73.         iup.hbox{
  74.             pluginlist,
  75.         },
  76.     }
  77.    
  78.     local footer = iup.hbox{
  79.         iup.fill{},
  80.         closebutton,
  81.         iup.fill{size = 15},
  82.     }
  83.        
  84.     local main = iup.vbox{
  85.         body,
  86.         footer,
  87.         gap = 10,
  88.     }
  89.        
  90.     local dlg = iup.dialog{
  91.         main,
  92.         defaultesc=closebutton,
  93.         bgcolor="0 0 0 *",
  94.         fullscreen="YES",
  95.         title = 'Plugin Manager Mockup',
  96.         border="NO",
  97.         resize="NO",
  98.         menubox="YES",
  99.         topmost="YES",
  100.     }
  101.        
  102.     dlg:map()
  103.    
  104.     pluginlist:setup_list()
  105.    
  106.     return dlg
  107. end
  108.  
  109. PluginManager.dlg = CreateManagerUI()
  110.  
  111. RegisterUserCommand('pmanager', function() ShowDialog(PluginManager.dlg) end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement