Advertisement
Guest User

NativeUI.lua

a guest
Jun 24th, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 135.20 KB | None | 0 0
  1. UIResRectangle = setmetatable({}, UIResRectangle)
  2. UIResRectangle.__index = UIResRectangle
  3. UIResRectangle.__call = function() return "Rectangle" end
  4.  
  5. UIResText = setmetatable({}, UIResText)
  6. UIResText.__index = UIResText
  7. UIResText.__call = function() return "Text" end
  8.  
  9. Sprite = setmetatable({}, Sprite)
  10. Sprite.__index = Sprite
  11. Sprite.__call = function() return "Sprite" end
  12.  
  13. UIMenuItem = setmetatable({}, UIMenuItem)
  14. UIMenuItem.__index = UIMenuItem
  15. UIMenuItem.__call = function() return "UIMenuItem", "UIMenuItem" end
  16.  
  17. UIMenuCheckboxItem = setmetatable({}, UIMenuCheckboxItem)
  18. UIMenuCheckboxItem.__index = UIMenuCheckboxItem
  19. UIMenuCheckboxItem.__call = function() return "UIMenuItem", "UIMenuCheckboxItem" end
  20.  
  21. UIMenuListItem = setmetatable({}, UIMenuListItem)
  22. UIMenuListItem.__index = UIMenuListItem
  23. UIMenuListItem.__call = function() return "UIMenuItem", "UIMenuListItem" end
  24.  
  25. UIMenuSliderItem = setmetatable({}, UIMenuSliderItem)
  26. UIMenuSliderItem.__index = UIMenuSliderItem
  27. UIMenuSliderItem.__call = function() return "UIMenuItem", "UIMenuSliderItem" end
  28.  
  29. UIMenuColouredItem = setmetatable({}, UIMenuColouredItem)
  30. UIMenuColouredItem.__index = UIMenuColouredItem
  31. UIMenuColouredItem.__call = function() return "UIMenuItem", "UIMenuColouredItem" end
  32.  
  33. UIMenuHeritageWindow = setmetatable({}, UIMenuHeritageWindow)
  34. UIMenuHeritageWindow.__index = UIMenuHeritageWindow
  35. UIMenuHeritageWindow.__call = function() return "UIMenuWindow", "UIMenuHeritageWindow" end
  36.  
  37. UIMenuGridPanel = setmetatable({}, UIMenuGridPanel)
  38. UIMenuGridPanel.__index = UIMenuGridPanel
  39. UIMenuGridPanel.__call = function() return "UIMenuPanel", "UIMenuGridPanel" end
  40.  
  41. UIMenuColourPanel = setmetatable({}, UIMenuColourPanel)
  42. UIMenuColourPanel.__index = UIMenuColourPanel
  43. UIMenuColourPanel.__call = function() return "UIMenuPanel", "UIMenuColourPanel" end
  44.  
  45. UIMenuPercentagePanel = setmetatable({}, UIMenuPercentagePanel)
  46. UIMenuPercentagePanel.__index = UIMenuPercentagePanel
  47. UIMenuPercentagePanel.__call = function() return "UIMenuPanel", "UIMenuPercentagePanel" end
  48.  
  49. UIMenu = setmetatable({}, UIMenu)
  50. UIMenu.__index = UIMenu
  51. UIMenu.__call = function() return "UIMenu" end
  52.  
  53. MenuPool = setmetatable({}, MenuPool)
  54. MenuPool.__index = MenuPool
  55.  
  56. NativeUI = {}
  57.  
  58. CharacterMap = { [' '] = 6, ['!'] = 6, ['"'] = 6, ['#'] = 11,['$'] = 10, ['%'] = 17,['&'] = 13, ['\\'] = 4,['('] = 6, [')'] = 6,['*'] = 7, ['+'] = 10, [','] = 4, ['-'] = 6,  ['.'] = 4,  ['/'] = 7,  ['0'] = 12, ['1'] = 7,  ['2'] = 11, ['3'] = 11, ['4'] = 11, ['5'] = 11, ['6'] = 12, ['7'] = 10, ['8'] = 11, ['9'] = 11, [':'] = 5,  [';'] = 4,  ['<'] = 9,  ['='] = 9,  ['>'] = 9,  ['?'] = 10, ['@'] = 15, ['A'] = 12, ['B'] = 13, ['C'] = 14, ['D'] = 14, ['E'] = 12, ['F'] = 12, ['G'] = 15, ['H'] = 14, ['I'] = 5,  ['J'] = 11, ['K'] = 13, ['L'] = 11, ['M'] = 16, ['N'] = 14, ['O'] = 16, ['P'] = 12, ['Q'] = 15, ['R'] = 13, ['S'] = 12, ['T'] = 11, ['U'] = 13, ['V'] = 12, ['W'] = 18, ['X'] = 11, ['Y'] = 11, ['Z'] = 12, ['['] = 6,  [']'] = 6,  ['^'] = 9,  ['_'] = 18, ['`'] = 8,  ['a'] = 11, ['b'] = 12, ['c'] = 11, ['d'] = 12, ['e'] = 12, ['f'] = 5,  ['g'] = 13, ['h'] = 11, ['i'] = 4,  ['j'] = 4,  ['k'] = 10, ['l'] = 4,  ['m'] = 18, ['n'] = 11, ['o'] = 12, ['p'] = 12, ['q'] = 12, ['r'] = 7,  ['s'] = 9,  ['t'] = 5,  ['u'] = 11, ['v'] = 10, ['w'] = 14, ['x'] = 9,  ['y'] = 10, ['z'] = 9,  ['{'] = 6,  ['|'] = 3,  ['}'] = 6 }
  59.  
  60. BadgeStyle = { None = 0, BronzeMedal = 1, GoldMedal = 2, SilverMedal = 3, Alert = 4, Crown = 5, Ammo = 6, Armour = 7, Barber = 8, Clothes = 9, Franklin = 10, Bike = 11, Car = 12, Gun = 13, Heart = 14, Makeup = 15, Mask = 16, Michael = 17, Star = 18, Tattoo = 19, Trevor = 20, Lock = 21, Tick = 22 }
  61.  
  62. BadgeTexture = {
  63.     [0] = function() return "" end,
  64.     [1] = function() return "mp_medal_bronze" end,
  65.     [2] = function() return "mp_medal_gold" end,
  66.     [3] = function() return "medal_silver" end,
  67.     [4] = function() return "mp_alerttriangle" end,
  68.     [5] = function() return "mp_hostcrown" end,
  69.     [6] = function(Selected) if Selected then return "shop_ammo_icon_b" else return "shop_ammo_icon_a" end end,
  70.     [7] = function(Selected) if Selected then return "shop_armour_icon_b" else return "shop_armour_icon_a" end end,
  71.     [8] = function(Selected) if Selected then return "shop_barber_icon_b" else return "shop_barber_icon_a"  end end,
  72.     [9] = function(Selected) if Selected then return "shop_clothing_icon_b" else return "shop_clothing_icon_a" end end,
  73.     [10] = function(Selected) if Selected then return "shop_franklin_icon_b" else return "shop_franklin_icon_a" end end,
  74.     [11] = function(Selected) if Selected then return "shop_garage_bike_icon_b" else return "shop_garage_bike_icon_a" end end,
  75.     [12] = function(Selected) if Selected then return "shop_garage_icon_b" else return "shop_garage_icon_a" end end,
  76.     [13] = function(Selected) if Selected then return "shop_gunclub_icon_b" else return "shop_gunclub_icon_a" end end,
  77.     [14] = function(Selected) if Selected then return "shop_health_icon_b" else return "shop_health_icon_a" end end,
  78.     [15] = function(Selected) if Selected then return "shop_makeup_icon_b" else return "shop_makeup_icon_a" end end,
  79.     [16] = function(Selected) if Selected then return "shop_mask_icon_b" else return "shop_mask_icon_a" end end,
  80.     [17] = function(Selected) if Selected then return "shop_michael_icon_b" else return "shop_michael_icon_a" end end,
  81.     [18] = function() return "shop_new_star" end,
  82.     [19] = function(Selected) if Selected then return "shop_tattoos_icon_b" else return "shop_tattoos_icon_" end end,
  83.     [20] = function(Selected) if Selected then return "shop_trevor_icon_b" else return "shop_trevor_icon_a" end end,
  84.     [21] = function() return "shop_lock" end,
  85.     [22] = function() return "shop_tick_icon" end,
  86. }
  87.  
  88. BadgeDictionary = {
  89.     [0] = function(Selected)
  90.         if Selected then
  91.             return "commonmenu"
  92.         else
  93.             return "commonmenu"
  94.         end
  95.     end,
  96. }
  97.  
  98. BadgeColour = {
  99.     [5] = function(Selected) if Selected then return 0, 0, 0, 255 else return 255, 255, 255, 255 end end,
  100.     [21] = function(Selected) if Selected then return 0, 0, 0, 255 else return 255, 255, 255, 255 end end,
  101.     [22] = function(Selected) if Selected then return 0, 0, 0, 255 else return 255, 255, 255, 255   end end,
  102. }
  103.  
  104. Colours = {
  105.     PureWhite = function() return {255, 255, 255, 255} end,
  106.     White = function() return {240, 240, 240, 255} end,
  107.     Black = function() return {0, 0, 0, 255} end,
  108.     Grey = function() return {155, 155, 155, 255} end,
  109.     GreyLight = function() return {205, 205, 205, 255} end,
  110.     GreyDark = function() return {77, 77, 77, 255} end,
  111.     Red = function() return {224, 50, 50, 255} end,
  112.     RedLight = function() return {240, 153, 153, 255} end,
  113.     RedDark = function() return {112, 25, 25, 255} end,
  114.     Blue = function() return {93, 182, 229, 255} end,
  115.     BlueLight = function() return {174, 219, 242, 255} end,
  116.     BlueDark = function() return {47, 92, 115, 255} end,
  117.     Yellow = function() return {240, 200, 80, 255} end,
  118.     YellowLight = function() return {254, 235, 169, 255} end,
  119.     YellowDark = function() return {126, 107, 41, 255} end,
  120.     Orange = function() return {255, 133, 85, 255} end,
  121.     OrangeLight = function() return {255, 194, 170, 255} end,
  122.     OrangeDark = function() return {127, 66, 42, 255} end,
  123.     Green = function() return {114, 204, 114, 255} end,
  124.     GreenLight = function() return {185, 230, 185, 255} end,
  125.     GreenDark = function() return {57, 102, 57, 255} end,
  126.     Purple = function() return {132, 102, 226, 255} end,
  127.     PurpleLight = function() return {192, 179, 239, 255} end,
  128.     PurpleDark = function() return {67, 57, 111, 255} end,
  129.     Pink = function() return {203, 54, 148, 255} end,
  130.     RadarHealth = function() return {53, 154, 71, 255} end,
  131.     RadarArmour = function() return {93, 182, 229, 255} end,
  132.     RadarDamage = function() return {235, 36, 39, 255} end,
  133.     NetPlayer1 = function() return {194, 80, 80, 255} end,
  134.     NetPlayer2 = function() return {156, 110, 175, 255} end,
  135.     NetPlayer3 = function() return {255, 123, 196, 255} end,
  136.     NetPlayer4 = function() return {247, 159, 123, 255} end,
  137.     NetPlayer5 = function() return {178, 144, 132, 255} end,
  138.     NetPlayer6 = function() return {141, 206, 167, 255} end,
  139.     NetPlayer7 = function() return {113, 169, 175, 255} end,
  140.     NetPlayer8 = function() return {211, 209, 231, 255} end,
  141.     NetPlayer9 = function() return {144, 127, 153, 255} end,
  142.     NetPlayer10 = function() return {106, 196, 191, 255} end,
  143.     NetPlayer11 = function() return {214, 196, 153, 255} end,
  144.     NetPlayer12 = function() return {234, 142, 80, 255} end,
  145.     NetPlayer13 = function() return {152, 203, 234, 255} end,
  146.     NetPlayer14 = function() return {178, 98, 135, 255} end,
  147.     NetPlayer15 = function() return {144, 142, 122, 255} end,
  148.     NetPlayer16 = function() return {166, 117, 94, 255} end,
  149.     NetPlayer17 = function() return {175, 168, 168, 255} end,
  150.     NetPlayer18 = function() return {232, 142, 155, 255} end,
  151.     NetPlayer19 = function() return {187, 214, 91, 255} end,
  152.     NetPlayer20 = function() return {12, 123, 86, 255} end,
  153.     NetPlayer21 = function() return {123, 196, 255, 255} end,
  154.     NetPlayer22 = function() return {171, 60, 230, 255} end,
  155.     NetPlayer23 = function() return {206, 169, 13, 255} end,
  156.     NetPlayer24 = function() return {71, 99, 173, 255} end,
  157.     NetPlayer25 = function() return {42, 166, 185, 255} end,
  158.     NetPlayer26 = function() return {186, 157, 125, 255} end,
  159.     NetPlayer27 = function() return {201, 225, 255, 255} end,
  160.     NetPlayer28 = function() return {240, 240, 150, 255} end,
  161.     NetPlayer29 = function() return {237, 140, 161, 255} end,
  162.     NetPlayer30 = function() return {249, 138, 138, 255} end,
  163.     NetPlayer31 = function() return {252, 239, 166, 255} end,
  164.     NetPlayer32 = function() return {240, 240, 240, 255} end,
  165.     SimpleBlipDefault = function() return {159, 201, 166, 255} end,
  166.     MenuBlue = function() return {140, 140, 140, 255} end,
  167.     MenuGreyLight = function() return {140, 140, 140, 255} end,
  168.     MenuBlueExtraDark = function() return {40, 40, 40, 255} end,
  169.     MenuYellow = function() return {240, 160, 0, 255} end,
  170.     MenuYellowDark = function() return {240, 160, 0, 255} end,
  171.     MenuGreen = function() return {240, 160, 0, 255} end,
  172.     MenuGrey = function() return {140, 140, 140, 255} end,
  173.     MenuGreyDark = function() return {60, 60, 60, 255} end,
  174.     MenuHighlight = function() return {30, 30, 30, 255} end,
  175.     MenuStandard = function() return {140, 140, 140, 255} end,
  176.     MenuDimmed = function() return {75, 75, 75, 255} end,
  177.     MenuExtraDimmed = function() return {50, 50, 50, 255} end,
  178.     BriefTitle = function() return {95, 95, 95, 255} end,
  179.     MidGreyMp = function() return {100, 100, 100, 255} end,
  180.     NetPlayer1Dark = function() return {93, 39, 39, 255} end,
  181.     NetPlayer2Dark = function() return {77, 55, 89, 255} end,
  182.     NetPlayer3Dark = function() return {124, 62, 99, 255} end,
  183.     NetPlayer4Dark = function() return {120, 80, 80, 255} end,
  184.     NetPlayer5Dark = function() return {87, 72, 66, 255} end,
  185.     NetPlayer6Dark = function() return {74, 103, 83, 255} end,
  186.     NetPlayer7Dark = function() return {60, 85, 88, 255} end,
  187.     NetPlayer8Dark = function() return {105, 105, 64, 255} end,
  188.     NetPlayer9Dark = function() return {72, 63, 76, 255} end,
  189.     NetPlayer10Dark = function() return {53, 98, 95, 255} end,
  190.     NetPlayer11Dark = function() return {107, 98, 76, 255} end,
  191.     NetPlayer12Dark = function() return {117, 71, 40, 255} end,
  192.     NetPlayer13Dark = function() return {76, 101, 117, 255} end,
  193.     NetPlayer14Dark = function() return {65, 35, 47, 255} end,
  194.     NetPlayer15Dark = function() return {72, 71, 61, 255} end,
  195.     NetPlayer16Dark = function() return {85, 58, 47, 255} end,
  196.     NetPlayer17Dark = function() return {87, 84, 84, 255} end,
  197.     NetPlayer18Dark = function() return {116, 71, 77, 255} end,
  198.     NetPlayer19Dark = function() return {93, 107, 45, 255} end,
  199.     NetPlayer20Dark = function() return {6, 61, 43, 255} end,
  200.     NetPlayer21Dark = function() return {61, 98, 127, 255} end,
  201.     NetPlayer22Dark = function() return {85, 30, 115, 255} end,
  202.     NetPlayer23Dark = function() return {103, 84, 6, 255} end,
  203.     NetPlayer24Dark = function() return {35, 49, 86, 255} end,
  204.     NetPlayer25Dark = function() return {21, 83, 92, 255} end,
  205.     NetPlayer26Dark = function() return {93, 98, 62, 255} end,
  206.     NetPlayer27Dark = function() return {100, 112, 127, 255} end,
  207.     NetPlayer28Dark = function() return {120, 120, 75, 255} end,
  208.     NetPlayer29Dark = function() return {152, 76, 93, 255} end,
  209.     NetPlayer30Dark = function() return {124, 69, 69, 255} end,
  210.     NetPlayer31Dark = function() return {10, 43, 50, 255} end,
  211.     NetPlayer32Dark = function() return {95, 95, 10, 255} end,
  212.     Bronze = function() return {180, 130, 97, 255} end,
  213.     Silver = function() return {150, 153, 161, 255} end,
  214.     Gold = function() return {214, 181, 99, 255} end,
  215.     Platinum = function() return {166, 221, 190, 255} end,
  216.     Gang1 = function() return {29, 100, 153, 255} end,
  217.     Gang2 = function() return {214, 116, 15, 255} end,
  218.     Gang3 = function() return {135, 125, 142, 255} end,
  219.     Gang4 = function() return {229, 119, 185, 255} end,
  220.     SameCrew = function() return {252, 239, 166, 255} end,
  221.     Freemode = function() return {45, 110, 185, 255} end,
  222.     PauseBg = function() return {0, 0, 0, 255} end,
  223.     Friendly = function() return {93, 182, 229, 255} end,
  224.     Enemy = function() return {194, 80, 80, 255} end,
  225.     Location = function() return {240, 200, 80, 255} end,
  226.     Pickup = function() return {114, 204, 114, 255} end,
  227.     PauseSingleplayer = function() return {114, 204, 114, 255} end,
  228.     FreemodeDark = function() return {22, 55, 92, 255} end,
  229.     InactiveMission = function() return {154, 154, 154, 255} end,
  230.     Damage = function() return {194, 80, 80, 255} end,
  231.     PinkLight = function() return {252, 115, 201, 255} end,
  232.     PmMitemHighlight = function() return {252, 177, 49, 255} end,
  233.     ScriptVariable = function() return {0, 0, 0, 255} end,
  234.     Yoga = function() return {109, 247, 204, 255} end,
  235.     Tennis = function() return {241, 101, 34, 255} end,
  236.     Golf = function() return {214, 189, 97, 255} end,
  237.     ShootingRange = function() return {112, 25, 25, 255} end,
  238.     FlightSchool = function() return {47, 92, 115, 255} end,
  239.     NorthBlue = function() return {93, 182, 229, 255} end,
  240.     SocialClub = function() return {234, 153, 28, 255} end,
  241.     PlatformBlue = function() return {11, 55, 123, 255} end,
  242.     PlatformGreen = function() return {146, 200, 62, 255} end,
  243.     PlatformGrey = function() return {234, 153, 28, 255} end,
  244.     FacebookBlue = function() return {66, 89, 148, 255} end,
  245.     IngameBg = function() return {0, 0, 0, 255} end,
  246.     Darts = function() return {114, 204, 114, 255} end,
  247.     Waypoint = function() return {164, 76, 242, 255} end,
  248.     Michael = function() return {101, 180, 212, 255} end,
  249.     Franklin = function() return {171, 237, 171, 255} end,
  250.     Trevor = function() return {255, 163, 87, 255} end,
  251.     GolfP1 = function() return {240, 240, 240, 255} end,
  252.     GolfP2 = function() return {235, 239, 30, 255} end,
  253.     GolfP3 = function() return {255, 149, 14, 255} end,
  254.     GolfP4 = function() return {246, 60, 161, 255} end,
  255.     WaypointLight = function() return {210, 166, 249, 255} end,
  256.     WaypointDark = function() return {82, 38, 121, 255} end,
  257.     PanelLight = function() return {0, 0, 0, 255} end,
  258.     MichaelDark = function() return {72, 103, 116, 255} end,
  259.     FranklinDark = function() return {85, 118, 85, 255} end,
  260.     TrevorDark = function() return {127, 81, 43, 255} end,
  261.     ObjectiveRoute = function() return {240, 200, 80, 255} end,
  262.     PausemapTint = function() return {0, 0, 0, 255} end,
  263.     PauseDeselect = function() return {100, 100, 100, 255} end,
  264.     PmWeaponsPurchasable = function() return {45, 110, 185, 255} end,
  265.     PmWeaponsLocked = function() return {240, 240, 240, 255} end,
  266.     EndScreenBg = function() return {0, 0, 0, 255} end,
  267.     Chop = function() return {224, 50, 50, 255} end,
  268.     PausemapTintHalf = function() return {0, 0, 0, 255} end,
  269.     NorthBlueOfficial = function() return {0, 71, 133, 255} end,
  270.     ScriptVariable2 = function() return {0, 0, 0, 255} end,
  271.     H = function() return {33, 118, 37, 255} end,
  272.     HDark = function() return {37, 102, 40, 255} end,
  273.     T = function() return {234, 153, 28, 255} end,
  274.     TDark = function() return {225, 140, 8, 255} end,
  275.     HShard = function() return {20, 40, 0, 255} end,
  276.     ControllerMichael = function() return {48, 255, 255, 255} end,
  277.     ControllerFranklin = function() return {48, 255, 0, 255} end,
  278.     ControllerTrevor = function() return {176, 80, 0, 255} end,
  279.     ControllerChop = function() return {127, 0, 0, 255} end,
  280.     VideoEditorVideo = function() return {53, 166, 224, 255} end,
  281.     VideoEditorAudio = function() return {162, 79, 157, 255} end,
  282.     VideoEditorText = function() return {104, 192, 141, 255} end,
  283.     HbBlue = function() return {29, 100, 153, 255} end,
  284.     HbYellow = function() return {234, 153, 28, 255} end,
  285.     VideoEditorScore = function() return {240, 160, 1, 255} end,
  286.     VideoEditorAudioFadeout = function() return {59, 34, 57, 255} end,
  287.     VideoEditorTextFadeout = function() return {41, 68, 53, 255} end,
  288.     VideoEditorScoreFadeout = function() return {82, 58, 10, 255} end,
  289.     HeistBackground = function() return {37, 102, 40, 255} end,
  290.     VideoEditorAmbient = function() return {240, 200, 80, 255} end,
  291.     VideoEditorAmbientFadeout = function() return {80, 70, 34, 255} end,
  292.     Gb = function() return {255, 133, 85, 255} end,
  293.     G = function() return {255, 194, 170, 255} end,
  294.     B = function() return {255, 133, 85, 255} end,
  295.     LowFlow = function() return {240, 200, 80, 255} end,
  296.     LowFlowDark = function() return {126, 107, 41, 255} end,
  297.     G1 = function() return {247, 159, 123, 255} end,
  298.     G2 = function() return {226, 134, 187, 255} end,
  299.     G3 = function() return {239, 238, 151, 255} end,
  300.     G4 = function() return {113, 169, 175, 255} end,
  301.     G5 = function() return {160, 140, 193, 255} end,
  302.     G6 = function() return {141, 206, 167, 255} end,
  303.     G7 = function() return {181, 214, 234, 255} end,
  304.     G8 = function() return {178, 144, 132, 255} end,
  305.     G9 = function() return {0, 132, 114, 255} end,
  306.     G10 = function() return {216, 85, 117, 255} end,
  307.     G11 = function() return {30, 100, 152, 255} end,
  308.     G12 = function() return {43, 181, 117, 255} end,
  309.     G13 = function() return {233, 141, 79, 255} end,
  310.     G14 = function() return {137, 210, 215, 255} end,
  311.     G15 = function() return {134, 125, 141, 255} end,
  312.     Adversary = function() return {109, 34, 33, 255} end,
  313.     DegenRed = function() return {255, 0, 0, 255} end,
  314.     DegenYellow = function() return {255, 255, 0, 255} end,
  315.     DegenGreen = function() return {0, 255, 0, 255} end,
  316.     DegenCyan = function() return {0, 255, 255, 255} end,
  317.     DegenBlue = function() return {0, 0, 255, 255} end,
  318.     DegenMagenta = function() return {255, 0, 255, 255} end,
  319.     Stunt1 = function() return {38, 136, 234, 255} end,
  320.     Stunt2 = function() return {224, 50, 50, 255} end,
  321. }
  322.  
  323. --[[
  324.     Utils.lua
  325.     Utilities
  326. --]]
  327.  
  328. function GetResolution()
  329.     local W, H = GetActiveScreenResolution()
  330.     --Citizen.Trace(tostring(W) .. ", " .. tostring(H))
  331.     if (W/H) > 3.5 then
  332.     return GetScreenResolution()
  333.     else
  334.     return W, H
  335.     end
  336. end
  337.  
  338. --[[function FormatXWYH(Value, Value2)
  339.     local W, H = GetScreenResolution()
  340.     local AW, AH = GetResolution()
  341.     local XW = Value/W - ((Value / W) - (Value / ((AW >= 1920) and AW or 1920)))
  342.     local YH = Value2/H - ((Value2 / H) - (Value2 / ((AH >= 1080) and AH or 1080)))
  343.     return XW, YH
  344. end]]
  345.  
  346. function getScreenResolutionMaintainRatio()
  347.     local screenW, screenH = GetScreenResolution()
  348.     local height = 1080
  349.     local ratio = screenW / screenH
  350.     local width = height * ratio
  351.  
  352.     return width, height
  353. end
  354.  
  355. function math.round(num, numDecimalPlaces)
  356.     return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
  357. end
  358.  
  359. function tobool(input)
  360.     if input == "true" or tonumber(input) == 1 or input == true then
  361.     return true
  362.     else
  363.     return false
  364.     end
  365. end
  366.  
  367. function string.split(inputstr, sep)
  368.     if sep == nil then
  369.     sep = "%s"
  370.     end
  371.     local t={} ; i=1
  372.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  373.     t[i] = str
  374.     i = i + 1
  375.     end
  376.  
  377.     return t
  378. end
  379.  
  380. function string.starts(String, Start)
  381.     return string.sub(String, 1, string.len(Start)) == Start
  382. end
  383.  
  384. --[[function IsMouseInBounds(X, Y, Width, Height)
  385.     local MX, MY = math.round(GetControlNormal(0, 239) * 1920), math.round(GetControlNormal(0, 240) * 1080)
  386.     MX, MY = FormatXWYH(MX, MY)
  387.     X, Y = FormatXWYH(X, Y)
  388.     Width, Height = FormatXWYH(Width, Height)
  389.     return (MX >= X and MX <= X + Width) and (MY > Y and MY < Y + Height)
  390. end]]
  391.  
  392. function IsMouseInBounds(X, Y, Width, Height)
  393.     local resX, resY = getScreenResolutionMaintainRatio()
  394.     local mouseX, mouseY = math.round(GetControlNormal(0, 239) * resX), math.round(GetControlNormal(0, 240) * resY)
  395.  
  396.     return (mouseX >= X and mouseX <= X + Width) and (mouseY > Y and mouseY < Y + Height);
  397. end
  398.  
  399.  
  400. --[[function GetSafeZoneBounds()
  401.     local SafeSize = GetSafeZoneSize()
  402.     SafeSize = math.round(SafeSize, 2)
  403.     SafeSize = (SafeSize * 100) - 90
  404.     SafeSize = 10 - SafeSize
  405.  
  406.     local W, H = 1920, 1080
  407.  
  408.     return {X = math.round(SafeSize * ((W/H) * 5.4)), Y = math.round(SafeSize * 5.4)}
  409. end]]
  410.  
  411. function GetSafeZoneBounds()
  412.     local SafeSize = GetSafeZoneSize()
  413.     local g = math.round(SafeSize, 2)
  414.     g = (g * 100) - 90
  415.     g = 10 - g
  416.  
  417.     local hmp = 5.4
  418.     local screenW, screenH = GetScreenResolution()
  419.     local ratio = screenW / screenH
  420.     local wmp = ratio * hmp
  421.  
  422.     return {X = math.round(g * wmp), Y = math.round(g * hmp)}
  423. end
  424.  
  425. function Controller()
  426.     return not IsInputDisabled(2)
  427. end
  428.  
  429. --[[    
  430.     UIResRectangle.lua
  431.     Elements
  432. --]]
  433.  
  434. function UIResRectangle.New(X, Y, Width, Height, R, G, B, A)
  435.     local _UIResRectangle = {
  436.         X = tonumber(X) or 0,
  437.         Y = tonumber(Y) or 0,
  438.         Width = tonumber(Width) or 0,
  439.         Height = tonumber(Height) or 0,
  440.         _Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255},
  441.     }
  442.     return setmetatable(_UIResRectangle, UIResRectangle)
  443. end
  444.  
  445. function UIResRectangle:Position(X, Y)
  446.     if tonumber(X) and tonumber(Y) then
  447.         self.X = tonumber(X)
  448.         self.Y = tonumber(Y)
  449.     else
  450.         return {X = self.X, Y = self.Y}
  451.     end
  452. end
  453.  
  454. function UIResRectangle:Size(Width, Height)
  455.     if tonumber(Width) and tonumber(Height) then
  456.         self.Width = tonumber(Width)
  457.         self.Height = tonumber(Height)
  458.     else
  459.         return {Width = self.Width, Height = self.Height}
  460.     end
  461. end
  462.  
  463. function UIResRectangle:Colour(R, G, B, A)
  464.     if tonumber(R) or tonumber(G) or tonumber(B) or tonumber(A) then
  465.         self._Colour.R = tonumber(R) or 255
  466.         self._Colour.B = tonumber(B) or 255
  467.         self._Colour.G = tonumber(G) or 255
  468.         self._Colour.A = tonumber(A) or 255
  469.     else
  470.         return self._Colour
  471.     end
  472. end
  473.  
  474. --[[function UIResRectangle:Draw()
  475.     local Position = self:Position()
  476.     local Size = self:Size()
  477.     Size.Width, Size.Height = FormatXWYH(Size.Width, Size.Height)
  478.     Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
  479.     DrawRect(Position.X + Size.Width * 0.5, Position.Y + Size.Height * 0.5, Size.Width, Size.Height, self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
  480. end]]
  481.  
  482. function UIResRectangle:Draw()
  483.     local Position = self:Position()
  484.     local Size = self:Size()
  485.     local screenW, screenH = GetScreenResolution()
  486.     local height = 1080
  487.     local ratio = screenW / screenH
  488.     local width = height * ratio
  489.  
  490.     local w, h = Size.Width / width, Size.Height / height
  491.     local x, y = ((Position.X) / width) + w * 0.5, ((Position.Y) / height) + h * 0.5
  492.  
  493.     DrawRect(x, y, w, h, self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
  494. end
  495.  
  496. --[[function DrawRectangle(X, Y, Width, Height, R, G, B, A)
  497.     X, Y, Width, Height = X or 0, Y or 0, Width or 0, Height or 0
  498.     X, Y = FormatXWYH(X, Y)
  499.     Width, Height = FormatXWYH(Width, Height)
  500.     DrawRect(X + Width * 0.5, Y + Height * 0.5, Width, Height, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
  501. end]]
  502.  
  503. function DrawRectangle(X, Y, Width, Height, R, G, B, A)
  504.     X, Y, Width, Height = X or 0, Y or 0, Width or 0, Height or 0
  505.     local screenW, screenH = GetScreenResolution()
  506.     local height = 1080
  507.     local ratio = screenW / screenH
  508.     local width = height * ratio
  509.  
  510.     local w, h = Width / width, Height / height
  511.     local x, y = ((X) / width) + w * 0.5, ((Y) / height) + h * 0.5
  512.  
  513.     DrawRect(x, y, w, h, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
  514. end
  515.  
  516. --[[
  517.     UIResText.lua
  518.     Elements
  519. --]]
  520.  
  521. function GetCharacterCount(str)
  522.     local characters = 0
  523.     for c in str:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
  524.         local a = c:byte(1, -1)
  525.         if a ~= nil then
  526.             characters = characters + 1
  527.         end
  528.     end
  529.     return characters
  530. end
  531.  
  532. function GetByteCount(str)
  533.     local bytes = 0
  534.  
  535.     for c in str:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
  536.         local a,b,c,d = c:byte(1, -1)
  537.         if a ~= nil then
  538.             bytes = bytes + 1
  539.         end
  540.         if b ~= nil then
  541.             bytes = bytes + 1
  542.         end
  543.         if c ~= nil then
  544.             bytes = bytes + 1
  545.         end
  546.         if d ~= nil then
  547.             bytes = bytes + 1
  548.         end
  549.     end
  550.     return bytes
  551. end
  552.  
  553. function AddLongStringForAscii(str)
  554.     local maxbytelength = 99
  555.     for i = 0, GetCharacterCount(str), 99 do
  556.         AddTextComponentSubstringPlayerName(string.sub(str, i, math.min(maxbytelength, GetCharacterCount(str) - i))) --needs changed
  557.     end
  558. end
  559.  
  560. function AddLongStringForUtf8(str)
  561.     local maxbytelength = 99
  562.     local bytecount = GetByteCount(str)
  563.  
  564.     if bytecount < maxbytelength then
  565.         AddTextComponentSubstringPlayerName(str)
  566.         return
  567.     end
  568.  
  569.     local startIndex = 0
  570.  
  571.     for i = 0, GetCharacterCount(str), 1 do
  572.         local length = i - startIndex
  573.         if GetByteCount(string.sub(str, startIndex, length)) > maxbytelength then
  574.             AddTextComponentSubstringPlayerName(string.sub(str, startIndex, length - 1))
  575.             i = i - 1
  576.             startIndex = startIndex + (length - 1)
  577.         end
  578.     end
  579.     AddTextComponentSubstringPlayerName(string.sub(str, startIndex, GetCharacterCount(str) - startIndex))
  580. end
  581.  
  582. function AddLongString(str)
  583.     local bytecount = GetByteCount(str)
  584.     if bytecount == GetCharacterCount(str) then
  585.         AddLongStringForAscii(str)
  586.     else
  587.         AddLongStringForUtf8(str)
  588.     end
  589. end
  590.  
  591. function MeasureStringWidthNoConvert(str, font, scale)
  592.     BeginTextCommandWidth("STRING")
  593.     AddLongString(str)
  594.     SetTextFont(font or 0)
  595.     SetTextScale(1.0, scale or 0)
  596.     return EndTextCommandGetWidth(true)
  597. end
  598.  
  599. function MeasureStringWidth(str, font, scale)
  600.     return MeasureStringWidthNoConvert(str, font, scale) * 1920
  601. end
  602.  
  603. function UIResText.New(Text, X, Y, Scale, R, G, B, A, Font, Alignment, DropShadow, Outline, WordWrap)
  604.     local _UIResText = {
  605.         _Text = tostring(Text) or "",
  606.         X = tonumber(X) or 0,
  607.         Y = tonumber(Y) or 0,
  608.         Scale = tonumber(Scale) or 0,
  609.         _Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255},
  610.         Font = tonumber(Font) or 0,
  611.         Alignment = Alignment or nil,
  612.         DropShadow = Dropshadow or nil,
  613.         Outline = Outline or nil,
  614.         WordWrap = tonumber(WordWrap) or 0,
  615.     }
  616.     return setmetatable(_UIResText, UIResText)
  617. end
  618.  
  619. function UIResText:Position(X, Y)
  620.     if tonumber(X) and tonumber(Y) then
  621.         self.X = tonumber(X)
  622.         self.Y = tonumber(Y)
  623.     else
  624.         return {X = self.X, Y = self.Y}
  625.     end
  626. end
  627.  
  628. function UIResText:Colour(R, G, B, A)
  629.     if tonumber(R) and tonumber(G) and tonumber(B) and tonumber(A) then
  630.         self._Colour.R = tonumber(R)
  631.         self._Colour.B = tonumber(B)
  632.         self._Colour.G = tonumber(G)
  633.         self._Colour.A = tonumber(A)
  634.     else
  635.         return self._Colour
  636.     end
  637. end
  638.  
  639. function UIResText:Text(Text)
  640.     if tostring(Text) and Text ~= nil then
  641.         self._Text = tostring(Text)
  642.     else
  643.         return self._Text
  644.     end
  645. end
  646.  
  647. function UIResText:Draw()
  648.     local Position = self:Position()
  649.     --Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
  650.  
  651.     local screenW, screenH = GetScreenResolution()
  652.     local height = 1080
  653.     local ratio = screenW / screenH
  654.     local width = height * ratio
  655.  
  656.     Position.X, Position.Y = (Position.X) / width, (Position.Y) / height
  657.  
  658.     SetTextFont(self.Font)
  659.     SetTextScale(1.0, self.Scale)
  660.     SetTextColour(self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
  661.  
  662.     if self.DropShadow then
  663.         SetTextDropShadow()
  664.     end
  665.     if self.Outline then
  666.         SetTextOutline()
  667.     end
  668.  
  669.     if self.Alignment ~= nil then
  670.         if self.Alignment == 1 or self.Alignment == "Center" or self.Alignment == "Centre" then
  671.             SetTextCentre(true)
  672.         elseif self.Alignment == 2 or self.Alignment == "Right" then
  673.             SetTextRightJustify(true)
  674.             SetTextWrap(0, Position.X)
  675.         end
  676.     end
  677.  
  678.     if tonumber(self.WordWrap) then
  679.         if tonumber(self.WordWrap) ~= 0 then
  680.             SetTextWrap(Position.X, Position.X + (tonumber(self.WordWrap) / Resolution.Width))
  681.         end
  682.     end
  683.  
  684.     BeginTextCommandDisplayText("STRING")
  685.     AddLongString(self._Text)
  686.     EndTextCommandDisplayText(Position.X, Position.Y)
  687. end
  688.  
  689. function RenderText(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap)
  690.     Text = tostring(Text)
  691.     --X, Y = FormatXWYH(X, Y)
  692.  
  693.     local screenW, screenH = GetScreenResolution()
  694.     local height = 1080
  695.     local ratio = screenW / screenH
  696.     local width = height * ratio
  697.  
  698.     X, Y = (X) / width, (Y) / height
  699.  
  700.     SetTextFont(Font or 0)
  701.     SetTextScale(1.0, Scale or 0)
  702.     SetTextColour(R or 255, G or 255, B or 255, A or 255)
  703.  
  704.     if DropShadow then
  705.         SetTextDropShadow()
  706.     end
  707.     if Outline then
  708.         SetTextOutline()
  709.     end
  710.  
  711.     if Alignment ~= nil then
  712.         if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
  713.             SetTextCentre(true)
  714.         elseif Alignment == 2 or Alignment == "Right" then
  715.             SetTextRightJustify(true)
  716.             SetTextWrap(0, X)
  717.         end
  718.     end
  719.  
  720.     if tonumber(WordWrap) then
  721.         if tonumber(WordWrap) ~= 0 then
  722.             --WordWrap, _ = FormatXWYH(WordWrap, 0)
  723.             local xsize = (X + WordWrap) / width;
  724.             SetTextWrap(WordWrap, xsize)
  725.             --SetTextWrap(WordWrap, X - WordWrap)
  726.         end
  727.     end
  728.  
  729.     BeginTextCommandDisplayText("STRING")
  730.     AddLongString(Text)
  731.     EndTextCommandDisplayText(X, Y)
  732. end
  733.  
  734. --[[
  735.     Sprite.lua
  736.     Elements
  737. --]]
  738.  
  739. function Sprite.New(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
  740.     local _Sprite = {
  741.         TxtDictionary = tostring(TxtDictionary),
  742.         TxtName = tostring(TxtName),
  743.         X = tonumber(X) or 0,
  744.         Y = tonumber(Y) or 0,
  745.         Width = tonumber(Width) or 0,
  746.         Height = tonumber(Height) or 0,
  747.         Heading = tonumber(Heading) or 0,
  748.         _Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255},
  749.     }
  750.     return setmetatable(_Sprite, Sprite)
  751. end
  752.  
  753. function Sprite:Position(X, Y)
  754.     if tonumber(X) and tonumber(Y) then
  755.         self.X = tonumber(X)
  756.         self.Y = tonumber(Y)
  757.     else
  758.         return {X = self.X, Y = self.Y}
  759.     end
  760. end
  761.  
  762. function Sprite:Size(Width, Height)
  763.     if tonumber(Width) and tonumber(Width) then
  764.         self.Width = tonumber(Width)
  765.         self.Height = tonumber(Height)
  766.     else
  767.         return {Width = self.Width, Height = self.Height}
  768.     end
  769. end
  770.  
  771. function Sprite:Colour(R, G, B, A)
  772.     if tonumber(R) or tonumber(G) or tonumber(B) or tonumber(A) then
  773.         self._Colour.R = tonumber(R) or 255
  774.         self._Colour.B = tonumber(B) or 255
  775.         self._Colour.G = tonumber(G) or 255
  776.         self._Colour.A = tonumber(A) or 255
  777.     else
  778.         return self._Colour
  779.     end
  780. end
  781.  
  782. function Sprite:Draw()
  783.     if not HasStreamedTextureDictLoaded(self.TxtDictionary) then
  784.         RequestStreamedTextureDict(self.TxtDictionary, true)
  785.     end
  786.     local Position = self:Position()
  787.     local Size = self:Size()
  788.     --Size.Width, Size.Height = FormatXWYH(Size.Width, Size.Height)
  789.     --Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
  790.  
  791.     local screenW, screenH = GetScreenResolution()
  792.     local height = 1080
  793.     local ratio = screenW / screenH
  794.     local width = height * ratio
  795.  
  796.     local w, h = (Size.Width / width), (Size.Height / height)
  797.     local x, y = (Position.X / width) + w * 0.5, (Position.Y / height) + w * 0.5
  798.  
  799.     DrawSprite(self.TxtDictionary, self.TxtName, x, y, w, h, self.Heading, self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
  800.     --DrawSprite(self.TxtDictionary, self.TxtName, Position.X + Size.Width * 0.5, Position.Y + Size.Height * 0.5, Size.Width, Size.Height, self.Heading, self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
  801. end
  802.  
  803. function DrawTexture(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
  804.     if not HasStreamedTextureDictLoaded(tostring(TxtDictionary) or "") then
  805.         RequestStreamedTextureDict(tostring(TxtDictionary) or "", true)
  806.     end
  807.     X, Y, Width, Height = X or 0, Y or 0, Width or 0, Height or 0
  808.     --X, Y = FormatXWYH(X, Y)
  809.     --Width, Height = FormatXWYH(Width, Height)
  810.  
  811.     local screenW, screenH = GetScreenResolution()
  812.     local height = 1080
  813.     local ratio = screenW / screenH
  814.     local width = height * ratio
  815.  
  816.     local w, h = (Width / width), (Height / height)
  817.     local x, y = (X / width) + w * 0.5, (Y / height) + w * 0.5
  818.  
  819.     DrawSprite(tostring(TxtDictionary) or "", tostring(TxtName) or "", x, y, w, h, tonumber(Heading) or 0, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
  820.     --DrawSprite(tostring(TxtDictionary) or "", tostring(TxtName) or "", X + Width * 0.5, Y + Height * 0.5, Width, Height, tonumber(Heading) or 0, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
  821. end
  822.  
  823. --[[
  824.     StringMeasurer.lua
  825.     Elements
  826. --]]
  827.  
  828. function MeasureString(str)
  829.     local output = 0
  830.     for i = 1, GetCharacterCount(str), 1 do
  831.         if CharacterMap[string.sub(str, i, i)] then
  832.             output = output + CharacterMap[string.sub(str, i, i)] + 1
  833.         end
  834.     end
  835.     return output
  836. end
  837.  
  838. --[[
  839.     Badge.lua
  840.     Elements
  841. --]]
  842.  
  843. function GetBadgeTexture(Badge, Selected)
  844.     if BadgeTexture[Badge] then
  845.         return BadgeTexture[Badge](Selected)
  846.     else
  847.         return ""
  848.     end
  849. end
  850.  
  851. function GetBadgeDictionary(Badge, Selected)
  852.     if BadgeDictionary[Badge] then
  853.         return BadgeDictionary[Badge](Selected)
  854.     else
  855.         return "commonmenu"
  856.     end
  857. end
  858.  
  859. function GetBadgeColour(Badge, Selected)
  860.     if BadgeColour[Badge] then
  861.         return BadgeColour[Badge](Selected)
  862.     else
  863.         return 255, 255, 255, 255
  864.     end
  865. end
  866.  
  867. --[[
  868.     Colours.lua
  869.     Elements
  870. --]]
  871.  
  872. --[[
  873.     UIMenuItem.lua
  874.     Items
  875. --]]
  876.  
  877. function UIMenuItem.New(Text, Description)
  878.     _UIMenuItem = {
  879.         Rectangle = UIResRectangle.New(0, 0, 431, 38, 255, 255, 255, 20),
  880.         Text = UIResText.New(tostring(Text) or "", 8, 0, 0.33, 245, 245, 245, 255, 0),
  881.         _Description = tostring(Description) or "";
  882.         SelectedSprite = Sprite.New("commonmenu", "gradient_nav", 0, 0, 431, 38),
  883.         LeftBadge = { Sprite = Sprite.New("commonmenu", "", 0, 0, 40, 40), Badge = 0},
  884.         RightBadge = { Sprite = Sprite.New("commonmenu", "", 0, 0, 40, 40), Badge = 0},
  885.         Label = {
  886.             Text = UIResText.New("", 0, 0, 0.35, 245, 245, 245, 255, 0, "Right"),
  887.             MainColour = {R = 255, G = 255, B = 255, A = 255},
  888.             HighlightColour = {R = 0, G = 0, B = 0, A = 255},
  889.         },
  890.         _Selected = false,
  891.         _Hovered = false,
  892.         _Enabled = true,
  893.         _Offset = {X = 0, Y = 0},
  894.         ParentMenu = nil,
  895.         Activated = function(menu, item) end
  896.     }
  897.     return setmetatable(_UIMenuItem, UIMenuItem)
  898. end
  899.  
  900. function UIMenuItem:SetParentMenu(Menu)
  901.     if Menu() == "UIMenu" then
  902.         self.ParentMenu = Menu
  903.     else
  904.         return self.ParentMenu
  905.     end
  906. end
  907.  
  908. function UIMenuItem:Selected(bool)
  909.     if bool ~= nil then
  910.         self._Selected = tobool(bool)
  911.     else
  912.         return self._Selected
  913.     end
  914. end
  915.  
  916. function UIMenuItem:Hovered(bool)
  917.     if bool ~= nil then
  918.         self._Hovered = tobool(bool)
  919.     else
  920.         return self._Hovered
  921.     end
  922. end
  923.  
  924. function UIMenuItem:Enabled(bool)
  925.     if bool ~= nil then
  926.         self._Enabled = tobool(bool)
  927.     else
  928.         return self._Enabled
  929.     end
  930. end
  931.  
  932. function UIMenuItem:Description(str)
  933.     if tostring(str) and str ~= nil then
  934.         self._Description = tostring(str)
  935.     else
  936.         return self._Description
  937.     end
  938. end
  939.  
  940. function UIMenuItem:Offset(X, Y)
  941.     if tonumber(X) or tonumber(Y) then
  942.         if tonumber(X) then
  943.             self._Offset.X = tonumber(X)
  944.         end
  945.         if tonumber(Y) then
  946.             self._Offset.Y = tonumber(Y)
  947.         end
  948.     else
  949.         return self._Offset
  950.     end
  951. end
  952.  
  953. function UIMenuItem:Position(Y)
  954.     if tonumber(Y) then
  955.         self.Rectangle:Position(self._Offset.X, Y + 144 + self._Offset.Y)
  956.         self.SelectedSprite:Position(0 + self._Offset.X, Y + 144 + self._Offset.Y)
  957.         self.Text:Position(8 + self._Offset.X, Y + 147 + self._Offset.Y)
  958.         self.LeftBadge.Sprite:Position(0 + self._Offset.X, Y + 142 + self._Offset.Y)
  959.         self.RightBadge.Sprite:Position(385 + self._Offset.X, Y + 142 + self._Offset.Y)
  960.         self.Label.Text:Position(420 + self._Offset.X, Y + 148 + self._Offset.Y)
  961.     end
  962. end
  963.  
  964. function UIMenuItem:RightLabel(Text, MainColour, HighlightColour)
  965.     if tostring(Text) and Text ~= nil then
  966.         if type(MainColour) == "table" then
  967.             self.Label.MainColour = MainColour
  968.         end
  969.         if type(HighlightColour) == "table" then
  970.             self.Label.HighlightColour = HighlightColour
  971.         end
  972.         self.Label.Text:Text(tostring(Text))
  973.     else
  974.         return self.Label.Text:Text()
  975.     end
  976. end
  977.  
  978. function UIMenuItem:SetLeftBadge(Badge)
  979.     if tonumber(Badge) then
  980.         self.LeftBadge.Badge = tonumber(Badge)
  981.     end
  982. end
  983.  
  984. function UIMenuItem:SetRightBadge(Badge)
  985.     if tonumber(Badge) then
  986.         self.RightBadge.Badge = tonumber(Badge)
  987.     end
  988. end
  989.  
  990. function UIMenuItem:Text(Text)
  991.     if tostring(Text) and Text ~= nil then
  992.         self.Text:Text(tostring(Text))
  993.     else
  994.         return self.Text:Text()
  995.     end
  996. end
  997.  
  998. function UIMenuItem:Draw()
  999.     self.Rectangle:Size(431 + self.ParentMenu.WidthOffset, 38)
  1000.     self.SelectedSprite:Size(431 + self.ParentMenu.WidthOffset, 38)
  1001.  
  1002.     if self._Hovered and not self._Selected then
  1003.         self.Rectangle:Draw()
  1004.     end
  1005.  
  1006.     if self._Selected then
  1007.         self.SelectedSprite:Draw()
  1008.     end
  1009.  
  1010.     if self._Enabled then
  1011.         if self._Selected then
  1012.             self.Text:Colour(0, 0, 0, 255)
  1013.             self.Label.Text:Colour(self.Label.HighlightColour.R, self.Label.HighlightColour.G, self.Label.HighlightColour.B, self.Label.HighlightColour.A)
  1014.         else
  1015.             self.Text:Colour(245, 245, 245, 255)
  1016.             self.Label.Text:Colour(self.Label.MainColour.R, self.Label.MainColour.G, self.Label.MainColour.B, self.Label.MainColour.A)
  1017.         end
  1018.     else
  1019.         self.Text:Colour(163, 159, 148, 255)
  1020.         self.Label.Text:Colour(163, 159, 148, 255)
  1021.     end
  1022.  
  1023.     if self.LeftBadge.Badge == BadgeStyle.None then
  1024.         self.Text:Position(8 + self._Offset.X, self.Text.Y)
  1025.     else
  1026.         self.Text:Position(35 + self._Offset.X, self.Text.Y)
  1027.         self.LeftBadge.Sprite.TxtDictionary = GetBadgeDictionary(self.LeftBadge.Badge, self._Selected)
  1028.         self.LeftBadge.Sprite.TxtName = GetBadgeTexture(self.LeftBadge.Badge, self._Selected)
  1029.         self.LeftBadge.Sprite:Colour(GetBadgeColour(self.LeftBadge.Badge, self._Selected))
  1030.         self.LeftBadge.Sprite:Draw()
  1031.     end
  1032.  
  1033.     if self.RightBadge.Badge ~= BadgeStyle.None then
  1034.         self.RightBadge.Sprite:Position(385 + self._Offset.X + self.ParentMenu.WidthOffset, self.RightBadge.Sprite.Y)
  1035.         self.RightBadge.Sprite.TxtDictionary = GetBadgeDictionary(self.RightBadge.Badge, self._Selected)
  1036.         self.RightBadge.Sprite.TxtName = GetBadgeTexture(self.RightBadge.Badge, self._Selected)
  1037.         self.RightBadge.Sprite:Colour(GetBadgeColour(self.RightBadge.Badge, self._Selected))
  1038.         self.RightBadge.Sprite:Draw()
  1039.     end
  1040.  
  1041.     if self.Label.Text:Text() ~= "" and string.len(self.Label.Text:Text()) > 0 then
  1042.         self.Label.Text:Position(420 + self._Offset.X + self.ParentMenu.WidthOffset, self.Label.Text.Y)
  1043.         self.Label.Text:Draw()
  1044.     end
  1045.  
  1046.     self.Text:Draw()
  1047. end
  1048.  
  1049. --[[
  1050.     UIMenuCheckboxItem.lua
  1051.     Items
  1052. --]]
  1053.  
  1054. function UIMenuCheckboxItem.New(Text, Check, Description)
  1055.     local _UIMenuCheckboxItem = {
  1056.         Base = UIMenuItem.New(Text or "", Description or ""),
  1057.         CheckedSprite = Sprite.New("commonmenu", "shop_box_blank", 410, 95, 50, 50),
  1058.         Checked = tobool(Check),
  1059.         CheckboxEvent = function(menu, item, checked) end,
  1060.     }
  1061.     return setmetatable(_UIMenuCheckboxItem, UIMenuCheckboxItem)
  1062. end
  1063.  
  1064. function UIMenuCheckboxItem:SetParentMenu(Menu)
  1065.     if Menu() == "UIMenu" then
  1066.         self.Base.ParentMenu = Menu
  1067.     else
  1068.         return self.Base.ParentMenu
  1069.     end
  1070. end
  1071.  
  1072. function UIMenuCheckboxItem:Position(Y)
  1073.     if tonumber(Y) then
  1074.         self.Base:Position(Y)
  1075.         self.CheckedSprite:Position(380 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, Y + 138 + self.Base._Offset.Y)
  1076.     end
  1077. end
  1078.  
  1079. function UIMenuCheckboxItem:Selected(bool)
  1080.     if bool ~= nil then
  1081.         self.Base._Selected = tobool(bool)
  1082.     else
  1083.         return self.Base._Selected
  1084.     end
  1085. end
  1086.  
  1087. function UIMenuCheckboxItem:Hovered(bool)
  1088.     if bool ~= nil then
  1089.         self.Base._Hovered = tobool(bool)
  1090.     else
  1091.         return self.Base._Hovered
  1092.     end
  1093. end
  1094.  
  1095. function UIMenuCheckboxItem:Enabled(bool)
  1096.     if bool ~= nil then
  1097.         self.Base._Enabled = tobool(bool)
  1098.     else
  1099.         return self.Base._Enabled
  1100.     end
  1101. end
  1102.  
  1103. function UIMenuCheckboxItem:Description(str)
  1104.     if tostring(str) and str ~= nil then
  1105.         self.Base._Description = tostring(str)
  1106.     else
  1107.         return self.Base._Description
  1108.     end
  1109. end
  1110.  
  1111. function UIMenuCheckboxItem:Offset(X, Y)
  1112.     if tonumber(X) or tonumber(Y) then
  1113.         if tonumber(X) then
  1114.             self.Base._Offset.X = tonumber(X)
  1115.         end
  1116.         if tonumber(Y) then
  1117.             self.Base._Offset.Y = tonumber(Y)
  1118.         end
  1119.     else
  1120.         return self.Base._Offset
  1121.     end
  1122. end
  1123.  
  1124. function UIMenuCheckboxItem:Text(Text)
  1125.     if tostring(Text) and Text ~= nil then
  1126.         self.Base.Text:Text(tostring(Text))
  1127.     else
  1128.         return self.Base.Text:Text()
  1129.     end
  1130. end
  1131.  
  1132. function UIMenuCheckboxItem:SetLeftBadge()
  1133.     error("This item does not support badges")
  1134. end
  1135.  
  1136. function UIMenuCheckboxItem:SetRightBadge()
  1137.     error("This item does not support badges")
  1138. end
  1139.  
  1140. function UIMenuCheckboxItem:RightLabel()
  1141.     error("This item does not support a right label")
  1142. end
  1143.  
  1144. function UIMenuCheckboxItem:Draw()
  1145.     self.Base:Draw()
  1146.     self.CheckedSprite:Position(380 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, self.CheckedSprite.Y)
  1147.     if self.Base:Selected() then
  1148.         if self.Checked then
  1149.             self.CheckedSprite.TxtName = "shop_box_tickb"
  1150.         else
  1151.             self.CheckedSprite.TxtName = "shop_box_blankb"
  1152.         end
  1153.     else
  1154.         if self.Checked then
  1155.             self.CheckedSprite.TxtName = "shop_box_tick"
  1156.         else
  1157.             self.CheckedSprite.TxtName = "shop_box_blank"
  1158.         end
  1159.     end
  1160.     self.CheckedSprite:Draw()
  1161. end
  1162.  
  1163. --[[
  1164.     UIMenuListItem.lua
  1165.     Items
  1166. --]]
  1167.  
  1168. function UIMenuListItem.New(Text, Items, Index, Description)
  1169.     if type(Items) ~= "table" then Items = {} end
  1170.     if Index == 0 then Index = 1 end
  1171.     local _UIMenuListItem = {
  1172.         Base = UIMenuItem.New(Text or "", Description or ""),
  1173.         Items = Items,
  1174.         LeftArrow = Sprite.New("commonmenu", "arrowleft", 110, 105, 30, 30),
  1175.         RightArrow = Sprite.New("commonmenu", "arrowright", 280, 105, 30, 30),
  1176.         ItemText = UIResText.New("", 290, 104, 0.35, 255, 255, 255, 255, 0, "Right"),
  1177.         _Index = tonumber(Index) or 1,
  1178.         Panels = {},
  1179.         OnListChanged = function(menu, item, newindex) end,
  1180.         OnListSelected = function(menu, item, newindex) end,
  1181.     }
  1182.     return setmetatable(_UIMenuListItem, UIMenuListItem)
  1183. end
  1184.  
  1185. function UIMenuListItem:SetParentMenu(Menu)
  1186.     if Menu ~= nil and Menu() == "UIMenu" then
  1187.         self.Base.ParentMenu = Menu
  1188.     else
  1189.         return self.Base.ParentMenu
  1190.     end
  1191. end
  1192.  
  1193. function UIMenuListItem:Position(Y)
  1194.     if tonumber(Y) then
  1195.         self.LeftArrow:Position(300 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, 147 + Y + self.Base._Offset.Y)
  1196.         self.RightArrow:Position(400 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, 147 + Y + self.Base._Offset.Y)
  1197.         self.ItemText:Position(300 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, 147 + Y + self.Base._Offset.Y)
  1198.         self.Base:Position(Y)
  1199.     end
  1200. end
  1201.  
  1202. function UIMenuListItem:Selected(bool)
  1203.     if bool ~= nil then
  1204.         self.Base._Selected = tobool(bool)
  1205.     else
  1206.         return self.Base._Selected
  1207.     end
  1208. end
  1209.  
  1210. function UIMenuListItem:Hovered(bool)
  1211.     if bool ~= nil then
  1212.         self.Base._Hovered = tobool(bool)
  1213.     else
  1214.         return self.Base._Hovered
  1215.     end
  1216. end
  1217.  
  1218. function UIMenuListItem:Enabled(bool)
  1219.     if bool ~= nil then
  1220.         self.Base._Enabled = tobool(bool)
  1221.     else
  1222.         return self.Base._Enabled
  1223.     end
  1224. end
  1225.  
  1226. function UIMenuListItem:Description(str)
  1227.     if tostring(str) and str ~= nil then
  1228.         self.Base._Description = tostring(str)
  1229.     else
  1230.         return self.Base._Description
  1231.     end
  1232. end
  1233.  
  1234. function UIMenuListItem:Offset(X, Y)
  1235.     if tonumber(X) or tonumber(Y) then
  1236.         if tonumber(X) then
  1237.             self.Base._Offset.X = tonumber(X)
  1238.         end
  1239.         if tonumber(Y) then
  1240.             self.Base._Offset.Y = tonumber(Y)
  1241.         end
  1242.     else
  1243.         return self.Base._Offset
  1244.     end
  1245. end
  1246.  
  1247. function UIMenuListItem:Text(Text)
  1248.     if tostring(Text) and Text ~= nil then
  1249.         self.Base.Text:Text(tostring(Text))
  1250.     else
  1251.         return self.Base.Text:Text()
  1252.     end
  1253. end
  1254.  
  1255. function UIMenuListItem:Index(Index)
  1256.     if tonumber(Index) then
  1257.         if tonumber(Index) > #self.Items then
  1258.             self._Index = 1
  1259.         elseif tonumber(Index) < 1 then
  1260.             self._Index = #self.Items
  1261.         else
  1262.             self._Index = tonumber(Index)
  1263.         end
  1264.     else
  1265.         return self._Index
  1266.     end
  1267. end
  1268.  
  1269. function UIMenuListItem:ItemToIndex(Item)
  1270.     for i = 1, #self.Items do
  1271.         if type(Item) == type(self.Items[i]) and Item == self.Items[i] then
  1272.             return i
  1273.         elseif type(self.Items[i]) == "table" and (type(Item) == type(self.Items[i].Name) or type(Item) == type(self.Items[i].Value)) and (Item == self.Items[i].Name or Item == self.Items[i].Value) then
  1274.             return i
  1275.         end
  1276.     end
  1277. end
  1278.  
  1279. function UIMenuListItem:IndexToItem(Index)
  1280.     if tonumber(Index) then
  1281.         if tonumber(Index) == 0 then Index = 1 end
  1282.         if self.Items[tonumber(Index)] then
  1283.             return self.Items[tonumber(Index)]
  1284.         end
  1285.     end
  1286. end
  1287.  
  1288. function UIMenuListItem:SetLeftBadge()
  1289.     error("This item does not support badges")
  1290. end
  1291.  
  1292. function UIMenuListItem:SetRightBadge()
  1293.     error("This item does not support badges")
  1294. end
  1295.  
  1296. function UIMenuListItem:RightLabel()
  1297.     error("This item does not support a right label")
  1298. end
  1299.  
  1300. function UIMenuListItem:AddPanel(Panel)
  1301.     if Panel() == "UIMenuPanel" then
  1302.         table.insert(self.Panels, Panel)
  1303.         Panel:SetParentItem(self)
  1304.     end
  1305. end
  1306.  
  1307. function UIMenuListItem:RemovePanelAt(Index)
  1308.     if tonumber(Index) then
  1309.         if self.Panels[Index] then
  1310.             table.remove(self.Panels, tonumber(Index))
  1311.         end
  1312.     end
  1313. end
  1314.  
  1315. function UIMenuListItem:FindPanelIndex(Panel)
  1316.     if Panel() == "UIMenuPanel" then
  1317.         for Index = 1, #self.Panels do
  1318.             if self.Panels[Index] == Panel then
  1319.                 return Index
  1320.             end
  1321.         end
  1322.     end
  1323.     return nil
  1324. end
  1325.  
  1326. function UIMenuListItem:FindPanelItem()
  1327.     for Index = #self.Items, 1, -1 do
  1328.         if self.Items[Index].Panel then
  1329.             return Index
  1330.         end
  1331.     end
  1332.     return nil
  1333. end
  1334.  
  1335. function UIMenuListItem:Draw()
  1336.     self.Base:Draw()
  1337.  
  1338.     if self:Enabled() then
  1339.         if self:Selected() then
  1340.             self.ItemText:Colour(0, 0, 0, 255)
  1341.             self.LeftArrow:Colour(0, 0, 0, 255)
  1342.             self.RightArrow:Colour(0, 0, 0, 255)
  1343.         else
  1344.             self.ItemText:Colour(245, 245, 245, 255)
  1345.             self.LeftArrow:Colour(245, 245, 245, 255)
  1346.             self.RightArrow:Colour(245, 245, 245, 255)
  1347.         end
  1348.     else
  1349.         self.ItemText:Colour(163, 159, 148, 255)
  1350.         self.LeftArrow:Colour(163, 159, 148, 255)
  1351.         self.RightArrow:Colour(163, 159, 148, 255)
  1352.     end
  1353.  
  1354.     local Text = (type(self.Items[self._Index]) == "table") and tostring(self.Items[self._Index].Name) or tostring(self.Items[self._Index])
  1355.     local Offset = MeasureStringWidth(Text, 0, 0.35)
  1356.  
  1357.     self.ItemText:Text(Text)
  1358.     self.LeftArrow:Position(378 - Offset + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, self.LeftArrow.Y)
  1359.  
  1360.     if self:Selected() then
  1361.         self.LeftArrow:Draw()
  1362.         self.RightArrow:Draw()
  1363.         self.ItemText:Position(403 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, self.ItemText.Y)
  1364.     else
  1365.         self.ItemText:Position(418 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, self.ItemText.Y)
  1366.     end
  1367.  
  1368.     self.ItemText:Draw()
  1369. end
  1370.  
  1371. --[[
  1372.     UIMenuSliderItem.lua
  1373.     Items
  1374. --]]
  1375.  
  1376. function UIMenuSliderItem.New(Text, Items, Index, Description, Divider)
  1377.     if type(Items) ~= "table" then Items = {} end
  1378.     if Index == 0 then Index = 1 end
  1379.     local _UIMenuSliderItem = {
  1380.         Base = UIMenuItem.New(Text or "", Description or ""),
  1381.         Items = Items,
  1382.         ShowDivider = tobool(Divider),
  1383.         LeftArrow = Sprite.New("commonmenutu", "arrowleft", 0, 105, 15, 15),
  1384.         RightArrow = Sprite.New("commonmenutu", "arrowright", 0, 105, 15, 15),
  1385.         Background = UIResRectangle.New(0, 0, 150, 9, 4, 32, 57, 255),
  1386.         Slider = UIResRectangle.New(0, 0, 75, 9, 57, 116, 200, 255),
  1387.         Divider = UIResRectangle.New(0, 0, 2.5, 20, 245, 245, 245, 255),
  1388.         _Index = tonumber(Index) or 1,
  1389.         OnSliderChanged = function(menu, item, newindex) end,
  1390.         OnSliderSelected = function(menu, item, newindex) end,
  1391.     }
  1392.     return setmetatable(_UIMenuSliderItem, UIMenuSliderItem)
  1393. end
  1394.  
  1395. function UIMenuSliderItem:SetParentMenu(Menu)
  1396.     if Menu() == "UIMenu" then
  1397.         self.Base.ParentMenu = Menu
  1398.     else
  1399.         return self.Base.ParentMenu
  1400.     end
  1401. end
  1402.  
  1403. function UIMenuSliderItem:Position(Y)
  1404.     if tonumber(Y) then
  1405.         self.Background:Position(250 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, Y + 158.5 + self.Base._Offset.Y)
  1406.         self.Slider:Position(250 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, Y + 158.5 + self.Base._Offset.Y)
  1407.         self.Divider:Position(323.5 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, Y + 153 + self.Base._Offset.Y)
  1408.         self.LeftArrow:Position(235 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, 155.5 + Y + self.Base._Offset.Y)
  1409.         self.RightArrow:Position(400 + self.Base._Offset.X + self.Base.ParentMenu.WidthOffset, 155.5 + Y + self.Base._Offset.Y)
  1410.         self.Base:Position(Y)
  1411.     end
  1412. end
  1413.  
  1414. function UIMenuSliderItem:Selected(bool)
  1415.     if bool ~= nil then
  1416.         self.Base._Selected = tobool(bool)
  1417.     else
  1418.         return self.Base._Selected
  1419.     end
  1420. end
  1421.  
  1422. function UIMenuSliderItem:Hovered(bool)
  1423.     if bool ~= nil then
  1424.         self.Base._Hovered = tobool(bool)
  1425.     else
  1426.         return self.Base._Hovered
  1427.     end
  1428. end
  1429.  
  1430. function UIMenuSliderItem:Enabled(bool)
  1431.     if bool ~= nil then
  1432.         self.Base._Enabled = tobool(bool)
  1433.     else
  1434.         return self.Base._Enabled
  1435.     end
  1436. end
  1437.  
  1438. function UIMenuSliderItem:Description(str)
  1439.     if tostring(str) and str ~= nil then
  1440.         self.Base._Description = tostring(str)
  1441.     else
  1442.         return self.Base._Description
  1443.     end
  1444. end
  1445.  
  1446. function UIMenuSliderItem:Offset(X, Y)
  1447.     if tonumber(X) or tonumber(Y) then
  1448.         if tonumber(X) then
  1449.             self.Base._Offset.X = tonumber(X)
  1450.         end
  1451.         if tonumber(Y) then
  1452.             self.Base._Offset.Y = tonumber(Y)
  1453.         end
  1454.     else
  1455.         return self.Base._Offset
  1456.     end
  1457. end
  1458.  
  1459. function UIMenuSliderItem:Text(Text)
  1460.     if tostring(Text) and Text ~= nil then
  1461.         self.Base.Text:Text(tostring(Text))
  1462.     else
  1463.         return self.Base.Text:Text()
  1464.     end
  1465. end
  1466.  
  1467. function UIMenuSliderItem:Index(Index)
  1468.     if tonumber(Index) then
  1469.         if tonumber(Index) > #self.Items then
  1470.             self._Index = 1
  1471.         elseif tonumber(Index) < 1 then
  1472.             self._Index = #self.Items
  1473.         else
  1474.             self._Index = tonumber(Index)
  1475.         end
  1476.     else
  1477.         return self._Index
  1478.     end
  1479. end
  1480.  
  1481. function UIMenuSliderItem:ItemToIndex(Item)
  1482.     for i = 1, #self.Items do
  1483.         if type(Item) == type(self.Items[i]) and Item == self.Items[i] then
  1484.             return i
  1485.         end
  1486.     end
  1487. end
  1488.  
  1489. function UIMenuSliderItem:IndexToItem(Index)
  1490.     if tonumber(Index) then
  1491.         if tonumber(Index) == 0 then Index = 1 end
  1492.         if self.Items[tonumber(Index)] then
  1493.             return self.Items[tonumber(Index)]
  1494.         end
  1495.     end
  1496. end
  1497.  
  1498. function UIMenuSliderItem:SetLeftBadge()
  1499.     error("This item does not support badges")
  1500. end
  1501.  
  1502. function UIMenuSliderItem:SetRightBadge()
  1503.     error("This item does not support badges")
  1504. end
  1505.  
  1506. function UIMenuSliderItem:RightLabel()
  1507.     error("This item does not support a right label")
  1508. end
  1509.  
  1510. function UIMenuSliderItem:Draw()
  1511.     self.Base:Draw()
  1512.  
  1513.     if self:Enabled() then
  1514.         if self:Selected() then
  1515.             self.LeftArrow:Colour(0, 0, 0, 255)
  1516.             self.RightArrow:Colour(0, 0, 0, 255)
  1517.         else
  1518.             self.LeftArrow:Colour(245, 245, 245, 255)
  1519.             self.RightArrow:Colour(245, 245, 245, 255)
  1520.         end
  1521.     else
  1522.         self.LeftArrow:Colour(163, 159, 148, 255)
  1523.         self.RightArrow:Colour(163, 159, 148, 255)
  1524.     end
  1525.    
  1526.     local Offset = ((self.Background.Width - self.Slider.Width)/(#self.Items - 1)) * (self._Index-1)
  1527.  
  1528.     self.Slider:Position(250 + self.Base._Offset.X + Offset + self.Base.ParentMenu.WidthOffset, self.Slider.Y)
  1529.  
  1530.     if self:Selected() then
  1531.         self.LeftArrow:Draw()
  1532.         self.RightArrow:Draw()
  1533.     end
  1534.  
  1535.     self.Background:Draw()
  1536.     self.Slider:Draw()
  1537.     if self.ShowDivider then
  1538.         self.Divider:Draw()
  1539.     end
  1540. end
  1541.  
  1542. --[[
  1543.     UIMenuColouredItem.lua
  1544.     Items
  1545. --]]
  1546.  
  1547. function UIMenuColouredItem.New(Text, Description, MainColour, HighlightColour)
  1548.     if type(Colour) ~= "table" then Colour = {R = 0, G = 0, B = 0, A = 255} end
  1549.     if type(HighlightColour) ~= "table" then Colour = {R = 255, G = 255, B = 255, A = 255} end
  1550.     local _UIMenuColouredItem = {
  1551.         Base = UIMenuItem.New(Text or "", Description or ""),
  1552.         Rectangle = UIResRectangle.New(0, 0, 431, 38, MainColour.R, MainColour.G, MainColour.B, MainColour.A),
  1553.         MainColour = MainColour,
  1554.         HighlightColour = HighlightColour,
  1555.         Activated = function(menu, item) end,
  1556.     }
  1557.     _UIMenuColouredItem.Base.SelectedSprite:Colour(HighlightColour.R, HighlightColour.G, HighlightColour.B, HighlightColour.A)
  1558.     return setmetatable(_UIMenuColouredItem, UIMenuColouredItem)
  1559. end
  1560.  
  1561. function UIMenuColouredItem:SetParentMenu(Menu)
  1562.     if Menu() == "UIMenu" then
  1563.         self.Base.ParentMenu = Menu
  1564.     else
  1565.         return self.Base.ParentMenu
  1566.     end
  1567. end
  1568.  
  1569. function UIMenuColouredItem:Position(Y)
  1570.     if tonumber(Y) then
  1571.         self.Base:Position(Y)
  1572.         self.Rectangle:Position(self.Base._Offset.X, Y + 144 + self.Base._Offset.Y)
  1573.     end
  1574. end
  1575.  
  1576. function UIMenuColouredItem:Selected(bool)
  1577.     if bool ~= nil then
  1578.         self.Base._Selected = tobool(bool)
  1579.     else
  1580.         return self.Base._Selected
  1581.     end
  1582. end
  1583.  
  1584. function UIMenuColouredItem:Hovered(bool)
  1585.     if bool ~= nil then
  1586.         self.Base._Hovered = tobool(bool)
  1587.     else
  1588.         return self.Base._Hovered
  1589.     end
  1590. end
  1591.  
  1592. function UIMenuColouredItem:Enabled(bool)
  1593.     if bool ~= nil then
  1594.         self.Base._Enabled = tobool(bool)
  1595.     else
  1596.         return self.Base._Enabled
  1597.     end
  1598. end
  1599.  
  1600. function UIMenuColouredItem:Description(str)
  1601.     if tostring(str) and str ~= nil then
  1602.         self.Base._Description = tostring(str)
  1603.     else
  1604.         return self.Base._Description
  1605.     end
  1606. end
  1607.  
  1608. function UIMenuColouredItem:Offset(X, Y)
  1609.     if tonumber(X) or tonumber(Y) then
  1610.         if tonumber(X) then
  1611.             self.Base._Offset.X = tonumber(X)
  1612.         end
  1613.         if tonumber(Y) then
  1614.             self.Base._Offset.Y = tonumber(Y)
  1615.         end
  1616.     else
  1617.         return self.Base._Offset
  1618.     end
  1619. end
  1620.  
  1621. function UIMenuColouredItem:Text(Text)
  1622.     if tostring(Text) and Text ~= nil then
  1623.         self.Base.Text:Text(tostring(Text))
  1624.     else
  1625.         return self.Base.Text:Text()
  1626.     end
  1627. end
  1628.  
  1629. function UIMenuColouredItem:RightLabel(Text, MainColour, HighlightColour)
  1630.     if tostring(Text) and Text ~= nil then
  1631.         if type(MainColour) == "table" then
  1632.             self.Base.Label.MainColour = MainColour
  1633.         end
  1634.         if type(HighlightColour) == "table" then
  1635.             self.Base.Label.HighlightColour = HighlightColour
  1636.         end
  1637.         self.Base.Label.Text:Text(tostring(Text))
  1638.     else
  1639.         return self.Base.Label.Text:Text()
  1640.     end
  1641. end
  1642.  
  1643. function UIMenuColouredItem:SetLeftBadge(Badge)
  1644.     if tonumber(Badge) then
  1645.         self.Base.LeftBadge.Badge = tonumber(Badge)
  1646.     end
  1647. end
  1648.  
  1649. function UIMenuColouredItem:SetRightBadge(Badge)
  1650.     if tonumber(Badge) then
  1651.         self.Base.RightBadge.Badge = tonumber(Badge)
  1652.     end
  1653. end
  1654.  
  1655. function UIMenuColouredItem:Draw()
  1656.     self.Rectangle:Draw()
  1657.     self.Base:Draw()
  1658. end
  1659.  
  1660. --[[
  1661.     UIMenuHeritageWindow.lua
  1662.     Windows
  1663. --]]
  1664.  
  1665. function UIMenuHeritageWindow.New(Mum, Dad)
  1666.     if not tonumber(Mum) then Mum = 0 end
  1667.     if not (Mum >= 0 and Mum <= 21) then Mum = 0 end
  1668.     if not tonumber(Dad) then Dad = 0 end
  1669.     if not (Dad >= 0 and Dad <= 23) then Dad = 0 end
  1670.     _UIMenuHeritageWindow = {
  1671.         Background = Sprite.New("pause_menu_pages_char_mom_dad", "mumdadbg", 0, 0, 431, 228), -- Background is required, must be a sprite or a rectangle.
  1672.         MumSprite = Sprite.New("char_creator_portraits", ((Mum < 21) and "female_"..Mum or "special_female_"..(tonumber(string.sub(Mum, 2, 2)) - 1)), 0, 0, 228, 228),
  1673.         DadSprite = Sprite.New("char_creator_portraits", ((Dad < 21) and "male_"..Dad or "special_male_"..(tonumber(string.sub(Dad, 2, 2)) - 1)), 0, 0, 228, 228),
  1674.         Mum = Mum,
  1675.         Dad = Dad,
  1676.         _Offset = {X = 0, Y = 0}, -- required
  1677.         ParentMenu = nil, -- required
  1678.     }
  1679.     return setmetatable(_UIMenuHeritageWindow, UIMenuHeritageWindow)
  1680. end
  1681.  
  1682. function UIMenuHeritageWindow:SetParentMenu(Menu) -- required
  1683.     if Menu() == "UIMenu" then
  1684.         self.ParentMenu = Menu
  1685.     else
  1686.         return self.ParentMenu
  1687.     end
  1688. end
  1689.  
  1690. function UIMenuHeritageWindow:Offset(X, Y) -- required
  1691.     if tonumber(X) or tonumber(Y) then
  1692.         if tonumber(X) then
  1693.             self._Offset.X = tonumber(X)
  1694.         end
  1695.         if tonumber(Y) then
  1696.             self._Offset.Y = tonumber(Y)
  1697.         end
  1698.     else
  1699.         return self._Offset
  1700.     end
  1701. end
  1702.  
  1703. function UIMenuHeritageWindow:Position(Y) -- required
  1704.     if tonumber(Y) then
  1705.         self.Background:Position(self._Offset.X, 144 + Y + self._Offset.Y)
  1706.         self.MumSprite:Position(self._Offset.X + (self.ParentMenu.WidthOffset/2) + 25, 144 + Y + self._Offset.Y)
  1707.         self.DadSprite:Position(self._Offset.X + (self.ParentMenu.WidthOffset/2) + 195, 144 + Y + self._Offset.Y)
  1708.     end
  1709. end
  1710.  
  1711. function UIMenuHeritageWindow:Index(Mum, Dad)
  1712.     if not tonumber(Mum) then Mum = self.Mum end
  1713.     if not (Mum >= 0 and Mum <= 21) then Mum = self.Mum end
  1714.     if not tonumber(Dad) then Dad = self.Dad end
  1715.     if not (Dad >= 0 and Dad <= 23) then Dad = self.Dad end
  1716.  
  1717.     self.Mum = Mum
  1718.     self.Dad = Dad
  1719.  
  1720.     self.MumSprite.TxtName = ((self.Mum < 21) and "female_"..self.Mum or "special_female_"..(tonumber(string.sub(Mum, 2, 2)) - 1))
  1721.     self.DadSprite.TxtName = ((self.Dad < 21) and "male_"..self.Dad or "special_male_"..(tonumber(string.sub(Dad, 2, 2)) - 1))
  1722. end
  1723.  
  1724. function UIMenuHeritageWindow:Draw() -- required
  1725.     self.Background:Size(431 + self.ParentMenu.WidthOffset, 228)
  1726.     self.Background:Draw()
  1727.     self.DadSprite:Draw()
  1728.     self.MumSprite:Draw()
  1729. end
  1730.  
  1731. --[[
  1732.     UIMenuGridPanel.lua
  1733.     Panels
  1734. --]]
  1735.  
  1736. function UIMenuGridPanel.New(TopText, LeftText, RightText, BottomText)
  1737.     _UIMenuGridPanel = {
  1738.         Data = {
  1739.             Enabled = true,
  1740.         },
  1741.         Background = Sprite.New("commonmenu", "gradient_bgd", 0, 0, 431, 275),
  1742.         Grid = Sprite.New("pause_menu_pages_char_mom_dad", "nose_grid", 0, 0, 200, 200, 0),
  1743.         Circle = Sprite.New("mpinventory","in_world_circle", 0, 0, 20, 20, 0),
  1744.         Audio = {Slider = "CONTINUOUS_SLIDER", Library = "HUD_FRONTEND_DEFAULT_SOUNDSET", Id = nil},
  1745.         ParentItem = nil,
  1746.         Text = {
  1747.             Top = UIResText.New(TopText or "Top", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  1748.             Left = UIResText.New(LeftText or "Left", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  1749.             Right = UIResText.New(RightText or "Right", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  1750.             Bottom = UIResText.New(BottomText or "Bottom", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  1751.         },
  1752.     }
  1753.  
  1754.     return setmetatable(_UIMenuGridPanel, UIMenuGridPanel)
  1755. end
  1756.  
  1757. function UIMenuGridPanel:SetParentItem(Item) -- required
  1758.     if Item() == "UIMenuItem" then
  1759.         self.ParentItem = Item
  1760.     else
  1761.         return self.ParentItem
  1762.     end
  1763. end
  1764.  
  1765. function UIMenuGridPanel:Enabled(Enabled)
  1766.     if type(Enabled) == "boolean" then
  1767.         self.Data.Enabled = Enabled
  1768.     else
  1769.         return self.Data.Enabled
  1770.     end
  1771. end
  1772.  
  1773. function UIMenuGridPanel:CirclePosition(X, Y)
  1774.     if tonumber(X) and tonumber(Y) then
  1775.         self.Circle.X = (self.Grid.X + 20) + ((self.Grid.Width - 40) * ((X >= 0.0 and X <= 1.0) and X or 0.0)) - (self.Circle.Width/2)
  1776.         self.Circle.Y = (self.Grid.Y + 20) + ((self.Grid.Height - 40) * ((Y >= 0.0 and Y <= 1.0) and Y or 0.0)) - (self.Circle.Height/2)
  1777.     else
  1778.         return math.round((self.Circle.X - (self.Grid.X + 20) + (self.Circle.Width/2))/(self.Grid.Width - 40), 2), math.round((self.Circle.Y - (self.Grid.Y + 20) + (self.Circle.Height/2))/(self.Grid.Height - 40), 2)
  1779.     end
  1780. end
  1781.  
  1782. function UIMenuGridPanel:Position(Y) -- required
  1783.     if tonumber(Y) then
  1784.         local ParentOffsetX, ParentOffsetWidth = self.ParentItem:Offset().X, self.ParentItem:SetParentMenu().WidthOffset
  1785.         self.Background:Position(ParentOffsetX, Y)
  1786.         self.Grid:Position(ParentOffsetX + 115.5 + (ParentOffsetWidth/2), 37.5 + Y)
  1787.         self.Text.Top:Position(ParentOffsetX + 215.5 + (ParentOffsetWidth/2), 5 + Y)
  1788.         self.Text.Left:Position(ParentOffsetX + 57.75 + (ParentOffsetWidth/2), 120 + Y)
  1789.         self.Text.Right:Position(ParentOffsetX + 373.25 + (ParentOffsetWidth/2), 120 + Y)
  1790.         self.Text.Bottom:Position(ParentOffsetX + 215.5 + (ParentOffsetWidth/2), 240 + Y)
  1791.  
  1792.         if not self.CircleLocked then
  1793.             self.CircleLocked = true
  1794.             self:CirclePosition(0.5, 0.5)
  1795.         end
  1796.     end
  1797. end
  1798.  
  1799. function UIMenuGridPanel:UpdateParent(X, Y)
  1800.     local _, ParentType = self.ParentItem()
  1801.     if ParentType == "UIMenuListItem" then
  1802.         local PanelItemIndex = self.ParentItem:FindPanelItem()
  1803.         if PanelItemIndex then
  1804.             self.ParentItem.Items[PanelItemIndex].Value[self.ParentItem:FindPanelIndex(self)] = {X = X, Y = Y}
  1805.             self.ParentItem:Index(PanelItemIndex)
  1806.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  1807.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  1808.         else
  1809.             local PanelIndex = self.ParentItem:FindPanelIndex(self)
  1810.             for Index = 1, #self.ParentItem.Items do
  1811.                 if type(self.ParentItem.Items[Index]) == "table" then
  1812.                     if not self.ParentItem.Items[Index].Panels then self.ParentItem.Items[Index].Panels = {} end
  1813.                     self.ParentItem.Items[Index].Panels[PanelIndex] = {X = X, Y = Y}
  1814.                 else
  1815.                     self.ParentItem.Items[Index] = {Name = tostring(self.ParentItem.Items[Index]), Value = self.ParentItem.Items[Index], Panels = {[PanelIndex] = {X = X, Y = Y}}}
  1816.                 end
  1817.             end
  1818.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  1819.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)    
  1820.         end
  1821.     end
  1822. end
  1823.  
  1824. function UIMenuGridPanel:Functions()
  1825.     local SafeZone = {X = 0, Y = 0}
  1826.     if self.ParentItem:SetParentMenu().Settings.ScaleWithSafezone then
  1827.        SafeZone = GetSafeZoneBounds()
  1828.     end
  1829.  
  1830.     if IsMouseInBounds(self.Grid.X + 20 + SafeZone.X, self.Grid.Y + 20 + SafeZone.Y, self.Grid.Width - 40, self.Grid.Height - 40) then
  1831.         if IsDisabledControlJustPressed(0, 24) then
  1832.             if not self.Pressed then
  1833.                 self.Pressed = true
  1834.                 Citizen.CreateThread(function()
  1835.                     self.Audio.Id = GetSoundId()
  1836.                     PlaySoundFrontend(self.Audio.Id, self.Audio.Slider, self.Audio.Library, 1)
  1837.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(self.Grid.X + 20 + SafeZone.X, self.Grid.Y + 20 + SafeZone.Y, self.Grid.Width - 40, self.Grid.Height - 40) do
  1838.                         Citizen.Wait(0)
  1839.                         local CursorX, CursorY = math.round(GetControlNormal(0, 239) * 1920) - SafeZone.X - (self.Circle.Width/2), math.round(GetControlNormal(0, 240) * 1080) - SafeZone.Y - (self.Circle.Height/2)
  1840.  
  1841.                         self.Circle:Position(((CursorX > (self.Grid.X + 10 + self.Grid.Width - 40)) and (self.Grid.X + 10 + self.Grid.Width - 40) or ((CursorX < (self.Grid.X + 20 - (self.Circle.Width/2))) and (self.Grid.X + 20 - (self.Circle.Width/2)) or CursorX)), ((CursorY > (self.Grid.Y + 10 + self.Grid.Height - 40)) and (self.Grid.Y + 10 + self.Grid.Height - 40) or ((CursorY < (self.Grid.Y + 20 - (self.Circle.Height/2))) and (self.Grid.Y + 20 - (self.Circle.Height/2)) or CursorY)))
  1842.                     end
  1843.                     StopSound(self.Audio.Id)
  1844.                     ReleaseSoundId(self.Audio.Id)
  1845.                     self.Pressed = false
  1846.                 end)
  1847.                 Citizen.CreateThread(function()
  1848.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(self.Grid.X + 20 + SafeZone.X, self.Grid.Y + 20 + SafeZone.Y, self.Grid.Width - 40, self.Grid.Height - 40) do
  1849.                         Citizen.Wait(75)
  1850.                         local ResultX, ResultY = math.round((self.Circle.X - (self.Grid.X + 20) + (self.Circle.Width/2))/(self.Grid.Width - 40), 2), math.round((self.Circle.Y - (self.Grid.Y + 20) + (self.Circle.Height/2))/(self.Grid.Height - 40), 2)
  1851.  
  1852.                         self:UpdateParent(((ResultX >= 0.0 and ResultX <= 1.0) and ResultX or ((ResultX <= 0) and 0.0) or 1.0), ((ResultY >= 0.0 and ResultY <= 1.0) and ResultY or ((ResultY <= 0) and 0.0) or 1.0))
  1853.                     end
  1854.                 end)
  1855.             end
  1856.         end
  1857.     end
  1858. end
  1859.  
  1860. function UIMenuGridPanel:Draw() -- required
  1861.     if self.Data.Enabled then
  1862.         self.Background:Size(431 + self.ParentItem:SetParentMenu().WidthOffset, 275)
  1863.  
  1864.         self.Background:Draw()
  1865.         self.Grid:Draw()
  1866.         self.Circle:Draw()
  1867.         self.Text.Top:Draw()
  1868.         self.Text.Left:Draw()
  1869.         self.Text.Right:Draw()
  1870.         self.Text.Bottom:Draw()
  1871.         self:Functions()
  1872.     end
  1873. end
  1874.  
  1875. --[[
  1876.     UIMenuColourPanel.lua
  1877.     Panels
  1878. --]]
  1879.  
  1880. UIMenuColourPanel = setmetatable({}, UIMenuColourPanel)
  1881. UIMenuColourPanel.__index = UIMenuColourPanel
  1882. UIMenuColourPanel.__call = function() return "UIMenuPanel", "UIMenuColourPanel" end
  1883.  
  1884. function UIMenuColourPanel.New(Title, Colours)
  1885.     _UIMenuColourPanel = {
  1886.         Data = {
  1887.             Pagination = {
  1888.                 Min = 1,
  1889.                 Max = 8,
  1890.                 Total = 8,
  1891.             },
  1892.             Index = 1000,
  1893.             Items = Colours,
  1894.             Title = Title or "Title",
  1895.             Enabled = true,
  1896.         },
  1897.         Background = Sprite.New("commonmenu", "gradient_bgd", 0, 0, 431, 112),
  1898.         Bar = {},
  1899.         LeftArrow = Sprite.New("commonmenu", "arrowleft", 0, 0, 30, 30),
  1900.         RightArrow = Sprite.New("commonmenu", "arrowright", 0, 0, 30, 30),
  1901.         SelectedRectangle = UIResRectangle.New(0, 0, 44.5, 8),
  1902.         Text = UIResText.New(Title.." (1 of "..#Colours..")" or "Title".." (1 of "..#Colours..")", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  1903.         ParentItem = nil,
  1904.     }
  1905.  
  1906.     for Index = 1, #Colours do
  1907.         if Index < 10 then
  1908.             table.insert(_UIMenuColourPanel.Bar, UIResRectangle.New(0, 0, 44.5, 44.5, table.unpack(Colours[Index])))
  1909.         else
  1910.             break
  1911.         end
  1912.     end
  1913.  
  1914.     if #_UIMenuColourPanel.Data.Items ~= 0 then
  1915.         _UIMenuColourPanel.Data.Index = 1000 - (1000 % #_UIMenuColourPanel.Data.Items)
  1916.         _UIMenuColourPanel.Data.Pagination.Max = _UIMenuColourPanel.Data.Pagination.Total + 1
  1917.         _UIMenuColourPanel.Data.Pagination.Min = 0
  1918.     end
  1919.     return setmetatable(_UIMenuColourPanel, UIMenuColourPanel)
  1920. end
  1921.  
  1922. function UIMenuColourPanel:SetParentItem(Item) -- required
  1923.     if Item() == "UIMenuItem" then
  1924.         self.ParentItem = Item
  1925.     else
  1926.         return self.ParentItem
  1927.     end
  1928. end
  1929.  
  1930. function UIMenuColourPanel:Enabled(Enabled)
  1931.     if type(Enabled) == "boolean" then
  1932.         self.Data.Enabled = Enabled
  1933.     else
  1934.         return self.Data.Enabled
  1935.     end
  1936. end
  1937.  
  1938. function UIMenuColourPanel:Position(Y) -- required
  1939.     if tonumber(Y) then
  1940.         local ParentOffsetX, ParentOffsetWidth = self.ParentItem:Offset().X, self.ParentItem:SetParentMenu().WidthOffset
  1941.  
  1942.         self.Background:Position(ParentOffsetX, Y)
  1943.         for Index = 1, #self.Bar do
  1944.             self.Bar[Index]:Position(15 + (44.5 * (Index - 1)) + ParentOffsetX + (ParentOffsetWidth/2), 55 + Y)
  1945.         end
  1946.         self.SelectedRectangle:Position(15 + (44.5 * ((self:CurrentSelection() - self.Data.Pagination.Min) - 1)) + ParentOffsetX + (ParentOffsetWidth/2), 47 + Y)
  1947.         self.LeftArrow:Position(7.5 + ParentOffsetX + (ParentOffsetWidth/2), 15 + Y)
  1948.         self.RightArrow:Position(393.5 + ParentOffsetX + (ParentOffsetWidth/2), 15 + Y)
  1949.         self.Text:Position(215.5 + ParentOffsetX + (ParentOffsetWidth/2), 15 + Y)
  1950.     end
  1951. end
  1952.  
  1953. function UIMenuColourPanel:CurrentSelection(value)
  1954.     if tonumber(value) then
  1955.         if #self.Data.Items == 0 then
  1956.             self.Data.Index = 0
  1957.         end
  1958.  
  1959.         self.Data.Index = 1000000 - (1000000 % #self.Data.Items) + tonumber(value)
  1960.  
  1961.         if self:CurrentSelection() > self.Data.Pagination.Max then
  1962.             self.Data.Pagination.Min = self:CurrentSelection() - (self.Data.Pagination.Total + 1)
  1963.             self.Data.Pagination.Max = self:CurrentSelection()
  1964.         elseif self:CurrentSelection() < self.Data.Pagination.Min then
  1965.             self.Data.Pagination.Min = self:CurrentSelection() - 1
  1966.             self.Data.Pagination.Max = self:CurrentSelection() + (self.Data.Pagination.Total + 1)
  1967.         end
  1968.  
  1969.         self:UpdateSelection()
  1970.     else
  1971.         if #self.Data.Items == 0 then
  1972.             return 1
  1973.         else
  1974.             if self.Data.Index % #self.Data.Items == 0 then
  1975.                 return 1
  1976.             else
  1977.                 return self.Data.Index % #self.Data.Items + 1
  1978.             end
  1979.         end
  1980.     end
  1981. end
  1982.  
  1983. function UIMenuColourPanel:UpdateParent(Colour)
  1984.     local _, ParentType = self.ParentItem()
  1985.     if ParentType == "UIMenuListItem" then
  1986.         local PanelItemIndex = self.ParentItem:FindPanelItem()
  1987.         local PanelIndex = self.ParentItem:FindPanelIndex(self)
  1988.         if PanelItemIndex then
  1989.             self.ParentItem.Items[PanelItemIndex].Value[PanelIndex] = Colour
  1990.             self.ParentItem:Index(PanelItemIndex)
  1991.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  1992.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  1993.         else
  1994.             for Index = 1, #self.ParentItem.Items do
  1995.                 if type(self.ParentItem.Items[Index]) == "table" then
  1996.                     if not self.ParentItem.Items[Index].Panels then self.ParentItem.Items[Index].Panels = {} end
  1997.                     self.ParentItem.Items[Index].Panels[PanelIndex] = Colour
  1998.                 else
  1999.                     self.ParentItem.Items[Index] = {Name = tostring(self.ParentItem.Items[Index]), Value = self.ParentItem.Items[Index], Panels = {[PanelIndex] = Colour}}
  2000.                 end
  2001.             end
  2002.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  2003.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)    
  2004.         end
  2005.     end
  2006. end
  2007.  
  2008.  
  2009. function UIMenuColourPanel:UpdateSelection()
  2010.     local CurrentSelection = self:CurrentSelection()
  2011.     self:UpdateParent(CurrentSelection)
  2012.  
  2013.     self.SelectedRectangle:Position(15 + (44.5 * ((CurrentSelection - self.Data.Pagination.Min) - 1)) + self.ParentItem:Offset().X, self.SelectedRectangle.Y)
  2014.     for Index = 1, 9 do
  2015.         self.Bar[Index]:Colour(table.unpack(self.Data.Items[self.Data.Pagination.Min + Index]))
  2016.     end
  2017.     self.Text:Text(self.Data.Title.." ("..CurrentSelection.." of "..#self.Data.Items..")")
  2018. end
  2019.  
  2020. function UIMenuColourPanel:Functions()
  2021.  
  2022.     local SafeZone = {X = 0, Y = 0}
  2023.     if self.ParentItem:SetParentMenu().Settings.ScaleWithSafezone then
  2024.        SafeZone = GetSafeZoneBounds()
  2025.     end
  2026.  
  2027.  
  2028.     if IsMouseInBounds(self.LeftArrow.X + SafeZone.X, self.LeftArrow.Y + SafeZone.Y, self.LeftArrow.Width, self.LeftArrow.Height) then
  2029.         if IsDisabledControlJustPressed(0, 24) then
  2030.             if #self.Data.Items > self.Data.Pagination.Total + 1 then
  2031.                 if self:CurrentSelection() <= self.Data.Pagination.Min + 1 then
  2032.                     if self:CurrentSelection() == 1 then
  2033.                         self.Data.Pagination.Min = #self.Data.Items - (self.Data.Pagination.Total + 1)
  2034.                         self.Data.Pagination.Max = #self.Data.Items
  2035.                         self.Data.Index = 1000 - (1000 % #self.Data.Items)
  2036.                         self.Data.Index = self.Data.Index + (#self.Data.Items - 1)
  2037.                         self:UpdateSelection()
  2038.                     else
  2039.                         self.Data.Pagination.Min = self.Data.Pagination.Min - 1
  2040.                         self.Data.Pagination.Max = self.Data.Pagination.Max - 1
  2041.                         self.Data.Index = self.Data.Index - 1
  2042.                         self:UpdateSelection()
  2043.                     end
  2044.                 else
  2045.                     self.Data.Index = self.Data.Index - 1
  2046.                     self:UpdateSelection()
  2047.                 end
  2048.             else
  2049.                 self.Data.Index = self.Data.Index - 1
  2050.                 self:UpdateSelection()
  2051.             end
  2052.         end
  2053.     end
  2054.  
  2055.     if IsMouseInBounds(self.RightArrow.X + SafeZone.X, self.RightArrow.Y + SafeZone.Y, self.RightArrow.Width, self.RightArrow.Height) then
  2056.         if IsDisabledControlJustPressed(0, 24) then
  2057.             if #self.Data.Items > self.Data.Pagination.Total + 1 then
  2058.                 if self:CurrentSelection() >= self.Data.Pagination.Max then
  2059.                     if self:CurrentSelection() == #self.Data.Items then
  2060.                         self.Data.Pagination.Min = 0
  2061.                         self.Data.Pagination.Max = self.Data.Pagination.Total + 1
  2062.                         self.Data.Index = 1000 - (1000 % #self.Data.Items)
  2063.                         self:UpdateSelection()
  2064.                     else
  2065.                         self.Data.Pagination.Max = self.Data.Pagination.Max + 1
  2066.                         self.Data.Pagination.Min = self.Data.Pagination.Max - (self.Data.Pagination.Total + 1)
  2067.                         self.Data.Index = self.Data.Index + 1
  2068.                         self:UpdateSelection()
  2069.                     end
  2070.                 else
  2071.                     self.Data.Index = self.Data.Index + 1
  2072.                     self:UpdateSelection()
  2073.                 end
  2074.             else
  2075.                 self.Data.Index = self.Data.Index + 1
  2076.                 self:UpdateSelection()
  2077.             end
  2078.         end
  2079.     end
  2080.  
  2081.     for Index = 1, #self.Bar do
  2082.         if IsMouseInBounds(self.Bar[Index].X + SafeZone.X, self.Bar[Index].Y + SafeZone.Y, self.Bar[Index].Width, self.Bar[Index].Height) then
  2083.             if IsDisabledControlJustPressed(0, 24) then
  2084.                 self:CurrentSelection(self.Data.Pagination.Min + Index - 1)
  2085.             end
  2086.         end
  2087.     end
  2088. end
  2089.  
  2090. function UIMenuColourPanel:Draw() -- required
  2091.     if self.Data.Enabled then
  2092.         self.Background:Size(431 + self.ParentItem:SetParentMenu().WidthOffset, 112)
  2093.  
  2094.         self.Background:Draw()
  2095.         self.LeftArrow:Draw()
  2096.         self.RightArrow:Draw()
  2097.         self.Text:Draw()
  2098.         self.SelectedRectangle:Draw()
  2099.         for Index = 1, #self.Bar do
  2100.             self.Bar[Index]:Draw()
  2101.         end
  2102.         self:Functions()
  2103.     end
  2104. end
  2105.  
  2106. --[[
  2107.     UIMenuPercentagePanel.lua
  2108.     Panels
  2109. --]]
  2110.  
  2111. UIMenuPercentagePanel = setmetatable({}, UIMenuPercentagePanel)
  2112. UIMenuPercentagePanel.__index = UIMenuPercentagePanel
  2113. UIMenuPercentagePanel.__call = function() return "UIMenuPanel", "UIMenuPercentagePanel" end
  2114.  
  2115. function UIMenuPercentagePanel.New(MinText, MaxText)
  2116.     _UIMenuPercentagePanel = {
  2117.         Data = {
  2118.             Enabled = true,
  2119.         },
  2120.         Background = Sprite.New("commonmenu", "gradient_bgd", 0, 0, 431, 76),
  2121.         ActiveBar = UIResRectangle.New(0, 0, 413, 10, 245, 245, 245, 255),
  2122.         BackgroundBar = UIResRectangle.New(0, 0, 413, 10, 87, 87, 87, 255),
  2123.         Text = {
  2124.             Min = UIResText.New(MinText or "0%", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  2125.             Max = UIResText.New("100%", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  2126.             Title = UIResText.New(MaxText or "Opacity", 0, 0, 0.35, 255, 255, 255, 255, 0, "Centre"),
  2127.         },
  2128.         Audio = {Slider = "CONTINUOUS_SLIDER", Library = "HUD_FRONTEND_DEFAULT_SOUNDSET", Id = nil},
  2129.         ParentItem = nil,
  2130.     }
  2131.  
  2132.     return setmetatable(_UIMenuPercentagePanel, UIMenuPercentagePanel)
  2133. end
  2134.  
  2135. function UIMenuPercentagePanel:SetParentItem(Item) -- required
  2136.     if Item() == "UIMenuItem" then
  2137.         self.ParentItem = Item
  2138.     else
  2139.         return self.ParentItem
  2140.     end
  2141. end
  2142.  
  2143. function UIMenuPercentagePanel:Enabled(Enabled)
  2144.     if type(Enabled) == "boolean" then
  2145.         self.Data.Enabled = Enabled
  2146.     else
  2147.         return self.Data.Enabled
  2148.     end
  2149. end
  2150.  
  2151. function UIMenuPercentagePanel:Position(Y) -- required
  2152.     if tonumber(Y) then
  2153.         local ParentOffsetX, ParentOffsetWidth = self.ParentItem:Offset().X, self.ParentItem:SetParentMenu().WidthOffset
  2154.         self.Background:Position(ParentOffsetX, Y)
  2155.         self.ActiveBar:Position(ParentOffsetX + (ParentOffsetWidth/2) + 9, 50 + Y)
  2156.         self.BackgroundBar:Position(ParentOffsetX + (ParentOffsetWidth/2) + 9, 50 + Y)
  2157.         self.Text.Min:Position(ParentOffsetX + (ParentOffsetWidth/2) + 25, 15 + Y)
  2158.         self.Text.Max:Position(ParentOffsetX + (ParentOffsetWidth/2) + 398, 15 + Y)
  2159.         self.Text.Title:Position(ParentOffsetX + (ParentOffsetWidth/2) + 215.5, 15 + Y)
  2160.     end
  2161. end
  2162.  
  2163. function UIMenuPercentagePanel:Percentage(Value)
  2164.     if tonumber(Value) then
  2165.         local Percent = ((Value < 0.0) and 0.0) or ((Value > 1.0) and 1.0 or Value)
  2166.         self.ActiveBar:Size(self.BackgroundBar.Width * Percent, self.ActiveBar.Height)
  2167.     end
  2168. end
  2169.  
  2170. function UIMenuPercentagePanel:UpdateParent(Percentage)
  2171.     local _, ParentType = self.ParentItem()
  2172.     if ParentType == "UIMenuListItem" then
  2173.         local PanelItemIndex = self.ParentItem:FindPanelItem()
  2174.         if PanelItemIndex then
  2175.             self.ParentItem.Items[PanelItemIndex].Value[self.ParentItem:FindPanelIndex(self)] = Percentage
  2176.             self.ParentItem:Index(PanelItemIndex)
  2177.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  2178.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  2179.         else
  2180.             local PanelIndex = self.ParentItem:FindPanelIndex(self)
  2181.             for Index = 1, #self.ParentItem.Items do
  2182.                 if type(self.ParentItem.Items[Index]) == "table" then
  2183.                     if not self.ParentItem.Items[Index].Panels then self.ParentItem.Items[Index].Panels = {} end
  2184.                     self.ParentItem.Items[Index].Panels[PanelIndex] = Percentage
  2185.                 else
  2186.                     self.ParentItem.Items[Index] = {Name = tostring(self.ParentItem.Items[Index]), Value = self.ParentItem.Items[Index], Panels = {[PanelIndex] = Percentage}}
  2187.                 end
  2188.             end
  2189.             self.ParentItem.Base.ParentMenu.OnListChange(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)
  2190.             self.ParentItem.OnListChanged(self.ParentItem.Base.ParentMenu, self.ParentItem, self.ParentItem._Index)    
  2191.         end
  2192.     end
  2193. end
  2194.  
  2195. function UIMenuPercentagePanel:Functions()
  2196.  
  2197.     local SafeZone = {X = 0, Y = 0}
  2198.     if self.ParentItem:SetParentMenu().Settings.ScaleWithSafezone then
  2199.        SafeZone = GetSafeZoneBounds()
  2200.     end
  2201.  
  2202.     if IsMouseInBounds(self.BackgroundBar.X + SafeZone.X, self.BackgroundBar.Y - 4 + SafeZone.Y, self.BackgroundBar.Width, self.BackgroundBar.Height + 8) then
  2203.         if IsDisabledControlJustPressed(0, 24) then
  2204.             if not self.Pressed then
  2205.                 self.Pressed = true
  2206.                 Citizen.CreateThread(function()
  2207.                     self.Audio.Id = GetSoundId()
  2208.                     PlaySoundFrontend(self.Audio.Id, self.Audio.Slider, self.Audio.Library, 1)
  2209.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(self.BackgroundBar.X + SafeZone.X, self.BackgroundBar.Y - 4 + SafeZone.Y, self.BackgroundBar.Width, self.BackgroundBar.Height + 8) do
  2210.                         Citizen.Wait(0)
  2211.                         local Progress = (math.round(GetControlNormal(0, 239) * 1920) - SafeZone.X) - self.ActiveBar.X
  2212.                         self.ActiveBar:Size(((Progress >= 0 and Progress <= 413) and Progress or ((Progress < 0) and 0 or 413)), self.ActiveBar.Height)
  2213.                     end
  2214.                     StopSound(self.Audio.Id)
  2215.                     ReleaseSoundId(self.Audio.Id)
  2216.                     self.Pressed = false
  2217.                 end)
  2218.                 Citizen.CreateThread(function()
  2219.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(self.BackgroundBar.X + SafeZone.X, self.BackgroundBar.Y - 4 + SafeZone.Y, self.BackgroundBar.Width, self.BackgroundBar.Height + 8) do
  2220.                         Citizen.Wait(75)
  2221.                         local Progress = (math.round(GetControlNormal(0, 239) * 1920) - SafeZone.X) - self.ActiveBar.X
  2222.                         self:UpdateParent(math.round(((Progress >= 0 and Progress <= 413) and Progress or ((Progress < 0) and 0 or 413))/self.BackgroundBar.Width, 2))
  2223.                     end
  2224.                 end)
  2225.             end
  2226.         end
  2227.     end
  2228. end
  2229.  
  2230.  
  2231. function UIMenuPercentagePanel:Draw() -- required
  2232.     if self.Data.Enabled then
  2233.         self.Background:Size(431 + self.ParentItem:SetParentMenu().WidthOffset, 76)
  2234.         self.Background:Draw()
  2235.         self.BackgroundBar:Draw()
  2236.         self.ActiveBar:Draw()
  2237.         self.Text.Min:Draw()
  2238.         self.Text.Max:Draw()
  2239.         self.Text.Title:Draw()
  2240.         self:Functions()
  2241.     end
  2242. end
  2243.  
  2244. --[[
  2245.     UIMenu.lua
  2246.     Menus
  2247. --]]
  2248.  
  2249. function UIMenu.New(Title, Subtitle, X, Y, TxtDictionary, TxtName)
  2250.     local X, Y = tonumber(X) or 0, tonumber(Y) or 0
  2251.     if Title ~= nil then Title = tostring(Title) or "" else Title = "" end
  2252.     if Subtitle ~= nil then Subtitle = tostring(Subtitle) or "" else Subtitle = "" end
  2253.     if TxtDictionary ~= nil then TxtDictionary = tostring(TxtDictionary) or "commonmenu" else TxtDictionary = "commonmenu" end
  2254.     if TxtName ~= nil then TxtName = tostring(TxtName) or "interaction_bgd" else TxtName = "interaction_bgd" end
  2255.     local _UIMenu = {
  2256.         Logo = Sprite.New(TxtDictionary, TxtName, 0 + X, 0 + Y, 431, 107),
  2257.         Banner = nil,
  2258.         Title = UIResText.New(Title, 215 + X, 20 + Y, 1.15, 255, 255, 255, 255, 1, 1),
  2259.         Subtitle = {ExtraY = 0},
  2260.         WidthOffset = 0,
  2261.         Position = {X = X, Y = Y},
  2262.         Pagination = {Min = 0, Max = 9, Total = 9},
  2263.         PageCounter = {PreText = ""},
  2264.         Extra = {},
  2265.         Description = {},
  2266.         Items = {},
  2267.         Windows = {},
  2268.         Children = {},
  2269.         Controls = {},
  2270.         ParentMenu = nil,
  2271.         ParentItem = nil,
  2272.         _Visible = false,
  2273.         ActiveItem = 1000,
  2274.         Dirty = false;
  2275.         ReDraw = true,
  2276.         InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS"),
  2277.         InstructionalButtons = {},
  2278.         OnIndexChange = function(menu, newindex) end,
  2279.         OnListChange = function(menu, list, newindex) end,
  2280.         OnSliderChange = function(menu, slider, newindex) end,
  2281.         OnCheckboxChange = function(menu, item, checked) end,
  2282.         OnListSelect = function(menu, list, index) end,
  2283.         OnSliderSelect = function(menu, slider, index) end,
  2284.         OnItemSelect = function(menu, item, index) end,
  2285.         OnMenuChanged = function(menu, newmenu, forward) end,
  2286.         OnMenuClosed = function(menu) end,
  2287.         Settings = {
  2288.             InstructionalButtons = true,
  2289.             MultilineFormats = true,
  2290.             ScaleWithSafezone = true,
  2291.             ResetCursorOnOpen = true,
  2292.             MouseControlsEnabled = true,
  2293.             MouseEdgeEnabled = true,
  2294.             ControlDisablingEnabled = true,
  2295.             Audio = {
  2296.                 Library = "HUD_FRONTEND_DEFAULT_SOUNDSET",
  2297.                 UpDown = "NAV_UP_DOWN",
  2298.                 LeftRight = "NAV_LEFT_RIGHT",
  2299.                 Select = "SELECT",
  2300.                 Back = "BACK",
  2301.                 Error = "ERROR",
  2302.             },
  2303.         }
  2304.     }
  2305.  
  2306.     if Subtitle ~= "" and Subtitle ~= nil then
  2307.         _UIMenu.Subtitle.Rectangle = UIResRectangle.New(0 + _UIMenu.Position.X, 107 + _UIMenu.Position.Y, 431, 37, 0, 0, 0, 255)
  2308.         _UIMenu.Subtitle.Text = UIResText.New(Subtitle, 8 + _UIMenu.Position.X, 110 + _UIMenu.Position.Y, 0.35, 245, 245, 245, 255, 0)
  2309.         _UIMenu.Subtitle.BackupText = Subtitle
  2310.         _UIMenu.Subtitle.Formatted = false
  2311.         if string.starts(Subtitle, "~") then
  2312.             _UIMenu.PageCounter.PreText = string.sub(Subtitle, 1, 3)
  2313.         end
  2314.         _UIMenu.PageCounter.Text = UIResText.New("", 425 + _UIMenu.Position.X, 110 + _UIMenu.Position.Y, 0.35, 245, 245, 245, 255, 0, "Right")
  2315.         _UIMenu.Subtitle.ExtraY = 37
  2316.     end
  2317.    
  2318.     _UIMenu.ArrowSprite = Sprite.New("commonmenu", "shop_arrows_upanddown", 190 + _UIMenu.Position.X, 147 + 37 * (_UIMenu.Pagination.Total + 1) + _UIMenu.Position.Y - 37 + _UIMenu.Subtitle.ExtraY, 50, 50)
  2319.     _UIMenu.Extra.Up = UIResRectangle.New(0 + _UIMenu.Position.X, 144 + 38 * (_UIMenu.Pagination.Total + 1) + _UIMenu.Position.Y - 37 + _UIMenu.Subtitle.ExtraY, 431, 18, 0, 0, 0, 200)
  2320.     _UIMenu.Extra.Down = UIResRectangle.New(0 + _UIMenu.Position.X, 144 + 18 + 38 * (_UIMenu.Pagination.Total + 1) + _UIMenu.Position.Y - 37 + _UIMenu.Subtitle.ExtraY, 431, 18, 0, 0, 0, 200)
  2321.  
  2322.     _UIMenu.Description.Bar = UIResRectangle.New(_UIMenu.Position.X, 123, 431, 4, 0, 0, 0, 255)
  2323.     _UIMenu.Description.Rectangle = Sprite.New("commonmenu", "gradient_bgd", _UIMenu.Position.X, 127, 431, 30)
  2324.     _UIMenu.Description.Text = UIResText.New("Description", _UIMenu.Position.X + 5, 125, 0.35)
  2325.  
  2326.     _UIMenu.Background = Sprite.New("commonmenu", "gradient_bgd", _UIMenu.Position.X, 144 + _UIMenu.Position.Y - 37 + _UIMenu.Subtitle.ExtraY, 290, 25)
  2327.  
  2328.     Citizen.CreateThread(function()
  2329.         if not HasScaleformMovieLoaded(_UIMenu.InstructionalScaleform) then
  2330.             _UIMenu.InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS")
  2331.             while not HasScaleformMovieLoaded(_UIMenu.InstructionalScaleform) do
  2332.                 Citizen.Wait(0)
  2333.             end
  2334.         end
  2335.     end)
  2336.     return setmetatable(_UIMenu, UIMenu)
  2337. end
  2338.  
  2339. function UIMenu:SetMenuWidthOffset(Offset)
  2340.     if tonumber(Offset) then
  2341.         self.WidthOffset = math.floor(tonumber(Offset))
  2342.         self.Logo:Size(431 + self.WidthOffset, 107)
  2343.         self.Title:Position(((self.WidthOffset + 431)/2) + self.Position.X, 20 + self.Position.Y)
  2344.         if self.Subtitle.Rectangle ~= nil then
  2345.             self.Subtitle.Rectangle:Size(431 + self.WidthOffset + 100, 37)            
  2346.             self.PageCounter.Text:Position(425 + self.Position.X + self.WidthOffset, 110 + self.Position.Y)
  2347.         end
  2348.         if self.Banner ~= nil then
  2349.             self.Banner:Size(431 + self.WidthOffset, 107)
  2350.         end
  2351.     end
  2352. end
  2353.  
  2354. function UIMenu:DisEnableControls(bool)
  2355.     if bool then
  2356.         EnableAllControlActions(2)
  2357.     else
  2358.         DisableAllControlActions(2)
  2359.     end
  2360.  
  2361.     if bool then
  2362.         return
  2363.     else
  2364.         if Controller() then
  2365.             EnableControlAction(0, 2, true)
  2366.             EnableControlAction(0, 1, true)
  2367.             EnableControlAction(0, 25, true)
  2368.             EnableControlAction(0, 24, true)
  2369.         else
  2370.             EnableControlAction(0, 201, true)
  2371.             EnableControlAction(0, 195, true)
  2372.             EnableControlAction(0, 196, true)
  2373.             EnableControlAction(0, 187, true)
  2374.             EnableControlAction(0, 188, true)
  2375.             EnableControlAction(0, 189, true)
  2376.             EnableControlAction(0, 190, true)
  2377.             EnableControlAction(0, 202, true)
  2378.             EnableControlAction(0, 217, true)
  2379.             EnableControlAction(0, 242, true)
  2380.             EnableControlAction(0, 241, true)
  2381.             EnableControlAction(0, 239, true)
  2382.             EnableControlAction(0, 240, true)
  2383.             EnableControlAction(0, 31, true)
  2384.             EnableControlAction(0, 30, true)
  2385.             EnableControlAction(0, 21, true)
  2386.             EnableControlAction(0, 22, true)
  2387.             EnableControlAction(0, 23, true)
  2388.             EnableControlAction(0, 75, true)
  2389.             EnableControlAction(0, 71, true)
  2390.             EnableControlAction(0, 72, true)
  2391.             EnableControlAction(0, 59, true)
  2392.             EnableControlAction(0, 89, true)
  2393.             EnableControlAction(0, 9, true)
  2394.             EnableControlAction(0, 8, true)
  2395.             EnableControlAction(0, 90, true)
  2396.             EnableControlAction(0, 76, true)
  2397.         end
  2398.     end
  2399. end
  2400.  
  2401. function UIMenu:InstructionalButtons(bool)
  2402.     if bool ~= nil then
  2403.         self.Settings.InstrucitonalButtons = tobool(bool)
  2404.     end
  2405. end
  2406.  
  2407. function UIMenu:SetBannerSprite(Sprite)
  2408.     if Sprite() == "Sprite" then
  2409.         self.Logo = Sprite
  2410.         self.Logo:Size(431 + self.WidthOffset, 107)
  2411.         self.Logo:Position(self.Position.X, self.Position.Y)
  2412.         self.Banner = nil
  2413.     end
  2414. end
  2415.  
  2416. function UIMenu:SetBannerRectangle(Rectangle)
  2417.     if Rectangle() == "Rectangle" then
  2418.         self.Banner = Rectangle
  2419.         self.Banner:Size(431 + self.WidthOffset, 107)
  2420.         self.Banner:Position(self.Position.X, self.Position.Y)
  2421.         self.Logo = nil
  2422.     end
  2423. end
  2424.  
  2425. function UIMenu:CurrentSelection(value)
  2426.     if tonumber(value) then
  2427.         if #self.Items == 0 then
  2428.             self.ActiveItem = 0
  2429.         end
  2430.  
  2431.         self.Items[self:CurrentSelection()]:Selected(false)
  2432.         self.ActiveItem = 1000000 - (1000000 % #self.Items) + tonumber(value)
  2433.  
  2434.         if self:CurrentSelection() > self.Pagination.Max then
  2435.             self.Pagination.Min = self:CurrentSelection() - self.Pagination.Total
  2436.             self.Pagination.Max = self:CurrentSelection()
  2437.         elseif self:CurrentSelection() < self.Pagination.Min then
  2438.             self.Pagination.Min = self:CurrentSelection()
  2439.             self.Pagination.Max = self:CurrentSelection() + self.Pagination.Total
  2440.         end
  2441.     else
  2442.         if #self.Items == 0 then
  2443.             return 1
  2444.         else
  2445.             if self.ActiveItem % #self.Items == 0 then
  2446.                 return 1
  2447.             else
  2448.                 return self.ActiveItem % #self.Items + 1
  2449.             end
  2450.         end
  2451.     end
  2452. end
  2453.  
  2454. function UIMenu:CalculateWindowHeight()
  2455.     local Height = 0
  2456.     for i = 1, #self.Windows do
  2457.         Height = Height + self.Windows[i].Background:Size().Height
  2458.     end
  2459.     return Height
  2460. end
  2461.  
  2462. function UIMenu:RecaulculateDescriptionPosition()
  2463.     local WindowHeight = self:CalculateWindowHeight()
  2464.     self.Description.Bar:Position(self.Position.X, 149 - 37 + self.Subtitle.ExtraY + self.Position.Y + WindowHeight)
  2465.     self.Description.Rectangle:Position(self.Position.X, 149 - 37 + self.Subtitle.ExtraY + self.Position.Y + WindowHeight)
  2466.     self.Description.Text:Position(self.Position.X + 8, 155 - 37 + self.Subtitle.ExtraY + self.Position.Y + WindowHeight)
  2467.  
  2468.     self.Description.Bar:Size(431 + self.WidthOffset, 4)
  2469.     self.Description.Rectangle:Size(431 + self.WidthOffset, 30)
  2470.  
  2471.     local count = #self.Items
  2472.     if count > self.Pagination.Total + 1 then
  2473.         count = self.Pagination.Total + 2
  2474.     end
  2475.  
  2476.     self.Description.Bar:Position(self.Position.X, 38 * count + self.Description.Bar:Position().Y)
  2477.     self.Description.Rectangle:Position(self.Position.X, 38 * count + self.Description.Rectangle:Position().Y)
  2478.     self.Description.Text:Position(self.Position.X + 8, 38 * count + self.Description.Text:Position().Y)
  2479. end
  2480.  
  2481. function UIMenu:CaclulatePanelPosition(HasDescription)
  2482.     local Height = self:CalculateWindowHeight() + 149 - 37 + self.Subtitle.ExtraY + self.Position.Y
  2483.  
  2484.     local count = #self.Items
  2485.     if count > self.Pagination.Total + 1 then
  2486.         count = self.Pagination.Total + 2
  2487.     end
  2488.  
  2489.     if HasDescription then
  2490.         Height = Height + self.Description.Rectangle:Size().Height + 5
  2491.     end
  2492.  
  2493.     return 38 * count + Height
  2494. end
  2495.  
  2496. function UIMenu:AddWindow(Window)
  2497.     if Window() == "UIMenuWindow" then
  2498.         Window:SetParentMenu(self)
  2499.         Window:Offset(self.Position.X, self.Position.Y)
  2500.         table.insert(self.Windows, Window)
  2501.         self.ReDraw = true
  2502.         self:RecaulculateDescriptionPosition()
  2503.     end
  2504. end
  2505.  
  2506. function UIMenu:RemoveWindowAt(Index)
  2507.     if tonumber(Index) then
  2508.         if self.Windows[Index] then
  2509.             table.remove(self.Windows, Index)
  2510.             self.ReDraw = true
  2511.             self:RecaulculateDescriptionPosition()
  2512.         end
  2513.     end
  2514. end
  2515.  
  2516. function UIMenu:AddItem(Item)
  2517.     if Item() == "UIMenuItem" then
  2518.         local SelectedItem = self:CurrentSelection()
  2519.         Item:SetParentMenu(self)
  2520.         Item:Offset(self.Position.X, self.Position.Y)
  2521.         Item:Position((#self.Items * 25) - 37 + self.Subtitle.ExtraY)
  2522.         table.insert(self.Items, Item)
  2523.         self:RecaulculateDescriptionPosition()
  2524.         self:CurrentSelection(SelectedItem)
  2525.     end
  2526. end
  2527.  
  2528. function UIMenu:RemoveItemAt(Index)
  2529.     if tonumber(Index) then
  2530.         if self.Items[Index] then
  2531.             local SelectedItem = self:CurrentSelection()
  2532.             if #self.Items > self.Pagination.Total and self.Pagination.Max == #self.Items - 1 then
  2533.                 self.Pagination.Min = self.Pagination.Min - 1
  2534.                 self.Pagination.Max = self.Pagination.Max + 1
  2535.             end
  2536.             table.remove(self.Items, tonumber(Index))
  2537.             self:RecaulculateDescriptionPosition()
  2538.             self:CurrentSelection(SelectedItem)
  2539.         end
  2540.     end
  2541. end
  2542.  
  2543. function UIMenu:RefreshIndex()
  2544.     if #self.Items == 0 then
  2545.         self.ActiveItem = 1000
  2546.         self.Pagination.Max = self.Pagination.Total + 1
  2547.         self.Pagination.Min = 0
  2548.         return
  2549.     end
  2550.     self.Items[self:CurrentSelection()]:Selected(false)
  2551.     self.ActiveItem = 1000 - (1000 % #self.Items)
  2552.     self.Pagination.Max = self.Pagination.Total + 1
  2553.     self.Pagination.Min = 0
  2554.     self.ReDraw = true
  2555. end
  2556.  
  2557. function UIMenu:Clear()
  2558.     self.Items = {}
  2559.     self.ReDraw = true
  2560.     self:RecaulculateDescriptionPosition()
  2561. end
  2562.  
  2563. function UIMenu:MultilineFormat(str)
  2564.     if tostring(str) then
  2565.  
  2566.         local PixelPerLine = 425 + self.WidthOffset
  2567.         local AggregatePixels = 0
  2568.         local output = ""
  2569.         local words = string.split(tostring(str), " ")
  2570.  
  2571.         for i = 1, #words do
  2572.             local offset = MeasureStringWidth(words[i], 0, 0.35)
  2573.             AggregatePixels = AggregatePixels + offset
  2574.             if AggregatePixels > PixelPerLine then
  2575.                 output = output .. "\n" .. words[i] .. " "
  2576.                 AggregatePixels = offset + MeasureString(" ")
  2577.             else
  2578.                 output = output .. words[i] .. " "
  2579.                 AggregatePixels = AggregatePixels + MeasureString(" ")
  2580.             end
  2581.         end
  2582.         return output
  2583.     end
  2584. end
  2585.  
  2586. function UIMenu:DrawCalculations()
  2587.     local WindowHeight = self:CalculateWindowHeight()
  2588.  
  2589.     if self.Settings.MultilineFormats then
  2590.         if self.Subtitle.Rectangle and not self.Subtitle.Formatted then
  2591.             self.Subtitle.Formatted = true
  2592.             self.Subtitle.Text:Text(self:MultilineFormat(self.Subtitle.Text:Text()))
  2593.  
  2594.             local Linecount = #string.split(self.Subtitle.Text:Text(), "\n")
  2595.             self.Subtitle.ExtraY = ((Linecount == 1) and 37 or ((Linecount + 1) * 22))
  2596.             self.Subtitle.Rectangle:Size(431 + self.WidthOffset, self.Subtitle.ExtraY)
  2597.         end
  2598.     elseif self.Subtitle.Formatted then
  2599.         self.Subtitle.Formatted = false
  2600.         self.Subtitle.ExtraY = 37
  2601.         self.Subtitle.Rectangle:Size(431 + self.WidthOffset, self.Subtitle.ExtraY)
  2602.         self.Subtitle.Text:Text(self.Subtitle.BackupText)
  2603.     end
  2604.  
  2605.     if #self.Items > self.Pagination.Total + 1 then
  2606.         self.Background:Size(431 + self.WidthOffset, (38 * (self.Pagination.Total + 1)) + WindowHeight + ((self.Subtitle.ExtraY > 0) and (self.Subtitle.ExtraY - 37) or 0))
  2607.     else
  2608.         self.Background:Size(431 + self.WidthOffset, (38 * #self.Items) + WindowHeight + ((self.Subtitle.ExtraY > 0) and (self.Subtitle.ExtraY - 37) or 0))
  2609.     end
  2610.  
  2611.     self.Extra.Up:Size(431 + self.WidthOffset, 18)
  2612.     self.Extra.Down:Size(431 + self.WidthOffset, 18)
  2613.  
  2614.     self.Extra.Up:Position(self.Position.X, 144 + 38 * (self.Pagination.Total + 1) + self.Position.Y - 37 + self.Subtitle.ExtraY + WindowHeight)
  2615.     self.Extra.Down:Position(self.Position.X, 144 + 18 + 38 * (self.Pagination.Total + 1) + self.Position.Y - 37 + self.Subtitle.ExtraY + WindowHeight)
  2616.  
  2617.     if self.WidthOffset > 0 then
  2618.         self.ArrowSprite:Position(190 + self.Position.X + (self.WidthOffset / 2), WindowHeight + 147 + 37 * (self.Pagination.Total + 1) + self.Position.Y - 37 + self.Subtitle.ExtraY)
  2619.     else
  2620.         self.ArrowSprite:Position(190 + self.Position.X + self.WidthOffset, WindowHeight + 147 + 37 * (self.Pagination.Total + 1) + self.Position.Y - 37 + self.Subtitle.ExtraY)
  2621.     end
  2622.  
  2623.     self.ReDraw = false
  2624.  
  2625.     if #self.Items ~= 0 and self.Items[self:CurrentSelection()]:Description() ~= "" then
  2626.         self:RecaulculateDescriptionPosition()
  2627.  
  2628.         local description = self.Items[self:CurrentSelection()]:Description()
  2629.         if self.Settings.MultilineFormats then
  2630.             self.Description.Text:Text(self:MultilineFormat(description))
  2631.         else
  2632.             self.Description.Text:Text(description)
  2633.         end
  2634.  
  2635.         local Linecount = #string.split(self.Description.Text:Text(), "\n")
  2636.         self.Description.Rectangle:Size(431 + self.WidthOffset, ((Linecount == 1) and 37 or ((Linecount + 1) * 22)))
  2637.     end
  2638. end
  2639.  
  2640. function UIMenu:Visible(bool)
  2641.     if bool ~= nil then
  2642.         self._Visible = tobool(bool)
  2643.         self.JustOpened = tobool(bool)
  2644.         self.Dirty = tobool(bool)
  2645.         self:UpdateScaleform()
  2646.         if self.ParentMenu ~= nil or tobool(bool) == false then
  2647.             return
  2648.         end
  2649.         if self.Settings.ResetCursorOnOpen then
  2650.             local W, H = GetScreenResolution()
  2651.             SetCursorLocation(W / 2, H / 2)
  2652.             SetCursorSprite(1)
  2653.         end
  2654.     else
  2655.         return self._Visible
  2656.     end
  2657. end
  2658.  
  2659. function UIMenu:ProcessControl()
  2660.     if not self._Visible then
  2661.         return
  2662.     end
  2663.  
  2664.     if self.JustOpened then
  2665.         self.JustOpened = false
  2666.         return
  2667.     end
  2668.  
  2669.     if IsDisabledControlJustReleased(0, 177) or IsDisabledControlJustReleased(1, 177) or IsDisabledControlJustReleased(2, 177) or IsDisabledControlJustReleased(0, 199) or IsDisabledControlJustReleased(1, 199) or IsDisabledControlJustReleased(2, 199) then
  2670.         self:GoBack()
  2671.     end
  2672.     if #self.Items == 0 then
  2673.         return
  2674.     end
  2675.  
  2676.     if not self.UpPressed then
  2677.         if IsDisabledControlJustPressed(0, 172) or IsDisabledControlJustPressed(1, 172) or IsDisabledControlJustPressed(2, 172) or IsDisabledControlJustPressed(0, 241) or IsDisabledControlJustPressed(1, 241) or IsDisabledControlJustPressed(2, 241) or IsDisabledControlJustPressed(2, 241) then
  2678.             Citizen.CreateThread(function()
  2679.                 self.UpPressed = true
  2680.                 if #self.Items > self.Pagination.Total + 1 then
  2681.                     self:GoUpOverflow()
  2682.                 else
  2683.                     self:GoUp()
  2684.                 end
  2685.                 self:UpdateScaleform()
  2686.                 Citizen.Wait(175)
  2687.                 while IsDisabledControlPressed(0, 172) or IsDisabledControlPressed(1, 172) or IsDisabledControlPressed(2, 172) or IsDisabledControlPressed(0, 241) or IsDisabledControlPressed(1, 241) or IsDisabledControlPressed(2, 241) or IsDisabledControlPressed(2, 241) do
  2688.                     if #self.Items > self.Pagination.Total + 1 then
  2689.                         self:GoUpOverflow()
  2690.                     else
  2691.                         self:GoUp()
  2692.                     end
  2693.                     self:UpdateScaleform()
  2694.                     Citizen.Wait(125)
  2695.                 end
  2696.                 self.UpPressed = false
  2697.             end)
  2698.         end
  2699.     end
  2700.  
  2701.     if not self.DownPressed then
  2702.         if IsDisabledControlJustPressed(0, 173) or IsDisabledControlJustPressed(1, 173) or IsDisabledControlJustPressed(2, 173) or IsDisabledControlJustPressed(0, 242) or IsDisabledControlJustPressed(1, 242) or IsDisabledControlJustPressed(2, 242) then
  2703.             Citizen.CreateThread(function()
  2704.                 self.DownPressed = true
  2705.                 if #self.Items > self.Pagination.Total + 1 then
  2706.                     self:GoDownOverflow()
  2707.                 else
  2708.                     self:GoDown()
  2709.                 end
  2710.                 self:UpdateScaleform()
  2711.                 Citizen.Wait(175)
  2712.                 while IsDisabledControlPressed(0, 173) or IsDisabledControlPressed(1, 173) or IsDisabledControlPressed(2, 173) or IsDisabledControlPressed(0, 242) or IsDisabledControlPressed(1, 242) or IsDisabledControlPressed(2, 242) do
  2713.                     if #self.Items > self.Pagination.Total + 1 then
  2714.                         self:GoDownOverflow()
  2715.                     else
  2716.                         self:GoDown()
  2717.                     end
  2718.                     self:UpdateScaleform()
  2719.                     Citizen.Wait(125)
  2720.                 end
  2721.                 self.DownPressed = false
  2722.             end)
  2723.         end
  2724.     end
  2725.  
  2726.     if not self.LeftPressed then
  2727.         if IsDisabledControlPressed(0, 174) or IsDisabledControlPressed(1, 174) or IsDisabledControlPressed(2, 174) then
  2728.             Citizen.CreateThread(function()
  2729.                 self.LeftPressed = true
  2730.                 self:GoLeft()
  2731.                 Citizen.Wait(175)
  2732.                 while IsDisabledControlPressed(0, 174) or IsDisabledControlPressed(1, 174) or IsDisabledControlPressed(2, 174) do
  2733.                     self:GoLeft()
  2734.                     Citizen.Wait(125)
  2735.                 end
  2736.                 self.LeftPressed = false
  2737.             end)
  2738.         end
  2739.     end
  2740.  
  2741.     if not self.RightPressed then
  2742.         if IsDisabledControlPressed(0, 175) or IsDisabledControlPressed(1, 175) or IsDisabledControlPressed(2, 175) then
  2743.             Citizen.CreateThread(function()
  2744.                 self.RightPressed = true
  2745.                 self:GoRight()
  2746.                 Citizen.Wait(175)
  2747.                 while IsDisabledControlPressed(0, 175) or IsDisabledControlPressed(1, 175) or IsDisabledControlPressed(2, 175) do
  2748.                     self:GoRight()
  2749.                     Citizen.Wait(125)
  2750.                 end
  2751.                 self.RightPressed = false
  2752.             end)
  2753.         end
  2754.     end
  2755.  
  2756.     if IsDisabledControlJustPressed(0, 201) or IsDisabledControlJustPressed(1, 201) or IsDisabledControlJustPressed(2, 201) then
  2757.         self:SelectItem()
  2758.     end
  2759. end
  2760.  
  2761. function UIMenu:GoUpOverflow()
  2762.     if #self.Items <= self.Pagination.Total + 1 then
  2763.         return
  2764.     end
  2765.  
  2766.     if self:CurrentSelection() <= self.Pagination.Min + 1 then
  2767.         if self:CurrentSelection() == 1 then
  2768.             self.Pagination.Min = #self.Items - (self.Pagination.Total + 1)
  2769.             self.Pagination.Max = #self.Items
  2770.             self.Items[self:CurrentSelection()]:Selected(false)
  2771.             self.ActiveItem = 1000 - (1000 % #self.Items)
  2772.             self.ActiveItem = self.ActiveItem + (#self.Items - 1)
  2773.             self.Items[self:CurrentSelection()]:Selected(true)
  2774.         else
  2775.             self.Pagination.Min = self.Pagination.Min - 1
  2776.             self.Pagination.Max = self.Pagination.Max - 1
  2777.             self.Items[self:CurrentSelection()]:Selected(false)
  2778.             self.ActiveItem = self.ActiveItem - 1
  2779.             self.Items[self:CurrentSelection()]:Selected(true)
  2780.         end
  2781.     else
  2782.         self.Items[self:CurrentSelection()]:Selected(false)
  2783.         self.ActiveItem = self.ActiveItem - 1
  2784.         self.Items[self:CurrentSelection()]:Selected(true)
  2785.     end
  2786.     PlaySoundFrontend(-1, self.Settings.Audio.UpDown, self.Settings.Audio.Library, true)
  2787.     self.OnIndexChange(self, self:CurrentSelection())
  2788.     self.ReDraw = true
  2789. end
  2790.  
  2791. function UIMenu:GoUp()
  2792.     if #self.Items > self.Pagination.Total + 1 then
  2793.         return
  2794.     end
  2795.     self.Items[self:CurrentSelection()]:Selected(false)
  2796.     self.ActiveItem = self.ActiveItem - 1
  2797.     self.Items[self:CurrentSelection()]:Selected(true)
  2798.     PlaySoundFrontend(-1, self.Settings.Audio.UpDown, self.Settings.Audio.Library, true)
  2799.     self.OnIndexChange(self, self:CurrentSelection())
  2800.     self.ReDraw = true
  2801. end
  2802.  
  2803. function UIMenu:GoDownOverflow()
  2804.     if #self.Items <= self.Pagination.Total + 1 then
  2805.         return
  2806.     end
  2807.  
  2808.     if self:CurrentSelection() >= self.Pagination.Max then
  2809.         if self:CurrentSelection() == #self.Items then
  2810.             self.Pagination.Min = 0
  2811.             self.Pagination.Max = self.Pagination.Total + 1
  2812.             self.Items[self:CurrentSelection()]:Selected(false)
  2813.             self.ActiveItem = 1000 - (1000 % #self.Items)
  2814.             self.Items[self:CurrentSelection()]:Selected(true)
  2815.         else
  2816.             self.Pagination.Max = self.Pagination.Max + 1
  2817.             self.Pagination.Min = self.Pagination.Max - (self.Pagination.Total + 1)
  2818.             self.Items[self:CurrentSelection()]:Selected(false)
  2819.             self.ActiveItem = self.ActiveItem + 1
  2820.             self.Items[self:CurrentSelection()]:Selected(true)            
  2821.         end
  2822.     else
  2823.         self.Items[self:CurrentSelection()]:Selected(false)
  2824.         self.ActiveItem = self.ActiveItem + 1
  2825.         self.Items[self:CurrentSelection()]:Selected(true)
  2826.     end
  2827.     PlaySoundFrontend(-1, self.Settings.Audio.UpDown, self.Settings.Audio.Library, true)
  2828.     self.OnIndexChange(self, self:CurrentSelection())
  2829.     self.ReDraw = true
  2830. end
  2831.  
  2832. function UIMenu:GoDown()
  2833.     if #self.Items > self.Pagination.Total + 1 then
  2834.         return
  2835.     end
  2836.  
  2837.     self.Items[self:CurrentSelection()]:Selected(false)
  2838.     self.ActiveItem = self.ActiveItem + 1
  2839.     self.Items[self:CurrentSelection()]:Selected(true)
  2840.     PlaySoundFrontend(-1, self.Settings.Audio.UpDown, self.Settings.Audio.Library, true)
  2841.     self.OnIndexChange(self, self:CurrentSelection())
  2842.     self.ReDraw = true
  2843. end
  2844.  
  2845. function UIMenu:GoLeft()
  2846.     local type, subtype = self.Items[self:CurrentSelection()]()
  2847.     if subtype ~= "UIMenuListItem" and subtype ~= "UIMenuSliderItem" then
  2848.         return
  2849.     end
  2850.  
  2851.     if subtype == "UIMenuListItem" then
  2852.         local Item = self.Items[self:CurrentSelection()]
  2853.         Item:Index(Item._Index - 1)
  2854.         self.OnListChange(self, Item, Item._Index)
  2855.         Item.OnListChanged(self, Item, Item._Index)
  2856.         PlaySoundFrontend(-1, self.Settings.Audio.LeftRight, self.Settings.Audio.Library, true)
  2857.     elseif subtype == "UIMenuSliderItem" then
  2858.         local Item = self.Items[self:CurrentSelection()]
  2859.         Item:Index(Item._Index - 1)
  2860.         self.OnSliderChange(self, Item, Item:Index())
  2861.         Item.OnSliderChanged(self, Item, Item._Index)
  2862.         PlaySoundFrontend(-1, self.Settings.Audio.LeftRight, self.Settings.Audio.Library, true)
  2863.     end
  2864. end
  2865.  
  2866. function UIMenu:GoRight()
  2867.     local type, subtype = self.Items[self:CurrentSelection()]()
  2868.     if subtype ~= "UIMenuListItem" and subtype ~= "UIMenuSliderItem" then
  2869.         return
  2870.     end
  2871.  
  2872.     if subtype == "UIMenuListItem" then
  2873.         local Item = self.Items[self:CurrentSelection()]
  2874.         Item:Index(Item._Index + 1)
  2875.         self.OnListChange(self, Item, Item._Index)
  2876.         Item.OnListChanged(self, Item, Item._Index)
  2877.         PlaySoundFrontend(-1, self.Settings.Audio.LeftRight, self.Settings.Audio.Library, true)
  2878.     elseif subtype == "UIMenuSliderItem" then
  2879.         local Item = self.Items[self:CurrentSelection()]
  2880.         Item:Index(Item._Index + 1)
  2881.         self.OnSliderChange(self, Item, Item:Index())
  2882.         Item.OnSliderChanged(self, Item, Item._Index)
  2883.         PlaySoundFrontend(-1, self.Settings.Audio.LeftRight, self.Settings.Audio.Library, true)
  2884.     end
  2885. end
  2886.  
  2887. function UIMenu:SelectItem()
  2888.     if not self.Items[self:CurrentSelection()]:Enabled() then
  2889.         PlaySoundFrontend(-1, self.Settings.Audio.Error, self.Settings.Audio.Library, true)
  2890.         return
  2891.     end
  2892.     local Item = self.Items[self:CurrentSelection()]
  2893.     local type, subtype = Item()
  2894.     if subtype == "UIMenuCheckboxItem" then
  2895.         Item.Checked = not Item.Checked
  2896.         PlaySoundFrontend(-1, self.Settings.Audio.Select, self.Settings.Audio.Library, true)
  2897.         self.OnCheckboxChange(self, Item, Item.Checked)
  2898.         Item.CheckboxEvent(self, Item, Item.Checked)
  2899.     elseif subtype == "UIMenuListItem" then
  2900.         PlaySoundFrontend(-1, self.Settings.Audio.Select, self.Settings.Audio.Library, true)
  2901.         self.OnListSelect(self, Item, Item._Index)
  2902.         Item.OnListSelected(self, Item, Item._Index)
  2903.     elseif subtype == "UIMenuSliderItem" then
  2904.         PlaySoundFrontend(-1, self.Settings.Audio.Select, self.Settings.Audio.Library, true)
  2905.         self.OnSliderSelect(self, Item, Item._Index)
  2906.         Item.OnSliderSelected(self, Item, Item._Index)
  2907.     else
  2908.         PlaySoundFrontend(-1, self.Settings.Audio.Select, self.Settings.Audio.Library, true)
  2909.         self.OnItemSelect(self, Item, self:CurrentSelection())
  2910.         Item.Activated(self, Item)
  2911.         if not self.Children[Item] then
  2912.             return
  2913.         end
  2914.         self:Visible(false)
  2915.         self.Children[Item]:Visible(true)
  2916.         self.OnMenuChanged(self, self.Children[self.Items[self:CurrentSelection()]], true)
  2917.     end
  2918. end
  2919.  
  2920. function UIMenu:GoBack()
  2921.     PlaySoundFrontend(-1, self.Settings.Audio.Back, self.Settings.Audio.Library, true)
  2922.     self:Visible(false)
  2923.     if self.ParentMenu ~= nil then
  2924.         self.ParentMenu:Visible(true)
  2925.         self.OnMenuChanged(self, self.ParentMenu, false)
  2926.         if self.Settings.ResetCursorOnOpen then
  2927.             local W, H = GetActiveScreenResolution()
  2928.             SetCursorLocation(W / 2, H / 2)
  2929.         end
  2930.     end
  2931.     self.OnMenuClosed(self)
  2932. end
  2933.  
  2934. function UIMenu:BindMenuToItem(Menu, Item)
  2935.     if Menu() == "UIMenu" and Item() == "UIMenuItem" then
  2936.         Menu.ParentMenu = self
  2937.         Menu.ParentItem = Item
  2938.         self.Children[Item] = Menu
  2939.     end
  2940. end
  2941.  
  2942. function UIMenu:ReleaseMenuFromItem(Item)
  2943.     if Item() == "UIMenuItem" then
  2944.         if not self.Children[Item] then
  2945.             return false
  2946.         end
  2947.         self.Children[Item].ParentMenu = nil
  2948.         self.Children[Item].ParentItem = nil
  2949.         self.Children[Item] = nil
  2950.         return true
  2951.     end
  2952. end
  2953.  
  2954. function UIMenu:Draw()
  2955.     if not self._Visible then
  2956.         return
  2957.     end
  2958.  
  2959.     HideHudComponentThisFrame(19)
  2960.  
  2961.     if self.Settings.ControlDisablingEnabled then
  2962.         self:DisEnableControls(false)
  2963.     end
  2964.  
  2965.     if self.Settings.InstructionalButtons then
  2966.         DrawScaleformMovieFullscreen(self.InstructionalScaleform, 255, 255, 255, 255, 0)
  2967.     end
  2968.  
  2969.     if self.Settings.ScaleWithSafezone then
  2970.         ScreenDrawPositionBegin(76, 84)
  2971.         ScreenDrawPositionRatio(0, 0, 0, 0)
  2972.     end
  2973.  
  2974.     if self.ReDraw then
  2975.         self:DrawCalculations()
  2976.     end
  2977.  
  2978.     if self.Logo then
  2979.         self.Logo:Draw()
  2980.     elseif self.Banner then
  2981.         self.Banner:Draw()
  2982.     end
  2983.  
  2984.     self.Title:Draw()
  2985.  
  2986.     if self.Subtitle.Rectangle then
  2987.         self.Subtitle.Rectangle:Draw()
  2988.         self.Subtitle.Text:Draw()
  2989.     end
  2990.  
  2991.     if #self.Items ~= 0 or #self.Windows ~= 0 then
  2992.         self.Background:Draw()
  2993.     end
  2994.  
  2995.     if #self.Windows ~= 0 then
  2996.         local WindowOffset = 0
  2997.         for index = 1, #self.Windows do
  2998.             if self.Windows[index - 1] then
  2999.                 WindowOffset = WindowOffset + self.Windows[index - 1].Background:Size().Height
  3000.             end
  3001.             local Window = self.Windows[index]
  3002.             Window:Position(WindowOffset + self.Subtitle.ExtraY - 37)
  3003.             Window:Draw()
  3004.         end
  3005.     end
  3006.  
  3007.     if #self.Items == 0 then
  3008.         if self.Settings.ScaleWithSafezone then
  3009.             ScreenDrawPositionEnd()
  3010.         end
  3011.         return
  3012.     end
  3013.  
  3014.     local CurrentSelection = self:CurrentSelection()
  3015.     self.Items[CurrentSelection]:Selected(true)
  3016.  
  3017.     if self.Items[CurrentSelection]:Description() ~= "" then
  3018.         self.Description.Bar:Draw()
  3019.         self.Description.Rectangle:Draw()
  3020.         self.Description.Text:Draw()
  3021.     end
  3022.  
  3023.     if self.Items[CurrentSelection].Panels ~= nil then
  3024.         if #self.Items[CurrentSelection].Panels ~= 0 then
  3025.             local PanelOffset = self:CaclulatePanelPosition(self.Items[CurrentSelection]:Description() ~= "")
  3026.             for index = 1, #self.Items[CurrentSelection].Panels do
  3027.                 if self.Items[CurrentSelection].Panels[index - 1] then
  3028.                     PanelOffset = PanelOffset + self.Items[CurrentSelection].Panels[index - 1].Background:Size().Height + 5
  3029.                 end
  3030.                 self.Items[CurrentSelection].Panels[index]:Position(PanelOffset)
  3031.                 self.Items[CurrentSelection].Panels[index]:Draw()
  3032.             end
  3033.         end
  3034.     end
  3035.  
  3036.     local WindowHeight = self:CalculateWindowHeight()
  3037.  
  3038.     if #self.Items <= self.Pagination.Total + 1 then
  3039.         local count = 0
  3040.         for index = 1, #self.Items do
  3041.             Item = self.Items[index]
  3042.             Item:Position(count * 38 - 37 + self.Subtitle.ExtraY + WindowHeight)
  3043.             Item:Draw()
  3044.             count = count + 1
  3045.         end
  3046.     else
  3047.         local count = 0
  3048.         for index = self.Pagination.Min + 1, self.Pagination.Max, 1 do
  3049.             if self.Items[index] then
  3050.                 Item = self.Items[index]                
  3051.                 Item:Position(count * 38 - 37 + self.Subtitle.ExtraY + WindowHeight)
  3052.                 Item:Draw()
  3053.                 count = count + 1
  3054.             end
  3055.         end
  3056.  
  3057.         self.Extra.Up:Draw()
  3058.         self.Extra.Down:Draw()
  3059.         self.ArrowSprite:Draw()
  3060.  
  3061.         if self.PageCounter.Text ~= nil then
  3062.             local Caption = self.PageCounter.PreText .. CurrentSelection .. " / " .. #self.Items
  3063.             self.PageCounter.Text:Text(Caption)
  3064.             self.PageCounter.Text:Draw()
  3065.         end
  3066.     end
  3067.  
  3068.     if self.Settings.ScaleWithSafezone then
  3069.         ScreenDrawPositionEnd()
  3070.     end
  3071. end
  3072.  
  3073. function UIMenu:ProcessMouse()
  3074.     if not self._Visible or self.JustOpened or #self.Items == 0 or tobool(Controller()) or not self.Settings.MouseControlsEnabled then
  3075.         EnableControlAction(0, 2, true)
  3076.         EnableControlAction(0, 1, true)
  3077.         EnableControlAction(0, 25, true)
  3078.         EnableControlAction(0, 24, true)
  3079.         if self.Dirty then
  3080.             for _, Item in pairs(self.Items) do
  3081.                 if Item:Hovered() then
  3082.                     Item:Hovered(false)
  3083.                 end
  3084.             end
  3085.         end
  3086.         return
  3087.     end
  3088.  
  3089.     local SafeZone = {X = 0, Y = 0}
  3090.     local WindowHeight = self:CalculateWindowHeight()
  3091.     if self.Settings.ScaleWithSafezone then
  3092.        SafeZone = GetSafeZoneBounds()
  3093.     end
  3094.  
  3095.     local Limit = #self.Items
  3096.     local Counter = 0
  3097.  
  3098.     ShowCursorThisFrame()
  3099.  
  3100.     if #self.Items > self.Pagination.Total + 1 then
  3101.         Limit = self.Pagination.Max
  3102.     end
  3103.  
  3104.     if IsMouseInBounds(0, 0, 30, 1080) and self.Settings.MouseEdgeEnabled then
  3105.         SetGameplayCamRelativeHeading(GetGameplayCamRelativeHeading() + 5)
  3106.         SetCursorSprite(6)
  3107.     elseif IsMouseInBounds(1920 - 30, 0, 30, 1080) and self.Settings.MouseEdgeEnabled then
  3108.         SetGameplayCamRelativeHeading(GetGameplayCamRelativeHeading() - 5)
  3109.         SetCursorSprite(7)  
  3110.     elseif self.Settings.MouseEdgeEnabled then
  3111.         SetCursorSprite(1)
  3112.     end
  3113.  
  3114.     for i = self.Pagination.Min + 1, Limit, 1 do
  3115.         local X, Y = self.Position.X + SafeZone.X, self.Position.Y + 144 - 37 + self.Subtitle.ExtraY + (Counter * 38) + SafeZone.Y + WindowHeight
  3116.         local Width, Height = 431 + self.WidthOffset, 38
  3117.         local Item = self.Items[i]
  3118.         local Type, SubType = Item()
  3119.  
  3120.         if IsMouseInBounds(X, Y, Width, Height) then
  3121.             Item:Hovered(true)
  3122.             if not self.Controls.MousePressed then
  3123.                 if IsDisabledControlJustPressed(0, 24) then
  3124.                     Citizen.CreateThread(function()
  3125.                         local _X, _Y, _Width, _Height = X, Y, Width, Height
  3126.                         self.Controls.MousePressed = true
  3127.                         if Item:Selected() and Item:Enabled() then
  3128.                             if SubType == "UIMenuListItem" then
  3129.                                 if IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height ) then
  3130.                                     self:GoLeft()
  3131.                                 elseif not IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3132.                                     self:SelectItem()
  3133.                                 end
  3134.                                 if IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3135.                                     self:GoRight()
  3136.                                 elseif not IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height) then
  3137.                                     self:SelectItem()
  3138.                                 end
  3139.                             elseif SubType == "UIMenuSliderItem" then
  3140.                                 if IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height) then
  3141.                                     self:GoLeft()
  3142.                                 elseif not IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3143.                                     self:SelectItem()
  3144.                                 end
  3145.                                 if IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3146.                                     self:GoRight()
  3147.                                 elseif not IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height) then
  3148.                                     self:SelectItem()
  3149.                                 end
  3150.                             else
  3151.                                 self:SelectItem()
  3152.                             end
  3153.                         elseif not Item:Selected() then
  3154.                             self:CurrentSelection(i-1)
  3155.                             PlaySoundFrontend(-1, self.Settings.Audio.Error, self.Settings.Audio.Library, true)
  3156.                             self.OnIndexChange(self, self:CurrentSelection())
  3157.                             self.ReDraw = true
  3158.                             self:UpdateScaleform()
  3159.                         elseif not Item:Enabled() and Item:Selected() then
  3160.                             PlaySoundFrontend(-1, self.Settings.Audio.Error, self.Settings.Audio.Library, true)
  3161.                         end
  3162.                         Citizen.Wait(175)
  3163.                         while IsDisabledControlPressed(0, 24) and IsMouseInBounds(_X, _Y, _Width, _Height) do
  3164.                             if Item:Selected() and Item:Enabled() then
  3165.                                 if SubType == "UIMenuListItem" then
  3166.                                     if IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height) then
  3167.                                         self:GoLeft()
  3168.                                     end
  3169.                                     if IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3170.                                         self:GoRight()
  3171.                                     end
  3172.                                 elseif SubType == "UIMenuSliderItem" then
  3173.                                     if IsMouseInBounds(Item.LeftArrow.X + SafeZone.X, Item.LeftArrow.Y + SafeZone.Y, Item.LeftArrow.Width, Item.LeftArrow.Height) then
  3174.                                         self:GoLeft()
  3175.                                     end
  3176.                                     if IsMouseInBounds(Item.RightArrow.X + SafeZone.X, Item.RightArrow.Y + SafeZone.Y, Item.RightArrow.Width, Item.RightArrow.Height) then
  3177.                                         self:GoRight()
  3178.                                     end
  3179.                                 end
  3180.                             elseif not Item:Selected() then
  3181.                                 self:CurrentSelection(i-1)
  3182.                                 PlaySoundFrontend(-1, self.Settings.Audio.Error, self.Settings.Audio.Library, true)
  3183.                                 self.OnIndexChange(self, self:CurrentSelection())
  3184.                                 self.ReDraw = true
  3185.                                 self:UpdateScaleform()
  3186.                             elseif not Item:Enabled() and Item:Selected() then
  3187.                                 PlaySoundFrontend(-1, self.Settings.Audio.Error, self.Settings.Audio.Library, true)
  3188.                             end
  3189.                             Citizen.Wait(125)                      
  3190.                         end
  3191.                         self.Controls.MousePressed = false
  3192.                     end)
  3193.                 end
  3194.             end
  3195.         else
  3196.             Item:Hovered(false)
  3197.         end
  3198.         Counter = Counter + 1
  3199.     end
  3200.  
  3201.     local ExtraX, ExtraY = self.Position.X  + SafeZone.X, 144 + 38 * (self.Pagination.Total + 1) + self.Position.Y - 37 + self.Subtitle.ExtraY + SafeZone.Y + WindowHeight
  3202.  
  3203.     if #self.Items <= self.Pagination.Total + 1 then return end
  3204.  
  3205.     if IsMouseInBounds(ExtraX, ExtraY, 431 + self.WidthOffset, 18) then
  3206.         self.Extra.Up:Colour(30, 30, 30, 255)
  3207.         if not self.Controls.MousePressed then
  3208.             if IsDisabledControlJustPressed(0, 24) then
  3209.                 Citizen.CreateThread(function()
  3210.                     local _ExtraX, _ExtraY = ExtraX, ExtraY
  3211.                     self.Controls.MousePressed = true
  3212.                     if #self.Items > self.Pagination.Total + 1 then
  3213.                         self:GoUpOverflow()
  3214.                     else
  3215.                         self:GoUp()
  3216.                     end
  3217.                     Citizen.Wait(175)
  3218.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(_ExtraX, _ExtraY, 431 + self.WidthOffset, 18) do
  3219.                         if #self.Items > self.Pagination.Total + 1 then
  3220.                             self:GoUpOverflow()
  3221.                         else
  3222.                             self:GoUp()
  3223.                         end
  3224.                         Citizen.Wait(125)
  3225.                     end
  3226.                     self.Controls.MousePressed = false              
  3227.                 end)
  3228.             end
  3229.         end
  3230.     else
  3231.         self.Extra.Up:Colour(0, 0, 0, 200)
  3232.     end
  3233.  
  3234.     if IsMouseInBounds(ExtraX, ExtraY + 18, 431 + self.WidthOffset, 18) then
  3235.         self.Extra.Down:Colour(30, 30, 30, 255)
  3236.         if not self.Controls.MousePressed then
  3237.             if IsDisabledControlJustPressed(0, 24) then
  3238.                 Citizen.CreateThread(function()
  3239.                     local _ExtraX, _ExtraY = ExtraX, ExtraY
  3240.                     self.Controls.MousePressed = true
  3241.                     if #self.Items > self.Pagination.Total + 1 then
  3242.                         self:GoDownOverflow()
  3243.                     else
  3244.                         self:GoDown()
  3245.                     end
  3246.                     Citizen.Wait(175)
  3247.                     while IsDisabledControlPressed(0, 24) and IsMouseInBounds(_ExtraX, _ExtraY + 18, 431 + self.WidthOffset, 18) do
  3248.                         if #self.Items > self.Pagination.Total + 1 then
  3249.                             self:GoDownOverflow()
  3250.                         else
  3251.                             self:GoDown()
  3252.                         end
  3253.                         Citizen.Wait(125)
  3254.                     end
  3255.                     self.Controls.MousePressed = false              
  3256.                 end)
  3257.             end
  3258.         end
  3259.     else
  3260.         self.Extra.Down:Colour(0, 0, 0, 200)
  3261.     end
  3262. end
  3263.  
  3264. function UIMenu:AddInstructionButton(button)
  3265.     if type(button) == "table" and #button == 2 then
  3266.         table.insert(self.InstructionalButtons, button)
  3267.     end
  3268. end
  3269.  
  3270. function UIMenu:RemoveInstructionButton(button)
  3271.     if type(button) == "table" then
  3272.         for i = 1, #self.InstructionalButtons do
  3273.             if button == self.InstructionalButtons[i] then
  3274.                 table.remove(self.InstructionalButtons, i)
  3275.                 break
  3276.             end
  3277.         end
  3278.     else
  3279.         if tonumber(button) then
  3280.             if self.InstructionalButtons[tonumber(button)] then
  3281.                 table.remove(self.InstructionalButtons, tonumber(button))
  3282.             end
  3283.         end
  3284.     end
  3285. end
  3286.  
  3287. function UIMenu:UpdateScaleform()
  3288.     if not self._Visible or not self.Settings.InstructionalButtons then
  3289.         return
  3290.     end
  3291.    
  3292.     PushScaleformMovieFunction(self.InstructionalScaleform, "CLEAR_ALL")
  3293.     PopScaleformMovieFunction()
  3294.  
  3295.     PushScaleformMovieFunction(self.InstructionalScaleform, "TOGGLE_MOUSE_BUTTONS")
  3296.     PushScaleformMovieFunctionParameterInt(0)
  3297.     PopScaleformMovieFunction()
  3298.  
  3299.     PushScaleformMovieFunction(self.InstructionalScaleform, "CREATE_CONTAINER")
  3300.     PopScaleformMovieFunction()
  3301.  
  3302.     PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT")
  3303.     PushScaleformMovieFunctionParameterInt(0)
  3304.     PushScaleformMovieFunctionParameterString(GetControlInstructionalButton(2, 176, 0))
  3305.     PushScaleformMovieFunctionParameterString("Select")
  3306.     PopScaleformMovieFunction()
  3307.  
  3308.     PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT")
  3309.     PushScaleformMovieFunctionParameterInt(1)
  3310.     PushScaleformMovieFunctionParameterString(GetControlInstructionalButton(2, 177, 0))
  3311.     PushScaleformMovieFunctionParameterString("Back")
  3312.     PopScaleformMovieFunction()
  3313.  
  3314.     local count = 2
  3315.  
  3316.     for i = 1, #self.InstructionalButtons do
  3317.         if self.InstructionalButtons[i] then
  3318.             if #self.InstructionalButtons[i] == 2 then
  3319.                 PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT")
  3320.                 PushScaleformMovieFunctionParameterInt(count)
  3321.                 PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][1])
  3322.                 PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][2])
  3323.                 PopScaleformMovieFunction()
  3324.                 count = count + 1
  3325.             end
  3326.         end
  3327.     end
  3328.  
  3329.     PushScaleformMovieFunction(self.InstructionalScaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
  3330.     PushScaleformMovieFunctionParameterInt(-1)
  3331.     PopScaleformMovieFunction()
  3332. end
  3333.  
  3334. --[[
  3335.     MenuPool.lua
  3336.     Menus
  3337. --]]
  3338.  
  3339. function MenuPool.New()
  3340.     local _MenuPool = {
  3341.         Menus = {}
  3342.     }
  3343.     return setmetatable(_MenuPool, MenuPool)
  3344. end
  3345.  
  3346. function MenuPool:AddSubMenu(Menu, Text, Description, KeepPosition)
  3347.     if Menu() == "UIMenu" then
  3348.         local Item = UIMenuItem.New(tostring(Text), Description or "")
  3349.         Menu:AddItem(Item)
  3350.         local SubMenu
  3351.         if KeepPosition then
  3352.             SubMenu = UIMenu.New(Menu.Title:Text(), Text, Menu.Position.X, Menu.Position.Y)
  3353.         else
  3354.             SubMenu = UIMenu.New(Menu.Title:Text(), Text)
  3355.         end
  3356.         self:Add(SubMenu)
  3357.         Menu:BindMenuToItem(SubMenu, Item)
  3358.         return SubMenu
  3359.     end
  3360. end
  3361.  
  3362. function MenuPool:Add(Menu)
  3363.     if Menu() == "UIMenu" then
  3364.         table.insert(self.Menus, Menu)
  3365.     end
  3366. end
  3367.  
  3368. function MenuPool:MouseEdgeEnabled(bool)
  3369.     if bool ~= nil then
  3370.         for _, Menu in pairs(self.Menus) do
  3371.             Menu.Settings.MouseEdgeEnabled = tobool(bool)
  3372.         end
  3373.     end
  3374. end
  3375.  
  3376. function MenuPool:ControlDisablingEnabled(bool)
  3377.     if bool ~= nil then
  3378.         for _, Menu in pairs(self.Menus) do
  3379.             Menu.Settings.ControlDisablingEnabled = tobool(bool)
  3380.         end
  3381.     end
  3382. end
  3383.  
  3384. function MenuPool:ResetCursorOnOpen(bool)
  3385.     if bool ~= nil then
  3386.         for _, Menu in pairs(self.Menus) do
  3387.             Menu.Settings.ResetCursorOnOpen = tobool(bool)
  3388.         end
  3389.     end
  3390. end
  3391.  
  3392. function MenuPool:MultilineFormats(bool)
  3393.     if bool ~= nil then
  3394.         for _, Menu in pairs(self.Menus) do
  3395.             Menu.Settings.MultilineFormats = tobool(bool)
  3396.         end
  3397.     end
  3398. end
  3399.  
  3400. function MenuPool:Audio(Attribute, Setting)
  3401.     if Attribute ~= nil and Setting ~= nil then
  3402.         for _, Menu in pairs(self.Menus) do
  3403.             if Menu.Settings.Audio[Attribute] then
  3404.                 Menu.Settings.Audio[Attribute] = Setting
  3405.             end
  3406.         end
  3407.     end
  3408. end
  3409.  
  3410. function MenuPool:WidthOffset(offset)
  3411.     if tonumber(offset) then
  3412.         for _, Menu in pairs(self.Menus) do
  3413.             Menu:SetMenuWidthOffset(tonumber(offset))
  3414.         end
  3415.     end
  3416. end
  3417.  
  3418. function MenuPool:CounterPreText(str)
  3419.     if str ~= nil then
  3420.         for _, Menu in pairs(self.Menus) do
  3421.             Menu.PageCounter.PreText = tostring(str)
  3422.         end
  3423.     end
  3424. end
  3425.  
  3426. function MenuPool:DisableInstructionalButtons(bool)
  3427.     if bool ~= nil then
  3428.         for _, Menu in pairs(self.Menus) do
  3429.             Menu.Settings.InstructionalButtons = tobool(bool)
  3430.         end
  3431.     end
  3432. end
  3433.  
  3434. function MenuPool:MouseControlsEnabled(bool)
  3435.     if bool ~= nil then
  3436.         for _, Menu in pairs(self.Menus) do
  3437.             Menu.Settings.MouseControlsEnabled = tobool(bool)
  3438.         end
  3439.     end
  3440. end
  3441.  
  3442. function MenuPool:RefreshIndex()
  3443.     for _, Menu in pairs(self.Menus) do
  3444.         Menu:RefreshIndex()
  3445.     end
  3446. end
  3447.  
  3448. function MenuPool:ProcessMenus()
  3449.     self:ProcessControl()
  3450.     self:ProcessMouse()
  3451.     self:Draw()
  3452. end
  3453.  
  3454. function MenuPool:ProcessControl()
  3455.     for _, Menu in pairs(self.Menus) do
  3456.         if Menu:Visible() then
  3457.             Menu:ProcessControl()
  3458.         end
  3459.     end
  3460. end
  3461.  
  3462. function MenuPool:ProcessMouse()
  3463.     for _, Menu in pairs(self.Menus) do
  3464.         if Menu:Visible() then
  3465.             Menu:ProcessMouse()
  3466.         end
  3467.     end
  3468. end
  3469.  
  3470. function MenuPool:Draw()
  3471.     for _, Menu in pairs(self.Menus) do
  3472.         if Menu:Visible() then
  3473.             Menu:Draw()
  3474.         end
  3475.     end
  3476. end
  3477.  
  3478. function MenuPool:IsAnyMenuOpen()
  3479.     local open = false
  3480.     for _, Menu in pairs(self.Menus) do
  3481.         if Menu:Visible() then
  3482.             open = true
  3483.             break
  3484.         end
  3485.     end
  3486.     return open
  3487. end
  3488.  
  3489. function MenuPool:CloseAllMenus()
  3490.     for _, Menu in pairs(self.Menus) do
  3491.         if Menu:Visible() then
  3492.             Menu:Visible(false)
  3493.         end
  3494.     end
  3495. end
  3496.  
  3497. function MenuPool:SetBannerSprite(Sprite)
  3498.     if Sprite() == "Sprite" then
  3499.         for _, Menu in pairs(self.Menus) do
  3500.             Menu:SetBannerSprite(Sprite)
  3501.         end
  3502.     end
  3503. end
  3504.  
  3505. function MenuPool:SetBannerRectangle(Rectangle)
  3506.     if Rectangle() == "Rectangle" then
  3507.         for _, Menu in pairs(self.Menus) do
  3508.             Menu:SetBannerRectangle(Rectangle)
  3509.         end
  3510.     end
  3511. end
  3512.  
  3513. function MenuPool:TotalItemsPerPage(Value)
  3514.     if tonumber(Value) then
  3515.         for _, Menu in pairs(self.Menus) do
  3516.             Menu.Pagination.Total = Value - 1
  3517.         end
  3518.     end
  3519. end
  3520. --[[
  3521.     Wrappers
  3522. --]]
  3523.  
  3524. function NativeUI.CreatePool()
  3525.     return MenuPool.New()
  3526. end
  3527.  
  3528. function NativeUI.CreateMenu(Title, Subtitle, X, Y, TxtDictionary, TxtName)
  3529.     return UIMenu.New(Title, Subtitle, X, Y, TxtDictionary, TxtName)
  3530. end
  3531.  
  3532. function NativeUI.CreateItem(Text, Description)
  3533.     return UIMenuItem.New(Text, Description)
  3534. end
  3535.  
  3536. function NativeUI.CreateColouredItem(Text, Description, MainColour, HighlightColour)
  3537.     return UIMenuColouredItem.New(Text, Description, MainColour, HighlightColour)
  3538. end
  3539.  
  3540. function NativeUI.CreateCheckboxItem(Text, Check, Description)
  3541.     return UIMenuCheckboxItem.New(Text, Check, Description)
  3542. end
  3543.  
  3544. function NativeUI.CreateListItem(Text, Items, Index, Description)
  3545.     return UIMenuListItem.New(Text, Items, Index, Description)
  3546. end
  3547.  
  3548. function NativeUI.CreateSliderItem(Text, Items, Index, Description, Divider)
  3549.     return UIMenuSliderItem.New(Text, Items, Index, Description, Divider)
  3550. end
  3551.  
  3552. function NativeUI.CreateHeritageWindow(Mum, Dad)
  3553.     return UIMenuHeritageWindow.New(Mum, Dad)
  3554. end
  3555.  
  3556. function NativeUI.CreateGridPanel(TopText, LeftText, RightText, BottomText)
  3557.     return UIMenuGridPanel.New(TopText, LeftText, RightText, BottomText)
  3558. end
  3559.  
  3560. function NativeUI.CreateColourPanel(Title, Colours)
  3561.     return UIMenuColourPanel.New(Title, Colours)
  3562. end
  3563.  
  3564. function NativeUI.CreatePercentagePanel(MinText, MaxText)
  3565.     return UIMenuPercentagePanel.New(MinText, MaxText)
  3566. end
  3567.  
  3568. function NativeUI.CreateSprite(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
  3569.     return UI.Sprite.New(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
  3570. end
  3571.  
  3572. function NativeUI.CreateRectangle(X, Y, Width, Height, R, G, B, A)
  3573.     return UI.Rectangle.New(X, Y, Width, Height, R, G, B, A)
  3574. end
  3575.  
  3576. function NativeUI.CreateText(Text, X, Y, Scale, R, G, B, A, Font, Alignment, DropShadow, Outline, WordWrap)
  3577.     return UI.Text.New(Text, X, Y, Scale, R, G, B, A, Font, Alignment, DropShadow, Outline, WordWrap)
  3578. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement