Advertisement
draugath

Untitled

Jun 22nd, 2014
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.50 KB | None | 0 0
  1. -- I HATE writing GUIs
  2. DroidButtons.ui = {}
  3. local ui = DroidButtons.ui
  4.  
  5. local bool_map  = {[true] = 'ON', [false] = 'OFF'}
  6. local state_map = {ON = true,  OFF = false}
  7. local val_map   = {[true] = 1, [false] = 0}
  8.  
  9. local commandlist, joystick_cmds, joycmdlist2, joycmdlist3, joycmdlist, radarcmdlist, radarcmdlist2 = dofile('vars.lua')
  10.  
  11.  
  12. function ui:BuildButtonsTab()
  13.     local buttons_tab
  14.     local buttonlist
  15.     local deletebutton, editbutton, addbutton
  16.  
  17.     buttonlist = iup.stationsublist{}
  18.  
  19.     deletebutton = iup.stationbutton{title = 'Delete', active = 'NO'}
  20.     editbutton = iup.stationbutton{title = 'Edit', active = 'NO'}
  21.     addbutton = iup.stationbutton{title = 'Add', active = 'YES'}
  22.  
  23.     buttons_tab = iup.vbox{
  24.         iup.vbox{iup.hbox{iup.fill{}},iup.fill{}},
  25.         --buttonlist,
  26.         --iup.hbox{addbutton, editbutton, deletebutton, gap = 15},
  27.         tabtitle = 'Buttons',
  28.     }
  29.  
  30.     -- ----------------------------------------------------------------
  31.  
  32.  
  33.     return buttons_tab
  34. end
  35.  
  36.  
  37. function ui:BuildAccelTab()
  38.     local accel_tab
  39.     local xaxiscmd, yaxiscmd, custom_accel, set_tilt
  40.    
  41.     xaxiscmd = iup.stationsublist(joycmdlist);
  42.     yaxiscmd = iup.stationsublist(joycmdlist);
  43.     custom_accel = iup.stationtoggle{title = 'Use Custom Accelerometer Bindings'}
  44.     set_tilt = iup.stationbutton{title = 'Set'}
  45.    
  46.     accel_tab = iup.vbox{
  47. --      iup.label{title = 'Tilt Configuration'},
  48. --      custom_accel,
  49. --      iup.hbox{iup.label{title = 'Left/Right'}, xaxiscmd},
  50. --      iup.hbox{iup.label{title = 'Fore/Back'}, yaxiscmd},
  51. --      set_tilt,
  52. --      gap = 10,
  53.         tabtitle = 'Accelerometer',
  54.     }
  55.    
  56.     -- ----------------------------------------------------------------
  57.    
  58.     return accel_tab
  59. end
  60.  
  61. function ui:BuildSupportTab()
  62.     local support_tab
  63.     local vo_forum_button
  64.     local vo_ticket_button
  65.     local voupr_button
  66.     local voupr_db_button
  67.     local db_thread_button
  68.     local db_ticket_button
  69.    
  70.     local support_button_size
  71.  
  72.     voupr_button = iup.stationbutton{title = "Vendetta Online Unofficial Plugin Repository"}
  73.         -- Get the size of the largest button for uniformity
  74.         iup.Map(voupr_button)
  75.         support_button_size = voupr_button.size
  76.     vo_forum_button = iup.stationbutton{title = "Vendetta Online Forums", size = support_button_size}
  77.     vo_ticket_button = iup.stationbutton{title = "Vendetta Online Support Ticket", size = support_button_size}
  78.     voupr_db_button = iup.stationbutton{title = "VOUPR: DroidButtons", size = support_button_size}
  79.     db_thread_button = iup.stationbutton{title = "DroidButtons Discussion Thread", size = support_button_size}
  80.     db_ticket_button = iup.stationbutton{title = "DroidButtons Issue Tracker", size = support_button_size}
  81.  
  82.     support_tab = iup.vbox{
  83. --      vo_forum_button,
  84. --      vo_ticket_button,
  85. --      voupr_button,
  86. --      voupr_db_button,
  87. --      db_thread_button,
  88. --      db_ticket_button,
  89. --      gap = 10,
  90.         tabtitle = 'Support',
  91.     }
  92.  
  93.     -- ----------------------------------------------------------------
  94.  
  95.     function vo_forum_button:action() Game.OpenWebBrowser("http://www.vendetta-online.com/x/msgboard/") end
  96.     function vo_ticket_button:action() Game.OpenWebBrowser("http://www.vendetta-online.com/x/support") end
  97.     function voupr_button:action() Game.OpenWebBrowser("http://www.voupr.com") end
  98.     function voupr_db_button:action() Game.OpenWebBrowser("http://www.voupr.com/plugin.php?name=droidbuttons") end
  99.     function db_thread_button:action() Game.OpenWebBrowser("http://www.vendetta-online.com/x/msgboard/16/27594") end
  100.     function db_ticket_button:action() Game.OpenWebBrowser("https://bitbucket.org/draugath/droidbuttons/issues?status=new&status=open") end
  101.  
  102.     return support_tab
  103. end
  104.  
  105. function ui:BuildMainDialog()
  106.     local dlg, content
  107.     local tabs
  108.     local closebutton
  109.     local optionsbutton
  110.  
  111.     tabs = iup.pda_root_tabs{
  112.         self:BuildButtonsTab(),
  113.         --self:BuildAccelTab(),
  114.         --self:BuildSupportTab(),
  115.     }
  116.  
  117.     optionsbutton = iup.stationbutton{title = "Options"}
  118.     closebutton = iup.stationbutton{title = "Close"}
  119.  
  120.    
  121.     content = iup.pdarootframe{
  122.         iup.pdarootframebg{
  123.             iup.vbox{
  124.                 tabs,
  125.                 iup.hbox{iup.fill{}, optionsbutton, closebutton, gap = 15},
  126.                 gap = 10,
  127.             },
  128.         },
  129.     }
  130.  
  131.     dlg = iup.dialog{
  132.         content,
  133.         defaultesc = closebutton,
  134.         bgcolor = "0 0 0 *",
  135.         fullscreen="YES",
  136.         title = 'DroidButtons v'..DroidButtons.version..': Button Management',
  137.         border = "NO",
  138.         resize = "NO",
  139.         menubox = "YES",
  140.         topmost = "YES",
  141.     }
  142.     iup.Map(dlg)
  143.     -- ----------------------------------------------------------------
  144.  
  145.     function closebutton:action()
  146.         HideDialog(iup.GetDialog(self))
  147.     end
  148.    
  149.     return dlg
  150. end
  151.  
  152.  
  153.  
  154. ui.dialog = ui:BuildMainDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement