Advertisement
Mister_Stefan

aw senseui

Aug 2nd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.03 KB | None | 0 0
  1. --[[
  2. ui by Ruppet
  3. ====================================
  4. ui is Immediate-Mode Gui for Aimware which have "GameSense" cheat style.
  5. ]]--
  6.  
  7. -- Anti multiload
  8. local gs_fonts = {
  9. verdana_12 = draw.CreateFont( "Verdana", 13, 0 ),
  10. verdana_12b = draw.CreateFont( "Verdana", 12.5, 0 ),
  11. verdana_10 = draw.CreateFont( "Verdana", 10, 400 ),
  12. astriumtabs = draw.CreateFont( "Astriumtabs2", 41, 400 )
  13. }
  14.  
  15. if ui ~= nil then
  16. return
  17. end
  18. local Senseun_Tab = gui.Tab( gui.Reference("Settings") , "Senseun_Tab", "GameSense UI" );
  19. gui.Combobox(Senseun_Tab, "ThemeColor", "Theme color", "Green", "Blue", "Red", "Purple", "Orange", "Pink");
  20.  
  21. ui = {};
  22. ui.EnableLogs = false;
  23.  
  24.  
  25. ui.Keys = {
  26. esc = 27, f1 = 112, f2 = 113, f3 = 114, f4 = 115, f5 = 116,
  27. f6 = 117, f7 = 118, f8 = 119, f9 = 120, f10 = 121, f11 = 122,
  28. f12 = 123, tilde = 192, one = 49, two = 50, three = 51, four = 52,
  29. five = 53, six = 54, seven = 55, eight = 56, nine = 57, zero = 48,
  30. minus = 189, equals = 187, backslash = 220, backspace = 8,
  31. tab = 9, q = 81, w = 87, e = 69, r = 82, t = 84, y = 89, u = 85,
  32. i = 73, o = 79, p = 80, bracket_o = 219, bracket_c = 221,
  33. a = 65, s = 83, d = 68, f = 70, g = 71, h = 72, j = 74, k = 75,
  34. l = 76, semicolon = 186, quotes = 222, caps = 20, enter = 13,
  35. shift = 16, z = 90, x = 88, c = 67, v = 86, b = 66, n = 78,
  36. m = 77, comma = 188, dot = 190, slash = 191, ctrl = 17,
  37. win = 91, alt = 18, space = 32, scroll = 145, pause = 19,
  38. insert = 45, home = 36, pageup = 33, pagedn = 34, delete = 46,
  39. end_key = 35, uparrow = 38, leftarrow = 37, downarrow = 40,
  40. rightarrow = 39, num = 144, num_slash = 111, num_mult = 106,
  41. num_sub = 109, num_7 = 103, num_8 = 104, num_9 = 105, num_plus = 107,
  42. num_4 = 100, num_5 = 101, num_6 = 102, num_1 = 97, num_2 = 98,
  43. num_3 = 99, num_enter = 13, num_0 = 96, num_dot = 110, mouse_1 = 1, mouse_2 = 2, mouse_3 = 6, mouse_4 = 4, mouse_5 = 5
  44. };
  45.  
  46. ui.KeyDetection = {
  47. always_on = 1,
  48. on_hotkey = 2,
  49. toggle = 3,
  50. off_hotkey = 4
  51. };
  52.  
  53. ui.Icons = {
  54. rage = { "C", 6 },
  55. legit = { "D", 5 },
  56. visuals = { "E", 4 },
  57. settings = { "F", 3 },
  58. skinchanger = { "G", 2 },
  59. playerlist = { "H", 1 },
  60. antiaim = { "I", 0 }
  61. };
  62.  
  63. local gs_windows = {}; -- Contains all windows
  64. local gs_curwindow = ""; -- Current window ID
  65. local gs_curgroup = ""; -- Current group ID
  66. local gs_curtab = ""; -- Current tab
  67. local gs_curinput = ""; -- Current input
  68.  
  69.  
  70.  
  71. local gs_curchild = {
  72. id = "",
  73. x = 0,
  74. y = 0,
  75. elements = {},
  76. selected = {},
  77. multiselect = false,
  78. last_id = "",
  79. minimal_width = 0
  80. };
  81.  
  82. local gs_isBlocked = false;
  83.  
  84. local gs_mx = 0; -- Mouse X
  85. local gs_my = 0; -- Mouse Y
  86.  
  87. -- CUSTOM DRAWING --
  88. local render = {};
  89.  
  90. render.outline = function( x, y, w, h, col )
  91. draw.Color( col[1], col[2], col[3], col[4] );
  92. draw.OutlinedRect( x, y, x + w, y + h );
  93. end
  94.  
  95. render.rect = function( x, y, w, h, col )
  96. draw.Color( col[1], col[2], col[3], col[4] );
  97. draw.FilledRect( x, y, x + w, y + h );
  98. end
  99.  
  100. render.rect2 = function( x, y, w, h )
  101. draw.FilledRect( x, y, x + w, y + h );
  102. end
  103.  
  104. render.gradient = function( x, y, w, h, col1, col2, is_vertical )
  105. render.rect( x, y, w, h, col1 );
  106.  
  107. local r, g, b = col2[1], col2[2], col2[3];
  108.  
  109. if is_vertical then
  110. for i = 1, h do
  111. local a = i / h * 255;
  112. render.rect( x, y + i, w, 1, { r, g, b, a } );
  113. end
  114. else
  115. for i = 1, w do
  116. local a = i / w * 255;
  117. render.rect( x + i, y, 1, h, { r, g, b, a } );
  118. end
  119. end
  120. end
  121.  
  122. render.text = function( x, y, text, col, font )
  123. if font ~= nil then
  124. draw.SetFont( font )
  125. else
  126. draw.SetFont( gs_fonts.verdana_12 )
  127. end
  128.  
  129. draw.Color( col[1], col[2], col[3], col[4] );
  130. draw.Text( x, y, text );
  131. end
  132. -- CUSTOM DRAWING --
  133.  
  134. -- Needed for some actions
  135. local function gs_clone( orig )
  136. return { table.unpack( orig ) };
  137. end
  138.  
  139. -- Check if a and b in bounds
  140. local function gs_inbounds( a, b, mina, minb, maxa, maxb )
  141. if a >= mina and a <= maxa and b >= minb and b <= maxb then
  142. return true;
  143. else
  144. return false;
  145. end
  146. end
  147.  
  148. -- Get size of non-array table
  149. local function gs_tablecount( T )
  150. local count = 0
  151. for _ in pairs(T) do count = count + 1 end
  152. return count
  153. end
  154.  
  155. -- Just checks if logs are enabled
  156. local function gs_log( text )
  157. if ui.EnableLogs then
  158. print( text );
  159. end
  160. end
  161.  
  162. -- Clamps value
  163. local function gs_clamp( val, min, max )
  164. if val < min then return min end
  165. if val > max then return max end
  166.  
  167. return val;
  168. end
  169.  
  170. -- I'm too lazy to do shit what I moved into this func
  171. local function gs_newelement()
  172. local wnd = gs_windows[gs_curwindow];
  173. local group = wnd.groups[gs_curgroup];
  174.  
  175. return wnd, group;
  176. end
  177.  
  178. -- Begins window
  179. local function gs_beginwindow( id, x, y, w, h )
  180. -- Check values
  181. if id == nil or x < 0 or y < 0 or w < 0 or h < 25 then
  182. return false;
  183. end
  184.  
  185. -- Check if we already have window with id
  186. local wnd = gs_windows[id];
  187.  
  188. if wnd == nil then
  189. -- Create window
  190. wnd = {
  191. -- Position and size
  192. x = 0,
  193. y = 0,
  194. w = 0,
  195. h = 0,
  196.  
  197. -- Needed to work
  198. is_opened = true,
  199. alpha = 255,
  200. dx = 0,
  201. dy = 0,
  202. drag = false,
  203. resize = false,
  204. dmx = 0,
  205. dmy = 0,
  206. tabs = {},
  207. groups = {},
  208.  
  209. -- Settings
  210. is_movable = false,
  211. is_sizeable = false,
  212. open_key = nil,
  213. draw_texture = false
  214. };
  215.  
  216. wnd.x = x;
  217. wnd.y = y;
  218. wnd.w = w;
  219. wnd.h = h;
  220.  
  221. gs_windows[id] = wnd;
  222.  
  223. gs_log( "Window " .. id .. " has been created" );
  224. end
  225.  
  226. gs_curwindow = id;
  227.  
  228. -- Backend
  229. if wnd.open_key ~= nil then
  230. -- Window toggle
  231. if input.IsButtonPressed( wnd.open_key ) then
  232. wnd.is_opened = not wnd.is_opened;
  233. gs_log( "Window " .. id .. " has been toggled" );
  234. end
  235. end
  236.  
  237. -- Close animation
  238. local fade_factor = ((1.0 / 0.15) * globals.FrameTime()) * 200; -- Animation takes 150ms to finish. This helps to make it look the same on 200 fps and on 30fps
  239.  
  240. if not wnd.is_opened and wnd.alpha ~= 0 then
  241. wnd.alpha = gs_clamp( wnd.alpha - fade_factor, 0, 255 );
  242. end
  243.  
  244. -- Open animation
  245. if wnd.is_opened and wnd.alpha ~= 255 then
  246. wnd.alpha = gs_clamp( wnd.alpha + fade_factor, 0, 255 );
  247. end
  248.  
  249. gs_windows[id] = wnd;
  250.  
  251. -- Check if window opened
  252. if not wnd.is_opened and wnd.alpha == 0 then
  253. gs_curchild.id = "";
  254. gs_isBlocked = false;
  255. return false;
  256. end
  257.  
  258. -- Movement
  259. if wnd.is_movable then
  260. -- If clicked and in bounds
  261. if input.IsButtonDown( 1 ) then
  262. gs_mx, gs_my = input.GetMousePos();
  263.  
  264. if wnd.drag then
  265. wnd.x = gs_mx - wnd.dx;
  266. wnd.y = gs_my - wnd.dy;
  267. wnd.x2 = wnd.x + wnd.w;
  268. wnd.y2 = wnd.y + wnd.h;
  269. end
  270.  
  271. if gs_inbounds( gs_mx, gs_my, wnd.x, wnd.y, wnd.x + wnd.w, wnd.y + 20 ) and wnd.h > 30 then
  272. wnd.drag = true;
  273. wnd.dx = gs_mx - wnd.x;
  274. wnd.dy = gs_my - wnd.y;
  275. end
  276.  
  277. gs_windows[id] = wnd;
  278. else
  279. gs_windows[id].drag = false;
  280. end
  281. end
  282.  
  283. local size_changing = false;
  284.  
  285. if wnd.is_sizeable then
  286. -- If clicked and in bounds
  287. if input.IsButtonDown( 1 ) then
  288. gs_mx, gs_my = input.GetMousePos();
  289.  
  290. if wnd.resize then
  291. wnd.w = gs_mx - wnd.dmx;
  292. wnd.h = gs_my - wnd.dmy;
  293.  
  294. if wnd.w < 50 then
  295. wnd.w = 50;
  296. end
  297.  
  298. if wnd.h < 50 then
  299. wnd.h = 50;
  300. end
  301. end
  302.  
  303. if gs_inbounds( gs_mx, gs_my, wnd.x + wnd.w - 5, wnd.y + wnd.h - 5, wnd.x + wnd.w - 1, wnd.y + wnd.h - 1 ) then
  304. wnd.resize = true;
  305. size_changing = true;
  306. wnd.dmx = gs_mx - wnd.w;
  307. wnd.dmy = gs_my - wnd.h;
  308. end
  309.  
  310. gs_windows[id] = wnd;
  311. else
  312. gs_windows[id].resize = false;
  313. end
  314. end
  315.  
  316. -- Begin draw
  317. local lmd_outlinehelp = function( off, col )
  318. render.outline( wnd.x - off, wnd.y - off, wnd.w + off * 2, wnd.h + off * 2, col );
  319. end
  320.  
  321. -- Window base
  322. render.rect( wnd.x, wnd.y, wnd.w, wnd.h, { 14, 14, 14, wnd.alpha } );
  323.  
  324. if wnd.draw_texture then -- This thing is very shitty rn, waiting till polak will add textures into draw.
  325. draw.Color( 16, 16, 16, wnd.alpha );
  326. for i = 1, wnd.h, 4 do
  327.  
  328. local y1 = wnd.y+i;
  329. local y2 = y1-2;
  330.  
  331. for j=0, wnd.w, 4 do
  332. local x1 = wnd.x+j;
  333. render.rect2( x1 - 2, y1, 1, 3);
  334. render.rect2( x1 , y2, 1, 3);
  335. end
  336. end
  337. end
  338.  
  339. -- Window border
  340. lmd_outlinehelp( 0, { 31, 31, 31, wnd.alpha } );
  341.  
  342. if size_changing then
  343. lmd_outlinehelp( 1, { 149, 184, 6, wnd.alpha } );
  344. else
  345. lmd_outlinehelp( 1, { 60, 60, 60, wnd.alpha } );
  346. end
  347.  
  348. lmd_outlinehelp( 2, { 40, 40, 40, wnd.alpha } );
  349. lmd_outlinehelp( 3, { 40, 40, 40, wnd.alpha } );
  350. lmd_outlinehelp( 4, { 40, 40, 40, wnd.alpha } );
  351. lmd_outlinehelp( 5, { 60, 60, 60, wnd.alpha } );
  352. lmd_outlinehelp( 6, { 31, 31, 31, wnd.alpha } );
  353.  
  354. -- If sizeable, draw litte triangle
  355. if wnd.is_sizeable then
  356. if size_changing then
  357. render.rect( wnd.x + wnd.w - 5, wnd.y + wnd.h - 1, 5, 1, { 149, 184, 6, wnd.alpha } );
  358. render.rect( wnd.x + wnd.w - 4, wnd.y + wnd.h - 2, 4, 1, { 149, 184, 6, wnd.alpha } );
  359. render.rect( wnd.x + wnd.w - 3, wnd.y + wnd.h - 3, 3, 1, { 149, 184, 6, wnd.alpha } );
  360. render.rect( wnd.x + wnd.w - 2, wnd.y + wnd.h - 4, 2, 1, { 149, 184, 6, wnd.alpha } );
  361. render.rect( wnd.x + wnd.w - 1, wnd.y + wnd.h - 5, 1, 1, { 149, 184, 6, wnd.alpha } );
  362. else
  363. render.rect( wnd.x + wnd.w - 5, wnd.y + wnd.h - 1, 5, 1, { 60, 60, 60, wnd.alpha } );
  364. render.rect( wnd.x + wnd.w - 4, wnd.y + wnd.h - 2, 4, 1, { 60, 60, 60, wnd.alpha } );
  365. render.rect( wnd.x + wnd.w - 3, wnd.y + wnd.h - 3, 3, 1, { 60, 60, 60, wnd.alpha } );
  366. render.rect( wnd.x + wnd.w - 2, wnd.y + wnd.h - 4, 2, 1, { 60, 60, 60, wnd.alpha } );
  367. render.rect( wnd.x + wnd.w - 1, wnd.y + wnd.h - 5, 1, 1, { 60, 60, 60, wnd.alpha } );
  368. end
  369. end
  370.  
  371. return true;
  372. end
  373.  
  374. local function gs_addgradient( )
  375. local wnd = gs_windows[gs_curwindow];
  376.  
  377. render.gradient( wnd.x, wnd.y, wnd.w / 2, 1, { 59, 175, 222, wnd.alpha }, { 202, 70, 205, wnd.alpha }, false );
  378. render.gradient( wnd.x + ( wnd.w / 2 ), wnd.y, wnd.w / 2, 1, { 202, 70, 205, wnd.alpha }, { 201, 227, 58, wnd.alpha }, false );
  379. end
  380.  
  381. local function gs_endwindow( )
  382. if gs_curchild.id ~= "" then
  383. gs_mx, gs_my = input.GetMousePos();
  384.  
  385. local highest_w = 0;
  386.  
  387. draw.SetFont( gs_fonts.verdana_12b );
  388.  
  389. for i = 1, #gs_curchild.elements do
  390. local textw, texth = draw.GetTextSize( gs_curchild.elements[i] );
  391.  
  392. if highest_w < textw then
  393. highest_w = textw;
  394. end
  395. end
  396.  
  397. if highest_w < gs_curchild.minimal_width then
  398. highest_w = gs_curchild.minimal_width;
  399. end
  400.  
  401. if input.IsButtonPressed( 1 ) and not gs_inbounds( gs_mx, gs_my, gs_curchild.x, gs_curchild.y - 20, gs_curchild.x + 20 + highest_w, gs_curchild.y + 20 * #gs_curchild.elements + #gs_curchild.elements ) then
  402. gs_curchild.id = "";
  403. gs_curchild.minimal_width = 0;
  404. gs_isBlocked = false;
  405. end
  406.  
  407. render.rect( gs_curchild.x, gs_curchild.y, 20 + highest_w, 20 * #gs_curchild.elements + #gs_curchild.elements, { 36, 36, 36, 255 } );
  408.  
  409. local text_offset = 0;
  410.  
  411. for i = 1, #gs_curchild.elements do
  412. local r, g, b = 181, 181, 181;
  413. local speed = 3
  414. local fnt = gs_fonts.verdana_12;
  415.  
  416. if gs_inbounds( gs_mx, gs_my, gs_curchild.x, gs_curchild.y + text_offset, gs_curchild.x + 20 + highest_w, gs_curchild.y + text_offset + 20 ) then
  417. if input.IsButtonPressed( 1 ) then
  418. if gs_curchild.multiselect then
  419. if gs_curchild.selected[gs_curchild.elements[i]] == nil then
  420. gs_curchild.selected[gs_curchild.elements[i]] = true;
  421. else
  422. if gs_curchild.selected[gs_curchild.elements[i]] then
  423. gs_curchild.selected[gs_curchild.elements[i]] = false;
  424. else
  425. gs_curchild.selected[gs_curchild.elements[i]] = true;
  426. end
  427. end
  428. else
  429. gs_curchild.selected = { i };
  430. gs_curchild.minimal_width = 0;
  431. gs_curchild.last_id = gs_curchild.id;
  432. gs_curchild.id = "";
  433. gs_isBlocked = false;
  434. end
  435. end
  436.  
  437. render.rect( gs_curchild.x, gs_curchild.y + text_offset, 20 + highest_w, 21, { 28, 28, 28, 255 } );
  438. fnt = gs_fonts.verdana_12b;
  439. end
  440.  
  441. local r12, g12, b12 = 149, 184, 6;
  442.  
  443.  
  444. if not gs_curchild.multiselect then
  445. for k = 1, #gs_curchild.selected do
  446. if gs_curchild.selected[k] == i then
  447.  
  448. fnt = gs_fonts.verdana_12b;
  449. end
  450. end
  451. else
  452. if gs_curchild.selected[gs_curchild.elements[i]] ~= nil and gs_curchild.selected[gs_curchild.elements[i]] == true then
  453.  
  454. fnt = gs_fonts.verdana_12b;
  455. end
  456. end
  457.  
  458. render.text( gs_curchild.x + 10, gs_curchild.y + text_offset + 4, gs_curchild.elements[i], { r, g, b, 255 }, fnt );
  459.  
  460. text_offset = text_offset + 20 + 1;
  461. end
  462.  
  463. render.outline( gs_curchild.x, gs_curchild.y, 20 + highest_w, 20 * #gs_curchild.elements + #gs_curchild.elements, { 5, 5, 5, 255 } );
  464. end
  465.  
  466. gs_curwindow = "";
  467. end
  468.  
  469. local function gs_setwindowmovable( val )
  470. if gs_windows[gs_curwindow].is_movable ~= val then
  471. gs_windows[gs_curwindow].is_movable = val;
  472.  
  473. if val then val = "true" else val = "false" end
  474. gs_log("SetWindowMoveable has been set to " .. val);
  475. end
  476. end
  477.  
  478. local function gs_setwindowsizeable( val )
  479. if gs_windows[gs_curwindow].is_sizeable ~= val then
  480. gs_windows[gs_curwindow].is_sizeable = val;
  481.  
  482. if val then val = "true" else val = "false" end
  483. gs_log("SetWindowSizeable has been set to " .. val);
  484. end
  485. end
  486.  
  487. local function gs_setwindowdrawtexture( val )
  488. if gs_windows[gs_curwindow].draw_texture ~= val then
  489. gs_windows[gs_curwindow].draw_texture = val;
  490.  
  491. if val then val = "true" else val = "false" end
  492. gs_log("SetWindowDrawTexture has been set to " .. val);
  493. end
  494. end
  495.  
  496. local function gs_setwindowopenkey( val )
  497. if gs_windows[gs_curwindow].open_key ~= val then
  498. gs_windows[gs_curwindow].open_key = val;
  499.  
  500. local txt = "nil";
  501.  
  502. if val ~= nil then
  503. txt = val;
  504. end
  505.  
  506. gs_log("SetWindowOpenKey has been set to " .. txt);
  507. end
  508. end
  509.  
  510. local function gs_begingroup( id, title, x, y, w, h )
  511. local wnd = gs_windows[gs_curwindow];
  512. local tab = wnd.tabs[gs_curtab];
  513. local tx = 0;
  514.  
  515. if tab ~= nil then
  516. tx = 80;
  517. end
  518.  
  519. -- Checks
  520. if id == nil then return false end
  521.  
  522. -- Check if we already have window with id
  523. local group = wnd.groups[id];
  524.  
  525. if group == nil then
  526. -- Create window
  527. group = {
  528. -- Position and size
  529. x = 0,
  530. y = 0,
  531. w = 0,
  532. h = 0,
  533.  
  534. -- Other stuff
  535. title = nil,
  536. is_moveable = false,
  537. is_sizeable = false,
  538.  
  539. -- Stuff needed to work
  540. is_nextline = true,
  541. nextline_offset = 15,
  542. dx = 0,
  543. dy = 0,
  544. drag = false,
  545. resize = false,
  546. highest_w = 0,
  547. highest_h = 0,
  548. last_y = 20
  549. };
  550.  
  551. group.x = x + tx;
  552. group.y = y;
  553. group.w = w;
  554. group.h = h;
  555.  
  556. group.title = title;
  557.  
  558. wnd.groups[id] = group;
  559.  
  560. gs_log( "Group " .. id .. " has been created" );
  561. end
  562.  
  563. if group.x + wnd.x < wnd.x or group.y + wnd.y < wnd.y or wnd.x + group.x + group.w + 15 > wnd.x + wnd.w or wnd.y + group.y + group.h + 15 > wnd.y + wnd.h then
  564. return false;
  565. end
  566.  
  567. gs_curgroup = id;
  568.  
  569. draw.SetFont( gs_fonts.verdana_12b );
  570. local textw, texth = draw.GetTextSize( group.title );
  571. local oldw, oldh = draw.GetTextSize( title );
  572. local groupaftertext = group.w - 18 - textw - 3;
  573. local groupaftertext_n = group.w - 18 - oldw - 3;
  574.  
  575. local size_changing = false;
  576.  
  577. -- Movement
  578. if not gs_isBlocked then
  579. if group.is_moveable then
  580. -- If clicked and in bounds
  581. if input.IsButtonDown( 1 ) then
  582. gs_mx, gs_my = input.GetMousePos();
  583.  
  584. if group.drag then
  585. group.x = gs_mx - group.dx;
  586. group.y = gs_my - group.dy;
  587.  
  588. if group.x < 25 then
  589. group.x = 25;
  590. end
  591.  
  592. if wnd.w < group.x + group.w + 25 then
  593. group.x = group.x - ((group.x + group.w + 25) - wnd.w);
  594. end
  595.  
  596. if wnd.h < group.y + group.h + 25 then
  597. group.y = group.y - ((group.y + group.h + 25) - wnd.h);
  598. end
  599.  
  600. if group.y < 25 then
  601. group.y = 25;
  602. end
  603. end
  604.  
  605. if gs_inbounds( gs_mx, gs_my, wnd.x + group.x + 15, wnd.y + group.y, wnd.x + group.x + 15 + textw, wnd.y + group.y + texth ) and group.h > 30 then
  606. group.drag = true;
  607. size_changing = true;
  608. group.dx = gs_mx - group.x;
  609. group.dy = gs_my - group.y;
  610. end
  611.  
  612. wnd.groups[id] = group;
  613. else
  614. wnd.groups[id].drag = false;
  615. end
  616. end
  617.  
  618. if group.is_sizeable then
  619. -- If clicked and in bounds
  620. if input.IsButtonDown( 1 ) then
  621. gs_mx, gs_my = input.GetMousePos();
  622.  
  623. if group.resize then
  624. group.w = gs_mx - group.dmx;
  625. group.h = gs_my - group.dmy;
  626.  
  627. if group.w < 50 then
  628. group.w = 50;
  629. end
  630.  
  631. if group.w < group.highest_w + 50 then
  632. group.w = group.highest_w + 50;
  633. end
  634.  
  635. if group.h < 50 then
  636. group.h = 50;
  637. end
  638.  
  639. if group.h < group.highest_h + 25 then
  640. group.h = group.highest_h + 25;
  641. end
  642.  
  643. if group.w + group.x + 25 > wnd.w then
  644. group.w = group.w - ((group.w + group.x + 25) - wnd.w);
  645. end
  646.  
  647. if group.h + group.y + 25 > wnd.h then
  648. group.h = group.h - ((group.h + group.y + 25) - wnd.h);
  649. end
  650. end
  651.  
  652. if gs_inbounds( gs_mx, gs_my, wnd.x + group.x + group.w - 5, wnd.y + group.y + group.h - 5, wnd.x + group.x + group.w - 1, wnd.y + group.y + group.h - 1 ) then
  653. group.resize = true;
  654. size_changing = true;
  655. group.dmx = gs_mx - group.w;
  656. group.dmy = gs_my - group.h;
  657. end
  658.  
  659. wnd.groups[id] = group;
  660. else
  661. wnd.groups[id].resize = false;
  662. end
  663. end
  664. end
  665.  
  666. wnd.groups[id].highest_h = 0;
  667.  
  668. -- Draw
  669. if groupaftertext_n > 15 then
  670. group.title = title;
  671. end
  672.  
  673. -- Subtract title if width more than 15
  674. if groupaftertext < 15 then
  675. while groupaftertext < 15 do
  676. group.title = group.title:sub( 1, -2 );
  677.  
  678. textw, texth = draw.GetTextSize( group.title );
  679. groupaftertext = w - 18 - textw - 3;
  680. end
  681.  
  682. group.title = group.title:sub( 1, -5 );
  683. group.title = group.title .. "...";
  684. end
  685.  
  686. local r, g, b = 65, 65, 65;
  687.  
  688. if size_changing then
  689. r, g, b = 149, 184, 6;
  690. end
  691.  
  692. render.rect( wnd.x + group.x, wnd.y + group.y, group.w, group.h, { 19, 19, 19, wnd.alpha } );
  693.  
  694. render.rect( wnd.x + group.x, wnd.y + group.y, 1, group.h, { r, g, b, wnd.alpha } );
  695. render.rect( wnd.x + group.x - 1, wnd.y + group.y - 1, 1, group.h + 2, { 5, 5, 5, wnd.alpha } );
  696.  
  697. render.rect( wnd.x + group.x, wnd.y + group.y + group.h, group.w + 1, 1, { r, g, b, wnd.alpha } );
  698. render.rect( wnd.x + group.x - 1, wnd.y + group.y + group.h + 1, group.w + 3, 1, { 5, 5, 5, wnd.alpha } );
  699.  
  700. render.rect( wnd.x + group.x + group.w, wnd.y + group.y, 1, group.h, { r, g, b, wnd.alpha } );
  701. render.rect( wnd.x + group.x + group.w + 1, wnd.y + group.y - 1, 1, group.h + 2, { 5, 5, 5, wnd.alpha } );
  702.  
  703. if group.title ~= nil and groupaftertext >= 15 then
  704. render.rect( wnd.x + group.x, wnd.y + group.y, 15, 1, { r, g, b, wnd.alpha } );
  705. render.rect( wnd.x + group.x + 1, wnd.y + group.y - 1, 14, 1, { 5, 5, 5, wnd.alpha } );
  706.  
  707. if size_changing then
  708. render.text( wnd.x + group.x + 18, wnd.y + group.y - 6, group.title, { r, g, b, wnd.alpha }, gs_fonts.verdana_12b );
  709. else
  710. render.text( wnd.x + group.x + 18, wnd.y + group.y - 6, group.title, { 181, 181, 181, wnd.alpha }, gs_fonts.verdana_12b );
  711. end
  712.  
  713. render.rect( wnd.x + group.x + 18 + textw + 3, wnd.y + group.y, groupaftertext, 1, { r, g, b, wnd.alpha } );
  714. render.rect( wnd.x + group.x + 18 + textw + 3, wnd.y + group.y - 1, groupaftertext + 1, 1, { 5, 5, 5, wnd.alpha } );
  715. else
  716. render.rect( wnd.x + group.x, wnd.y + group.y, group.w, 1, { r, g, b, wnd.alpha } );
  717. render.rect( wnd.x + group.x + 1, wnd.y + group.y - 1, group.w + 1, 1, { 5, 5, 5, wnd.alpha } );
  718. end
  719.  
  720. -- If sizeable, draw litte triangle
  721. if group.is_sizeable then
  722. render.rect( wnd.x + group.x + group.w - 5, wnd.y + group.y + group.h - 1, 5, 1, { r, g, b, wnd.alpha } );
  723. render.rect( wnd.x + group.x + group.w - 4, wnd.y + group.y + group.h - 2, 4, 1, { r, g, b, wnd.alpha } );
  724. render.rect( wnd.x + group.x + group.w - 3, wnd.y + group.y + group.h - 3, 3, 1, { r, g, b, wnd.alpha } );
  725. render.rect( wnd.x + group.x + group.w - 2, wnd.y + group.y + group.h - 4, 2, 1, { r, g, b, wnd.alpha } );
  726. render.rect( wnd.x + group.x + group.w - 1, wnd.y + group.y + group.h - 5, 1, 1, { r, g, b, wnd.alpha } );
  727. end
  728.  
  729. return true;
  730. end
  731.  
  732. local function gs_endgroup( )
  733. local wnd = gs_windows[gs_curwindow];
  734. local group = wnd.groups[gs_curgroup];
  735.  
  736. if group.w + group.x + 25 > wnd.w then
  737. group.w = gs_clamp( group.w - ((group.w + group.x + 25) - wnd.w), 50, wnd.w - 50 );
  738. end
  739.  
  740. if group.h + group.y + 25 > wnd.h then
  741. group.h = gs_clamp( group.h - ((group.h + group.y + 25) - wnd.h), 50, wnd.h - 50 );
  742. end
  743.  
  744. if wnd.x + wnd.w < wnd.x + group.x + group.w + 25 then
  745. group.x = group.x - ((group.x + group.w + 25) - wnd.w);
  746. end
  747.  
  748. if wnd.y + wnd.h < wnd.y + group.y + group.h + 25 then
  749. group.y = group.y - ((group.y + group.h + 25) - wnd.h);
  750. end
  751.  
  752. if group.x < 25 then
  753. group.x = 25;
  754. end
  755.  
  756. if group.y < 25 then
  757. group.y = 25;
  758. end
  759.  
  760. if group.is_sizeable then
  761. if group.w < group.highest_w + 50 then
  762. group.w = group.highest_w + 50;
  763. end
  764.  
  765. if group.h < group.highest_h + 25 then
  766. group.h = group.highest_h + 25;
  767. end
  768.  
  769. if group.h + 15 < group.x + group.nextline_offset then
  770. group.h = group.nextline_offset + 15;
  771. end
  772. end
  773.  
  774. wnd.groups[gs_curgroup] = group;
  775.  
  776. wnd.groups[gs_curgroup].nextline_offset = 15;
  777. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].highest_h + 20;
  778. wnd.groups[gs_curgroup].is_nextline = true;
  779. wnd.groups[gs_curgroup].last_y = 20;
  780.  
  781. gs_curgroup = "";
  782. end
  783.  
  784. local function gs_setgroupmoveable( val )
  785. local wnd = gs_windows[gs_curwindow];
  786.  
  787. if wnd.groups[gs_curgroup].is_moveable ~= val then
  788. wnd.groups[gs_curgroup].is_moveable = val;
  789.  
  790. if val then val = "true" else val = "false" end
  791. gs_log("SetGroupMoveable has been set to " .. val);
  792. end
  793. end
  794.  
  795. local function gs_setgroupsizeable( val )
  796. local wnd = gs_windows[gs_curwindow];
  797.  
  798. if wnd.groups[gs_curgroup].is_sizeable ~= val then
  799. wnd.groups[gs_curgroup].is_sizeable = val;
  800.  
  801. if val then val = "true" else val = "false" end
  802. gs_log("SetGroupSizeable has been set to " .. val);
  803. end
  804. end
  805.  
  806. local function gs_checkbox( title, var , is_alt)
  807. local wnd, group = gs_newelement();
  808.  
  809. local textw, texth = draw.GetTextSize( title );
  810. local x, y = wnd.x + group.x + 10, wnd.y + group.y + group.nextline_offset;
  811.  
  812. -- Backend
  813. if input.IsButtonPressed( 1 ) and gs_inbounds( gs_mx, gs_my, x, y, x + 15 + textw, y + texth ) and not gs_isBlocked then
  814. -- Update value
  815. var = not var;
  816. end
  817.  
  818. -- Draw
  819. render.outline( x, y, 8, 8, { 5, 5, 5, wnd.alpha } );
  820.  
  821. local r12, g12, b12 = gui.GetValue("theme.nav.active");
  822.  
  823.  
  824. local r11, g11, b11 = gui.GetValue("theme.nav.bg");
  825.  
  826.  
  827. if var then
  828. render.gradient( x + 1, y + 1, 6, 5, { r12, g12, b12, wnd.alpha }, { r11, g11, b11, wnd.alpha }, true );
  829. else
  830. render.gradient( x + 1, y + 1, 6, 5, { 65, 65, 65, wnd.alpha }, { 45, 45, 45, wnd.alpha }, true );
  831. end
  832.  
  833. local r1, g1, b1 = 181, 181, 181;
  834.  
  835. if is_alt then
  836. r1, g1, b1 = 190, 190, 110;
  837. end
  838.  
  839. render.text( x + 13, y - 2, title, { r1, g1, b1, wnd.alpha } );
  840.  
  841. wnd.groups[gs_curgroup].is_nextline = true;
  842. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + 17;
  843.  
  844. if group.highest_w < 15 + textw then
  845. wnd.groups[gs_curgroup].highest_w = 15 + textw;
  846. end
  847.  
  848. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  849. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  850. end
  851.  
  852. wnd.groups[gs_curgroup].last_y = y;
  853.  
  854. return var;
  855. end
  856.  
  857.  
  858. ---------
  859.  
  860. -----
  861.  
  862. local function gs_button( title, w, h )
  863. local wnd, group = gs_newelement();
  864.  
  865. local textw, texth = draw.GetTextSize( title );
  866. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset;
  867.  
  868. -- Backend
  869. local var = false;
  870.  
  871. if input.IsButtonDown( 1 ) and gs_inbounds( gs_mx, gs_my, x, y, x + w, y + h ) and not gs_isBlocked then
  872. var = true;
  873. end
  874.  
  875. -- Draw
  876. render.outline( x, y, w, h, { 5, 5, 5, wnd.alpha } );
  877. render.outline( x + 1, y + 1, w - 2, h - 2, { 65, 65, 65, wnd.alpha } );
  878.  
  879. local r, g, b = 181, 181, 181;
  880.  
  881. if var then
  882. r, g, b = 255, 255, 255;
  883. render.gradient( x + 2, y + 2, w - 4, h - 5, { 45, 45, 45, wnd.alpha }, { 55, 55, 55, wnd.alpha }, true );
  884. else
  885. render.gradient( x + 2, y + 2, w - 4, h - 5, { 55, 55, 55, wnd.alpha }, { 45, 45, 45, wnd.alpha }, true );
  886. end
  887.  
  888. render.text( x + (w / 2 - textw / 2), y + (h / 2 - texth / 2), title, { r, g, b, wnd.alpha }, gs_fonts.verdana_12b );
  889.  
  890. wnd.groups[gs_curgroup].is_nextline = true;
  891. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + h + 5;
  892.  
  893. if group.highest_w < w then
  894. wnd.groups[gs_curgroup].highest_w = w;
  895. end
  896.  
  897. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  898. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  899. end
  900.  
  901. wnd.groups[gs_curgroup].last_y = y;
  902.  
  903. return var;
  904. end
  905.  
  906. local function gs_slider( title, min, max, fmt, min_text, max_text, show_buttons, var )
  907. local wnd, group = gs_newelement();
  908.  
  909. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset - 3;
  910. local textw, texth = 0, 0;
  911.  
  912. gs_mx, gs_my = input.GetMousePos();
  913.  
  914. if title ~= nil then
  915. textw, texth = draw.GetTextSize( title );
  916. texth = texth + 2;
  917. end
  918.  
  919. -- Backend
  920. local m = 0;
  921.  
  922. if min ~= 0 then
  923. m = min;
  924.  
  925. var = var - m;
  926. min = min - m;
  927. max = max - m;
  928. end
  929.  
  930. if not gs_isBlocked then
  931. if input.IsButtonDown( 1 ) and gs_inbounds( gs_mx, gs_my, x, y + texth, x + 155, y + texth + 8 ) then
  932. local relative_x = gs_clamp( gs_mx - x, 0, 153 );
  933. local ratio = relative_x / 153;
  934.  
  935. var = math.floor( min + ((max - min) * ratio) );
  936. end
  937.  
  938. -- Handle -/+ buttons
  939. if input.IsButtonPressed( 1 ) and gs_inbounds( gs_mx, gs_my, x - 5, y + texth + 1, x - 2, y + texth + 4 ) and show_buttons then
  940. var = var - 1;
  941. end
  942.  
  943. if input.IsButtonPressed( 1 ) and gs_inbounds( gs_mx, gs_my, x + 155 + 2, y + texth + 1, x + 155 + 5, y + texth + 4 ) and show_buttons then
  944. var = var + 1;
  945. end
  946. end
  947.  
  948. -- Clamp final value
  949. var = math.ceil( gs_clamp( var, min, max ) );
  950.  
  951. local w = 153 / max * var;
  952.  
  953. var = var + m;
  954. min = min + m;
  955. max = max + m;
  956.  
  957. -- Draw
  958. if title ~= nil then
  959. render.text( x, y - 1, title, { 181, 181, 181, wnd.alpha } );
  960. end
  961.  
  962. local r12, g12, b12 = 149, 184, 6;
  963.  
  964.  
  965. local r11, g11, b11 = 80, 99, 3;
  966.  
  967.  
  968. render.outline( x, y + texth + 3, 155, 7, { 5, 5, 5, wnd.alpha } );
  969. render.gradient( x + 1, y + texth + 4, 153, 4, { 45, 45, 45, wnd.alpha }, { 65, 65, 65, wnd.alpha }, true );
  970. render.gradient( x + 1, y + texth + 4, w, 4, { r12, g12, b12, wnd.alpha }, { r11, g11, b11, wnd.alpha }, true );
  971.  
  972. if show_buttons then
  973. if var ~= min then
  974. render.rect( x - 5, y + texth + 3, 3, 1, { 181, 181, 181, wnd.alpha } );
  975. end
  976.  
  977. if var ~= max then
  978. render.rect( x + 155 + 2, y + texth + 3, 3, 1, { 181, 181, 181, wnd.alpha } );
  979. render.rect( x + 155 + 3, y + texth + 2, 1, 3, { 181, 181, 181, wnd.alpha } );
  980. end
  981. end
  982.  
  983. local vard = var;
  984.  
  985. if fmt ~= nil then
  986. vard = vard .. fmt;
  987. end
  988.  
  989. if min_text ~= nil and var == min then
  990. vard = min_text;
  991. end
  992.  
  993. if max_text ~= nil and var == max then
  994. vard = max_text;
  995. end
  996.  
  997. draw.SetFont( gs_fonts.verdana_12b );
  998. local varw, varh = draw.GetTextSize( vard );
  999.  
  1000. render.text( x + w - varw / 2 + 10, y + texth + varh / 6, vard, { 181, 181, 181, wnd.alpha }, gs_fonts.verdana_12b );
  1001. draw.Color(181, 181, 181, wnd.alpha)
  1002. draw.TextShadow( x + w - varw / 2 + 10, y + texth + varh / 6, vard)
  1003. wnd.groups[gs_curgroup].is_nextline = true;
  1004. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + texth + 14;
  1005.  
  1006. if group.highest_w < 155 then
  1007. wnd.groups[gs_curgroup].highest_w = 155;
  1008. end
  1009.  
  1010. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1011. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1012. end
  1013.  
  1014. wnd.groups[gs_curgroup].last_y = y;
  1015.  
  1016. return var;
  1017. end
  1018. --
  1019.  
  1020. --
  1021. local function gs_label( text, is_alt )
  1022. local wnd, group = gs_newelement();
  1023.  
  1024. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset - 3;
  1025. local textw, texth = draw.GetTextSize( text );
  1026. local r, g, b = 181, 181, 181;
  1027.  
  1028. if is_alt then
  1029. r, g, b = 190, 190, 120;
  1030. end
  1031.  
  1032. render.text( x, y, text, { r, g, b, wnd.alpha } );
  1033.  
  1034. wnd.groups[gs_curgroup].is_nextline = true;
  1035. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + 17;
  1036.  
  1037. if group.highest_w < textw then
  1038. wnd.groups[gs_curgroup].highest_w = textw;
  1039. end
  1040.  
  1041. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1042. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1043. end
  1044.  
  1045. wnd.groups[gs_curgroup].last_y = y;
  1046. end
  1047.  
  1048. local gs_curbind = {
  1049. id = "",
  1050. is_selecting = false
  1051. };
  1052.  
  1053. local gs_keytable = {
  1054. esc = { 27, "[ESC]" }, f1 = { 112, "[F1]" }, f2 = { 113, "[F2]" }, f3 = { 114, "[F3]" }, f4 = { 115, "[F4]" }, f5 = { 116, "[F5]" },
  1055. f6 = { 117, "[F6]" }, f7 = { 118, "[F7]" }, f8 = { 119, "[F8]" }, f9 = { 120, "[F9]" }, f10 = { 121, "[F10]" }, f11 = { 122, "[F11]" },
  1056. f12 = { 123, "[F12]" }, tilde = { 192, "[~]" }, one = { 49, "[1]" }, two = { 50, "[2]" }, three = { 51, "[3]" }, four = { 52, "[4]" },
  1057. five = { 53, "[5]" }, six = { 54, "[6]" }, seven = { 55, "[7]" }, eight = { 56, "[8]" }, nine = { 57, "[9]" }, zero = { 48, "[0]" },
  1058. minus = { 189, "[_]" }, equals = { 187, "[=]" }, backslash = { 220, "[\\]" }, backspace = { 8, "[BKSP]" },
  1059. tab = { 9, "[TAB]" }, q = { 81, "[Q]" }, w = { 87, "[W]" }, e = { 69, "[E]" }, r = { 82, "[R]" }, t = { 84, "[T]" }, y = { 89, "[Y]" }, u = { 85, "[U]" },
  1060. i = { 73, "[I]" }, o = { 79, "[O]" }, p = { 80, "[P]" }, bracket_o = { 219, "[[]" }, bracket_c = { 221, "[]]" },
  1061. a = { 65, "[A]" }, s = { 83, "[S]" }, d = { 68, "[D]" }, f = { 70, "[F]" }, g = { 71, "[G]" }, h = { 72, "[H]" }, j = { 74, "[J]" }, k = { 75, "[K]" },
  1062. l = { 76, "[L]" }, semicolon = { 186, "[;]" }, quotes = { 222, "[']" }, caps = { 20, "[CAPS]" }, enter = { 13, "[RETN]" },
  1063. shift = { 16, "[SHI]" }, z = { 90, "[Z]" }, x = { 88, "[X]" }, c = { 67, "[C]" }, v = { 86, "[V]" }, b = { 66, "[B]" }, n = { 78, "[N]" },
  1064. m = { 77, "[M]" }, comma = { 188, "[,]" }, dot = { 190, "[.]" }, slash = { 191, "[/]" }, ctrl = { 17, "[CTRL]" },
  1065. win = { 91, "[WIN]" }, alt = { 18, "[ALT]" }, space = { 32, "[SPC]" }, scroll = { 145, "[SCRL]" }, pause = { 19, "[PAUS]" },
  1066. insert = { 45, "[INS]" }, home = { 36, "[HOME]" }, pageup = { 33, "[PGUP]" }, pagedn = { 34, "[PGDN]" }, delete = { 46, "[DEL]" },
  1067. end_key = { 35, "[END]" }, uparrow = { 38, "[UP]" }, leftarrow = { 37, "[LEFT]" }, downarrow = { 40, "[DOWN]" },
  1068. rightarrow = { 39, "[RGHT]" }, num = { 144, "[NUM]" }, num_slash = { 111, "[/]" }, num_mult = { 106, "[*]" },
  1069. num_sub = { 109, "[-]" }, num_7 = { 103, "[7]" }, num_8 = { 104, "[8]" }, num_9 = { 105, "[9]" }, num_plus = { 107, "[+]" },
  1070. num_4 = { 100, "[4]" }, num_5 = { 101, "[5]" }, num_6 = { 102, "[6]" }, num_1 = { 97, "[1]" }, num_2 = { 98, "[2]" },
  1071. num_3 = { 99, "[3]" }, num_enter = { 13, "[ENT]" }, num_0 = { 96, "[0]" }, num_dot = { 110, "[.]" }, mouse_1 = { 1, "[M1]" }, mouse_2 = { 2, "[M2]" }, mouse_6 = { 6, "[M5]" } , mouse_4 = { 4, "[M3]" }, mouse_5 = { 5, "[M4]" }
  1072. };
  1073.  
  1074. local function gs_key2name( key )
  1075. local ktxt = "[-]";
  1076.  
  1077. for k, v in pairs( gs_keytable ) do
  1078. if v[1] == key then
  1079. ktxt = v[2];
  1080. end
  1081. end
  1082.  
  1083. return ktxt;
  1084. end
  1085.  
  1086. local function gs_bind( id, detect_editable, var, key_held, detect_type )
  1087. local wnd, group = gs_newelement();
  1088.  
  1089. local x, y = wnd.x + group.x + group.w - 10, group.last_y;
  1090. local r, g, b = 96, 96, 96;
  1091.  
  1092. if gs_curbind.id == id then
  1093. if gs_curbind.is_selecting then
  1094. r, g, b = 255, 100, 0;
  1095. end
  1096. end
  1097.  
  1098. local did_select = false;
  1099.  
  1100. -- Backend
  1101. if gs_curbind.id == id and gs_curbind.is_selecting and not gs_isBlocked then
  1102. for k, v in pairs( ui.Keys ) do
  1103. if input.IsButtonPressed( v ) and v ~= ui.Keys.esc then
  1104. var = v;
  1105. gs_curbind.is_selecting = false;
  1106.  
  1107. did_select = true;
  1108. break;
  1109. else
  1110. if input.IsButtonPressed( v ) and v == ui.Keys.esc then
  1111. var = nil;
  1112. gs_curbind.is_selecting = false;
  1113.  
  1114. did_select = true;
  1115. break;
  1116. end
  1117. end
  1118. end
  1119.  
  1120. if not did_select then
  1121. gs_curbind.is_selecting = true;
  1122. end
  1123. end
  1124.  
  1125. local text = gs_key2name( var );
  1126.  
  1127. draw.SetFont( gs_fonts.verdana_10 );
  1128. local textw, texth = draw.GetTextSize( text );
  1129.  
  1130. x = x - textw;
  1131.  
  1132. gs_mx, gs_my = input.GetMousePos();
  1133.  
  1134. if input.IsButtonPressed( 1 ) then
  1135. if gs_inbounds( gs_mx, gs_my, x, y, x + textw, y + texth ) then
  1136. gs_curbind.id = id;
  1137. gs_curbind.is_selecting = true;
  1138. end
  1139. end
  1140.  
  1141. if input.IsButtonPressed( 2 ) and detect_editable and not gs_isBlocked then
  1142. if not gs_curbind.is_selecting then
  1143. if gs_inbounds( gs_mx, gs_my, x, y, x + textw, y + texth ) then
  1144. gs_curchild.minimal_width = 0;
  1145. gs_curchild.id = id .. "_child";
  1146. gs_curchild.x = x;
  1147. gs_curchild.multiselect = false;
  1148. gs_curchild.y = y + texth + 2;
  1149. gs_curchild.elements = { "Always on", "On hotkey", "Toggle", "Off hotkey" };
  1150. gs_curchild.selected = { detect_type };
  1151. gs_isBlocked = true;
  1152. end
  1153. end
  1154. end
  1155.  
  1156. if gs_curchild.last_id == id .. "_child" then
  1157. detect_type = gs_curchild.selected[1];
  1158. end
  1159.  
  1160. local held_done = false;
  1161.  
  1162. if detect_type == 3 or detect_type == 1 then
  1163. held_done = true;
  1164. end
  1165.  
  1166. if var ~= nil and var ~= 0 then
  1167. if detect_type == 2 and input.IsButtonDown( var ) then
  1168. held_done = true;
  1169. key_held = true;
  1170. end
  1171.  
  1172. if detect_type == 4 and input.IsButtonDown( var ) then
  1173. held_done = true;
  1174. key_held = false;
  1175. end
  1176.  
  1177. if detect_type == 3 and input.IsButtonPressed( var ) then
  1178. key_held = not key_held;
  1179. end
  1180.  
  1181. if detect_type == 1 then
  1182. key_held = true;
  1183. end
  1184.  
  1185. if not held_done then
  1186. if detect_type ~= 4 then
  1187. key_held = false;
  1188. else
  1189. key_held = true;
  1190. end
  1191. end
  1192. end
  1193.  
  1194. -- Draw
  1195. render.text( x, y, text, { r, g, b, wnd.alpha }, gs_fonts.verdana_10 );
  1196.  
  1197. return var, key_held, detect_type;
  1198. end
  1199.  
  1200. function gs_drawtabbar( )
  1201. local wnd = gs_newelement();
  1202. local tab = nil;
  1203.  
  1204. for k, v in pairs( wnd.tabs ) do
  1205. if v.selected then
  1206. tab = v;
  1207. end
  1208. end
  1209.  
  1210. if tab ~= nil then
  1211. local tabNumeric = 0;
  1212.  
  1213. for k, v in pairs( wnd.tabs ) do
  1214. if v.id == tab.id then
  1215. tabNumeric = v.numID;
  1216. end
  1217. end
  1218.  
  1219. render.rect( wnd.x, wnd.y, 79, 24 + tabNumeric * 80, { 12, 12, 12, wnd.alpha } );
  1220. render.rect( wnd.x, wnd.y + 24 + (tabNumeric + 1) * 80, 79, wnd.h - (24 + (tabNumeric + 1) * 80), { 12, 12, 12, wnd.alpha } );
  1221.  
  1222. render.rect( wnd.x + 80, wnd.y, 1, 25 + tabNumeric * 80, { 75, 75, 75, wnd.alpha } );
  1223. render.rect( wnd.x, wnd.y + 25 + tabNumeric * 80, 81, 1, { 75, 75, 75, wnd.alpha } );
  1224. render.rect( wnd.x, wnd.y + 25 + (tabNumeric + 1) * 80, 80, 1, { 75, 75, 75, wnd.alpha } );
  1225. render.rect( wnd.x + 80, wnd.y + 25 + (tabNumeric + 1) * 80, 1, wnd.h - (25 + (tabNumeric + 1) * 80), { 75, 75, 75, wnd.alpha } );
  1226. end
  1227. end
  1228.  
  1229. function gs_begintab( id, icon )
  1230. local wnd = gs_newelement();
  1231.  
  1232. if wnd.tabs[id] == nil then
  1233. local gs_tab = {
  1234. id = "",
  1235. icon = "",
  1236. numID = 0,
  1237.  
  1238. selected = false,
  1239.  
  1240. groups = {}
  1241. };
  1242.  
  1243. gs_tab.id = id;
  1244. gs_tab.icon = icon;
  1245. gs_tab.numID = gs_tablecount( wnd.tabs );
  1246.  
  1247. wnd.tabs[id] = gs_tab;
  1248. end
  1249.  
  1250. gs_curtab = id;
  1251.  
  1252. local tab = wnd.tabs[gs_curtab];
  1253.  
  1254. -- Backend
  1255.  
  1256. local r, g, b = 90, 90, 90;
  1257. if tab.selected then
  1258. r, g, b = 210, 210, 210;
  1259. end
  1260.  
  1261. local tabNumeric = 0;
  1262.  
  1263. for k, v in pairs( wnd.tabs ) do
  1264. if v.id == id then
  1265. tabNumeric = v.numID;
  1266. end
  1267. end
  1268.  
  1269. gs_mx, gs_my = input.GetMousePos();
  1270. if gs_inbounds( gs_mx, gs_my, wnd.x, wnd.y + (25 + tabNumeric * 80), wnd.x + 80, wnd.y + (25 + tabNumeric * 80) + 80 ) and not gs_isBlocked then
  1271. r, g, b = 210, 210, 210;
  1272.  
  1273. if input.IsButtonPressed( 1 ) then
  1274. for k, v in pairs( wnd.tabs ) do
  1275. wnd.tabs[k].selected = false;
  1276.  
  1277. if v.id == id then
  1278. wnd.tabs[k].selected = true;
  1279. end
  1280. end
  1281. end
  1282. end
  1283.  
  1284. -- Draw
  1285.  
  1286. draw.SetFont( gs_fonts.astriumtabs );
  1287. local textw, texth = draw.GetTextSize( tab.icon[1] );
  1288.  
  1289. render.text( wnd.x + (40 - textw / 2), wnd.y + (25 + tabNumeric * 80) + (40 - texth / 2) - tab.icon[2], tab.icon[1], { r, g, b, wnd.alpha }, gs_fonts.astriumtabs );
  1290.  
  1291. return tab.selected;
  1292. end
  1293.  
  1294. local function gs_endtab( )
  1295. local wnd = gs_newelement();
  1296. local smthselected = false;
  1297.  
  1298. for k, v in pairs( wnd.tabs ) do
  1299. if v.selected then
  1300. smthselected = true;
  1301. break;
  1302. end
  1303. end
  1304.  
  1305. if not smthselected then
  1306. wnd.tabs[gs_curtab].selected = true;
  1307. end
  1308.  
  1309. gs_curtab = "";
  1310. end
  1311.  
  1312. local function gs_combo( title, elements, var )
  1313. local wnd, group = gs_newelement();
  1314. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset - 3;
  1315. local bg_col = { 26, 26, 26, wnd.alpha };
  1316. local textw, texth = 0, 0;
  1317.  
  1318. if title ~= nil then
  1319. draw.GetTextSize( title );
  1320. end
  1321.  
  1322. local is_up = false;
  1323.  
  1324. local ltitle = elements[1] .. var;
  1325.  
  1326. if title ~= nil then
  1327. ltitle = title;
  1328. end
  1329.  
  1330. -- Backend
  1331. gs_mx, gs_my = input.GetMousePos();
  1332. if gs_inbounds( gs_mx, gs_my, x, y + texth + 2, x + 155, y + texth + 22 ) and not gs_isBlocked then
  1333. bg_col = { 36, 36, 36, wnd.alpha };
  1334.  
  1335. if input.IsButtonPressed( 1 ) then
  1336. gs_curchild.id = ltitle .. "_child";
  1337. gs_curchild.x = x;
  1338. gs_curchild.y = y + texth + 22;
  1339. gs_curchild.minimal_width = 135;
  1340. gs_curchild.multiselect = false;
  1341. gs_curchild.elements = elements;
  1342. gs_curchild.selected = { var };
  1343. gs_isBlocked = true;
  1344. end
  1345. end
  1346.  
  1347. if gs_curchild.id == ltitle .. "_child" then
  1348. is_up = true;
  1349. end
  1350.  
  1351. if gs_curchild.last_id == ltitle .. "_child" then
  1352. var = gs_curchild.selected[1];
  1353. gs_curchild.last_id = "";
  1354. end
  1355.  
  1356. -- Drawing
  1357. if title ~= nil then
  1358. --render.text( x, y-15, title, { 181, 181, 181, wnd.alpha } );
  1359. end
  1360.  
  1361. render.gradient( x, y + texth + 2, 155, 19, bg_col, { 36, 36, 36, wnd.alpha }, true );
  1362. render.outline( x, y + texth + 2, 155, 20, { 5, 5, 5, wnd.alpha } );
  1363.  
  1364. render.text( x + 10, y + 6 + texth , elements[var], { 181, 181, 181, wnd.alpha } );
  1365.  
  1366. if not is_up then
  1367. render.rect( x + 150 - 9, y + texth + 11, 5, 1, { 181, 181, 181, wnd.alpha } );
  1368. render.rect( x + 150 - 8, y + texth + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1369. render.rect( x + 150 - 7, y + texth + 13, 1, 1, { 181, 181, 181, wnd.alpha } );
  1370. else
  1371. render.rect( x + 150 - 7, y + texth + 11, 1, 1, { 181, 181, 181, wnd.alpha } );
  1372. render.rect( x + 150 - 8, y + texth + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1373. render.rect( x + 150 - 9, y + texth + 13, 5, 1, { 181, 181, 181, wnd.alpha } );
  1374. end
  1375.  
  1376. wnd.groups[gs_curgroup].is_nextline = true;
  1377. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + texth + 27;
  1378.  
  1379. if group.highest_w < 155 then
  1380. wnd.groups[gs_curgroup].highest_w = 155;
  1381. end
  1382.  
  1383. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1384. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1385. end
  1386.  
  1387. wnd.groups[gs_curgroup].last_y = y;
  1388.  
  1389. return var;
  1390. end
  1391.  
  1392. local function gs_multicombo( title, elements, var )
  1393. local wnd, group = gs_newelement();
  1394. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset - 3;
  1395. local bg_col = { 26, 26, 26, wnd.alpha };
  1396. local textw, texth = draw.GetTextSize( title );
  1397. local is_up = false;
  1398.  
  1399. -- Backend
  1400. gs_mx, gs_my = input.GetMousePos();
  1401. if gs_inbounds( gs_mx, gs_my, x, y + texth + 2, x + 155, y + texth + 22 ) and not gs_isBlocked then
  1402. bg_col = { 36, 36, 36, wnd.alpha };
  1403.  
  1404. if input.IsButtonPressed( 1 ) then
  1405. gs_curchild.id = title .. "_child";
  1406. gs_curchild.x = x;
  1407. gs_curchild.y = y + texth + 22;
  1408. gs_curchild.minimal_width = 135;
  1409. gs_curchild.multiselect = true;
  1410. gs_curchild.elements = elements;
  1411. gs_curchild.selected = var;
  1412. gs_isBlocked = true;
  1413. end
  1414. end
  1415.  
  1416. if gs_curchild.id == title .. "_child" then
  1417. is_up = true;
  1418. end
  1419.  
  1420. if gs_curchild.last_id == title .. "_child" then
  1421. var = gs_curchild.selected;
  1422. gs_curchild.last_id = "";
  1423. end
  1424.  
  1425. -- Drawing
  1426. render.text( x, y, title, { 181, 181, 181, wnd.alpha } );
  1427.  
  1428. render.gradient( x, y + texth + 2, 155, 19, bg_col, { 36, 36, 36, wnd.alpha }, true );
  1429. render.outline( x, y + texth + 2, 155, 20, { 5, 5, 5, wnd.alpha } );
  1430.  
  1431. local fmt = "";
  1432. for i = 1, #elements do
  1433. local f_len = #fmt < 16;
  1434. local f_frst = #fmt <= 0;
  1435.  
  1436. if var[elements[i]] and f_len then
  1437. if not f_frst then
  1438. fmt = fmt .. ", ";
  1439. end
  1440.  
  1441. fmt = fmt .. elements[i];
  1442. else
  1443. if not f_len then
  1444. local selected = 0;
  1445.  
  1446. for k = 1, #elements do
  1447. if var[elements[k]] then
  1448. selected = selected + 1;
  1449. end
  1450. end
  1451.  
  1452. fmt = selected .. " selected";
  1453. break;
  1454. end
  1455. end
  1456. end
  1457.  
  1458. if fmt == "" then
  1459. fmt = "-";
  1460. end
  1461.  
  1462. render.text( x + 10, y + 6 + texth , fmt, { 181, 181, 181, wnd.alpha } );
  1463.  
  1464. if not is_up then
  1465. render.rect( x + 150 - 9, y + texth + 11, 5, 1, { 181, 181, 181, wnd.alpha } );
  1466. render.rect( x + 150 - 8, y + texth + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1467. render.rect( x + 150 - 7, y + texth + 13, 1, 1, { 181, 181, 181, wnd.alpha } );
  1468. else
  1469. render.rect( x + 150 - 7, y + texth + 11, 1, 1, { 181, 181, 181, wnd.alpha } );
  1470. render.rect( x + 150 - 8, y + texth + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1471. render.rect( x + 150 - 9, y + texth + 13, 5, 1, { 181, 181, 181, wnd.alpha } );
  1472. end
  1473.  
  1474. wnd.groups[gs_curgroup].is_nextline = true;
  1475. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + texth + 27;
  1476.  
  1477. if group.highest_w < 155 then
  1478. wnd.groups[gs_curgroup].highest_w = 155;
  1479. end
  1480.  
  1481. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1482. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1483. end
  1484.  
  1485. wnd.groups[gs_curgroup].last_y = y;
  1486.  
  1487. return var;
  1488. end
  1489.  
  1490. -- it's like
  1491. -- [ normal, with shift ]
  1492. local gs_textTable = {
  1493. [ui.Keys.tilde] = { "`", "~" },
  1494. [ui.Keys.one] = { "1", "!" },
  1495. [ui.Keys.two] = { "2", "@" },
  1496. [ui.Keys.three] = { "3", "#" },
  1497. [ui.Keys.four] = { "4", "$" },
  1498. [ui.Keys.five] = { "5", "%" },
  1499. [ui.Keys.six] = { "6", "^" },
  1500. [ui.Keys.seven] = { "7", "&" },
  1501. [ui.Keys.eight] = { "8", "*" },
  1502. [ui.Keys.nine] = { "9", "(" },
  1503. [ui.Keys.zero] = { "0", ")" },
  1504. [ui.Keys.minus] = { "-", "_" },
  1505. [ui.Keys.equals] = { "=", "+" },
  1506. [ui.Keys.backslash] = { "\\", "|" },
  1507. [ui.Keys.q] = { "q", "Q" },
  1508. [ui.Keys.w] = { "w", "W" },
  1509. [ui.Keys.e] = { "e", "E" },
  1510. [ui.Keys.r] = { "r", "R" },
  1511. [ui.Keys.t] = { "t", "T" },
  1512. [ui.Keys.y] = { "y", "Y" },
  1513. [ui.Keys.u] = { "u", "U" },
  1514. [ui.Keys.i] = { "i", "I" },
  1515. [ui.Keys.o] = { "o", "O" },
  1516. [ui.Keys.p] = { "p", "P" },
  1517. [ui.Keys.bracket_o] = { "[", "{" },
  1518. [ui.Keys.bracket_c] = { "]", "}" },
  1519. [ui.Keys.a] = { "a", "A" },
  1520. [ui.Keys.s] = { "s", "S" },
  1521. [ui.Keys.d] = { "d", "D" },
  1522. [ui.Keys.f] = { "f", "F" },
  1523. [ui.Keys.g] = { "g", "G" },
  1524. [ui.Keys.h] = { "h", "H" },
  1525. [ui.Keys.j] = { "j", "J" },
  1526. [ui.Keys.k] = { "k", "K" },
  1527. [ui.Keys.l] = { "l", "L" },
  1528. [ui.Keys.semicolon] = { ";", ":" },
  1529. [ui.Keys.quotes] = { "'", "\"" },
  1530. [ui.Keys.z] = { "z", "Z" },
  1531. [ui.Keys.x] = { "x", "X" },
  1532. [ui.Keys.c] = { "c", "C" },
  1533. [ui.Keys.v] = { "v", "V" },
  1534. [ui.Keys.b] = { "b", "B" },
  1535. [ui.Keys.n] = { "n", "N" },
  1536. [ui.Keys.m] = { "m", "M" },
  1537. [ui.Keys.comma] = { ",", "<" },
  1538. [ui.Keys.dot] = { ".", ">" },
  1539. [ui.Keys.slash] = { "/", "?" },
  1540. [ui.Keys.space] = { " ", " " }
  1541. };
  1542.  
  1543. local function gs_listbox( elements, maxElements, showSearch, var, searchVar, scrollVar )
  1544. local wnd, group = gs_newelement();
  1545. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset - 3;
  1546.  
  1547. if showSearch then
  1548. render.outline( x, y, 155, 20, { 5, 5, 5, wnd.alpha } );
  1549. render.outline( x + 1, y + 1, 153, 18, { 28, 28, 28, wnd.alpha } );
  1550. render.rect( x + 2, y + 2, 151, 16, { 36, 36, 36, wnd.alpha } );
  1551.  
  1552. gs_mx, gs_my = input.GetMousePos();
  1553. if input.IsButtonDown( 1 ) then
  1554. if gs_inbounds( gs_mx, gs_my, x, y, x + 155, y + 20 ) then
  1555. gs_curinput = elements[1] .. maxElements .. var .. elements[#elements];
  1556. gs_isBlocked = true;
  1557. elseif not gs_inbounds( gs_mx, gs_my, x, y, x + 155, y + 20 ) and gs_curinput == elements[1] .. maxElements .. var .. elements[#elements] then
  1558. gs_curinput = "";
  1559. gs_isBlocked = false;
  1560. end
  1561. end
  1562.  
  1563. if gs_curinput == elements[1] .. maxElements .. var .. elements[#elements] then
  1564. if input.IsButtonPressed( ui.Keys.esc ) then
  1565. gs_curinput = "";
  1566. gs_isBlocked = false;
  1567. end
  1568.  
  1569. if input.IsButtonPressed( ui.Keys.backspace ) then
  1570. searchVar = searchVar:sub( 1, -2 );
  1571. end
  1572.  
  1573. for k, v in pairs( gs_textTable ) do
  1574. if input.IsButtonPressed( k ) then
  1575. if input.IsButtonDown( ui.Keys.shift ) then
  1576. if draw.GetTextSize( searchVar .. v[2] ) <= 135 then
  1577. searchVar = searchVar .. v[2];
  1578. end
  1579. else
  1580. if draw.GetTextSize( searchVar .. v[1] ) <= 135 then
  1581. searchVar = searchVar .. v[1];
  1582. end
  1583. end
  1584. end
  1585. end
  1586. end
  1587.  
  1588. if gs_curinput == elements[1] .. maxElements .. var .. elements[#elements] then
  1589. render.text( x + 8, y + 4, searchVar .. "_", { 181, 181, 181, wnd.alpha } );
  1590. else
  1591. render.text( x + 8, y + 4, searchVar, { 181, 181, 181, wnd.alpha } );
  1592. end
  1593.  
  1594. -- Do search thingy
  1595. if searchVar ~= "" then
  1596. local newElements = {};
  1597.  
  1598. for i = 1, #elements do
  1599. if elements[i]:sub( 1, #searchVar ) == searchVar then
  1600. newElements[#newElements + 1] = elements[i];
  1601. end
  1602. end
  1603.  
  1604. elements = newElements;
  1605. end
  1606.  
  1607. y = y + 20;
  1608. end
  1609.  
  1610. -- Prevent bugs here
  1611. if ( #elements - maxElements ) * 20 >= maxElements * 20 then
  1612. while ( #elements - maxElements ) * 20 >= maxElements * 20 do
  1613. maxElements = maxElements + 1;
  1614. end
  1615. end
  1616.  
  1617. local h = maxElements * 20;
  1618.  
  1619. render.outline( x, y, 155, h + 2, { 5, 5, 5, wnd.alpha } );
  1620. render.rect( x + 1, y + 1, 153, h, { 36, 36, 36, wnd.alpha } );
  1621.  
  1622. local bottomElements = 0;
  1623. local topElements = 0;
  1624. local shouldDrawScroll = false;
  1625.  
  1626. for i = 1, #elements do
  1627. local r, g, b = 181, 181, 181;
  1628. local font = gs_fonts.verdana_12;
  1629.  
  1630. local elementY = ( y + i * 20 - 19 ) - scrollVar * 20;
  1631. local shouldDraw = true;
  1632.  
  1633. if elementY > y + h then
  1634. shouldDraw = false;
  1635. bottomElements = bottomElements + 1;
  1636. shouldDrawScroll = true;
  1637. elseif elementY < y then
  1638. shouldDraw = false;
  1639. topElements = topElements + 1;
  1640. shouldDrawScroll = true;
  1641. end
  1642.  
  1643. if shouldDraw then
  1644. gs_mx, gs_my = input.GetMousePos();
  1645. if gs_inbounds( gs_mx, gs_my, x + 1, elementY, x + 149, elementY + 20 ) and not gs_isBlocked then
  1646. font = gs_fonts.verdana_12b;
  1647. render.rect( x + 1, elementY, 153, 20, { 28, 28, 28, wnd.alpha } );
  1648.  
  1649. if input.IsButtonPressed( 1 ) then
  1650. var = i;
  1651. end
  1652. end
  1653.  
  1654. if var == i then
  1655.  
  1656. font = gs_fonts.verdana_12b;
  1657.  
  1658. render.rect( x + 1, elementY, 153, 20, { 28, 28, 28, wnd.alpha } );
  1659. end
  1660.  
  1661. render.text( x + 10, elementY + 3, elements[i], { r, g, b, wnd.alpha }, font );
  1662. end
  1663. end
  1664.  
  1665. if shouldDrawScroll then
  1666. render.rect( x + 149, y + 1, 5, h, { 32, 32, 32, wnd.alpha } );
  1667.  
  1668. local c = 38;
  1669. local scrY = y + scrollVar + scrollVar * 20 + 1;
  1670. local scrH = ( h - ( ( #elements - maxElements ) * 20 ) ) - scrollVar;
  1671.  
  1672. gs_mx, gs_my = input.GetMousePos();
  1673. if gs_inbounds( gs_mx, gs_my, x + 149, scrY, x + 154, scrY + scrH ) and not gs_isBlocked then
  1674. c = 46;
  1675.  
  1676. if input.IsButtonDown( 1 ) then
  1677. c = 28;
  1678. end
  1679. end
  1680.  
  1681. if gs_inbounds( gs_mx, gs_my, x + 149, y, x + 154, y + h ) and input.IsButtonDown( 1 ) and not gs_isBlocked then
  1682. local relative_y = gs_clamp( gs_my - y, 0, h );
  1683. local ratio = relative_y / h + ( relative_y / h ) / 2;
  1684.  
  1685. scrollVar = gs_clamp( math.floor( ( #elements - maxElements ) * ratio ), 0, #elements - maxElements );
  1686. end
  1687.  
  1688. render.outline( x + 149, scrY, 5, scrH, { c, c, c, wnd.alpha } );
  1689. render.rect( x + 150, scrY + 1, 3, scrH - 1, { c + 8, c + 8, c + 8, wnd.alpha } );
  1690.  
  1691. if bottomElements ~= 0 then
  1692. render.rect( x + 150 - 9, y + h - 18 + 11, 5, 1, { 181, 181, 181, wnd.alpha } );
  1693. render.rect( x + 150 - 8, y + h - 18 + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1694. render.rect( x + 150 - 7, y + h - 18 + 13, 1, 1, { 181, 181, 181, wnd.alpha } );
  1695. end
  1696.  
  1697. if topElements ~= 0 then
  1698. render.rect( x + 150 - 7, y - 5 + 11, 1, 1, { 181, 181, 181, wnd.alpha } );
  1699. render.rect( x + 150 - 8, y - 5 + 12, 3, 1, { 181, 181, 181, wnd.alpha } );
  1700. render.rect( x + 150 - 9, y - 5 + 13, 5, 1, { 181, 181, 181, wnd.alpha } );
  1701. end
  1702. end
  1703.  
  1704. wnd.groups[gs_curgroup].is_nextline = true;
  1705. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + h + 5;
  1706.  
  1707. if showSearch then
  1708. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + 20;
  1709. end
  1710.  
  1711. if group.highest_w < 155 then
  1712. wnd.groups[gs_curgroup].highest_w = 155;
  1713. end
  1714.  
  1715. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1716. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1717. end
  1718.  
  1719. wnd.groups[gs_curgroup].last_y = y;
  1720.  
  1721. if showSearch then
  1722. wnd.groups[gs_curgroup].last_y = wnd.groups[gs_curgroup].last_y - 20;
  1723. end
  1724.  
  1725. return var, scrollVar, searchVar;
  1726. end
  1727.  
  1728. local function gs_textbox( id, title, var )
  1729. local wnd, group = gs_newelement();
  1730. local x, y = wnd.x + group.x + 25, wnd.y + group.y + group.nextline_offset;
  1731.  
  1732. if title ~= nil then
  1733. render.text( x, y, title, { 181, 181, 181, wnd.alpha } );
  1734.  
  1735. y = y + 13;
  1736. end
  1737.  
  1738. render.outline( x, y, 155, 20, { 5, 5, 5, wnd.alpha } );
  1739. render.outline( x + 1, y + 1, 153, 18, { 28, 28, 28, wnd.alpha } );
  1740. render.rect( x + 2, y + 2, 151, 16, { 36, 36, 36, wnd.alpha } );
  1741.  
  1742. gs_mx, gs_my = input.GetMousePos();
  1743. if input.IsButtonDown( 1 ) then
  1744. if gs_inbounds( gs_mx, gs_my, x, y, x + 155, y + 20 ) then
  1745. gs_curinput = id;
  1746. gs_isBlocked = true;
  1747. elseif not gs_inbounds( gs_mx, gs_my, x, y, x + 155, y + 20 ) and gs_curinput == id then
  1748. gs_curinput = "";
  1749. gs_isBlocked = false;
  1750. end
  1751. end
  1752.  
  1753. if gs_curinput == id then
  1754. if input.IsButtonPressed( ui.Keys.esc ) then
  1755. gs_curinput = "";
  1756. gs_isBlocked = false;
  1757. end
  1758.  
  1759. if input.IsButtonPressed( ui.Keys.backspace ) then
  1760. var = var:sub( 1, -2 );
  1761. end
  1762.  
  1763. for k, v in pairs( gs_textTable ) do
  1764. if input.IsButtonPressed( k ) then
  1765. if input.IsButtonDown( ui.Keys.shift ) then
  1766. if draw.GetTextSize( var .. v[2] ) <= 135 then
  1767. var = var .. v[2];
  1768. end
  1769. else
  1770. if draw.GetTextSize( var .. v[1] ) <= 135 then
  1771. var = var .. v[1];
  1772. end
  1773. end
  1774. end
  1775. end
  1776. end
  1777.  
  1778. if gs_curinput == id then
  1779. render.text( x + 8, y + 4, var .. "_", { 181, 181, 181, wnd.alpha } );
  1780. else
  1781. render.text( x + 8, y + 4, var, { 181, 181, 181, wnd.alpha } );
  1782. end
  1783.  
  1784. wnd.groups[gs_curgroup].is_nextline = true;
  1785. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + 28;
  1786.  
  1787. if title ~= nil then
  1788. wnd.groups[gs_curgroup].nextline_offset = wnd.groups[gs_curgroup].nextline_offset + 13;
  1789. end
  1790.  
  1791. if group.highest_w < 155 then
  1792. wnd.groups[gs_curgroup].highest_w = 155;
  1793. end
  1794.  
  1795. if group.highest_h < wnd.groups[gs_curgroup].nextline_offset then
  1796. wnd.groups[gs_curgroup].highest_h = wnd.groups[gs_curgroup].nextline_offset - wnd.groups[gs_curgroup].nextline_offset / 2;
  1797. end
  1798.  
  1799. wnd.groups[gs_curgroup].last_y = y;
  1800.  
  1801. if title ~= nil then
  1802. wnd.groups[gs_curgroup].last_y = wnd.groups[gs_curgroup].last_y + 13;
  1803. end
  1804.  
  1805. return var;
  1806. end
  1807.  
  1808. --API
  1809. ui.BeginWindow = gs_beginwindow;
  1810. ui.AddGradient = gs_addgradient;
  1811. ui.EndWindow = gs_endwindow;
  1812. ui.SetWindowMoveable = gs_setwindowmovable;
  1813. ui.SetWindowOpenKey = gs_setwindowopenkey;
  1814. ui.SetWindowDrawTexture = gs_setwindowdrawtexture;
  1815. ui.BeginGroup = gs_begingroup;
  1816. ui.EndGroup = gs_endgroup;
  1817. ui.Checkbox = gs_checkbox;
  1818. ui.SetWindowSizeable = gs_setwindowsizeable;
  1819. ui.SetGroupMoveable = gs_setgroupmoveable;
  1820. ui.SetGroupSizeable = gs_setgroupsizeable;
  1821. ui.Button = gs_button;
  1822. ui.Slider = gs_slider;
  1823. ui.Label = gs_label;
  1824. ui.Bind = gs_bind;
  1825. ui.BeginTab = gs_begintab;
  1826. ui.DrawTabBar = gs_drawtabbar;
  1827. ui.EndTab = gs_endtab;
  1828. ui.Combo = gs_combo;
  1829. ui.MultiCombo = gs_multicombo;
  1830. ui.Listbox = gs_listbox;
  1831. ui.Textbox = gs_textbox;
  1832. --
  1833. ui.ColorPicker = gs_ColorPicker;
  1834.  
  1835. -- Let's add some useless hook here to make aimware think that script loaded
  1836. callbacks.Register( "CreateMove", "ui", function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement