├── LICENSE ├── README.md ├── RageUI ├── RMenu.lua ├── components │ ├── Audio.lua │ ├── Enum.lua │ ├── Keys.lua │ ├── Rectangle.lua │ ├── Sprite.lua │ ├── Text.lua │ └── Visual.lua └── menu │ ├── Menu.lua │ ├── MenuController.lua │ ├── RageUI.lua │ ├── elements │ ├── ItemsBadge.lua │ ├── ItemsColour.lua │ └── PanelColour.lua │ ├── items │ ├── UIButton.lua │ ├── UICheckBox.lua │ ├── UIList.lua │ ├── UISeparator.lua │ ├── UISlider.lua │ ├── UISliderHeritage.lua │ └── UISliderProgress.lua │ ├── panels │ ├── UIColourPanel.lua │ ├── UIGridPanel.lua │ ├── UIPercentagePanel.lua │ ├── UISliderPanel.lua │ ├── UISpritPanel.lua │ └── UIStatisticsPanel.lua │ └── windows │ └── UIHeritage.lua ├── client ├── client.lua ├── events.lua ├── function.lua ├── info.lua ├── main.lua ├── manipulation.lua └── play.lua ├── fxmanifest.lua ├── html ├── index.html └── scripts │ ├── SoundPlayer.js │ ├── functions.js │ └── listener.js ├── server └── server.lua ├── spotify_system.sql └── stream ├── RageUI_.ytd ├── banner_spotify.ytd ├── casinoui_cards_blackjack.ytd ├── casinoui_cards_blackjack_high.ytd ├── casinoui_cards_three.ytd ├── casinoui_cards_three_high.ytd ├── casinoui_insidetrack.ytd ├── casinoui_lucky_wheel.ytd ├── casinoui_roulette.ytd ├── casinoui_roulette_high.ytd ├── casinoui_slots_angel.ytd ├── casinoui_slots_deity.ytd ├── casinoui_slots_diamond.ytd ├── casinoui_slots_evacuator.ytd ├── casinoui_slots_fame.ytd ├── casinoui_slots_impotent.ytd ├── casinoui_slots_knife.ytd ├── casinoui_slots_ranger.ytd ├── mpawardcasino.ytd └── root_cause.ytd /README.md: -------------------------------------------------------------------------------- 1 | # SpotifySystem 2 | 3 | # FR 4 | - Script permettant d'écouter de la musique depuis un menu, sur FiveM. 5 | - Le menu s'ouvre avec la commande /spotify 6 | - Simple d'utilisation 7 | - Optimisation 0.00 ms 8 | - Lib : RageUI et https://github.com/Xogy/xsound 9 | - Pour tout support AigleIsBack#7053 & Yatox#3203 10 | 11 | # EN 12 | - Script allowing to listen to music from a menu, on FiveM. 13 | - You can open this menu with command /spotify 14 | - Easily utilisation 15 | - Optimization 0.00 ms 16 | - Lib: RageUI and https://github.com/Xogy/xsound 17 | - For any question AigleIsBack#7053 & Yatox#3203 18 | 19 | # Preview 20 | - https://streamable.com/j7nl0o 21 | 22 | # Contributor 23 | 24 | - [Yatox](https://github.com/Yatox18) 25 | -------------------------------------------------------------------------------- /RageUI/RMenu.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Dylan Malandain. 4 | --- DateTime: 29/10/2019 02:40 5 | --- 6 | 7 | ---@class RageUI 8 | RageUI = {} 9 | 10 | ---@class Item 11 | RageUI.Item = {} 12 | 13 | ---@class Panel 14 | RageUI.Panel = {} 15 | 16 | ---@class Window 17 | RageUI.Window = {} 18 | 19 | ---@class RMenu 20 | RMenu = setmetatable({}, RMenu) 21 | 22 | ---@type table 23 | local TotalMenus = {} 24 | 25 | ---Add 26 | ---@param Type string 27 | ---@param Name string 28 | ---@param Menu table 29 | ---@return RMenu 30 | ---@public 31 | function RMenu.Add(Type, Name, Menu) 32 | if RMenu[Type] ~= nil then 33 | RMenu[Type][Name] = { 34 | Menu = Menu 35 | } 36 | else 37 | RMenu[Type] = {} 38 | RMenu[Type][Name] = { 39 | Menu = Menu 40 | } 41 | end 42 | return table.insert(TotalMenus, Menu) 43 | end 44 | 45 | ---Get 46 | ---@param Type string 47 | ---@param Name string 48 | ---@return table 49 | ---@public 50 | function RMenu:Get(Type, Name) 51 | if self[Type] ~= nil and self[Type][Name] ~= nil then 52 | return self[Type][Name].Menu 53 | end 54 | end 55 | 56 | ---GetType 57 | ---@param Type string 58 | ---@return table 59 | ---@public 60 | function RMenu:GetType(Type) 61 | if self[Type] ~= nil then 62 | return self[Type] 63 | end 64 | end 65 | 66 | ---Settings 67 | ---@param Type string 68 | ---@param Name string 69 | ---@param Settings string 70 | ---@param Value any optional 71 | ---@return void 72 | ---@public 73 | function RMenu:Settings(Type, Name, Settings, Value) 74 | if Value ~= nil then 75 | self[Type][Name][Settings] = Value 76 | else 77 | return self[Type][Name][Settings] 78 | end 79 | end 80 | 81 | ---Delete 82 | ---@param Type string 83 | ---@param Name string 84 | ---@return void 85 | ---@public 86 | function RMenu:Delete(Type, Name) 87 | self[Type][Name] = nil 88 | collectgarbage() 89 | end 90 | 91 | ---DeleteType 92 | ---@param Type string 93 | ---@return void 94 | ---@public 95 | function RMenu:DeleteType(Type) 96 | self[Type] = nil 97 | collectgarbage() 98 | end 99 | -------------------------------------------------------------------------------- /RageUI/components/Audio.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Dylan Malandain. 4 | --- DateTime: 24/07/2019 03:38 5 | --- 6 | 7 | 8 | ---PlaySound 9 | --- 10 | --- Reference : N/A 11 | --- 12 | ---@param Library string 13 | ---@param Sound string 14 | ---@param IsLooped boolean 15 | ---@return nil 16 | ---@public 17 | function RageUI.PlaySound(Library, Sound, IsLooped) 18 | local audioId 19 | if not IsLooped then 20 | PlaySoundFrontend(-1, Sound, Library, true) 21 | else 22 | if not audioId then 23 | Citizen.CreateThread(function() 24 | audioId = GetSoundId() 25 | PlaySoundFrontend(audioId, Sound, Library, true) 26 | Citizen.Wait(0.01) 27 | StopSound(audioId) 28 | ReleaseSoundId(audioId) 29 | audioId = nil 30 | end) 31 | end 32 | end 33 | end 34 | 35 | 36 | -------------------------------------------------------------------------------- /RageUI/components/Enum.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | ---@class Enum 4 | local enums = { 5 | __index = function(table, key) 6 | if rawget(table.enums, key) then 7 | return key 8 | end 9 | end 10 | } 11 | 12 | ---Enum 13 | ---@param t table 14 | ---@return Enum 15 | function RageUI.Enum(t) 16 | local e = { enums = t } 17 | return setmetatable(e, enums) 18 | end 19 | -------------------------------------------------------------------------------- /RageUI/components/Keys.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ---@class Keys 5 | Keys = {}; 6 | 7 | ---Register 8 | ---@param Controls string 9 | ---@param ControlName string 10 | ---@param Description string 11 | ---@param Action function 12 | ---@return Keys 13 | ---@public 14 | function Keys.Register(Controls, ControlName, Description, Action) 15 | local _Keys = { 16 | CONTROLS = Controls 17 | } 18 | RegisterKeyMapping(string.format('rageui-%s', ControlName), Description, "keyboard", Controls) 19 | RegisterCommand(string.format('rageui-%s', ControlName), function(source, args) 20 | if (Action ~= nil) then 21 | print(string.format('RageUI - Pressed keys %s', Controls)) 22 | Action(); 23 | end 24 | end, false) 25 | return setmetatable(_Keys, Keys) 26 | end 27 | 28 | ---Exists 29 | ---@param Controls string 30 | ---@return boolean 31 | function Keys:Exists(Controls) 32 | return self.CONTROLS == Controls and true or false 33 | end 34 | -------------------------------------------------------------------------------- /RageUI/components/Rectangle.lua: -------------------------------------------------------------------------------- 1 | ---RenderRectangle 2 | --- 3 | --- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/UIResRectangle.lua#L84 4 | --- 5 | ---@param X number 6 | ---@param Y number 7 | ---@param Width number 8 | ---@param Height number 9 | ---@param R number 10 | ---@param G number 11 | ---@param B number 12 | ---@param A number 13 | ---@return nil 14 | ---@public 15 | function RenderRectangle(X, Y, Width, Height, R, G, B, A) 16 | local X, Y, Width, Height = (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080, (tonumber(Width) or 0) / 1920, (tonumber(Height) or 0) / 1080 17 | 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) 18 | end 19 | -------------------------------------------------------------------------------- /RageUI/components/Sprite.lua: -------------------------------------------------------------------------------- 1 | ---RenderSprite 2 | --- 3 | --- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/Sprite.lua#L90 4 | --- 5 | ---@param TextureDictionary string 6 | ---@param TextureName string 7 | ---@param X number 8 | ---@param Y number 9 | ---@param Width number 10 | ---@param Height number 11 | ---@param Heading number 12 | ---@param R number 13 | ---@param G number 14 | ---@param B number 15 | ---@param A number 16 | ---@return nil 17 | ---@public 18 | function RenderSprite(TextureDictionary, TextureName, X, Y, Width, Height, Heading, R, G, B, A) 19 | ---@type number 20 | local X, Y, Width, Height = (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080, (tonumber(Width) or 0) / 1920, (tonumber(Height) or 0) / 1080 21 | 22 | if not HasStreamedTextureDictLoaded(TextureDictionary) then 23 | RequestStreamedTextureDict(TextureDictionary, true) 24 | end 25 | 26 | DrawSprite(TextureDictionary, TextureName, X + Width * 0.5, Y + Height * 0.5, Width, Height, Heading or 0, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255) 27 | end -------------------------------------------------------------------------------- /RageUI/components/Text.lua: -------------------------------------------------------------------------------- 1 | ---StringToArray 2 | --- 3 | --- Reference : Frazzle <3 4 | --- 5 | ---@param str string 6 | function StringToArray(str) 7 | local charCount = #str 8 | local strCount = math.ceil(charCount / 99) 9 | local strings = {} 10 | 11 | for i = 1, strCount do 12 | local start = (i - 1) * 99 + 1 13 | local clamp = math.clamp(#string.sub(str, start), 0, 99) 14 | local finish = ((i ~= 1) and (start - 1) or 0) + clamp 15 | 16 | strings[i] = string.sub(str, start, finish) 17 | end 18 | 19 | return strings 20 | end 21 | 22 | ---MeasureStringWidth 23 | --- 24 | --- Reference : Frazzle <3 25 | --- 26 | ---@param str string 27 | ---@param font number 28 | ---@param scale number 29 | ---@return _G 30 | ---@public 31 | function MeasureStringWidth(str, font, scale) 32 | BeginTextCommandWidth("CELL_EMAIL_BCON") 33 | AddTextComponentSubstringPlayerName(str) 34 | SetTextFont(font or 0) 35 | SetTextScale(1.0, scale or 0) 36 | return EndTextCommandGetWidth(true) * 1920 37 | end 38 | 39 | 40 | ---AddText 41 | --- 42 | --- Reference : Frazzle <3 43 | --- 44 | ---@param str string 45 | function AddText(str) 46 | local str = tostring(str) 47 | local charCount = #str 48 | 49 | if charCount < 100 then 50 | AddTextComponentSubstringPlayerName(str) 51 | else 52 | local strings = StringToArray(str) 53 | 54 | for s = 1, #strings do 55 | AddTextComponentSubstringPlayerName(strings[s]) 56 | end 57 | end 58 | end 59 | 60 | 61 | ---GetLineCount 62 | --- 63 | --- Reference : Frazzle <3 64 | --- 65 | ---@param Text string 66 | ---@param X number 67 | ---@param Y number 68 | ---@param Font number 69 | ---@param Scale number 70 | ---@param R number 71 | ---@param G number 72 | ---@param B number 73 | ---@param A number 74 | ---@param Alignment string 75 | ---@param DropShadow boolean 76 | ---@param Outline boolean 77 | ---@param WordWrap number 78 | ---@return function 79 | ---@public 80 | function GetLineCount(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap) 81 | ---@type table 82 | local Text, X, Y = tostring(Text), (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080 83 | SetTextFont(Font or 0) 84 | SetTextScale(1.0, Scale or 0) 85 | SetTextColour(tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255) 86 | if DropShadow then 87 | SetTextDropShadow() 88 | end 89 | if Outline then 90 | SetTextOutline() 91 | end 92 | if Alignment ~= nil then 93 | if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then 94 | SetTextCentre(true) 95 | elseif Alignment == 2 or Alignment == "Right" then 96 | SetTextRightJustify(true) 97 | end 98 | end 99 | if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then 100 | if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then 101 | SetTextWrap(X - ((WordWrap / 1920) / 2), X + ((WordWrap / 1920) / 2)) 102 | elseif Alignment == 2 or Alignment == "Right" then 103 | SetTextWrap(0, X) 104 | else 105 | SetTextWrap(X, X + (WordWrap / 1920)) 106 | end 107 | else 108 | if Alignment == 2 or Alignment == "Right" then 109 | SetTextWrap(0, X) 110 | end 111 | end 112 | 113 | BeginTextCommandLineCount("CELL_EMAIL_BCON") 114 | AddText(Text) 115 | return GetTextScreenLineCount(X, Y) 116 | end 117 | 118 | ---RenderText 119 | --- 120 | --- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/UIResText.lua#L189 121 | --- 122 | ---@param Text string 123 | ---@param X number 124 | ---@param Y number 125 | ---@param Font number 126 | ---@param Scale number 127 | ---@param R number 128 | ---@param G number 129 | ---@param B number 130 | ---@param A number 131 | ---@param Alignment string 132 | ---@param DropShadow boolean 133 | ---@param Outline boolean 134 | ---@param WordWrap number 135 | ---@return nil 136 | ---@public 137 | function RenderText(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap) 138 | ---@type table 139 | local Text, X, Y = tostring(Text), (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080 140 | SetTextFont(Font or 0) 141 | SetTextScale(1.0, Scale or 0) 142 | SetTextColour(tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255) 143 | if DropShadow then 144 | SetTextDropShadow() 145 | end 146 | if Outline then 147 | SetTextOutline() 148 | end 149 | if Alignment ~= nil then 150 | if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then 151 | SetTextCentre(true) 152 | elseif Alignment == 2 or Alignment == "Right" then 153 | SetTextRightJustify(true) 154 | end 155 | end 156 | if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then 157 | if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then 158 | SetTextWrap(X - ((WordWrap / 1920) / 2), X + ((WordWrap / 1920) / 2)) 159 | elseif Alignment == 2 or Alignment == "Right" then 160 | SetTextWrap(0, X) 161 | else 162 | SetTextWrap(X, X + (WordWrap / 1920)) 163 | end 164 | else 165 | if Alignment == 2 or Alignment == "Right" then 166 | SetTextWrap(0, X) 167 | end 168 | end 169 | BeginTextCommandDisplayText("CELL_EMAIL_BCON") 170 | AddText(Text) 171 | EndTextCommandDisplayText(X, Y) 172 | end 173 | -------------------------------------------------------------------------------- /RageUI/components/Visual.lua: -------------------------------------------------------------------------------- 1 | 2 | ---@class Visual 3 | Visual = Visual or {}; 4 | 5 | local function AddLongString(txt) 6 | for i = 100, string.len(txt), 99 do 7 | local sub = string.sub(txt, i, i + 99) 8 | AddTextComponentSubstringPlayerName(sub) 9 | end 10 | end 11 | 12 | function Visual.Popup() 13 | 14 | end 15 | 16 | function Visual.Radar() 17 | 18 | end 19 | 20 | function Visual.Subtitle(text, time) 21 | ClearPrints() 22 | BeginTextCommandPrint("STRING") 23 | AddTextComponentSubstringPlayerName(text) 24 | EndTextCommandPrint(time and math.ceil(time) or 0, true) 25 | end 26 | 27 | function Visual.FloatingHelpText(text, sound, loop) 28 | BeginTextCommandDisplayHelp("jamyfafi") 29 | AddTextComponentSubstringPlayerName(text) 30 | if string.len(text) > 99 then 31 | AddLongString(text) 32 | end 33 | EndTextCommandDisplayHelp(0, loop or 0, sound or true, -1) 34 | end 35 | 36 | function Visual.Prompt(text, spinner) 37 | BeginTextCommandBusyspinnerOn("STRING") 38 | AddTextComponentSubstringPlayerName(text) 39 | EndTextCommandBusyspinnerOn(spinner or 1) 40 | end 41 | 42 | function Visual.PromptDuration(duration, text, spinner) 43 | Citizen.CreateThread(function() 44 | Citizen.Wait(0) 45 | Visual.Prompt(text, spinner) 46 | Citizen.Wait(duration) 47 | if (BusyspinnerIsOn()) then 48 | BusyspinnerOff(); 49 | end 50 | end) 51 | end 52 | -------------------------------------------------------------------------------- /RageUI/menu/Menu.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Dylan Malandain. 4 | --- DateTime: 21/04/2019 21:20 5 | --- 6 | 7 | ---CreateMenu 8 | ---@param Title string 9 | ---@param Subtitle string 10 | ---@param X number 11 | ---@param Y number 12 | ---@param TextureDictionary string 13 | ---@param TextureName string 14 | ---@param R number 15 | ---@param G number 16 | ---@param B number 17 | ---@param A number 18 | ---@return RageUIMenus 19 | ---@public 20 | function RageUI.CreateMenu(Title, Subtitle, X, Y, TextureDictionary, TextureName, R, G, B, A) 21 | 22 | ---@type table 23 | local Menu = {} 24 | Menu.Display = {}; 25 | 26 | Menu.InstructionalButtons = {} 27 | 28 | Menu.Display.Header = true; 29 | Menu.Display.Glare = true; 30 | Menu.Display.Subtitle = true; 31 | Menu.Display.Background = true; 32 | Menu.Display.Navigation = true; 33 | Menu.Display.InstructionalButton = true; 34 | Menu.Display.PageCounter = true; 35 | 36 | Menu.Title = Title or "" 37 | Menu.TitleFont = 1 38 | Menu.TitleScale = 1.2 39 | Menu.Subtitle = Subtitle or nil 40 | Menu.SubtitleHeight = -37 41 | Menu.Description = nil 42 | Menu.DescriptionHeight = RageUI.Settings.Items.Description.Background.Height 43 | Menu.X = X or 0 44 | Menu.Y = Y or 0 45 | Menu.Parent = nil 46 | Menu.WidthOffset = RageUI.UI.Style[RageUI.UI.Current].Width 47 | Menu.Open = false 48 | Menu.Controls = RageUI.Settings.Controls 49 | Menu.Index = 1 50 | Menu.Sprite = { Dictionary = TextureDictionary or "commonmenu", Texture = TextureName or "interaction_bgd", Color = { R = R, G = G, B = B, A = A } } 51 | Menu.Rectangle = nil 52 | Menu.Pagination = { Minimum = 1, Maximum = 10, Total = 10 } 53 | Menu.Safezone = true 54 | Menu.SafeZoneSize = nil 55 | Menu.EnableMouse = false 56 | Menu.Options = 0 57 | Menu.Closable = true 58 | Menu.InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS") 59 | Menu.CursorStyle = 1 60 | 61 | if string.starts(Menu.Subtitle, "~") then 62 | Menu.PageCounterColour = string.lower(string.sub(Menu.Subtitle, 1, 3)) 63 | else 64 | Menu.PageCounterColour = "" 65 | end 66 | 67 | if Menu.Subtitle ~= "" then 68 | local SubtitleLineCount = GetLineCount(Menu.Subtitle, Menu.X + RageUI.Settings.Items.Subtitle.Text.X, Menu.Y + RageUI.Settings.Items.Subtitle.Text.Y, 0, RageUI.Settings.Items.Subtitle.Text.Scale, 245, 245, 245, 255, nil, false, false, RageUI.Settings.Items.Subtitle.Background.Width + Menu.WidthOffset) 69 | 70 | if SubtitleLineCount > 1 then 71 | Menu.SubtitleHeight = 18 * SubtitleLineCount 72 | else 73 | Menu.SubtitleHeight = 0 74 | end 75 | end 76 | 77 | Citizen.CreateThread(function() 78 | if not HasScaleformMovieLoaded(Menu.InstructionalScaleform) then 79 | Menu.InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS") 80 | while not HasScaleformMovieLoaded(Menu.InstructionalScaleform) do 81 | Citizen.Wait(0) 82 | end 83 | end 84 | end) 85 | 86 | Citizen.CreateThread(function() 87 | local ScaleformMovie = RequestScaleformMovie("MP_MENU_GLARE") 88 | while not HasScaleformMovieLoaded(ScaleformMovie) do 89 | Citizen.Wait(0) 90 | end 91 | end) 92 | 93 | return setmetatable(Menu, RageUI.Menus) 94 | end 95 | 96 | ---CreateSubMenu 97 | ---@param ParentMenu function 98 | ---@param Title string 99 | ---@param Subtitle string 100 | ---@param X number 101 | ---@param Y number 102 | ---@param TextureDictionary string 103 | ---@param TextureName string 104 | ---@param R number 105 | ---@param G number 106 | ---@param B number 107 | ---@param A number 108 | ---@return RageUIMenus 109 | ---@public 110 | function RageUI.CreateSubMenu(ParentMenu, Title, Subtitle, X, Y, TextureDictionary, TextureName, R, G, B, A) 111 | if ParentMenu ~= nil then 112 | if ParentMenu() then 113 | local Menu = RageUI.CreateMenu(Title or ParentMenu.Title, Subtitle or string.upper(ParentMenu.Subtitle), X or ParentMenu.X, Y or ParentMenu.Y) 114 | Menu.Parent = ParentMenu 115 | Menu.WidthOffset = ParentMenu.WidthOffset 116 | Menu.Safezone = ParentMenu.Safezone 117 | if ParentMenu.Sprite then 118 | Menu.Sprite = { Dictionary = TextureDictionary or ParentMenu.Sprite.Dictionary, Texture = TextureName or ParentMenu.Sprite.Texture, Color = { R = R or ParentMenu.Sprite.Color.R, G = G or ParentMenu.Sprite.Color.G, B = B or ParentMenu.Sprite.Color.B, A = A or ParentMenu.Sprite.Color.A } } 119 | else 120 | Menu.Rectangle = ParentMenu.Rectangle 121 | end 122 | return setmetatable(Menu, RageUI.Menus) 123 | else 124 | return nil 125 | end 126 | else 127 | return nil 128 | end 129 | end 130 | 131 | function RageUI.Menus:DisplayHeader(boolean) 132 | self.Display.Header = boolean; 133 | return self.Display.Header; 134 | end 135 | 136 | function RageUI.Menus:DisplayGlare(boolean) 137 | self.Display.Glare = boolean; 138 | return self.Display.Glare; 139 | end 140 | 141 | function RageUI.Menus:DisplaySubtitle(boolean) 142 | self.Display.Subtitle = boolean; 143 | return self.Display.Subtitle; 144 | end 145 | 146 | function RageUI.Menus:DisplayNavigation(boolean) 147 | self.Display.Navigation = boolean; 148 | return self.Display.Navigation; 149 | end 150 | 151 | function RageUI.Menus:DisplayInstructionalButton(boolean) 152 | self.Display.InstructionalButton = boolean; 153 | return self.Display.InstructionalButton; 154 | end 155 | 156 | function RageUI.Menus:DisplayPageCounter(boolean) 157 | self.Display.PageCounter= boolean; 158 | return self.Display.PageCounter; 159 | end 160 | 161 | ---SetTitle 162 | ---@param Title string 163 | ---@return nil 164 | ---@public 165 | function RageUI.Menus:SetTitle(Title) 166 | self.Title = Title 167 | end 168 | 169 | function RageUI.Menus:SetStyleSize(Value) 170 | local witdh 171 | if Value >= 0 and Value <= 100 then 172 | witdh = Value 173 | else 174 | witdh = 100 175 | end 176 | self.WidthOffset = witdh 177 | end 178 | 179 | ---GetStyleSize 180 | ---@return any 181 | ---@public 182 | function RageUI.Menus:GetStyleSize() 183 | if (self.WidthOffset == 100) then 184 | return "RageUI" 185 | elseif (self.WidthOffset == 0) then 186 | return "NativeUI"; 187 | else 188 | return self.WidthOffset; 189 | end 190 | end 191 | 192 | ---SetStyleSize 193 | ---@param Int string 194 | ---@return void 195 | ---@public 196 | function RageUI.Menus:SetCursorStyle(Int) 197 | self.CursorStyle = Int or 1 or 0 198 | SetMouseCursorSprite(Int) 199 | end 200 | 201 | ---ResetCursorStyle 202 | ---@return void 203 | ---@public 204 | function RageUI.Menus:ResetCursorStyle() 205 | self.CursorStyle = 1 206 | SetMouseCursorSprite(1) 207 | end 208 | 209 | ---UpdateCursorStyle 210 | ---@return void 211 | ---@public 212 | function RageUI.Menus:UpdateCursorStyle() 213 | SetMouseCursorSprite(self.CursorStyle) 214 | end 215 | 216 | ---RefreshIndex 217 | ---@return void 218 | ---@public 219 | function RageUI.Menus:RefreshIndex() 220 | self.Index = 1 221 | end 222 | 223 | ---SetSubtitle 224 | ---@param Subtitle string 225 | ---@return nil 226 | ---@public 227 | function RageUI.Menus:SetSubtitle(Subtitle) 228 | 229 | self.Subtitle = string.upper(Subtitle) or string.upper(self.Subtitle) 230 | 231 | if string.starts(self.Subtitle, "~") then 232 | self.PageCounterColour = string.lower(string.sub(self.Subtitle, 1, 3)) 233 | else 234 | self.PageCounterColour = "" 235 | end 236 | if self.Subtitle ~= "" then 237 | local SubtitleLineCount = GetLineCount(self.Subtitle, self.X + RageUI.Settings.Items.Subtitle.Text.X, self.Y + RageUI.Settings.Items.Subtitle.Text.Y, 0, RageUI.Settings.Items.Subtitle.Text.Scale, 245, 245, 245, 255, nil, false, false, RageUI.Settings.Items.Subtitle.Background.Width + self.WidthOffset) 238 | 239 | if SubtitleLineCount > 1 then 240 | self.SubtitleHeight = 18 * SubtitleLineCount 241 | else 242 | self.SubtitleHeight = 0 243 | end 244 | 245 | else 246 | self.SubtitleHeight = -37 247 | end 248 | end 249 | 250 | ---PageCounter 251 | ---@param Subtitle string 252 | ---@return nil 253 | ---@public 254 | function RageUI.Menus:SetPageCounter(Subtitle) 255 | self.PageCounter = Subtitle 256 | end 257 | 258 | ---EditSpriteColor 259 | ---@param Colors table 260 | ---@return nil 261 | ---@public 262 | function RageUI.Menus:EditSpriteColor(R, G, B, A) 263 | if self.Sprite.Dictionary == "commonmenu" then 264 | self.Sprite.Color = { R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255 } 265 | end 266 | end 267 | ---SetPosition 268 | ---@param X number 269 | ---@param Y number 270 | ---@return nil 271 | ---@public 272 | function RageUI.Menus:SetPosition(X, Y) 273 | self.X = tonumber(X) or self.X 274 | self.Y = tonumber(Y) or self.Y 275 | end 276 | 277 | ---SetTotalItemsPerPage 278 | ---@param Value number 279 | ---@return nil 280 | ---@public 281 | function RageUI.Menus:SetTotalItemsPerPage(Value) 282 | self.Pagination.Total = tonumber(Value) or self.Pagination.Total 283 | end 284 | 285 | ---SetRectangleBanner 286 | ---@param R number 287 | ---@param G number 288 | ---@param B number 289 | ---@param A number 290 | ---@return nil 291 | ---@public 292 | function RageUI.Menus:SetRectangleBanner(R, G, B, A) 293 | self.Rectangle = { R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255 } 294 | self.Sprite = nil 295 | end 296 | 297 | ---SetSpriteBanner 298 | ---@param TextureDictionary string 299 | ---@param Texture string 300 | ---@return nil 301 | ---@public 302 | function RageUI.Menus:SetSpriteBanner(TextureDictionary, Texture) 303 | self.Sprite = { Dictionary = TextureDictionary or "commonmenu", Texture = Texture or "interaction_bgd" } 304 | self.Rectangle = nil 305 | end 306 | 307 | function RageUI.Menus:Closable(boolean) 308 | if type(boolean) == "boolean" then 309 | self.Closable = boolean 310 | else 311 | error("Type is not boolean") 312 | end 313 | end 314 | 315 | function RageUI.Menus:AddInstructionButton(button) 316 | if type(button) == "table" and #button == 2 then 317 | table.insert(self.InstructionalButtons, button) 318 | self.UpdateInstructionalButtons(true); 319 | end 320 | end 321 | 322 | function RageUI.Menus:RemoveInstructionButton(button) 323 | if type(button) == "table" then 324 | for i = 1, #self.InstructionalButtons do 325 | if button == self.InstructionalButtons[i] then 326 | table.remove(self.InstructionalButtons, i) 327 | self.UpdateInstructionalButtons(true); 328 | break 329 | end 330 | end 331 | else 332 | if tonumber(button) then 333 | if self.InstructionalButtons[tonumber(button)] then 334 | table.remove(self.InstructionalButtons, tonumber(button)) 335 | self.UpdateInstructionalButtons(true); 336 | end 337 | end 338 | end 339 | end 340 | 341 | function RageUI.Menus:UpdateInstructionalButtons(Visible) 342 | 343 | if not Visible then 344 | return 345 | end 346 | 347 | BeginScaleformMovieMethod(self.InstructionalScaleform, "CLEAR_ALL") 348 | EndScaleformMovieMethod() 349 | 350 | BeginScaleformMovieMethod(self.InstructionalScaleform, "TOGGLE_MOUSE_BUTTONS") 351 | ScaleformMovieMethodAddParamInt(0) 352 | EndScaleformMovieMethod() 353 | 354 | BeginScaleformMovieMethod(self.InstructionalScaleform, "CREATE_CONTAINER") 355 | EndScaleformMovieMethod() 356 | 357 | BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT") 358 | ScaleformMovieMethodAddParamInt(0) 359 | PushScaleformMovieMethodParameterButtonName(GetControlInstructionalButton(2, 176, 0)) 360 | PushScaleformMovieMethodParameterString(GetLabelText("HUD_INPUT2")) 361 | EndScaleformMovieMethod() 362 | 363 | if self.Closable then 364 | BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT") 365 | ScaleformMovieMethodAddParamInt(1) 366 | PushScaleformMovieMethodParameterButtonName(GetControlInstructionalButton(2, 177, 0)) 367 | PushScaleformMovieMethodParameterString(GetLabelText("HUD_INPUT3")) 368 | EndScaleformMovieMethod() 369 | end 370 | 371 | local count = 2 372 | 373 | if (self.InstructionalButtons ~= nil) then 374 | for i = 1, #self.InstructionalButtons do 375 | if self.InstructionalButtons[i] then 376 | if #self.InstructionalButtons[i] == 2 then 377 | BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT") 378 | ScaleformMovieMethodAddParamInt(count) 379 | PushScaleformMovieMethodParameterButtonName(self.InstructionalButtons[i][1]) 380 | PushScaleformMovieMethodParameterString(self.InstructionalButtons[i][2]) 381 | EndScaleformMovieMethod() 382 | count = count + 1 383 | end 384 | end 385 | end 386 | end 387 | 388 | BeginScaleformMovieMethod(self.InstructionalScaleform, "DRAW_INSTRUCTIONAL_BUTTONS") 389 | ScaleformMovieMethodAddParamInt(-1) 390 | EndScaleformMovieMethod() 391 | end 392 | -------------------------------------------------------------------------------- /RageUI/menu/MenuController.lua: -------------------------------------------------------------------------------- 1 | 2 | RageUI.LastControl = false 3 | 4 | local ControlActions = { 5 | 'Left', 6 | 'Right', 7 | 'Select', 8 | 'Click', 9 | } 10 | 11 | ---GoUp 12 | ---@param Options number 13 | ---@return nil 14 | ---@public 15 | function RageUI.GoUp(Options) 16 | local CurrentMenu = RageUI.CurrentMenu; 17 | if CurrentMenu ~= nil then 18 | Options = CurrentMenu.Options 19 | if CurrentMenu() then 20 | if (Options ~= 0) then 21 | if Options > CurrentMenu.Pagination.Total then 22 | if CurrentMenu.Index <= CurrentMenu.Pagination.Minimum then 23 | if CurrentMenu.Index == 1 then 24 | CurrentMenu.Pagination.Minimum = Options - (CurrentMenu.Pagination.Total - 1) 25 | CurrentMenu.Pagination.Maximum = Options 26 | CurrentMenu.Index = Options 27 | else 28 | CurrentMenu.Pagination.Minimum = (CurrentMenu.Pagination.Minimum - 1) 29 | CurrentMenu.Pagination.Maximum = (CurrentMenu.Pagination.Maximum - 1) 30 | CurrentMenu.Index = CurrentMenu.Index - 1 31 | end 32 | else 33 | CurrentMenu.Index = CurrentMenu.Index - 1 34 | end 35 | else 36 | if CurrentMenu.Index == 1 then 37 | CurrentMenu.Pagination.Minimum = Options - (CurrentMenu.Pagination.Total - 1) 38 | CurrentMenu.Pagination.Maximum = Options 39 | CurrentMenu.Index = Options 40 | else 41 | CurrentMenu.Index = CurrentMenu.Index - 1 42 | end 43 | end 44 | 45 | local Audio = RageUI.Settings.Audio 46 | RageUI.PlaySound(Audio[Audio.Use].UpDown.audioName, Audio[Audio.Use].UpDown.audioRef) 47 | RageUI.LastControl = true 48 | if (CurrentMenu.onIndexChange ~= nil) then 49 | Citizen.CreateThread(function() 50 | CurrentMenu.onIndexChange(CurrentMenu.Index) 51 | end) 52 | end 53 | else 54 | local Audio = RageUI.Settings.Audio 55 | RageUI.PlaySound(Audio[Audio.Use].Error.audioName, Audio[Audio.Use].Error.audioRef) 56 | end 57 | end 58 | end 59 | end 60 | 61 | ---GoDown 62 | ---@param Options number 63 | ---@return nil 64 | ---@public 65 | function RageUI.GoDown(Options) 66 | local CurrentMenu = RageUI.CurrentMenu; 67 | if CurrentMenu ~= nil then 68 | Options = CurrentMenu.Options 69 | if CurrentMenu() then 70 | if (Options ~= 0) then 71 | if Options > CurrentMenu.Pagination.Total then 72 | if CurrentMenu.Index >= CurrentMenu.Pagination.Maximum then 73 | if CurrentMenu.Index == Options then 74 | CurrentMenu.Pagination.Minimum = 1 75 | CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total 76 | CurrentMenu.Index = 1 77 | else 78 | CurrentMenu.Pagination.Maximum = (CurrentMenu.Pagination.Maximum + 1) 79 | CurrentMenu.Pagination.Minimum = CurrentMenu.Pagination.Maximum - (CurrentMenu.Pagination.Total - 1) 80 | CurrentMenu.Index = CurrentMenu.Index + 1 81 | end 82 | else 83 | CurrentMenu.Index = CurrentMenu.Index + 1 84 | end 85 | else 86 | if CurrentMenu.Index == Options then 87 | CurrentMenu.Pagination.Minimum = 1 88 | CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total 89 | CurrentMenu.Index = 1 90 | else 91 | CurrentMenu.Index = CurrentMenu.Index + 1 92 | end 93 | end 94 | local Audio = RageUI.Settings.Audio 95 | RageUI.PlaySound(Audio[Audio.Use].UpDown.audioName, Audio[Audio.Use].UpDown.audioRef) 96 | RageUI.LastControl = false 97 | if (CurrentMenu.onIndexChange ~= nil) then 98 | Citizen.CreateThread(function() 99 | CurrentMenu.onIndexChange(CurrentMenu.Index) 100 | end) 101 | end 102 | else 103 | local Audio = RageUI.Settings.Audio 104 | RageUI.PlaySound(Audio[Audio.Use].Error.audioName, Audio[Audio.Use].Error.audioRef) 105 | end 106 | end 107 | end 108 | end 109 | 110 | function RageUI.GoActionControl(Controls, Action) 111 | if Controls[Action or 'Left'].Enabled then 112 | for Index = 1, #Controls[Action or 'Left'].Keys do 113 | if not Controls[Action or 'Left'].Pressed then 114 | if IsDisabledControlJustPressed(Controls[Action or 'Left'].Keys[Index][1], Controls[Action or 'Left'].Keys[Index][2]) then 115 | Controls[Action or 'Left'].Pressed = true 116 | Citizen.CreateThread(function() 117 | Controls[Action or 'Left'].Active = true 118 | Citizen.Wait(0.01) 119 | Controls[Action or 'Left'].Active = false 120 | Citizen.Wait(175) 121 | while Controls[Action or 'Left'].Enabled and IsDisabledControlPressed(Controls[Action or 'Left'].Keys[Index][1], Controls[Action or 'Left'].Keys[Index][2]) do 122 | Controls[Action or 'Left'].Active = true 123 | Citizen.Wait(1) 124 | Controls[Action or 'Left'].Active = false 125 | Citizen.Wait(124) 126 | end 127 | Controls[Action or 'Left'].Pressed = false 128 | if (Action ~= ControlActions[5]) then 129 | Citizen.Wait(10) 130 | end 131 | end) 132 | break 133 | end 134 | end 135 | end 136 | end 137 | end 138 | 139 | function RageUI.GoActionControlSlider(Controls, Action) 140 | if Controls[Action].Enabled then 141 | for Index = 1, #Controls[Action].Keys do 142 | if not Controls[Action].Pressed then 143 | if IsDisabledControlJustPressed(Controls[Action].Keys[Index][1], Controls[Action].Keys[Index][2]) then 144 | Controls[Action].Pressed = true 145 | Citizen.CreateThread(function() 146 | Controls[Action].Active = true 147 | Citizen.Wait(1) 148 | Controls[Action].Active = false 149 | while Controls[Action].Enabled and IsDisabledControlPressed(Controls[Action].Keys[Index][1], Controls[Action].Keys[Index][2]) do 150 | Controls[Action].Active = true 151 | Citizen.Wait(1) 152 | Controls[Action].Active = false 153 | end 154 | Controls[Action].Pressed = false 155 | end) 156 | break 157 | end 158 | end 159 | end 160 | end 161 | end 162 | 163 | ---Controls 164 | ---@return nil 165 | ---@public 166 | function RageUI.Controls() 167 | local CurrentMenu = RageUI.CurrentMenu; 168 | if CurrentMenu ~= nil then 169 | if CurrentMenu() then 170 | if CurrentMenu.Open then 171 | 172 | local Controls = CurrentMenu.Controls; 173 | ---@type number 174 | local Options = CurrentMenu.Options 175 | RageUI.Options = CurrentMenu.Options 176 | if CurrentMenu.EnableMouse then 177 | DisableAllControlActions(2) 178 | end 179 | 180 | if not IsInputDisabled(2) then 181 | for Index = 1, #Controls.Enabled.Controller do 182 | EnableControlAction(Controls.Enabled.Controller[Index][1], Controls.Enabled.Controller[Index][2], true) 183 | end 184 | else 185 | for Index = 1, #Controls.Enabled.Keyboard do 186 | EnableControlAction(Controls.Enabled.Keyboard[Index][1], Controls.Enabled.Keyboard[Index][2], true) 187 | end 188 | end 189 | 190 | if Controls.Up.Enabled then 191 | for Index = 1, #Controls.Up.Keys do 192 | if not Controls.Up.Pressed then 193 | if IsDisabledControlJustPressed(Controls.Up.Keys[Index][1], Controls.Up.Keys[Index][2]) then 194 | Controls.Up.Pressed = true 195 | Citizen.CreateThread(function() 196 | RageUI.GoUp(Options) 197 | Citizen.Wait(175) 198 | while Controls.Up.Enabled and IsDisabledControlPressed(Controls.Up.Keys[Index][1], Controls.Up.Keys[Index][2]) do 199 | RageUI.GoUp(Options) 200 | Citizen.Wait(50) 201 | end 202 | Controls.Up.Pressed = false 203 | end) 204 | break 205 | end 206 | end 207 | end 208 | end 209 | 210 | if Controls.Down.Enabled then 211 | for Index = 1, #Controls.Down.Keys do 212 | if not Controls.Down.Pressed then 213 | if IsDisabledControlJustPressed(Controls.Down.Keys[Index][1], Controls.Down.Keys[Index][2]) then 214 | Controls.Down.Pressed = true 215 | Citizen.CreateThread(function() 216 | RageUI.GoDown(Options) 217 | Citizen.Wait(175) 218 | while Controls.Down.Enabled and IsDisabledControlPressed(Controls.Down.Keys[Index][1], Controls.Down.Keys[Index][2]) do 219 | RageUI.GoDown(Options) 220 | Citizen.Wait(50) 221 | end 222 | Controls.Down.Pressed = false 223 | end) 224 | break 225 | end 226 | end 227 | end 228 | end 229 | 230 | for i = 1, #ControlActions do 231 | RageUI.GoActionControl(Controls, ControlActions[i]) 232 | end 233 | 234 | RageUI.GoActionControlSlider(Controls, 'SliderLeft') 235 | RageUI.GoActionControlSlider(Controls, 'SliderRight') 236 | 237 | if Controls.Back.Enabled then 238 | for Index = 1, #Controls.Back.Keys do 239 | if not Controls.Back.Pressed then 240 | if IsDisabledControlJustPressed(Controls.Back.Keys[Index][1], Controls.Back.Keys[Index][2]) then 241 | Controls.Back.Pressed = true 242 | Citizen.CreateThread(function() 243 | Citizen.Wait(175) 244 | Controls.Down.Pressed = false 245 | end) 246 | break 247 | end 248 | end 249 | end 250 | end 251 | 252 | end 253 | end 254 | end 255 | end 256 | 257 | ---Navigation 258 | ---@return nil 259 | ---@public 260 | function RageUI.Navigation() 261 | local CurrentMenu = RageUI.CurrentMenu; 262 | if CurrentMenu ~= nil then 263 | if CurrentMenu() and (CurrentMenu.Display.Navigation) then 264 | if CurrentMenu.EnableMouse then 265 | SetMouseCursorActiveThisFrame() 266 | end 267 | if RageUI.Options > CurrentMenu.Pagination.Total then 268 | 269 | ---@type boolean 270 | local UpHovered = false 271 | 272 | ---@type boolean 273 | local DownHovered = false 274 | 275 | if not CurrentMenu.SafeZoneSize then 276 | CurrentMenu.SafeZoneSize = { X = 0, Y = 0 } 277 | 278 | if CurrentMenu.Safezone then 279 | CurrentMenu.SafeZoneSize = RageUI.GetSafeZoneBounds() 280 | 281 | SetScriptGfxAlign(76, 84) 282 | SetScriptGfxAlignParams(0, 0, 0, 0) 283 | end 284 | end 285 | 286 | if CurrentMenu.EnableMouse then 287 | UpHovered = RageUI.IsMouseInBounds(CurrentMenu.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height) 288 | DownHovered = RageUI.IsMouseInBounds(CurrentMenu.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + RageUI.Settings.Items.Navigation.Rectangle.Height + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height) 289 | 290 | if CurrentMenu.Controls.Click.Active then 291 | if UpHovered then 292 | RageUI.GoUp(RageUI.Options) 293 | elseif DownHovered then 294 | RageUI.GoDown(RageUI.Options) 295 | end 296 | end 297 | 298 | if UpHovered then 299 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 30, 30, 30, 255) 300 | else 301 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200) 302 | end 303 | 304 | if DownHovered then 305 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + RageUI.Settings.Items.Navigation.Rectangle.Height + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 30, 30, 30, 255) 306 | else 307 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + RageUI.Settings.Items.Navigation.Rectangle.Height + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200) 308 | end 309 | else 310 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200) 311 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + RageUI.Settings.Items.Navigation.Rectangle.Height + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200) 312 | end 313 | RenderSprite(RageUI.Settings.Items.Navigation.Arrows.Dictionary, RageUI.Settings.Items.Navigation.Arrows.Texture, CurrentMenu.X + RageUI.Settings.Items.Navigation.Arrows.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + RageUI.Settings.Items.Navigation.Arrows.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, RageUI.Settings.Items.Navigation.Arrows.Width, RageUI.Settings.Items.Navigation.Arrows.Height) 314 | RageUI.ItemOffset = RageUI.ItemOffset + (RageUI.Settings.Items.Navigation.Rectangle.Height * 2) 315 | end 316 | end 317 | end 318 | end 319 | 320 | ---GoBack 321 | ---@return nil 322 | ---@public 323 | function RageUI.GoBack() 324 | local CurrentMenu = RageUI.CurrentMenu 325 | if CurrentMenu ~= nil then 326 | local Audio = RageUI.Settings.Audio 327 | RageUI.PlaySound(Audio[Audio.Use].Back.audioName, Audio[Audio.Use].Back.audioRef) 328 | if CurrentMenu.Parent ~= nil then 329 | if CurrentMenu.Parent() then 330 | RageUI.NextMenu = CurrentMenu.Parent 331 | else 332 | RageUI.NextMenu = nil 333 | RageUI.Visible(CurrentMenu, false) 334 | end 335 | else 336 | RageUI.NextMenu = nil 337 | RageUI.Visible(CurrentMenu, false) 338 | end 339 | end 340 | end 341 | -------------------------------------------------------------------------------- /RageUI/menu/elements/ItemsBadge.lua: -------------------------------------------------------------------------------- 1 | RageUI.BadgeStyle = { 2 | -- DEFAULT BADGE 3 | None = function() 4 | return { 5 | BadgeTexture = "", 6 | BadgeDictionary = "commonmenu" 7 | } 8 | end, 9 | BronzeMedal = function() 10 | return { 11 | BadgeTexture = "mp_medal_bronze", 12 | } 13 | end, 14 | GoldMedal = function() 15 | return { 16 | BadgeTexture = "mp_medal_gold", 17 | } 18 | end, 19 | SilverMedal = function() 20 | return { 21 | BadgeTexture = "medal_silver", 22 | } 23 | end, 24 | Alert = function() 25 | return { 26 | BadgeTexture = "mp_alerttriangle", 27 | } 28 | end, 29 | Crown = function(Selected) 30 | return { 31 | BadgeTexture = "mp_hostcrown", 32 | BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 } 33 | } 34 | end, 35 | Ammo = function(Selected) 36 | return { 37 | BadgeTexture = Selected and "shop_ammo_icon_b" or "shop_ammo_icon_a", 38 | } 39 | end, 40 | Armour = function(Selected) 41 | return { 42 | BadgeTexture = Selected and "shop_armour_icon_b" or "shop_armour_icon_a", 43 | } 44 | end, 45 | Barber = function(Selected) 46 | return { 47 | BadgeTexture = Selected and "shop_barber_icon_b" or "shop_barber_icon_a", 48 | } 49 | end, 50 | Clothes = function(Selected) 51 | return { 52 | BadgeTexture = Selected and "shop_clothing_icon_b" or "shop_clothing_icon_a", 53 | } 54 | end, 55 | Franklin = function(Selected) 56 | return { 57 | BadgeTexture = Selected and "shop_franklin_icon_b" or "shop_franklin_icon_a", 58 | } 59 | end, 60 | Bike = function(Selected) 61 | return { 62 | BadgeTexture = Selected and "shop_garage_bike_icon_b" or "shop_garage_bike_icon_a", 63 | } 64 | end, 65 | Car = function(Selected) 66 | return { 67 | BadgeTexture = Selected and "shop_garage_icon_b" or "shop_garage_icon_a", 68 | } 69 | end, 70 | Boat = function(Selected) 71 | return { 72 | BadgeTexture = Selected and "mp_specitem_boat_black" or "mp_specitem_boat", 73 | BadgeDictionary = "mpinventory" 74 | } 75 | end, 76 | Heli = function(Selected) 77 | return { 78 | BadgeTexture = Selected and "mp_specitem_heli_black" or "mp_specitem_heli", 79 | BadgeDictionary = "mpinventory" 80 | } 81 | end, 82 | Plane = function(Selected) 83 | return { 84 | BadgeTexture = Selected and "mp_specitem_plane_black" or "mp_specitem_plane", 85 | BadgeDictionary = "mpinventory" 86 | } 87 | end, 88 | BoatPickup = function(Selected) 89 | return { 90 | BadgeTexture = Selected and "mp_specitem_boatpickup_black" or "mp_specitem_boatpickup", 91 | BadgeDictionary = "mpinventory" 92 | } 93 | end, 94 | Card = function(Selected) 95 | return { 96 | BadgeTexture = Selected and "mp_specitem_keycard_black" or "mp_specitem_keycard", 97 | BadgeDictionary = "mpinventory" 98 | } 99 | end, 100 | Gun = function(Selected) 101 | return { 102 | BadgeTexture = Selected and "shop_gunclub_icon_b" or "shop_gunclub_icon_a", 103 | } 104 | end, 105 | Heart = function(Selected) 106 | return { 107 | BadgeTexture = Selected and "shop_health_icon_b" or "shop_health_icon_a", 108 | } 109 | end, 110 | Makeup = function(Selected) 111 | return { 112 | BadgeTexture = Selected and "shop_makeup_icon_b" or "shop_makeup_icon_a", 113 | } 114 | end, 115 | Mask = function(Selected) 116 | return { 117 | BadgeTexture = Selected and "shop_mask_icon_b" or "shop_mask_icon_a", 118 | } 119 | end, 120 | Michael = function(Selected) 121 | return { 122 | BadgeTexture = Selected and "shop_michael_icon_b" or "shop_michael_icon_a", 123 | } 124 | end, 125 | Star = function() 126 | return { 127 | BadgeTexture = "shop_new_star", 128 | } 129 | end, 130 | Tattoo = function(Selected) 131 | return { 132 | BadgeTexture = Selected and "shop_tattoos_icon_b" or "shop_tattoos_icon_a", 133 | } 134 | end, 135 | Trevor = function(Selected) 136 | return { 137 | BadgeTexture = Selected and "shop_trevor_icon_b" or "shop_trevor_icon_a", 138 | } 139 | end, 140 | Lock = function(Selected) 141 | return { 142 | BadgeTexture = "shop_lock", 143 | BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 } 144 | } 145 | end, 146 | Tick = function(Selected) 147 | return { 148 | BadgeTexture = "shop_tick_icon", 149 | BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 } 150 | } 151 | end, 152 | Key = function(Selected) 153 | return { 154 | BadgeTexture = Selected and "mp_specitem_cuffkeys_black" or "mp_specitem_cuffkeys", 155 | BadgeDictionary = "mpinventory" 156 | } 157 | end, 158 | Coke = function(Selected) 159 | return { 160 | BadgeTexture = Selected and "mp_specitem_coke_black" or "mp_specitem_coke", 161 | BadgeDictionary = "mpinventory" 162 | } 163 | end, 164 | Heroin = function(Selected) 165 | return { 166 | BadgeTexture = Selected and "mp_specitem_heroin_black" or "mp_specitem_heroin", 167 | BadgeDictionary = "mpinventory" 168 | } 169 | end, 170 | Meth = function(Selected) 171 | return { 172 | BadgeTexture = Selected and "mp_specitem_meth_black" or "mp_specitem_meth", 173 | BadgeDictionary = "mpinventory" 174 | } 175 | end, 176 | Weed = function(Selected) 177 | return { 178 | BadgeTexture = Selected and "mp_specitem_weed_black" or "mp_specitem_weed", 179 | BadgeDictionary = "mpinventory" 180 | } 181 | end, 182 | Package = function(Selected) 183 | return { 184 | BadgeTexture = Selected and "mp_specitem_package_black" or "mp_specitem_package", 185 | BadgeDictionary = "mpinventory" 186 | } 187 | end, 188 | Cash = function(Selected) 189 | return { 190 | BadgeTexture = Selected and "mp_specitem_cash_black" or "mp_specitem_cash", 191 | BadgeDictionary = "mpinventory" 192 | } 193 | end, 194 | RP = function(Selected) 195 | return { 196 | BadgeTexture = "mp_anim_rp", 197 | BadgeDictionary = "mphud" 198 | } 199 | end, 200 | LSPD = function() 201 | return { 202 | BadgeTexture = "mpgroundlogo_cops", 203 | BadgeDictionary = "3dtextures" 204 | } 205 | end, 206 | Vagos = function() 207 | return { 208 | BadgeTexture = "mpgroundlogo_vagos", 209 | BadgeDictionary = "3dtextures" 210 | } 211 | end, 212 | Bikers = function() 213 | return { 214 | BadgeTexture = "mpgroundlogo_bikers", 215 | BadgeDictionary = "3dtextures" 216 | } 217 | end, 218 | 219 | -- CASINO 220 | Badbeat = function() 221 | return { 222 | BadgeTexture = "badbeat", 223 | BadgeDictionary = "mpawardcasino" 224 | } 225 | end, 226 | CashingOut = function() 227 | return { 228 | BadgeTexture = "cashingout", 229 | BadgeDictionary = "mpawardcasino" 230 | } 231 | end, 232 | FullHouse = function() 233 | return { 234 | BadgeTexture = "fullhouse", 235 | BadgeDictionary = "mpawardcasino" 236 | } 237 | end, 238 | HighRoller = function() 239 | return { 240 | BadgeTexture = "highroller", 241 | BadgeDictionary = "mpawardcasino" 242 | } 243 | end, 244 | HouseKeeping = function() 245 | return { 246 | BadgeTexture = "housekeeping", 247 | BadgeDictionary = "mpawardcasino" 248 | } 249 | end, 250 | LooseCheng = function() 251 | return { 252 | BadgeTexture = "loosecheng", 253 | BadgeDictionary = "mpawardcasino" 254 | } 255 | end, 256 | LuckyLucky = function() 257 | return { 258 | BadgeTexture = "luckylucky", 259 | BadgeDictionary = "mpawardcasino" 260 | } 261 | end, 262 | PlayToWin = function() 263 | return { 264 | BadgeTexture = "playtowin", 265 | BadgeDictionary = "mpawardcasino" 266 | } 267 | end, 268 | StraightFlush = function() 269 | return { 270 | BadgeTexture = "straightflush", 271 | BadgeDictionary = "mpawardcasino" 272 | } 273 | end, 274 | StrongArmTactics = function() 275 | return { 276 | BadgeTexture = "strongarmtactics", 277 | BadgeDictionary = "mpawardcasino" 278 | } 279 | end, 280 | TopPair = function() 281 | return { 282 | BadgeTexture = "toppair", 283 | BadgeDictionary = "mpawardcasino" 284 | } 285 | end, 286 | } -------------------------------------------------------------------------------- /RageUI/menu/elements/ItemsColour.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Dylan Malandain. 4 | --- DateTime: 24/07/2019 02:26 5 | --- 6 | 7 | RageUI.ItemsColour = { 8 | PureWhite = { 255, 255, 255, 255 }, 9 | White = { 240, 240, 240, 255 }, 10 | Black = { 0, 0, 0, 255 }, 11 | Grey = { 155, 155, 155, 255 }, 12 | GreyLight = { 205, 205, 205, 255 }, 13 | GreyDark = { 77, 77, 77, 255 }, 14 | Red = { 224, 50, 50, 255 }, 15 | RedLight = { 240, 153, 153, 255 }, 16 | RedDark = { 112, 25, 25, 255 }, 17 | Blue = { 93, 182, 229, 255 }, 18 | BlueLight = { 174, 219, 242, 255 }, 19 | BlueDark = { 47, 92, 115, 255 }, 20 | Yellow = { 240, 200, 80, 255 }, 21 | YellowLight = { 254, 235, 169, 255 }, 22 | YellowDark = { 126, 107, 41, 255 }, 23 | Orange = { 255, 133, 85, 255 }, 24 | OrangeLight = { 255, 194, 170, 255 }, 25 | OrangeDark = { 127, 66, 42, 255 }, 26 | Green = { 114, 204, 114, 255 }, 27 | GreenLight = { 185, 230, 185, 255 }, 28 | GreenDark = { 57, 102, 57, 255 }, 29 | Purple = { 132, 102, 226, 255 }, 30 | PurpleLight = { 192, 179, 239, 255 }, 31 | PurpleDark = { 67, 57, 111, 255 }, 32 | Pink = { 203, 54, 148, 255 }, 33 | RadarHealth = { 53, 154, 71, 255 }, 34 | RadarArmour = { 93, 182, 229, 255 }, 35 | RadarDamage = { 235, 36, 39, 255 }, 36 | NetPlayer1 = { 194, 80, 80, 255 }, 37 | NetPlayer2 = { 156, 110, 175, 255 }, 38 | NetPlayer3 = { 255, 123, 196, 255 }, 39 | NetPlayer4 = { 247, 159, 123, 255 }, 40 | NetPlayer5 = { 178, 144, 132, 255 }, 41 | NetPlayer6 = { 141, 206, 167, 255 }, 42 | NetPlayer7 = { 113, 169, 175, 255 }, 43 | NetPlayer8 = { 211, 209, 231, 255 }, 44 | NetPlayer9 = { 144, 127, 153, 255 }, 45 | NetPlayer10 = { 106, 196, 191, 255 }, 46 | NetPlayer11 = { 214, 196, 153, 255 }, 47 | NetPlayer12 = { 234, 142, 80, 255 }, 48 | NetPlayer13 = { 152, 203, 234, 255 }, 49 | NetPlayer14 = { 178, 98, 135, 255 }, 50 | NetPlayer15 = { 144, 142, 122, 255 }, 51 | NetPlayer16 = { 166, 117, 94, 255 }, 52 | NetPlayer17 = { 175, 168, 168, 255 }, 53 | NetPlayer18 = { 232, 142, 155, 255 }, 54 | NetPlayer19 = { 187, 214, 91, 255 }, 55 | NetPlayer20 = { 12, 123, 86, 255 }, 56 | NetPlayer21 = { 123, 196, 255, 255 }, 57 | NetPlayer22 = { 171, 60, 230, 255 }, 58 | NetPlayer23 = { 206, 169, 13, 255 }, 59 | NetPlayer24 = { 71, 99, 173, 255 }, 60 | NetPlayer25 = { 42, 166, 185, 255 }, 61 | NetPlayer26 = { 186, 157, 125, 255 }, 62 | NetPlayer27 = { 201, 225, 255, 255 }, 63 | NetPlayer28 = { 240, 240, 150, 255 }, 64 | NetPlayer29 = { 237, 140, 161, 255 }, 65 | NetPlayer30 = { 249, 138, 138, 255 }, 66 | NetPlayer31 = { 252, 239, 166, 255 }, 67 | NetPlayer32 = { 240, 240, 240, 255 }, 68 | SimpleBlipDefault = { 159, 201, 166, 255 }, 69 | MenuBlue = { 140, 140, 140, 255 }, 70 | MenuGreyLight = { 140, 140, 140, 255 }, 71 | MenuBlueExtraDark = { 40, 40, 40, 255 }, 72 | MenuYellow = { 240, 160, 0, 255 }, 73 | MenuYellowDark = { 240, 160, 0, 255 }, 74 | MenuGreen = { 240, 160, 0, 255 }, 75 | MenuGrey = { 140, 140, 140, 255 }, 76 | MenuGreyDark = { 60, 60, 60, 255 }, 77 | MenuHighlight = { 30, 30, 30, 255 }, 78 | MenuStandard = { 140, 140, 140, 255 }, 79 | MenuDimmed = { 75, 75, 75, 255 }, 80 | MenuExtraDimmed = { 50, 50, 50, 255 }, 81 | BriefTitle = { 95, 95, 95, 255 }, 82 | MidGreyMp = { 100, 100, 100, 255 }, 83 | NetPlayer1Dark = { 93, 39, 39, 255 }, 84 | NetPlayer2Dark = { 77, 55, 89, 255 }, 85 | NetPlayer3Dark = { 124, 62, 99, 255 }, 86 | NetPlayer4Dark = { 120, 80, 80, 255 }, 87 | NetPlayer5Dark = { 87, 72, 66, 255 }, 88 | NetPlayer6Dark = { 74, 103, 83, 255 }, 89 | NetPlayer7Dark = { 60, 85, 88, 255 }, 90 | NetPlayer8Dark = { 105, 105, 64, 255 }, 91 | NetPlayer9Dark = { 72, 63, 76, 255 }, 92 | NetPlayer10Dark = { 53, 98, 95, 255 }, 93 | NetPlayer11Dark = { 107, 98, 76, 255 }, 94 | NetPlayer12Dark = { 117, 71, 40, 255 }, 95 | NetPlayer13Dark = { 76, 101, 117, 255 }, 96 | NetPlayer14Dark = { 65, 35, 47, 255 }, 97 | NetPlayer15Dark = { 72, 71, 61, 255 }, 98 | NetPlayer16Dark = { 85, 58, 47, 255 }, 99 | NetPlayer17Dark = { 87, 84, 84, 255 }, 100 | NetPlayer18Dark = { 116, 71, 77, 255 }, 101 | NetPlayer19Dark = { 93, 107, 45, 255 }, 102 | NetPlayer20Dark = { 6, 61, 43, 255 }, 103 | NetPlayer21Dark = { 61, 98, 127, 255 }, 104 | NetPlayer22Dark = { 85, 30, 115, 255 }, 105 | NetPlayer23Dark = { 103, 84, 6, 255 }, 106 | NetPlayer24Dark = { 35, 49, 86, 255 }, 107 | NetPlayer25Dark = { 21, 83, 92, 255 }, 108 | NetPlayer26Dark = { 93, 98, 62, 255 }, 109 | NetPlayer27Dark = { 100, 112, 127, 255 }, 110 | NetPlayer28Dark = { 120, 120, 75, 255 }, 111 | NetPlayer29Dark = { 152, 76, 93, 255 }, 112 | NetPlayer30Dark = { 124, 69, 69, 255 }, 113 | NetPlayer31Dark = { 10, 43, 50, 255 }, 114 | NetPlayer32Dark = { 95, 95, 10, 255 }, 115 | Bronze = { 180, 130, 97, 255 }, 116 | Silver = { 150, 153, 161, 255 }, 117 | Gold = { 214, 181, 99, 255 }, 118 | Platinum = { 166, 221, 190, 255 }, 119 | Gang1 = { 29, 100, 153, 255 }, 120 | Gang2 = { 214, 116, 15, 255 }, 121 | Gang3 = { 135, 125, 142, 255 }, 122 | Gang4 = { 229, 119, 185, 255 }, 123 | SameCrew = { 252, 239, 166, 255 }, 124 | Freemode = { 45, 110, 185, 255 }, 125 | PauseBg = { 0, 0, 0, 255 }, 126 | Friendly = { 93, 182, 229, 255 }, 127 | Enemy = { 194, 80, 80, 255 }, 128 | Location = { 240, 200, 80, 255 }, 129 | Pickup = { 114, 204, 114, 255 }, 130 | PauseSingleplayer = { 114, 204, 114, 255 }, 131 | FreemodeDark = { 22, 55, 92, 255 }, 132 | InactiveMission = { 154, 154, 154, 255 }, 133 | Damage = { 194, 80, 80, 255 }, 134 | PinkLight = { 252, 115, 201, 255 }, 135 | PmMitemHighlight = { 252, 177, 49, 255 }, 136 | ScriptVariable = { 0, 0, 0, 255 }, 137 | Yoga = { 109, 247, 204, 255 }, 138 | Tennis = { 241, 101, 34, 255 }, 139 | Golf = { 214, 189, 97, 255 }, 140 | ShootingRange = { 112, 25, 25, 255 }, 141 | FlightSchool = { 47, 92, 115, 255 }, 142 | NorthBlue = { 93, 182, 229, 255 }, 143 | SocialClub = { 234, 153, 28, 255 }, 144 | PlatformBlue = { 11, 55, 123, 255 }, 145 | PlatformGreen = { 146, 200, 62, 255 }, 146 | PlatformGrey = { 234, 153, 28, 255 }, 147 | FacebookBlue = { 66, 89, 148, 255 }, 148 | IngameBg = { 0, 0, 0, 255 }, 149 | Darts = { 114, 204, 114, 255 }, 150 | Waypoint = { 164, 76, 242, 255 }, 151 | Michael = { 101, 180, 212, 255 }, 152 | Franklin = { 171, 237, 171, 255 }, 153 | Trevor = { 255, 163, 87, 255 }, 154 | GolfP1 = { 240, 240, 240, 255 }, 155 | GolfP2 = { 235, 239, 30, 255 }, 156 | GolfP3 = { 255, 149, 14, 255 }, 157 | GolfP4 = { 246, 60, 161, 255 }, 158 | WaypointLight = { 210, 166, 249, 255 }, 159 | WaypointDark = { 82, 38, 121, 255 }, 160 | PanelLight = { 0, 0, 0, 255 }, 161 | MichaelDark = { 72, 103, 116, 255 }, 162 | FranklinDark = { 85, 118, 85, 255 }, 163 | TrevorDark = { 127, 81, 43, 255 }, 164 | ObjectiveRoute = { 240, 200, 80, 255 }, 165 | PausemapTint = { 0, 0, 0, 255 }, 166 | PauseDeselect = { 100, 100, 100, 255 }, 167 | PmWeaponsPurchasable = { 45, 110, 185, 255 }, 168 | PmWeaponsLocked = { 240, 240, 240, 255 }, 169 | ScreenBg = { 0, 0, 0, 255 }, 170 | Chop = { 224, 50, 50, 255 }, 171 | PausemapTintHalf = { 0, 0, 0, 255 }, 172 | NorthBlueOfficial = { 0, 71, 133, 255 }, 173 | ScriptVariable2 = { 0, 0, 0, 255 }, 174 | H = { 33, 118, 37, 255 }, 175 | HDark = { 37, 102, 40, 255 }, 176 | T = { 234, 153, 28, 255 }, 177 | TDark = { 225, 140, 8, 255 }, 178 | HShard = { 20, 40, 0, 255 }, 179 | ControllerMichael = { 48, 255, 255, 255 }, 180 | ControllerFranklin = { 48, 255, 0, 255 }, 181 | ControllerTrevor = { 176, 80, 0, 255 }, 182 | ControllerChop = { 127, 0, 0, 255 }, 183 | VideoEditorVideo = { 53, 166, 224, 255 }, 184 | VideoEditorAudio = { 162, 79, 157, 255 }, 185 | VideoEditorText = { 104, 192, 141, 255 }, 186 | HbBlue = { 29, 100, 153, 255 }, 187 | HbYellow = { 234, 153, 28, 255 }, 188 | VideoEditorScore = { 240, 160, 1, 255 }, 189 | VideoEditorAudioFadeout = { 59, 34, 57, 255 }, 190 | VideoEditorTextFadeout = { 41, 68, 53, 255 }, 191 | VideoEditorScoreFadeout = { 82, 58, 10, 255 }, 192 | HeistBackground = { 37, 102, 40, 255 }, 193 | VideoEditorAmbient = { 240, 200, 80, 255 }, 194 | VideoEditorAmbientFadeout = { 80, 70, 34, 255 }, 195 | Gb = { 255, 133, 85, 255 }, 196 | G = { 255, 194, 170, 255 }, 197 | B = { 255, 133, 85, 255 }, 198 | LowFlow = { 240, 200, 80, 255 }, 199 | LowFlowDark = { 126, 107, 41, 255 }, 200 | G1 = { 247, 159, 123, 255 }, 201 | G2 = { 226, 134, 187, 255 }, 202 | G3 = { 239, 238, 151, 255 }, 203 | G4 = { 113, 169, 175, 255 }, 204 | G5 = { 160, 140, 193, 255 }, 205 | G6 = { 141, 206, 167, 255 }, 206 | G7 = { 181, 214, 234, 255 }, 207 | G8 = { 178, 144, 132, 255 }, 208 | G9 = { 0, 132, 114, 255 }, 209 | G10 = { 216, 85, 117, 255 }, 210 | G11 = { 30, 100, 152, 255 }, 211 | G12 = { 43, 181, 117, 255 }, 212 | G13 = { 233, 141, 79, 255 }, 213 | G14 = { 137, 210, 215, 255 }, 214 | G15 = { 134, 125, 141, 255 }, 215 | Adversary = { 109, 34, 33, 255 }, 216 | DegenRed = { 255, 0, 0, 255 }, 217 | DegenYellow = { 255, 255, 0, 255 }, 218 | DegenGreen = { 0, 255, 0, 255 }, 219 | DegenCyan = { 0, 255, 255, 255 }, 220 | DegenBlue = { 0, 0, 255, 255 }, 221 | DegenMagenta = { 255, 0, 255, 255 }, 222 | Stunt1 = { 38, 136, 234, 255 }, 223 | Stunt2 = { 224, 50, 50, 255 }, 224 | } 225 | 226 | -------------------------------------------------------------------------------- /RageUI/menu/elements/PanelColour.lua: -------------------------------------------------------------------------------- 1 | RageUI.PanelColour = { 2 | HairCut = { 3 | { 28, 31, 33 }, -- 0 4 | { 39, 42, 44 }, -- 1 5 | { 49, 46, 44 }, -- 2 6 | { 53, 38, 28 }, -- 3 7 | { 75, 50, 31 }, -- 4 8 | { 92, 59, 36 }, -- 5 9 | { 109, 76, 53 }, -- 6 10 | { 107, 80, 59 }, -- 7 11 | { 118, 92, 69 }, -- 8 12 | { 127, 104, 78 }, -- 9 13 | { 153, 129, 93 }, -- 10 14 | { 167, 147, 105 }, -- 11 15 | { 175, 156, 112 }, -- 12 16 | { 187, 160, 99 }, -- 13 17 | { 214, 185, 123 }, -- 14 18 | { 218, 195, 142 }, -- 15 19 | { 159, 127, 89 }, -- 16 20 | { 132, 80, 57 }, -- 17 21 | { 104, 43, 31 }, -- 18 22 | { 97, 18, 12 }, -- 19 23 | { 100, 15, 10 }, -- 20 24 | { 124, 20, 15 }, -- 21 25 | { 160, 46, 25 }, -- 22 26 | { 182, 75, 40 }, -- 23 27 | { 162, 80, 47 }, -- 24 28 | { 170, 78, 43 }, -- 25 29 | { 98, 98, 98 }, -- 26 30 | { 128, 128, 128}, -- 27 31 | { 170, 170, 170 }, -- 28 32 | { 197, 197, 197 }, -- 29 33 | { 70, 57, 85 }, -- 30 34 | { 90, 63, 107 }, -- 31 35 | { 118, 60, 118 }, -- 32 36 | { 237, 116, 227 }, -- 33 37 | { 235, 75, 147 }, -- 34 38 | { 242, 153, 188 }, -- 35 39 | { 4, 149, 158 }, -- 36 40 | { 2, 95, 134 }, -- 37 41 | { 2, 57, 116 }, -- 38 42 | { 63, 161, 106 }, -- 39 43 | { 33, 124, 97 }, -- 40 44 | { 24, 92, 85 }, -- 41 45 | { 182, 192, 52 }, -- 42 46 | { 112, 169, 11 }, -- 43 47 | { 67, 157, 19 }, -- 44 48 | { 220, 184, 87 }, -- 45 49 | { 229, 177, 3 }, -- 46 50 | { 230, 145, 2 }, -- 47 51 | { 242, 136, 49 }, -- 48 52 | { 251, 128, 87 }, -- 49 53 | { 226, 139, 88 }, -- 50 54 | { 209, 89, 60 }, -- 51 55 | { 206, 49, 32 }, -- 52 56 | { 173, 9, 3 }, -- 53 57 | { 136, 3, 2 }, -- 54 58 | { 31, 24, 20 }, -- 55 59 | { 41, 31, 25 }, -- 56 60 | { 46, 34, 27 }, -- 57 61 | { 55, 41, 30 }, -- 58 62 | { 46, 34, 24 }, -- 59 63 | { 35, 27, 21 }, -- 60 64 | { 2, 2, 2 }, -- 61 65 | { 112, 108, 102 }, -- 62 66 | { 157, 122, 80 } -- 63 67 | }, 68 | MakeUp = { 69 | { 153, 37, 50 }, -- 0 70 | { 200, 57, 93 }, -- 1 71 | { 189, 81, 108 }, -- 2 72 | { 184, 99, 122 }, -- 3 73 | { 166, 82, 107 }, -- 4 74 | { 177, 67, 76 }, -- 5 75 | { 127, 49, 51 }, -- 6 76 | { 164, 100, 93 }, -- 7 77 | { 193, 135, 121 }, -- 8 78 | { 203, 160, 150 }, -- 9 79 | { 198, 145, 143 }, -- 10 80 | { 171, 111, 99}, -- 11 81 | { 176, 96, 80 }, -- 12 82 | { 168, 76, 51 }, -- 13 83 | { 180, 113, 120 }, -- 14 84 | { 202, 127, 146 }, -- 15 85 | { 237, 156, 190 }, -- 16 86 | { 231, 117, 164 }, -- 17 87 | { 222, 62, 129 }, -- 18 88 | { 179, 76, 110 }, -- 19 89 | { 113, 39, 57 }, -- 20 90 | { 79, 31, 42 }, -- 21 91 | { 170, 34, 47 }, -- 22 92 | { 222, 32, 52 }, -- 23 93 | { 207, 8, 19 }, -- 24 94 | { 229, 84, 112 }, -- 25 95 | { 220, 63, 181 }, -- 26 96 | { 192, 39, 178 }, -- 27 97 | { 160, 28, 169 }, -- 28 98 | { 110, 24, 117 }, -- 29 99 | { 115, 20, 101 }, -- 30 100 | { 86, 22, 92 }, -- 31 101 | { 109, 26, 157 }, -- 32 102 | { 27, 55, 113 }, -- 33 103 | { 29, 78, 167 }, -- 34 104 | { 30, 116, 187 }, -- 35 105 | { 33, 163, 206 }, -- 36 106 | { 37, 194, 210 }, -- 37 107 | { 35, 204, 165 }, -- 38 108 | { 39, 192, 125 }, -- 39 109 | { 27, 156, 50 }, -- 40 110 | { 20, 134, 4 }, -- 41 111 | { 112, 208, 65 }, -- 42 112 | { 197, 234, 52 }, -- 43 113 | { 225, 227, 47 }, -- 44 114 | { 255, 221, 38 }, -- 45 115 | { 250, 192, 38 }, -- 46 116 | { 247, 138, 39 }, -- 47 117 | { 254, 89, 16 }, -- 48 118 | { 190, 110, 25 }, -- 49 119 | { 247, 201, 127 }, -- 50 120 | { 251, 229, 192 }, -- 51 121 | { 245, 245, 245 }, -- 52 122 | { 179, 180, 179 }, -- 53 123 | { 145, 145, 145 }, -- 54 124 | { 86, 78, 78 }, -- 55 125 | { 24, 14, 14 }, -- 56 126 | { 88, 150, 158 }, -- 57 127 | { 77, 111, 140 }, -- 58 128 | { 26, 43, 85 }, -- 59 129 | { 160, 126, 107 }, -- 60 130 | { 130, 99, 85 }, -- 61 131 | { 109, 83, 70 }, -- 62 132 | { 62, 45, 39 } -- 63 133 | } 134 | } 135 | 136 | -------------------------------------------------------------------------------- /RageUI/menu/items/UIButton.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local SettingsButton = { 3 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 4 | Text = { X = 8, Y = 3, Scale = 0.33 }, 5 | LeftBadge = { Y = -2, Width = 40, Height = 40 }, 6 | RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 }, 7 | RightText = { X = 420, Y = 4, Scale = 0.35 }, 8 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 9 | } 10 | 11 | ---ButtonWithStyle 12 | ---@param Label string 13 | ---@param Description string 14 | ---@param Style table 15 | ---@param Enabled boolean 16 | ---@param Callback function 17 | ---@param Submenu table 18 | ---@return nil 19 | ---@public 20 | function RageUI.Button(Label, Description, Style, Enabled, Action, Submenu) 21 | local CurrentMenu = RageUI.CurrentMenu 22 | if CurrentMenu ~= nil and CurrentMenu() then 23 | ---@type number 24 | local Option = RageUI.Options + 1 25 | 26 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 27 | ---@type boolean 28 | local Active = CurrentMenu.Index == Option 29 | 30 | RageUI.ItemsSafeZone(CurrentMenu) 31 | 32 | local haveLeftBadge = Style.LeftBadge and Style.LeftBadge ~= RageUI.BadgeStyle.None 33 | local haveRightBadge = (Style.RightBadge and Style.RightBadge ~= RageUI.BadgeStyle.None) or (not Enabled and Style.LockBadge ~= RageUI.BadgeStyle.None) 34 | local LeftBadgeOffset = haveLeftBadge and 27 or 0 35 | local RightBadgeOffset = haveRightBadge and 32 or 0 36 | if Style.Color and Style.Color.BackgroundColor then 37 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height, Style.Color.BackgroundColor[1], Style.Color.BackgroundColor[2], Style.Color.BackgroundColor[3], Style.Color.BackgroundColor[4]) 38 | end 39 | if Active then 40 | if Style.Color and Style.Color.HightLightColor then 41 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height, Style.Color.HightLightColor[1], Style.Color.HightLightColor[2], Style.Color.HightLightColor[3], Style.Color.HightLightColor[4]) 42 | else 43 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 44 | end 45 | end 46 | if Enabled then 47 | if haveLeftBadge then 48 | if (Style.LeftBadge ~= nil) then 49 | local LeftBadge = Style.LeftBadge(Active) 50 | RenderSprite(LeftBadge.BadgeDictionary or "commonmenu", LeftBadge.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, LeftBadge.BadgeColour and LeftBadge.BadgeColour.R or 255, LeftBadge.BadgeColour and LeftBadge.BadgeColour.G or 255, LeftBadge.BadgeColour and LeftBadge.BadgeColour.B or 255, LeftBadge.BadgeColour and LeftBadge.BadgeColour.A or 255) 51 | end 52 | end 53 | if haveRightBadge then 54 | if (Style.RightBadge ~= nil) then 55 | local RightBadge = Style.RightBadge(Active) 56 | RenderSprite(RightBadge.BadgeDictionary or "commonmenu", RightBadge.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, RightBadge.BadgeColour and RightBadge.BadgeColour.R or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.G or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.B or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.A or 255) 57 | end 58 | end 59 | if Style.RightLabel then 60 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, Active and 0 or 245, Active and 0 or 245, Active and 0 or 245, 255, 2) 61 | end 62 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, Active and 0 or 245, Active and 0 or 245, Active and 0 or 245, 255) 63 | else 64 | if haveRightBadge then 65 | local RightBadge = RageUI.BadgeStyle.Lock(Active) 66 | RenderSprite(RightBadge.BadgeDictionary or "commonmenu", RightBadge.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, RightBadge.BadgeColour and RightBadge.BadgeColour.R or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.G or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.B or 255, RightBadge.BadgeColour and RightBadge.BadgeColour.A or 255) 67 | end 68 | 69 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 163, 159, 148, 255) 70 | end 71 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 72 | RageUI.ItemsDescription(CurrentMenu, Description, Active); 73 | if Enabled then 74 | local Hovered = CurrentMenu.EnableMouse and (CurrentMenu.CursorStyle == 0 or CurrentMenu.CursorStyle == 1) and RageUI.ItemsMouseBounds(CurrentMenu, Active, Option + 1, SettingsButton); 75 | local Selected = (CurrentMenu.Controls.Select.Active or (Hovered and CurrentMenu.Controls.Click.Active)) and Active 76 | if (Action.onHovered ~= nil) and Hovered then 77 | Action.onHovered(); 78 | end 79 | if (Action.onActive ~= nil) and Active then 80 | Action.onActive(); 81 | end 82 | if Selected then 83 | local Audio = RageUI.Settings.Audio 84 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 85 | if (Action.onSelected ~= nil) then 86 | Citizen.CreateThread(function() 87 | Action.onSelected(); 88 | end) 89 | end 90 | if Submenu and Submenu() then 91 | RageUI.NextMenu = Submenu 92 | end 93 | end 94 | end 95 | end 96 | RageUI.Options = RageUI.Options + 1 97 | end 98 | end 99 | 100 | -------------------------------------------------------------------------------- /RageUI/menu/items/UICheckBox.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local SettingsButton = { 3 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 4 | Text = { X = 8, Y = 3, Scale = 0.33 }, 5 | LeftBadge = { Y = -2, Width = 40, Height = 40 }, 6 | RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 }, 7 | RightText = { X = 420, Y = 4, Scale = 0.35 }, 8 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 9 | } 10 | 11 | ---@type table 12 | local SettingsCheckbox = { 13 | Dictionary = "commonmenu", Textures = { 14 | "shop_box_blankb", -- 1 15 | "shop_box_tickb", -- 2 16 | "shop_box_blank", -- 3 17 | "shop_box_tick", -- 4 18 | "shop_box_crossb", -- 5 19 | "shop_box_cross", -- 6 20 | }, 21 | X = 380, Y = -6, Width = 50, Height = 50 22 | } 23 | 24 | RageUI.CheckboxStyle = { 25 | Tick = 1, 26 | Cross = 2 27 | } 28 | 29 | ---StyleCheckBox 30 | ---@param Selected number 31 | ---@param Checked boolean 32 | ---@param Box number 33 | ---@param BoxSelect number 34 | ---@return nil 35 | local function StyleCheckBox(Selected, Checked, Box, BoxSelect, OffSet) 36 | ---@type table 37 | local CurrentMenu = RageUI.CurrentMenu; 38 | if OffSet == nil then 39 | OffSet = 0 40 | end 41 | if Selected then 42 | if Checked then 43 | RenderSprite(SettingsCheckbox.Dictionary, SettingsCheckbox.Textures[Box], CurrentMenu.X + SettingsCheckbox.X + CurrentMenu.WidthOffset - OffSet, CurrentMenu.Y + SettingsCheckbox.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsCheckbox.Width, SettingsCheckbox.Height) 44 | else 45 | RenderSprite(SettingsCheckbox.Dictionary, SettingsCheckbox.Textures[1], CurrentMenu.X + SettingsCheckbox.X + CurrentMenu.WidthOffset - OffSet, CurrentMenu.Y + SettingsCheckbox.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsCheckbox.Width, SettingsCheckbox.Height) 46 | end 47 | else 48 | if Checked then 49 | RenderSprite(SettingsCheckbox.Dictionary, SettingsCheckbox.Textures[BoxSelect], CurrentMenu.X + SettingsCheckbox.X + CurrentMenu.WidthOffset - OffSet, CurrentMenu.Y + SettingsCheckbox.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsCheckbox.Width, SettingsCheckbox.Height) 50 | else 51 | RenderSprite(SettingsCheckbox.Dictionary, SettingsCheckbox.Textures[3], CurrentMenu.X + SettingsCheckbox.X + CurrentMenu.WidthOffset - OffSet, CurrentMenu.Y + SettingsCheckbox.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsCheckbox.Width, SettingsCheckbox.Height) 52 | end 53 | end 54 | end 55 | 56 | 57 | function RageUI.Checkbox(Label, Description, Checked, Style, Actions) 58 | ---@type table 59 | local CurrentMenu = RageUI.CurrentMenu; 60 | if CurrentMenu ~= nil then 61 | if CurrentMenu() then 62 | 63 | ---@type number 64 | local Option = RageUI.Options + 1 65 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 66 | ---@type number 67 | local Selected = CurrentMenu.Index == Option 68 | local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) 69 | local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) 70 | local BoxOffset = 0 71 | RageUI.ItemsSafeZone(CurrentMenu) 72 | 73 | local Hovered = false; 74 | 75 | ---@type boolean 76 | if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then 77 | Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton); 78 | end 79 | if Selected then 80 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 81 | end 82 | 83 | if type(Style) == "table" then 84 | if Style.Enabled == true or Style.Enabled == nil then 85 | if Selected then 86 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 87 | else 88 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255) 89 | end 90 | if type(Style) == 'table' then 91 | if Style.LeftBadge ~= nil then 92 | if Style.LeftBadge ~= RageUI.BadgeStyle.None then 93 | local BadgeData = Style.LeftBadge(Selected) 94 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 95 | end 96 | end 97 | if Style.RightBadge ~= nil then 98 | if Style.RightBadge ~= RageUI.BadgeStyle.None then 99 | local BadgeData = Style.RightBadge(Selected) 100 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 101 | end 102 | end 103 | end 104 | else 105 | ---@type table 106 | local LeftBadge = RageUI.BadgeStyle.Lock 107 | ---@type number 108 | local LeftBadgeOffset = ((LeftBadge == RageUI.BadgeStyle.None or LeftBadge == nil) and 0 or 27) 109 | 110 | if Selected then 111 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 112 | else 113 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 163, 159, 148, 255) 114 | end 115 | 116 | if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then 117 | local BadgeData = LeftBadge(Selected) 118 | 119 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) 120 | end 121 | end 122 | 123 | if Style.Enabled == true or Style.Enabled == nil then 124 | if Selected then 125 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 126 | 127 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 0, 0, 0, 255, 2) 128 | BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 129 | end 130 | else 131 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 132 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 245, 245, 245, 255, 2) 133 | BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 134 | end 135 | end 136 | end 137 | 138 | BoxOffset = RightBadgeOffset + BoxOffset 139 | if Style.Style ~= nil then 140 | if Style.Style == RageUI.CheckboxStyle.Tick then 141 | StyleCheckBox(Selected, Checked, 2, 4, BoxOffset) 142 | elseif Style.Style == RageUI.CheckboxStyle.Cross then 143 | StyleCheckBox(Selected, Checked, 5, 6, BoxOffset) 144 | else 145 | StyleCheckBox(Selected, Checked, 2, 4, BoxOffset) 146 | end 147 | else 148 | StyleCheckBox(Selected, Checked, 2, 4, BoxOffset) 149 | end 150 | 151 | if Selected and (CurrentMenu.Controls.Select.Active or (Hovered and CurrentMenu.Controls.Click.Active)) and (Style.Enabled == true or Style.Enabled == nil) then 152 | local Audio = RageUI.Settings.Audio 153 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 154 | Checked = not Checked 155 | if (Checked) then 156 | if (Actions.onChecked ~= nil) then 157 | Actions.onChecked(); 158 | end 159 | else 160 | if (Actions.onUnChecked ~= nil) then 161 | Actions.onUnChecked(); 162 | end 163 | end 164 | end 165 | else 166 | error("UICheckBox Style is not a `table`") 167 | end 168 | 169 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 170 | 171 | RageUI.ItemsDescription(CurrentMenu, Description, Selected) 172 | 173 | if (Actions.onSelected ~= nil) and (Selected) then 174 | Actions.onSelected(Checked); 175 | end 176 | 177 | end 178 | RageUI.Options = RageUI.Options + 1 179 | end 180 | end 181 | end 182 | 183 | 184 | -------------------------------------------------------------------------------- /RageUI/menu/items/UIList.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local SettingsButton = { 3 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 4 | Text = { X = 8, Y = 3, Scale = 0.33 }, 5 | LeftBadge = { Y = -2, Width = 40, Height = 40 }, 6 | RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 }, 7 | RightText = { X = 420, Y = 4, Scale = 0.35 }, 8 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 9 | } 10 | 11 | ---@type table 12 | local SettingsList = { 13 | LeftArrow = { Dictionary = "commonmenu", Texture = "arrowleft", X = 378, Y = 3, Width = 30, Height = 30 }, 14 | RightArrow = { Dictionary = "commonmenu", Texture = "arrowright", X = 400, Y = 3, Width = 30, Height = 30 }, 15 | Text = { X = 403, Y = 3, Scale = 0.35 }, 16 | } 17 | 18 | function RageUI.List(Label, Items, Index, Description, Style, Enabled, Actions, Submenu) 19 | ---@type table 20 | local CurrentMenu = RageUI.CurrentMenu; 21 | 22 | if CurrentMenu ~= nil then 23 | if CurrentMenu() then 24 | 25 | ---@type number 26 | local Option = RageUI.Options + 1 27 | 28 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 29 | 30 | ---@type number 31 | local Selected = CurrentMenu.Index == Option 32 | 33 | ---@type boolean 34 | local LeftArrowHovered, RightArrowHovered = false, false 35 | 36 | RageUI.ItemsSafeZone(CurrentMenu) 37 | 38 | local Hovered = false; 39 | local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) 40 | local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) 41 | local RightOffset = 0 42 | ---@type boolean 43 | if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then 44 | Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton); 45 | end 46 | local ListText = (type(Items[Index]) == "table") and string.format("← %s →", Items[Index].Name) or string.format("← %s →", Items[Index]) or "NIL" 47 | 48 | if Selected then 49 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 50 | end 51 | if Enabled == true or Enabled == nil then 52 | if Selected then 53 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 54 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 0, 0, 0, 255, 2) 55 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 56 | end 57 | else 58 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 59 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 60 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 245, 245, 245, 255, 2) 61 | end 62 | end 63 | end 64 | RightOffset = RightBadgeOffset * 1.3 + RightOffset 65 | if Enabled == true or Enabled == nil then 66 | if Selected then 67 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 68 | RenderText(ListText, CurrentMenu.X + SettingsList.Text.X + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsList.Text.Scale, 0, 0, 0, 255, 2) 69 | else 70 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255) 71 | RenderText(ListText, CurrentMenu.X + SettingsList.Text.X + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsList.Text.Scale, 245, 245, 245, 255, 2) 72 | end 73 | else 74 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 163, 159, 148, 255) 75 | if Selected then 76 | RenderText(ListText, CurrentMenu.X + SettingsList.Text.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsList.Text.Scale, 163, 159, 148, 255, 2) 77 | else 78 | RenderText(ListText, CurrentMenu.X + SettingsList.Text.X + 15 + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsList.Text.Scale, 163, 159, 148, 255, 2) 79 | end 80 | end 81 | 82 | if type(Style) == "table" then 83 | if Style.Enabled == true or Style.Enabled == nil then 84 | if type(Style) == 'table' then 85 | if Style.LeftBadge ~= nil then 86 | if Style.LeftBadge ~= RageUI.BadgeStyle.None then 87 | local BadgeData = Style.LeftBadge(Selected) 88 | 89 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 90 | end 91 | end 92 | 93 | if Style.RightBadge ~= nil then 94 | if Style.RightBadge ~= RageUI.BadgeStyle.None then 95 | local BadgeData = Style.RightBadge(Selected) 96 | 97 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 98 | end 99 | end 100 | end 101 | else 102 | ---@type table 103 | local LeftBadge = RageUI.BadgeStyle.Lock 104 | ---@type number 105 | if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then 106 | local BadgeData = LeftBadge(Selected) 107 | 108 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) 109 | end 110 | end 111 | else 112 | error("UICheckBox Style is not a `table`") 113 | end 114 | 115 | LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsList.Text.X + CurrentMenu.WidthOffset - RightOffset + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 2.5 + CurrentMenu.SafeZoneSize.Y , 15, 22.5) 116 | 117 | RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsList.Text.X + CurrentMenu.WidthOffset + CurrentMenu.SafeZoneSize.X - RightOffset - MeasureStringWidth(ListText, 0, SettingsList.Text.Scale), CurrentMenu.Y + SettingsList.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 2.5 + CurrentMenu.SafeZoneSize.Y , 15, 22.5) 118 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 119 | 120 | RageUI.ItemsDescription(CurrentMenu, Description, Selected); 121 | 122 | if Selected and (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) and not (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) then 123 | Index = Index - 1 124 | if Index < 1 then 125 | Index = #Items 126 | end 127 | if (Actions.onListChange ~= nil) then 128 | Actions.onListChange(Index, Items[Index]); 129 | end 130 | local Audio = RageUI.Settings.Audio 131 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 132 | elseif Selected and (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) and not (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) then 133 | Index = Index + 1 134 | if Index > #Items then 135 | Index = 1 136 | end 137 | if (Actions.onListChange ~= nil) then 138 | Actions.onListChange(Index, Items[Index]); 139 | end 140 | local Audio = RageUI.Settings.Audio 141 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 142 | end 143 | 144 | if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then 145 | local Audio = RageUI.Settings.Audio 146 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 147 | 148 | if (Actions.onSelected ~= nil) then 149 | Actions.onSelected(Index, Items[Index]); 150 | end 151 | 152 | if Submenu ~= nil and type(Submenu) == "table" then 153 | RageUI.NextMenu = Submenu[Index] 154 | end 155 | elseif Selected then 156 | if(Actions.onActive ~= nil) then 157 | Actions.onActive() 158 | end 159 | end 160 | end 161 | 162 | RageUI.Options = RageUI.Options + 1 163 | end 164 | end 165 | end 166 | -------------------------------------------------------------------------------- /RageUI/menu/items/UISeparator.lua: -------------------------------------------------------------------------------- 1 | 2 | ---@type table 3 | local SettingsButton = { 4 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 5 | Text = { X = 8, Y = 3, Scale = 0.33 }, 6 | } 7 | 8 | function RageUI.Separator(Label) 9 | local CurrentMenu = RageUI.CurrentMenu 10 | if CurrentMenu ~= nil then 11 | if CurrentMenu() then 12 | local Option = RageUI.Options + 1 13 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 14 | if (Label ~= nil) then 15 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + (CurrentMenu.WidthOffset * 2.5 ~= 0 and CurrentMenu.WidthOffset * 2.5 or 200), CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255, 1) 16 | end 17 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 18 | if (CurrentMenu.Index == Option) then 19 | if (RageUI.LastControl) then 20 | CurrentMenu.Index = Option - 1 21 | if (CurrentMenu.Index < 1) then 22 | CurrentMenu.Index = RageUI.CurrentMenu.Options 23 | end 24 | else 25 | CurrentMenu.Index = Option + 1 26 | end 27 | end 28 | end 29 | RageUI.Options = RageUI.Options + 1 30 | end 31 | end 32 | end 33 | 34 | -------------------------------------------------------------------------------- /RageUI/menu/items/UISlider.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local SettingsButton = { 3 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 4 | Text = { X = 8, Y = 3, Scale = 0.33 }, 5 | LeftBadge = { Y = -2, Width = 40, Height = 40 }, 6 | RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 }, 7 | RightText = { X = 420, Y = 4, Scale = 0.35 }, 8 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 9 | } 10 | 11 | ---@type table 12 | local SettingsSlider = { 13 | Background = { X = 250, Y = 14.5, Width = 150, Height = 9 }, 14 | Slider = { X = 250, Y = 14.5, Width = 75, Height = 9 }, 15 | Divider = { X = 323.5, Y = 9, Width = 2.5, Height = 20 }, 16 | LeftArrow = { Dictionary = "commonmenutu", Texture = "arrowleft", X = 235, Y = 11.5, Width = 15, Height = 15 }, 17 | RightArrow = { Dictionary = "commonmenutu", Texture = "arrowright", X = 400, Y = 11.5, Width = 15, Height = 15 }, 18 | } 19 | 20 | function RageUI.Slider(Label, ProgressStart, ProgressMax, Description, Divider, Style, Enabled, Actions) 21 | 22 | ---@type table 23 | local CurrentMenu = RageUI.CurrentMenu; 24 | local Audio = RageUI.Settings.Audio 25 | if CurrentMenu ~= nil then 26 | if CurrentMenu() then 27 | local Items = {} 28 | for i = 1, ProgressMax do 29 | table.insert(Items, i) 30 | end 31 | ---@type number 32 | local Option = RageUI.Options + 1 33 | 34 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 35 | 36 | ---@type number 37 | local Selected = CurrentMenu.Index == Option 38 | 39 | ---@type boolean 40 | local LeftArrowHovered, RightArrowHovered = false, false 41 | 42 | RageUI.ItemsSafeZone(CurrentMenu) 43 | 44 | local Hovered = false; 45 | local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) 46 | local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) 47 | local RightOffset = 0 48 | ---@type boolean 49 | if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then 50 | Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton); 51 | end 52 | 53 | if Selected then 54 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 55 | LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height) 56 | RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height) 57 | end 58 | if Enabled == true or Enabled == nil then 59 | if Selected then 60 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 61 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 0, 0, 0, 255, 2) 62 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 63 | end 64 | else 65 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 66 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 67 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 245, 245, 245, 255, 2) 68 | end 69 | end 70 | end 71 | RightOffset = RightOffset + RightBadgeOffset 72 | if Enabled == true or Enabled == nil then 73 | if Selected then 74 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 75 | 76 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 0, 0, 0, 0, 255) 77 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 0, 0, 0, 0, 255) 78 | else 79 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255) 80 | end 81 | else 82 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 163, 159, 148, 255) 83 | 84 | if Selected then 85 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 163, 159, 148, 255) 86 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 163, 159, 148, 255) 87 | end 88 | end 89 | 90 | if type(Style) == "table" then 91 | if Style.Enabled == true or Style.Enabled == nil then 92 | if type(Style) == 'table' then 93 | if Style.LeftBadge ~= nil then 94 | if Style.LeftBadge ~= RageUI.BadgeStyle.None then 95 | local BadgeData = Style.LeftBadge(Selected) 96 | 97 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 98 | end 99 | end 100 | 101 | if Style.RightBadge ~= nil then 102 | if Style.RightBadge ~= RageUI.BadgeStyle.None then 103 | local BadgeData = Style.RightBadge(Selected) 104 | 105 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 106 | end 107 | end 108 | end 109 | else 110 | ---@type table 111 | local LeftBadge = RageUI.BadgeStyle.Lock 112 | 113 | if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then 114 | local BadgeData = LeftBadge(Selected) 115 | 116 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) 117 | end 118 | end 119 | else 120 | error("UICheckBox Style is not a `table`") 121 | end 122 | RenderRectangle(CurrentMenu.X + SettingsSlider.Background.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Background.Width, SettingsSlider.Background.Height, 4, 32, 57, 255) 123 | RenderRectangle(CurrentMenu.X + SettingsSlider.Slider.X + (((SettingsSlider.Background.Width - SettingsSlider.Slider.Width) / (#Items - 1)) * (ProgressStart - 1)) + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Slider.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Slider.Width, SettingsSlider.Slider.Height, 57, 116, 200, 255) 124 | if Divider then 125 | RenderRectangle(CurrentMenu.X + SettingsSlider.Divider.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.Divider.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Divider.Width, SettingsSlider.Divider.Height, 245, 245, 245, 255) 126 | end 127 | 128 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 129 | 130 | RageUI.ItemsDescription(CurrentMenu, Description, Selected); 131 | 132 | if Selected and (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) and not (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) then 133 | ProgressStart = ProgressStart - 1 134 | if ProgressStart < 1 then 135 | ProgressStart = #Items 136 | end 137 | if (Actions.onSliderChange ~= nil) then 138 | Actions.onSliderChange(ProgressStart); 139 | end 140 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 141 | elseif Selected and (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) and not (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) then 142 | ProgressStart = ProgressStart + 1 143 | if ProgressStart > #Items then 144 | ProgressStart = 1 145 | end 146 | if (Actions.onSliderChange ~= nil) then 147 | Actions.onSliderChange(ProgressStart); 148 | end 149 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 150 | end 151 | 152 | if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then 153 | if (Actions.onSelected ~= nil) then 154 | Actions.onSelected(ProgressStart); 155 | end 156 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 157 | elseif Selected then 158 | if(Actions.onActive ~= nil) then 159 | Actions.onActive() 160 | end 161 | end 162 | end 163 | 164 | RageUI.Options = RageUI.Options + 1 165 | end 166 | end 167 | end 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /RageUI/menu/items/UISliderHeritage.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local SettingsButton = { 3 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 4 | Text = { X = 8, Y = 3, Scale = 0.33 }, 5 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 6 | } 7 | 8 | ---@type table 9 | local SettingsSlider = { 10 | Background = { X = 250, Y = 14.5, Width = 150, Height = 9 }, 11 | Slider = { X = 250, Y = 14.5, Width = 75, Height = 9 }, 12 | Divider = { X = 323.5, Y = 9, Width = 2.5, Height = 20 }, 13 | LeftArrow = { Dictionary = "mpleaderboard", Texture = "leaderboard_female_icon", X = 215, Y = 0, Width = 40, Height = 40 }, 14 | RightArrow = { Dictionary = "mpleaderboard", Texture = "leaderboard_male_icon", X = 395, Y = 0, Width = 40, Height = 40 }, 15 | } 16 | 17 | local Items = {} 18 | for i = 1, 10 do 19 | table.insert(Items, i) 20 | end 21 | 22 | function RageUI.UISliderHeritage(Label, ItemIndex, Description, Actions, Value) 23 | 24 | local CurrentMenu = RageUI.CurrentMenu; 25 | local Audio = RageUI.Settings.Audio 26 | 27 | if CurrentMenu ~= nil then 28 | if CurrentMenu() then 29 | 30 | ---@type number 31 | local Option = RageUI.Options + 1 32 | 33 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 34 | 35 | ---@type number 36 | local value = Value or 0.1 37 | local Selected = CurrentMenu.Index == Option 38 | 39 | ---@type boolean 40 | local LeftArrowHovered, RightArrowHovered = false, false 41 | 42 | RageUI.ItemsSafeZone(CurrentMenu) 43 | 44 | local Hovered = false; 45 | local RightOffset = 0 46 | 47 | ---@type boolean 48 | if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then 49 | Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton); 50 | end 51 | 52 | if Selected then 53 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 54 | LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height) 55 | RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height) 56 | end 57 | 58 | RightOffset = RightOffset 59 | 60 | if Selected then 61 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 62 | 63 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 0, 0, 0, 0, 255) 64 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 0, 0, 0, 0, 255) 65 | else 66 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255) 67 | 68 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 0, 255, 255, 255, 255) 69 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 0, 255, 255, 255, 255) 70 | end 71 | 72 | RenderRectangle(CurrentMenu.X + SettingsSlider.Background.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Background.Width, SettingsSlider.Background.Height, 4, 32, 57, 255) 73 | RenderRectangle(CurrentMenu.X + SettingsSlider.Slider.X + (((SettingsSlider.Background.Width - SettingsSlider.Slider.Width) / (#Items)) * (ItemIndex)) + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Slider.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Slider.Width, SettingsSlider.Slider.Height, 57, 116, 200, 255) 74 | 75 | RenderRectangle(CurrentMenu.X + SettingsSlider.Divider.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.Divider.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Divider.Width, SettingsSlider.Divider.Height, 245, 245, 245, 255) 76 | 77 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 78 | 79 | RageUI.ItemsDescription(CurrentMenu, Description, Selected); 80 | 81 | if Selected and (CurrentMenu.Controls.SliderLeft.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) and not (CurrentMenu.Controls.SliderRight.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) then 82 | ItemIndex = ItemIndex - value 83 | if ItemIndex < 0.1 then 84 | ItemIndex = 0.0 85 | else 86 | RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true) 87 | end 88 | if (Actions.onSliderChange ~= nil) then 89 | Actions.onSliderChange(ItemIndex / 10, ItemIndex); 90 | end 91 | elseif Selected and (CurrentMenu.Controls.SliderRight.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) and not (CurrentMenu.Controls.SliderLeft.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) then 92 | ItemIndex = ItemIndex + value 93 | if ItemIndex > #Items then 94 | ItemIndex = 10 95 | else 96 | RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true) 97 | end 98 | if (Actions.onSliderChange ~= nil) then 99 | Actions.onSliderChange(ItemIndex / 10, ItemIndex); 100 | end 101 | end 102 | 103 | if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then 104 | if (Actions.onSelected ~= nil) then 105 | Actions.onSelected(ItemIndex / 10, ItemIndex); 106 | end 107 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef, false) 108 | elseif Selected then 109 | if(Actions.onActive ~= nil) then 110 | Actions.onActive() 111 | end 112 | end 113 | 114 | end 115 | 116 | RageUI.Options = RageUI.Options + 1 117 | end 118 | end 119 | end 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /RageUI/menu/items/UISliderProgress.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Dylan Malandain. 4 | --- DateTime: 21/11/2019 01:33 5 | --- 6 | 7 | ---@type table 8 | local SettingsButton = { 9 | Rectangle = { Y = 0, Width = 431, Height = 38 }, 10 | Text = { X = 8, Y = 3, Scale = 0.33 }, 11 | LeftBadge = { Y = -2, Width = 40, Height = 40 }, 12 | RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 }, 13 | RightText = { X = 420, Y = 4, Scale = 0.35 }, 14 | SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 }, 15 | } 16 | 17 | ---@type table 18 | local SettingsSlider = { 19 | Background = { X = 250, Y = 14.5, Width = 150, Height = 9 }, 20 | Slider = { X = 250, Y = 14.5, Width = 150, Height = 9 }, 21 | LeftArrow = { Dictionary = "commonmenutu", Texture = "arrowleft", X = 235, Y = 11.5, Width = 15, Height = 15 }, 22 | RightArrow = { Dictionary = "commonmenutu", Texture = "arrowright", X = 400, Y = 11.5, Width = 15, Height = 15 }, 23 | } 24 | 25 | ---Slider 26 | ---@param Label string 27 | ---@param ProgressStart number 28 | ---@param ProgressMax number 29 | ---@param Description string 30 | ---@param Enabled boolean 31 | ---@param Callback function 32 | function RageUI.SliderProgress(Label, ProgressStart, ProgressMax, Description, Style, Enabled, Actions) 33 | 34 | ---@type table 35 | local CurrentMenu = RageUI.CurrentMenu; 36 | local Audio = RageUI.Settings.Audio 37 | 38 | if CurrentMenu ~= nil then 39 | if CurrentMenu() then 40 | 41 | local Items = {} 42 | for i = 1, ProgressMax do 43 | table.insert(Items, i) 44 | end 45 | ---@type number 46 | local Option = RageUI.Options + 1 47 | 48 | if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then 49 | 50 | ---@type number 51 | local Selected = CurrentMenu.Index == Option 52 | 53 | ---@type boolean 54 | local LeftArrowHovered, RightArrowHovered = false, false 55 | 56 | RageUI.ItemsSafeZone(CurrentMenu) 57 | 58 | local Hovered = false; 59 | local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) 60 | local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) 61 | local RightOffset = 0 62 | ---@type boolean 63 | if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then 64 | Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton); 65 | end 66 | 67 | if Selected then 68 | RenderSprite(SettingsButton.SelectedSprite.Dictionary, SettingsButton.SelectedSprite.Texture, CurrentMenu.X, CurrentMenu.Y + SettingsButton.SelectedSprite.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.SelectedSprite.Width + CurrentMenu.WidthOffset, SettingsButton.SelectedSprite.Height) 69 | LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height) 70 | RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height) 71 | end 72 | if Enabled == true or Enabled == nil then 73 | if Selected then 74 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 75 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 0, 0, 0, 255, 2) 76 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 77 | end 78 | else 79 | if Style.RightLabel ~= nil and Style.RightLabel ~= "" then 80 | RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) 81 | RenderText(Style.RightLabel, CurrentMenu.X + SettingsButton.RightText.X - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightText.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.RightText.Scale, 245, 245, 245, 255, 2) 82 | end 83 | end 84 | end 85 | RightOffset = RightOffset + RightBadgeOffset 86 | if Enabled == true or Enabled == nil then 87 | if Selected then 88 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255) 89 | 90 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 0, 0, 0, 0, 255) 91 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 0, 0, 0, 0, 255) 92 | else 93 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255) 94 | end 95 | else 96 | RenderText(Label, CurrentMenu.X + SettingsButton.Text.X + LeftBadgeOffset, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 163, 159, 148, 255) 97 | 98 | if Selected then 99 | RenderSprite(SettingsSlider.LeftArrow.Dictionary, SettingsSlider.LeftArrow.Texture, CurrentMenu.X + SettingsSlider.LeftArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.LeftArrow.Width, SettingsSlider.LeftArrow.Height, 163, 159, 148, 255) 100 | RenderSprite(SettingsSlider.RightArrow.Dictionary, SettingsSlider.RightArrow.Texture, CurrentMenu.X + SettingsSlider.RightArrow.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.RightArrow.Width, SettingsSlider.RightArrow.Height, 163, 159, 148, 255) 101 | end 102 | end 103 | 104 | if type(Style) == "table" then 105 | if Style.Enabled == true or Style.Enabled == nil then 106 | if type(Style) == 'table' then 107 | if Style.LeftBadge ~= nil then 108 | if Style.LeftBadge ~= RageUI.BadgeStyle.None then 109 | local BadgeData = Style.LeftBadge(Selected) 110 | 111 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 112 | end 113 | end 114 | 115 | if Style.RightBadge ~= nil then 116 | if Style.RightBadge ~= RageUI.BadgeStyle.None then 117 | local BadgeData = Style.RightBadge(Selected) 118 | 119 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, BadgeData.BadgeColour and BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour and BadgeData.BadgeColour.A or 255) 120 | end 121 | end 122 | end 123 | else 124 | ---@type table 125 | local LeftBadge = RageUI.BadgeStyle.Lock 126 | 127 | if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then 128 | local BadgeData = LeftBadge(Selected) 129 | 130 | RenderSprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) 131 | end 132 | end 133 | else 134 | error("UICheckBox Style is not a `table`") 135 | end 136 | 137 | if (type(Style.ProgressBackgroundColor) == "table") then 138 | RenderRectangle(CurrentMenu.X + SettingsSlider.Background.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsSlider.Background.Width, SettingsSlider.Background.Height, Style.ProgressBackgroundColor.R, Style.ProgressBackgroundColor.G, Style.ProgressBackgroundColor.B, Style.ProgressBackgroundColor.A) 139 | else 140 | error("Style ProgressBackgroundColor is not a table or undefined") 141 | end 142 | 143 | if (type(Style.ProgressColor) == "table") then 144 | RenderRectangle(CurrentMenu.X + SettingsSlider.Slider.X + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + SettingsSlider.Slider.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, (((SettingsSlider.Slider.Width) / (#Items - 1)) * (ProgressStart - 1)), SettingsSlider.Slider.Height, Style.ProgressColor.R, Style.ProgressColor.G, Style.ProgressColor.B, Style.ProgressColor.A) 145 | else 146 | error("Style ProgressColor is not a table or undefined") 147 | end 148 | 149 | RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height 150 | 151 | RageUI.ItemsDescription(CurrentMenu, Description, Selected); 152 | 153 | if Selected and (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) and not (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) then 154 | ProgressStart = ProgressStart - 1 155 | if ProgressStart < 1 then 156 | ProgressStart = #Items 157 | end 158 | if (Actions.onSliderChange ~= nil) then 159 | Actions.onSliderChange(ProgressStart); 160 | end 161 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 162 | elseif Selected and (CurrentMenu.Controls.Right.Active or (CurrentMenu.Controls.Click.Active and RightArrowHovered)) and not (CurrentMenu.Controls.Left.Active or (CurrentMenu.Controls.Click.Active and LeftArrowHovered)) then 163 | ProgressStart = ProgressStart + 1 164 | if ProgressStart > #Items then 165 | ProgressStart = 1 166 | end 167 | if (Actions.onSliderChange ~= nil) then 168 | Actions.onSliderChange(ProgressStart); 169 | end 170 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 171 | end 172 | 173 | if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then 174 | if (Actions.onSelected ~= nil) then 175 | Actions.onSelected(ProgressStart); 176 | end 177 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 178 | elseif Selected then 179 | if(Actions.onActive ~= nil) then 180 | Actions.onActive() 181 | end 182 | end 183 | end 184 | 185 | RageUI.Options = RageUI.Options + 1 186 | end 187 | end 188 | end 189 | 190 | 191 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UIColourPanel.lua: -------------------------------------------------------------------------------- 1 | ---@type table 2 | local Colour = { 3 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 112 }, 4 | LeftArrow = { Dictionary = "commonmenu", Texture = "arrowleft", X = 7.5, Y = 15, Width = 30, Height = 30 }, 5 | RightArrow = { Dictionary = "commonmenu", Texture = "arrowright", X = 393.5, Y = 15, Width = 30, Height = 30 }, 6 | Header = { X = 215.5, Y = 15, Scale = 0.35 }, 7 | Box = { X = 15, Y = 55, Width = 44.5, Height = 44.5 }, 8 | SelectedRectangle = { X = 15, Y = 47, Width = 44.5, Height = 8 }, 9 | Seperator = { Text = "of" } 10 | } 11 | 12 | ---ColourPanel 13 | ---@param Title string 14 | ---@param Colours thread 15 | ---@param MinimumIndex number 16 | ---@param CurrentIndex number 17 | ---@param Callback function 18 | ---@return nil 19 | ---@public 20 | function RageUI.ColourPanel(Title, Colours, MinimumIndex, CurrentIndex, Action, Index, Style) 21 | 22 | ---@type table 23 | local CurrentMenu = RageUI.CurrentMenu; 24 | 25 | if CurrentMenu ~= nil then 26 | if CurrentMenu() and (CurrentMenu.Index == Index) then 27 | 28 | ---@type number 29 | local Maximum = (#Colours > 9) and 9 or #Colours 30 | 31 | ---@type boolean 32 | local Hovered = RageUI.IsMouseInBounds(CurrentMenu.X + Colour.Box.X + CurrentMenu.SafeZoneSize.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.Box.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, (Colour.Box.Width * Maximum), Colour.Box.Height) 33 | 34 | ---@type number 35 | local LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + Colour.LeftArrow.X + CurrentMenu.SafeZoneSize.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.LeftArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.LeftArrow.Width, Colour.LeftArrow.Height) 36 | 37 | ---@type number 38 | local RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + Colour.RightArrow.X + CurrentMenu.SafeZoneSize.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.RightArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.RightArrow.Width, Colour.RightArrow.Height) 39 | 40 | ---@type boolean 41 | local Selected = false 42 | 43 | RenderSprite(Colour.Background.Dictionary, Colour.Background.Texture, CurrentMenu.X, CurrentMenu.Y + Colour.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.Background.Width + CurrentMenu.WidthOffset, Colour.Background.Height) 44 | RenderSprite(Colour.LeftArrow.Dictionary, Colour.LeftArrow.Texture, CurrentMenu.X + Colour.LeftArrow.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.LeftArrow.Width, Colour.LeftArrow.Height) 45 | RenderSprite(Colour.RightArrow.Dictionary, Colour.RightArrow.Texture, CurrentMenu.X + Colour.RightArrow.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.RightArrow.Width, Colour.RightArrow.Height) 46 | 47 | RenderRectangle(CurrentMenu.X + Colour.SelectedRectangle.X + (Colour.Box.Width * (CurrentIndex - MinimumIndex)) + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.SelectedRectangle.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.SelectedRectangle.Width, Colour.SelectedRectangle.Height, 245, 245, 245, 255) 48 | 49 | for Index = 1, Maximum do 50 | RenderRectangle(CurrentMenu.X + Colour.Box.X + (Colour.Box.Width * (Index - 1)) + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.Box.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.Box.Width, Colour.Box.Height, table.unpack(Colours[MinimumIndex + Index - 1])) 51 | end 52 | 53 | local ColourSeperator = {} 54 | if type(Style) == "table" then 55 | if type(Style.Seperator) == "table" then 56 | ColourSeperator = Style.Seperator 57 | else 58 | ColourSeperator = Colour.Seperator 59 | end 60 | else 61 | ColourSeperator = Colour.Seperator 62 | end 63 | 64 | RenderText((Title and Title or "") .. " (" .. CurrentIndex .. " " .. ColourSeperator.Text .. " " .. #Colours .. ")", CurrentMenu.X + RageUI.Settings.Panels.Grid.Text.Top.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + RageUI.Settings.Panels.Grid.Text.Top.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, RageUI.Settings.Panels.Grid.Text.Top.Scale, 245, 245, 245, 255, 1) 65 | 66 | if Hovered or LeftArrowHovered or RightArrowHovered then 67 | if RageUI.Settings.Controls.Click.Active then 68 | Selected = true 69 | 70 | if LeftArrowHovered then 71 | CurrentIndex = CurrentIndex - 1 72 | 73 | if CurrentIndex < 1 then 74 | CurrentIndex = #Colours 75 | MinimumIndex = #Colours - Maximum + 1 76 | elseif CurrentIndex < MinimumIndex then 77 | MinimumIndex = MinimumIndex - 1 78 | end 79 | elseif RightArrowHovered then 80 | CurrentIndex = CurrentIndex + 1 81 | 82 | if CurrentIndex > #Colours then 83 | CurrentIndex = 1 84 | MinimumIndex = 1 85 | elseif CurrentIndex > MinimumIndex + Maximum - 1 then 86 | MinimumIndex = MinimumIndex + 1 87 | end 88 | elseif Hovered then 89 | for Index = 1, Maximum do 90 | if RageUI.IsMouseInBounds(CurrentMenu.X + Colour.Box.X + (Colour.Box.Width * (Index - 1)) + CurrentMenu.SafeZoneSize.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Colour.Box.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Colour.Box.Width, Colour.Box.Height) then 91 | CurrentIndex = MinimumIndex + Index - 1 92 | end 93 | end 94 | end 95 | 96 | if (Action.onColorChange ~= nil) then 97 | Action.onColorChange(MinimumIndex, CurrentIndex) 98 | end 99 | end 100 | end 101 | 102 | RageUI.ItemOffset = RageUI.ItemOffset + Colour.Background.Height + Colour.Background.Y 103 | 104 | if (Hovered or LeftArrowHovered or RightArrowHovered) and RageUI.Settings.Controls.Click.Active then 105 | local Audio = RageUI.Settings.Audio 106 | RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef) 107 | end 108 | end 109 | end 110 | end 111 | 112 | 113 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UIGridPanel.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | local GridType = RageUI.Enum { 4 | Default = 1, 5 | Horizontal = 2, 6 | Vertical = 3 7 | } 8 | 9 | local GridSprite = { 10 | [GridType.Default] = { Dictionary = "pause_menu_pages_char_mom_dad", Texture = "nose_grid", }, 11 | [GridType.Horizontal] = { Dictionary = "RageUI_", Texture = "horizontal_grid", }, 12 | [GridType.Vertical] = { Dictionary = "RageUI_", Texture = "vertical_grid", }, 13 | } 14 | 15 | local Grid = { 16 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 275 }, 17 | Grid = { X = 115.5, Y = 47.5, Width = 200, Height = 200 }, 18 | Circle = { Dictionary = "mpinventory", Texture = "in_world_circle", X = 115.5, Y = 47.5, Width = 20, Height = 20 }, 19 | Text = { 20 | Top = { X = 215.5, Y = 15, Scale = 0.35 }, 21 | Bottom = { X = 215.5, Y = 250, Scale = 0.35 }, 22 | Left = { X = 57.75, Y = 130, Scale = 0.35 }, 23 | Right = { X = 373.25, Y = 130, Scale = 0.35 }, 24 | }, 25 | } 26 | 27 | local function UIGridPanel(Type, StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index) 28 | local CurrentMenu = RageUI.CurrentMenu 29 | if CurrentMenu ~= nil then 30 | if CurrentMenu() and ((CurrentMenu.Index == Index)) then 31 | local X = Type == GridType.Default and StartedX or Type == GridType.Horizontal and StartedX or Type == GridType.Vertical and 0.5 32 | local Y = Type == GridType.Default and StartedY or Type == GridType.Horizontal and 0.5 or Type == GridType.Vertical and StartedY 33 | local Hovered = RageUI.IsMouseInBounds(CurrentMenu.X + Grid.Grid.X + CurrentMenu.SafeZoneSize.X + 20, CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20, Grid.Grid.Width + CurrentMenu.WidthOffset - 40, Grid.Grid.Height - 40) 34 | local Selected = false 35 | local CircleX = CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20 36 | local CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 37 | if X < 0.0 or X > 1.0 then 38 | X = 0.0 39 | end 40 | if Y < 0.0 or Y > 1.0 then 41 | Y = 0.0 42 | end 43 | CircleX = CircleX + ((Grid.Grid.Width - 40) * X) - (Grid.Circle.Width / 2) 44 | CircleY = CircleY + ((Grid.Grid.Height - 40) * Y) - (Grid.Circle.Height / 2) 45 | RenderSprite(Grid.Background.Dictionary, Grid.Background.Texture, CurrentMenu.X, CurrentMenu.Y + Grid.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Grid.Background.Width + CurrentMenu.WidthOffset, Grid.Background.Height) 46 | RenderSprite(GridSprite[Type].Dictionary, GridSprite[Type].Texture, CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Grid.Grid.Width, Grid.Grid.Height) 47 | RenderSprite(Grid.Circle.Dictionary, Grid.Circle.Texture, CircleX, CircleY, Grid.Circle.Width, Grid.Circle.Height) 48 | if (Type == GridType.Default) then 49 | RenderText(TopText or "", CurrentMenu.X + Grid.Text.Top.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Top.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Top.Scale, 245, 245, 245, 255, 1) 50 | RenderText(BottomText or "", CurrentMenu.X + Grid.Text.Bottom.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Bottom.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Bottom.Scale, 245, 245, 245, 255, 1) 51 | RenderText(LeftText or "", CurrentMenu.X + Grid.Text.Left.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Left.Scale, 245, 245, 245, 255, 1) 52 | RenderText(RightText or "", CurrentMenu.X + Grid.Text.Right.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Right.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Right.Scale, 245, 245, 245, 255, 1) 53 | end 54 | if (Type == GridType.Vertical) then 55 | RenderText(TopText or "", CurrentMenu.X + Grid.Text.Top.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Top.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Top.Scale, 245, 245, 245, 255, 1) 56 | RenderText(BottomText or "", CurrentMenu.X + Grid.Text.Bottom.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Bottom.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Bottom.Scale, 245, 245, 245, 255, 1) 57 | end 58 | if (Type == GridType.Horizontal) then 59 | RenderText(LeftText or "", CurrentMenu.X + Grid.Text.Left.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Left.Scale, 245, 245, 245, 255, 1) 60 | RenderText(RightText or "", CurrentMenu.X + Grid.Text.Right.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Grid.Text.Right.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Grid.Text.Right.Scale, 245, 245, 245, 255, 1) 61 | end 62 | if Hovered then 63 | if IsDisabledControlPressed(0, 24) then 64 | Selected = true 65 | CircleX = math.round(GetControlNormal(2, 239) * 1920) - CurrentMenu.SafeZoneSize.X - (Grid.Circle.Width / 2) 66 | CircleY = math.round(GetControlNormal(2, 240) * 1080) - CurrentMenu.SafeZoneSize.Y - (Grid.Circle.Height / 2) 67 | if CircleX > (CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20 + Grid.Grid.Width - 40) then 68 | CircleX = CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20 + Grid.Grid.Width - 40 69 | elseif CircleX < (CurrentMenu.X + Grid.Grid.X + 20 - (Grid.Circle.Width / 2)) then 70 | CircleX = CurrentMenu.X + Grid.Grid.X + 20 - (Grid.Circle.Width / 2) 71 | end 72 | if CircleY > (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 + Grid.Grid.Height - 40) then 73 | CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 + Grid.Grid.Height - 40 74 | elseif CircleY < (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 - (Grid.Circle.Height / 2)) then 75 | CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 - (Grid.Circle.Height / 2) 76 | end 77 | X = math.round((CircleX - (CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20) + (Grid.Circle.Width / 2)) / (Grid.Grid.Width - 40), 2) 78 | Y = math.round((CircleY - (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20) + (Grid.Circle.Height / 2)) / (Grid.Grid.Height - 40), 2) 79 | if (X ~= StartedX) and (Y ~= StartedY) then 80 | Action.onPositionChange(X, Y, (X * 2 - 1), (Y * 2 - 1)) 81 | end 82 | StartedX = X; 83 | StartedY = Y; 84 | if X > 1.0 then 85 | X = 1.0 86 | end 87 | if Y > 1.0 then 88 | Y = 1.0 89 | end 90 | end 91 | end 92 | RageUI.ItemOffset = RageUI.ItemOffset + Grid.Background.Height + Grid.Background.Y 93 | if Hovered and Selected then 94 | local Audio = RageUI.Settings.Audio 95 | RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true) 96 | if (Action.onSelected ~= nil) then 97 | Action.onSelected(X, Y, (X * 2 - 1), (Y * 2 - 1)); 98 | end 99 | end 100 | 101 | end 102 | end 103 | end 104 | 105 | function RageUI.Grid(StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index) 106 | UIGridPanel(GridType.Default, StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index) 107 | end 108 | 109 | function RageUI.GridHorizontal(StartedX, LeftText, RightText, Action, Index) 110 | UIGridPanel(GridType.Horizontal, StartedX, nil, nil, nil, LeftText, RightText, Action, Index) 111 | end 112 | 113 | function RageUI.GridVertical(StartedY, TopText, BottomText, Action, Index) 114 | UIGridPanel(GridType.Vertical, nil, StartedY, TopText, BottomText, nil, nil, Action, Index) 115 | end 116 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UIPercentagePanel.lua: -------------------------------------------------------------------------------- 1 | local Percentage = { 2 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 76 }, 3 | Bar = { X = 9, Y = 50, Width = 413, Height = 10 }, 4 | Text = { 5 | Left = { X = 25, Y = 15, Scale = 0.35 }, 6 | Middle = { X = 215.5, Y = 15, Scale = 0.35 }, 7 | Right = { X = 398, Y = 15, Scale = 0.35 }, 8 | }, 9 | } 10 | 11 | ---PercentagePanel 12 | ---@param Percent number 13 | ---@param HeaderText string 14 | ---@param MinText string 15 | ---@param MaxText string 16 | ---@param Callback function 17 | ---@param Index number 18 | ---@return nil 19 | ---@public 20 | function RageUI.PercentagePanel(Percent, HeaderText, MinText, MaxText, Action, Index) 21 | local CurrentMenu = RageUI.CurrentMenu 22 | 23 | if CurrentMenu ~= nil then 24 | if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then 25 | 26 | ---@type boolean 27 | local Hovered = RageUI.IsMouseInBounds(CurrentMenu.X + Percentage.Bar.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + Percentage.Bar.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset - 4, Percentage.Bar.Width + CurrentMenu.WidthOffset, Percentage.Bar.Height + 8) 28 | 29 | ---@type boolean 30 | local Selected = false 31 | 32 | ---@type number 33 | local Progress = Percentage.Bar.Width 34 | 35 | if Percent < 0.0 then 36 | Percent = 0.0 37 | elseif Percent > 1.0 then 38 | Percent = 1.0 39 | end 40 | 41 | Progress = Progress * Percent 42 | 43 | RenderSprite(Percentage.Background.Dictionary, Percentage.Background.Texture, CurrentMenu.X, CurrentMenu.Y + Percentage.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percentage.Background.Width + CurrentMenu.WidthOffset, Percentage.Background.Height) 44 | RenderRectangle(CurrentMenu.X + Percentage.Bar.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Percentage.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percentage.Bar.Width, Percentage.Bar.Height, 87, 87, 87, 255) 45 | RenderRectangle(CurrentMenu.X + Percentage.Bar.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Percentage.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Progress, Percentage.Bar.Height, 245, 245, 245, 255) 46 | 47 | RenderText(HeaderText or "Opacity", CurrentMenu.X + Percentage.Text.Middle.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Percentage.Text.Middle.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Percentage.Text.Middle.Scale, 245, 245, 245, 255, 1) 48 | RenderText(MinText or "0%", CurrentMenu.X + Percentage.Text.Left.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Percentage.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Percentage.Text.Left.Scale, 245, 245, 245, 255, 1) 49 | RenderText(MaxText or "100%", CurrentMenu.X + Percentage.Text.Right.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + Percentage.Text.Right.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Percentage.Text.Right.Scale, 245, 245, 245, 255, 1) 50 | 51 | if Hovered then 52 | if IsDisabledControlPressed(0, 24) then 53 | Selected = true 54 | 55 | Progress = math.round(GetControlNormal(2, 239) * 1920) - CurrentMenu.SafeZoneSize.X - (CurrentMenu.X + Percentage.Bar.X + (CurrentMenu.WidthOffset / 2)) 56 | 57 | if Progress < 0 then 58 | Progress = 0 59 | elseif Progress > (Percentage.Bar.Width) then 60 | Progress = Percentage.Bar.Width 61 | end 62 | 63 | Percent = math.round(Progress / Percentage.Bar.Width, 2) 64 | if (Action.onProgressChange ~= nil) then 65 | Action.onProgressChange(Percent) 66 | end 67 | end 68 | end 69 | 70 | RageUI.ItemOffset = RageUI.ItemOffset + Percentage.Background.Height + Percentage.Background.Y 71 | 72 | if Hovered and Selected then 73 | local Audio = RageUI.Settings.Audio 74 | RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true) 75 | if (Action.onSelected ~= nil) then 76 | Action.onSelected(Percent) 77 | end 78 | end 79 | end 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UISliderPanel.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by Naytoxp. 4 | --- DateTime: 20/01/2021 18:21 5 | --- 6 | --- Commercial Info. 7 | --- Any use for commercial purposes is strictly prohibited and will be punished. 8 | --- 9 | --- @see RageUI 10 | --- 11 | 12 | local Slider = { 13 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 76 }, 14 | Text = { 15 | Left = { X = 18, Y = 8, Scale = 0.32 }, 16 | Right = { X = 380, Y = 8, Scale = 0.32 }, 17 | Upper = {X = 230, Y = 8, Scale = 0.32}, 18 | }, 19 | Bar = { X = 25, Y = 36, Width = 250, Height = 16 }, 20 | Slider = { X = 20, Y = 14.5, Width = 35, Height = 9 }, 21 | LeftArrow = { Dictionary = "commonmenu", Texture = "arrowleft", X = 12, Y = 32.5, Width = 25, Height = 25 }, 22 | RightArrow = { Dictionary = "commonmenu", Texture = "arrowright", X = 389, Y = 32.5, Width = 25, Height = 25 }, 23 | } 24 | 25 | function RageUI.SliderPanel(Value, MinValue, UpperText, MaxValue, Actions, Index) 26 | local CurrentMenu = RageUI.CurrentMenu 27 | if CurrentMenu ~= nil then 28 | if CurrentMenu() and ((CurrentMenu.Index == Index)) then 29 | Value = Value or 0 30 | Slider.Bar.Width = Slider.RightArrow.X- Slider.LeftArrow.X - Slider.LeftArrow.Width - 5 + CurrentMenu.WidthOffset 31 | Slider.Bar.X = Slider.LeftArrow.X + Slider.LeftArrow.Width 32 | Slider.Text.Upper.X = (Slider.Bar.Width) / 2 + Slider.Bar.X 33 | Slider.Text.Right.X = Slider.RightArrow.X + Slider.LeftArrow.Width 34 | local Hovered = false 35 | local LeftArrowHovered, RightArrowHovered = false, false 36 | local SliderW = Slider.Bar.Width / (64 + 1) 37 | local SliderX = CurrentMenu.X + Slider.Bar.X + Value * Slider.Bar.Width / MaxValue 38 | 39 | Hovered = RageUI.IsMouseInBounds(CurrentMenu.X + Slider.Bar.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + Slider.Bar.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset - 4, Slider.Bar.Width, Slider.Bar.Height + 8) 40 | 41 | RenderSprite("commonmenu", "gradient_bgd", CurrentMenu.X, CurrentMenu.Y + Slider.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.Background.Width + CurrentMenu.WidthOffset, Slider.Background.Height, 0.0, 255, 255, 255, 255) 42 | RenderText(MinValue, CurrentMenu.X + Slider.Text.Left.X, CurrentMenu.Y + Slider.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Slider.Text.Left.Scale, 255, 255, 255, 255) 43 | RenderText(UpperText, CurrentMenu.X + Slider.Text.Upper.X, CurrentMenu.Y + Slider.Text.Upper.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Slider.Text.Upper.Scale, 255, 255, 255, 255, "Center") 44 | RenderText(MaxValue, CurrentMenu.X + Slider.Text.Right.X + CurrentMenu.WidthOffset, CurrentMenu.Y + Slider.Text.Right.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Slider.Text.Right.Scale, 255, 255, 255, 255, "Right") 45 | 46 | RenderSprite(Slider.LeftArrow.Dictionary, Slider.LeftArrow.Texture, CurrentMenu.X + Slider.LeftArrow.X, CurrentMenu.Y + Slider.LeftArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.LeftArrow.Width, Slider.LeftArrow.Height, 0.0, 255, 255, 255, 255) 47 | RenderSprite(Slider.RightArrow.Dictionary, Slider.RightArrow.Texture, CurrentMenu.X + Slider.RightArrow.X + CurrentMenu.WidthOffset , CurrentMenu.Y + Slider.RightArrow.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.RightArrow.Width, Slider.RightArrow.Height, 0.0, 255, 255, 255, 255) 48 | RenderRectangle(CurrentMenu.X + Slider.Bar.X, CurrentMenu.Y + Slider.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.Bar.Width, Slider.Bar.Height, 87, 87, 87, 255) 49 | RenderRectangle(SliderX, CurrentMenu.Y + Slider.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SliderW, Slider.Bar.Height, 245, 245, 245, 255) 50 | 51 | LeftArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + Slider.LeftArrow.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + Slider.LeftArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.LeftArrow.Width, Slider.LeftArrow.Height) 52 | RightArrowHovered = RageUI.IsMouseInBounds(CurrentMenu.X + Slider.RightArrow.X + CurrentMenu.SafeZoneSize.X + CurrentMenu.WidthOffset, CurrentMenu.Y + Slider.RightArrow.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Slider.RightArrow.Width, Slider.RightArrow.Height) 53 | 54 | if Hovered then 55 | if IsDisabledControlPressed(0, 24) then 56 | local GetControl_X = GetDisabledControlNormal 57 | Value = (math.round(GetControl_X(2, 239) * 1920) - CurrentMenu.SafeZoneSize.X - Slider.Bar.X )/ Slider.Bar.Width * MaxValue 58 | if Value < 0 then 59 | Value = 0 60 | elseif Value >= MaxValue then 61 | Value = MaxValue 62 | end 63 | Value = math.round(Value, 0) 64 | print(Value) 65 | if (Actions.onSliderChange ~= nil) then 66 | Actions.onSliderChange(Value) 67 | end 68 | end 69 | elseif CurrentMenu.Controls.Click.Active and (LeftArrowHovered or RightArrowHovered) then 70 | local max = type(Items) == "table" and #Items or MaxValue 71 | Value = Value + (LeftArrowHovered and -1 or RightArrowHovered and 1) 72 | if Value < MinValue then 73 | Value = max 74 | elseif Value > max then 75 | Value = MinValue 76 | end 77 | print(Value) 78 | if (Actions.onSliderChange ~= nil) then 79 | Actions.onSliderChange(Value); 80 | end 81 | 82 | local Audio = RageUI.Settings.Audio 83 | RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef) 84 | end 85 | end 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UISpritPanel.lua: -------------------------------------------------------------------------------- 1 | --- 2 | --- Generated by EmmyLua(https://github.com/EmmyLua) 3 | --- Created by iTexZ. 4 | --- DateTime: 05/11/2020 02:17 5 | --- 6 | 7 | local TextPanels = { 8 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 42 }, 9 | } 10 | 11 | ---@type Panel 12 | function RageUI.RenderSprite(Dictionary, Texture) 13 | local CurrentMenu = RageUI.CurrentMenu 14 | if CurrentMenu ~= nil then 15 | if CurrentMenu() then 16 | RenderSprite(Dictionary, Texture, CurrentMenu.X, CurrentMenu.Y + TextPanels.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + (RageUI.StatisticPanelCount * 42), TextPanels.Background.Width + CurrentMenu.WidthOffset, TextPanels.Background.Height + 200, 0, 255, 255, 255, 255); 17 | RageUI.StatisticPanelCount = RageUI.StatisticPanelCount + 1 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /RageUI/menu/panels/UIStatisticsPanel.lua: -------------------------------------------------------------------------------- 1 | local Statistics = { 2 | Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 42 }, 3 | Text = { 4 | Left = { X = -40, Y = 15, Scale = 0.35 }, 5 | }, 6 | Bar = { Right = 8, Y = 27, Width = 200, Height = 10, OffsetRatio = 0.5 }, 7 | Divider = { 8 | [1] = { X = 200, Y = 27, Width = 2, Height = 10 }, 9 | [2] = { X = 200, Y = 27, Width = 2, Height = 10 }, 10 | [3] = { X = 200, Y = 27, Width = 2, Height = 10 }, 11 | [4] = { X = 200, Y = 27, Width = 2, Height = 10 }, 12 | [5] = { X = 200, Y = 27, Width = 2, Height = 10 }, 13 | } 14 | } 15 | 16 | function RageUI.StatisticPanel(Percent, Text, Index) 17 | local CurrentMenu = RageUI.CurrentMenu 18 | if CurrentMenu ~= nil then 19 | if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then 20 | 21 | ---@type number 22 | local BarWidth = Statistics.Bar.Width + CurrentMenu.WidthOffset * Statistics.Bar.OffsetRatio 23 | 24 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + Statistics.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + (RageUI.StatisticPanelCount * 42), Statistics.Background.Width + CurrentMenu.WidthOffset, Statistics.Background.Height, 0, 0, 0, 170) 25 | RenderText(Text or "", CurrentMenu.X + 8.0, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Statistics.Text.Left.Scale, 245, 245, 245, 255, 0) 26 | RenderRectangle(CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, BarWidth, Statistics.Bar.Height, 87, 87, 87, 255) 27 | RenderRectangle(CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percent * BarWidth, Statistics.Bar.Height, 255, 255, 255, 255) 28 | for i = 1, #Statistics.Divider, 1 do 29 | RenderRectangle((CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right) + i * ((BarWidth - (#Statistics.Divider / Statistics.Divider[i].Width)) / (#Statistics.Divider + 1)) + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Divider[i].Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Statistics.Divider[i].Width, Statistics.Divider[i].Height, 0, 0, 0, 255) 30 | end 31 | RageUI.StatisticPanelCount = RageUI.StatisticPanelCount + 1 32 | end 33 | end 34 | end 35 | 36 | function RageUI.StatisticPanelAdvanced(Text, Percent, RGBA1, Percent2, RGBA2, RGBA3, Index) 37 | local CurrentMenu = RageUI.CurrentMenu 38 | if CurrentMenu ~= nil then 39 | if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then 40 | 41 | RGBA1 = RGBA1 or { 255, 255, 255, 255 } 42 | local BarWidth = Statistics.Bar.Width + CurrentMenu.WidthOffset * Statistics.Bar.OffsetRatio 43 | 44 | ---@type number 45 | RenderRectangle(CurrentMenu.X, CurrentMenu.Y + Statistics.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + (RageUI.StatisticPanelCount * 42), Statistics.Background.Width + CurrentMenu.WidthOffset, Statistics.Background.Height, 0, 0, 0, 170) 46 | RenderText(Text or "", CurrentMenu.X + 8.0, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Text.Left.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Statistics.Text.Left.Scale, 245, 245, 245, 255, 0) 47 | RenderRectangle(CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, BarWidth, Statistics.Bar.Height, 87, 87, 87, 255) 48 | RenderRectangle(CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percent * BarWidth, Statistics.Bar.Height, RGBA1[1], RGBA1[2], RGBA1[3], RGBA1[4]) 49 | RGBA2 = RGBA2 or { 0, 153, 204, 255 } 50 | RGBA3 = RGBA3 or { 185, 0, 0, 255 } 51 | 52 | if Percent2 and Percent2 > 0 then 53 | local X = CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset + Percent * BarWidth 54 | RenderRectangle(X, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percent2 * BarWidth, Statistics.Bar.Height, RGBA2[1], RGBA2[2], RGBA2[3], RGBA2[4]) 55 | elseif Percent2 and Percent2 < 0 then 56 | local X = CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset + Percent * BarWidth 57 | RenderRectangle(X, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Percent2 * BarWidth, Statistics.Bar.Height, RGBA3[1], RGBA3[2], RGBA3[3], RGBA3[4]) 58 | end 59 | 60 | for i = 1, #Statistics.Divider, 1 do 61 | RenderRectangle((CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right) + i * ((BarWidth - (#Statistics.Divider / Statistics.Divider[i].Width)) / (#Statistics.Divider + 1)) + CurrentMenu.WidthOffset, (RageUI.StatisticPanelCount * 40) + CurrentMenu.Y + Statistics.Divider[i].Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Statistics.Divider[i].Width, Statistics.Divider[i].Height, 0, 0, 0, 255) 62 | end 63 | 64 | RageUI.StatisticPanelCount = RageUI.StatisticPanelCount + 1 65 | end 66 | end 67 | end 68 | 69 | -------------------------------------------------------------------------------- /RageUI/menu/windows/UIHeritage.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | ---@type table 4 | local Heritage = { 5 | Background = { Dictionary = "pause_menu_pages_char_mom_dad", Texture = "mumdadbg", Width = 431, Height = 228 }, 6 | Mum = { Dictionary = "char_creator_portraits", X = 25, Width = 228, Height = 228 }, 7 | Dad = { Dictionary = "char_creator_portraits", X = 195, Width = 228, Height = 228 }, 8 | } 9 | 10 | ---@type Window 11 | function RageUI.Window.Heritage(Mum, Dad) 12 | ---@type table 13 | local CurrentMenu = RageUI.CurrentMenu; 14 | if CurrentMenu ~= nil then 15 | if CurrentMenu() then 16 | if Mum < 0 or Mum > 21 then 17 | Mum = 0 18 | end 19 | if Dad < 0 or Dad > 23 then 20 | Dad = 0 21 | end 22 | if Mum == 21 then 23 | Mum = "special_female_" .. (tonumber(string.sub(Mum, 2, 2)) - 1) 24 | else 25 | Mum = "female_" .. Mum 26 | end 27 | if Dad >= 21 then 28 | Dad = "special_male_" .. (tonumber(string.sub(Dad, 2, 2)) - 1) 29 | else 30 | Dad = "male_" .. Dad 31 | end 32 | RenderSprite(Heritage.Background.Dictionary, Heritage.Background.Texture, CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Heritage.Background.Width + (CurrentMenu.WidthOffset / 1), Heritage.Background.Height) 33 | RenderSprite(Heritage.Dad.Dictionary, Dad, CurrentMenu.X + Heritage.Dad.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Heritage.Dad.Width, Heritage.Dad.Height) 34 | RenderSprite(Heritage.Mum.Dictionary, Mum, CurrentMenu.X + Heritage.Mum.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Heritage.Mum.Width, Heritage.Mum.Height) 35 | RageUI.ItemOffset = RageUI.ItemOffset + Heritage.Background.Height 36 | end 37 | end 38 | end 39 | 40 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 3 | 4 | local open = false 5 | local SliderProgress = 1 6 | local StartMusic = false 7 | local IsPaused = false 8 | local SpotifyMenu = RageUI.CreateMenu(false, "Action(s) disponibles", 0, 0, "banner_spotify", "banner_spotify") 9 | local SpotifyAddMusicMenu = RageUI.CreateSubMenu(SpotifyMenu, false, "Action(s) disponibles", 0, 0, "banner_spotify", "banner_spotify") 10 | local SpotifyPlayerMusicMenu = RageUI.CreateSubMenu(SpotifyMenu, false, "Action(s) disponibles", 0, 0, "banner_spotify", "banner_spotify") 11 | SpotifyMenu.Closed = function() 12 | RageUI.Visible(SpotifyMenu, false) 13 | open = false 14 | end 15 | 16 | function OpenSpotifyMenu() 17 | if open then 18 | open = false 19 | RageUI.Visible(SpotifyMenu,false) 20 | return 21 | else 22 | open = true 23 | RageUI.Visible(SpotifyMenu, true) 24 | Citizen.CreateThread(function () 25 | while open do 26 | RageUI.IsVisible(SpotifyMenu, function() 27 | RageUI.Button('Ajouter une musique', false , {RightLabel = "→"}, true , {}, SpotifyAddMusicMenu) 28 | RageUI.Button('Vos musiques', false , {RightLabel = "→"}, true , { 29 | onSelected = function() 30 | RefreshPlayerMusic() 31 | end 32 | },SpotifyPlayerMusicMenu) 33 | if StartMusic then 34 | RageUI.Separator("~g~Musique en cours:~s~ "..CurrentSong) 35 | RageUI.SliderProgress('Volume', SliderProgress, 10, false, { 36 | ProgressBackgroundColor = { R = 255, G = 255, B = 255, A = 255 }, 37 | ProgressColor = { R = 30, G = 215, B = 96, A = 255 }, 38 | }, true, { 39 | onSliderChange = function(Index) 40 | SliderProgress = Index 41 | setVolume("Music", Index/10) 42 | end 43 | }) 44 | if not IsPaused then 45 | RageUI.Button("Mettre en pause", false , {RightLabel = "→"}, true , { 46 | onSelected = function() 47 | Pause("Music") 48 | IsPaused = true 49 | end 50 | }) 51 | else 52 | RageUI.Button("Relancer", false , {RightLabel = "→"}, true , { 53 | onSelected = function() 54 | Resume("Music") 55 | IsPaused = false 56 | end 57 | }) 58 | end 59 | RageUI.Button('~r~Arrêter la musique', false , {RightLabel = "→"}, true , { 60 | onSelected = function() 61 | Destroy("Music") 62 | StartMusic = false 63 | end 64 | }) 65 | end 66 | end) 67 | RageUI.IsVisible(SpotifyAddMusicMenu, function() 68 | RageUI.Button("Nom de la musique", false, {RightLabel = current_song}, true, { 69 | onSelected = function() 70 | local NameOfSong = KeyboardInput("add_music", "Nom de votre musique", "", 15) 71 | current_song = NameOfSong 72 | end 73 | }) 74 | RageUI.Button("ID youtube de la musique", false, {RightLabel = current_url}, true, { 75 | onSelected = function() 76 | local URL = KeyboardInput("add_url", "ID Youtube de votre musique", "", 15) 77 | print(URL) 78 | current_url = URL 79 | print(current_url) 80 | end 81 | }) 82 | if current_song and current_url then 83 | RageUI.Button("Ajouter la musique", false, {RightLabel = "→", Color = {BackgroundColor = {30, 215, 96, 80}}}, true, { 84 | onSelected = function() 85 | TriggerServerEvent("SpotifySystem:AddMusic", current_song, current_url) 86 | Wait(100) 87 | current_song = "" 88 | current_url= "" 89 | end 90 | }) 91 | else 92 | RageUI.Button("Ajouter la musique", false, {RightLabel = "→", Color = {BackgroundColor = {30, 215, 96, 80}}}, false, {}) 93 | end 94 | end) 95 | RageUI.IsVisible(SpotifyPlayerMusicMenu, function() 96 | for i=1, #YourPlayerMusic do 97 | RageUI.Button(YourPlayerMusic[i].name, false, {RightLabel = "~g~Écouter~s~ →"}, true , { 98 | onSelected = function() 99 | PlayUrl("Music", "https://www.youtube.com/watch?v="..YourPlayerMusic[i].url, 0.1, false) 100 | CurrentSong = YourPlayerMusic[i].name 101 | StartMusic = true 102 | end 103 | }) 104 | end 105 | end) 106 | Wait(0) 107 | end 108 | end) 109 | end 110 | end 111 | 112 | 113 | 114 | RegisterCommand("spotify", function() 115 | RefreshPlayerMusic() 116 | OpenSpotifyMenu() 117 | end) 118 | -------------------------------------------------------------------------------- /client/events.lua: -------------------------------------------------------------------------------- 1 | RegisterNUICallback("data_status", function(data) 2 | if data.type == "finished" then 3 | soundInfo[data.id].playing = false 4 | TriggerEvent("xSound:songStopPlaying", data.id) 5 | end 6 | end) 7 | -------------------------------------------------------------------------------- /client/function.lua: -------------------------------------------------------------------------------- 1 | function KeyboardInput(entryTitle, textEntry, inputText, maxLength) 2 | AddTextEntry(entryTitle, textEntry) 3 | DisplayOnscreenKeyboard(1, entryTitle, "", inputText, "", "", "", maxLength) 4 | blockinput = true 5 | 6 | while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do 7 | Citizen.Wait(0) 8 | end 9 | 10 | if UpdateOnscreenKeyboard() ~= 2 then 11 | local result = GetOnscreenKeyboardResult() 12 | Citizen.Wait(500) 13 | blockinput = false 14 | return result 15 | else 16 | Citizen.Wait(500) 17 | blockinput = false 18 | return nil 19 | end 20 | end 21 | 22 | YourPlayerMusic = {} 23 | 24 | function RefreshPlayerMusic() 25 | ESX.TriggerServerCallback('SpotifySystem:GetMusic', function(ShowPlayerMusic) 26 | YourPlayerMusic = ShowPlayerMusic 27 | end) 28 | end -------------------------------------------------------------------------------- /client/info.lua: -------------------------------------------------------------------------------- 1 | soundInfo = {} 2 | 3 | defaultInfo = { 4 | volume = 1.0, 5 | url = "", 6 | id = "", 7 | position = nil, 8 | distance = 0, 9 | playing = false, 10 | paused = false, 11 | loop = false, 12 | } 13 | 14 | function getLink(name_) 15 | return soundInfo[name_].url 16 | end 17 | 18 | function getPosition(name_) 19 | return soundInfo[name_].position 20 | end 21 | 22 | function isLooped(name_) 23 | return soundInfo[name_].loop 24 | end 25 | 26 | function getInfo(name_) 27 | return soundInfo[name_] 28 | end 29 | 30 | function soundExists(name_) 31 | if soundInfo[name_] == nil then 32 | return false 33 | end 34 | return true 35 | end 36 | 37 | function isPlaying(name_) 38 | if soundInfo[name_] == nil then return false end 39 | return soundInfo[name_].playing 40 | end 41 | 42 | function isPaused(name_) 43 | return soundInfo[name_].paused 44 | end 45 | 46 | function getDistance(name_) 47 | return soundInfo[name_].distance 48 | end 49 | 50 | function getVolume(name_) 51 | return soundInfo[name_].volume 52 | end -------------------------------------------------------------------------------- /client/main.lua: -------------------------------------------------------------------------------- 1 | local NearZone = false 2 | 3 | Citizen.CreateThread(function() 4 | Citizen.Wait(1000) 5 | while true do 6 | if not NearZone then 7 | Wait(2500) 8 | else 9 | Wait(50) 10 | end 11 | local ped = PlayerPedId() 12 | local pos = GetEntityCoords(ped) 13 | SendNUIMessage({ 14 | status = "position", 15 | x = pos.x, 16 | y = pos.y, 17 | z = pos.z 18 | }) 19 | end 20 | end) 21 | 22 | 23 | MusicZone = { 24 | 25 | { 26 | name = "accessoire_ambience", 27 | link = "https://www.youtube.com/watch?v=e_FddI2HI7A", -- https://www.youtube.com/watch?v=rBLuvEwIF5E 28 | dst = 9.0, 29 | starting = 60.0, 30 | pos = vector3(-1123.8, -1440.4, 6.2), 31 | max = 0.1, 32 | }, 33 | { 34 | name = "casino_ambience", 35 | link = "https://www.youtube.com/watch?v=_ytFg0hFad8", -- https://www.youtube.com/watch?v=rBLuvEwIF5E 36 | dst = 100.0, 37 | starting = 60.0, 38 | pos = vector3(1110.3363037109,224.43264770508,-49.840751647949), 39 | max = 0.1, 40 | }, 41 | } 42 | 43 | Citizen.CreateThread(function() 44 | Wait(2000) 45 | while true do 46 | NearZone = false 47 | local pPed = GetPlayerPed(-1) 48 | local pCoords = GetEntityCoords(pPed) 49 | for k,v in pairs(MusicZone) do 50 | local dst = GetDistanceBetweenCoords(pCoords, v.pos, true) 51 | if not NearZone then 52 | if dst < v.starting then 53 | NearZone = true 54 | if soundExists(v.name) then 55 | Resume(v.name) 56 | else 57 | PlayUrlPos(v.name, v.link, v.max, v.pos, true) 58 | setVolumeMax(v.name, v.max) 59 | Distance(v.name, v.dst) 60 | end 61 | else 62 | if soundExists(v.name) then 63 | if not isPaused(v.name) then 64 | Pause(v.name) 65 | end 66 | end 67 | end 68 | end 69 | end 70 | 71 | if not NearZone then 72 | Wait(350) 73 | else 74 | Wait(50) 75 | end 76 | end 77 | end) -------------------------------------------------------------------------------- /client/manipulation.lua: -------------------------------------------------------------------------------- 1 | function Distance(name_, distance_) 2 | SendNUIMessage({ 3 | status = "distance", 4 | name = name_, 5 | distance = distance_, 6 | }) 7 | soundInfo[name_].distance = distance_ 8 | end 9 | 10 | function Position(name_, pos) 11 | SendNUIMessage({ 12 | status = "soundPosition", 13 | name = name_, 14 | x = pos.x, 15 | y = pos.y, 16 | z = pos.z, 17 | }) 18 | soundInfo[name_].position = pos 19 | soundInfo[name_].id = name_ 20 | end 21 | 22 | function Destroy(name_) 23 | SendNUIMessage({ 24 | status = "delete", 25 | name = name_ 26 | }) 27 | soundInfo[name_] = nil 28 | end 29 | 30 | function Resume(name_) 31 | SendNUIMessage({ 32 | status = "resume", 33 | name = name_ 34 | }) 35 | soundInfo[name_].playing = true 36 | soundInfo[name_].paused = false 37 | end 38 | 39 | function Pause(name_) 40 | SendNUIMessage({ 41 | status = "pause", 42 | name = name_ 43 | }) 44 | soundInfo[name_].playing = false 45 | soundInfo[name_].paused = true 46 | end 47 | 48 | function setVolume(name_, vol) 49 | SendNUIMessage({ 50 | status = "volume", 51 | volume = vol, 52 | name = name_, 53 | }) 54 | soundInfo[name_].volume = vol 55 | end 56 | 57 | function setVolumeMax(name_, vol) 58 | SendNUIMessage({ 59 | status = "max_volume", 60 | volume = vol, 61 | name = name_, 62 | }) 63 | soundInfo[name_].volume = vol 64 | end -------------------------------------------------------------------------------- /client/play.lua: -------------------------------------------------------------------------------- 1 | RegisterNetEvent("rs_sounds:playSound") 2 | AddEventHandler("rs_sounds:playSound", function(name,url,vol,loop) 3 | PlayUrl(name,url,vol,loop) 4 | end) 5 | 6 | RegisterNetEvent("rs_sounds:stopSound") 7 | AddEventHandler("rs_sounds:stopSound", function(name) 8 | Destroy(name) 9 | end) 10 | 11 | function PlayUrl(name_, url_, volume_, loop_) 12 | SendNUIMessage({ 13 | status = "url", 14 | name = name_, 15 | url = url_, 16 | x = 0, 17 | y = 0, 18 | z = 0, 19 | dynamic = false, 20 | volume = volume_, 21 | loop = loop_ or false, 22 | }) 23 | 24 | if soundInfo[name_] == nil then soundInfo[name_] = defaultInfo end 25 | 26 | soundInfo[name_].volume = volume_ 27 | soundInfo[name_].url = url_ 28 | soundInfo[name_].id = name_ 29 | soundInfo[name_].playing = true 30 | soundInfo[name_].loop = loop_ or false 31 | end 32 | 33 | function PlayUrlPos(name_, url_, volume_, pos, loop_) 34 | SendNUIMessage({ 35 | status = "url", 36 | name = name_, 37 | url = url_, 38 | x = pos.x, 39 | y = pos.y, 40 | z = pos.z, 41 | dynamic = true, 42 | volume = volume_, 43 | loop = loop_ or false, 44 | }) 45 | if soundInfo[name_] == nil then soundInfo[name_] = defaultInfo end 46 | 47 | soundInfo[name_].volume = volume_ 48 | soundInfo[name_].url = url_ 49 | soundInfo[name_].position = pos 50 | soundInfo[name_].id = name_ 51 | soundInfo[name_].playing = true 52 | soundInfo[name_].loop = loop_ or false 53 | end -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | game 'gta5' 3 | 4 | 5 | client_scripts { 6 | 'RageUI/RMenu.lua', 7 | 'RageUI/menu/RageUI.lua', 8 | 'RageUI/menu/Menu.lua', 9 | 'RageUI/menu/MenuController.lua', 10 | 'RageUI/components/*.lua', 11 | 'RageUI/menu/elements/*.lua', 12 | 'RageUI/menu/items/*.lua', 13 | 'RageUI/menu/panels/*.lua', 14 | 'RageUI/menu/windows/*.lua', 15 | 'client/*.lua', 16 | } 17 | 18 | server_scripts { 19 | '@mysql-async/lib/MySQL.lua', 20 | 'server/*.lua', 21 | } 22 | 23 | ui_page "html/index.html" 24 | 25 | files { 26 | "html/index.html", 27 | "html/scripts/listener.js", 28 | "html/scripts/SoundPlayer.js", 29 | "html/scripts/functions.js", 30 | } -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 39 | 40 | -------------------------------------------------------------------------------- /html/scripts/SoundPlayer.js: -------------------------------------------------------------------------------- 1 | function isReady(divId) { 2 | for (var soundName in soundList) { 3 | var sound = soundList[soundName]; 4 | if (sound.getDivId() === divId) { 5 | sound.isYoutubeReady(true); 6 | if (!sound.isDynamic()) sound.setVolume(sound.getVolume()) 7 | if (sound.isDynamic()) sound.setMaxVolume(sound.getVolume()) 8 | break; 9 | } 10 | } 11 | } 12 | 13 | function isLooped(divId) { 14 | for (var soundName in soundList) { 15 | var sound = soundList[soundName]; 16 | if (sound.getDivId() === divId && sound.isLoop() == true) { 17 | sound.destroyYoutubeApi(); 18 | sound.delete(); 19 | sound.create(); 20 | break; 21 | } 22 | } 23 | } 24 | 25 | function ended(divId) { 26 | for (var soundName in soundList) { 27 | var sound = soundList[soundName]; 28 | if (sound.getDivId() === divId && sound.isLoop() == false) { 29 | sound.destroyYoutubeApi(); 30 | $.post('http://xsound/data_status', JSON.stringify({ type: "finished", id: soundName })); 31 | break; 32 | } 33 | } 34 | } 35 | 36 | class SoundPlayer { 37 | static yPlayer = null; 38 | youtubeIsReady = false; 39 | constructor() { 40 | this.url = "test"; 41 | this.dynamic = false; 42 | this.distance = 10; 43 | this.volume = 1.0; 44 | this.pos = [0.0, 0.0, 0.0]; 45 | this.max_volume = -1.0; 46 | this.div_id = "myAudio_" + Math.floor(Math.random() * 9999999); 47 | this.loop = false; 48 | this.isYoutube = false; 49 | } 50 | 51 | isYoutubeReady(result) { 52 | this.youtubeIsReady = result; 53 | } 54 | 55 | getDistance() { return this.distance; } 56 | getLocation() { return this.pos; } 57 | getVolume() { return this.volume; } 58 | getUrlSound() { return this.url; } 59 | isDynamic() { return this.dynamic; } 60 | getDivId() { return this.div_id; } 61 | isLoop() { return this.loop; } 62 | 63 | setDistance(result) { this.distance = result; } 64 | setDynamic(result) { this.dynamic = result; } 65 | setLocation(x_, y_, z_) { this.pos = [x_, y_, z_]; } 66 | setSoundUrl(result) { this.url = result; } 67 | setLoop(result) { this.loop = result; } 68 | setMaxVolume(result) { this.max_volume = result; } 69 | setVolume(result) { 70 | this.volume = result; 71 | if (this.max_volume == -1) this.max_volume = result; 72 | if (this.max_volume > (this.volume - 0.01)) this.volume = this.max_volume; 73 | if (!this.isYoutube) { 74 | $("#" + this.div_id).prop("volume", result); 75 | } else { 76 | if (this.yPlayer && this.youtubeIsReady) this.yPlayer.setVolume(result * 100); 77 | } 78 | } 79 | 80 | create() { 81 | var link = getYoutubeUrlId(this.getUrlSound()); 82 | if (link === "") { 83 | this.isYoutube = false; 84 | if (this.isLoop()) { 85 | $("body").append(""); 86 | } else { 87 | $("body").append(""); 88 | } 89 | } else { 90 | this.isYoutube = true; 91 | this.isYoutubeReady(false); 92 | $("body").append(""); 93 | this.yPlayer = new YT.Player(this.div_id, { 94 | width: "0", 95 | height: "0", 96 | videoId: link, 97 | events: { 98 | 'onReady': function(event) { 99 | event.target.playVideo(); 100 | isReady(event.target.getIframe().id); 101 | }, 102 | 'onStateChange': function(event) { 103 | if (event.data == YT.PlayerState.ENDED) { 104 | isLooped(event.target.getIframe().id); 105 | } 106 | 107 | if (event.data == YT.PlayerState.ENDED) { 108 | ended(event.target.getIframe().id); 109 | } 110 | } 111 | } 112 | }); 113 | } 114 | } 115 | 116 | destroyYoutubeApi() { 117 | if (this.yPlayer) { 118 | /* this.yPlayer.stopVideo(); */ 119 | this.yPlayer.destroy(); 120 | this.youtubeIsReady = false; 121 | this.yPlayer = null; 122 | } 123 | } 124 | 125 | updateVolume(dd, maxd) { 126 | var d_max = maxd; 127 | var d_now = dd; 128 | 129 | var vol = 0; 130 | 131 | var distance = (d_now / d_max); 132 | if (distance < 1) { 133 | distance = distance * 100; 134 | var far_away = 100 - distance; 135 | vol = (this.max_volume / 100) * far_away;; 136 | this.setVolume(vol); 137 | } else this.setVolume(0); 138 | } 139 | 140 | play() { 141 | if (!this.isYoutube) { 142 | $("#" + this.div_id).prop("volume", this.getVolume()); 143 | $("#" + this.div_id)[0].play(); 144 | } else { 145 | if (this.youtubeIsReady) this.yPlayer.playVideo(); 146 | } 147 | } 148 | pause() { 149 | if (!this.isYoutube) { 150 | $("#" + this.div_id)[0].pause(); 151 | } else { 152 | if (this.youtubeIsReady) this.yPlayer.pauseVideo(); 153 | } 154 | } 155 | 156 | resume() { 157 | if (!this.isYoutube) { 158 | $("#" + this.div_id)[0].play(); 159 | } else { 160 | if (this.youtubeIsReady) this.yPlayer.playVideo(); 161 | } 162 | } 163 | 164 | delete() { $("#" + this.div_id).remove(); } 165 | 166 | mute() { 167 | if (!this.isYoutube) { 168 | $("#" + this.div_id).prop("volume", 0); 169 | } else { 170 | if (this.youtubeIsReady) this.yPlayer.setVolume(0); 171 | } 172 | } 173 | unmute() { 174 | if (!this.isYoutube) { 175 | $("#" + this.div_id).prop("volume", this.getVolume()); 176 | } else { 177 | if (this.youtubeIsReady) this.yPlayer.setVolume(this.getVolume() * 100); 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /html/scripts/functions.js: -------------------------------------------------------------------------------- 1 | function getYoutubeUrlId(url) 2 | { 3 | var videoId = ""; 4 | if( url.indexOf("youtube") !== -1 ){ 5 | var urlParts = url.split("?v="); 6 | videoId = urlParts[1].substring(0,11); 7 | } 8 | 9 | if( url.indexOf("youtu.be") !== -1 ){ 10 | var urlParts = url.replace("//", "").split("/"); 11 | videoId = urlParts[1].substring(0,11); 12 | } 13 | return videoId; 14 | } -------------------------------------------------------------------------------- /html/scripts/listener.js: -------------------------------------------------------------------------------- 1 | var soundList = []; 2 | var playingRightNow = []; 3 | 4 | var playerPos = [0, 0, 0]; 5 | $(function() { 6 | window.addEventListener('message', function(event) { 7 | var item = event.data; 8 | if (item.status === "position") { 9 | playerPos = [item.x, item.y, item.z]; 10 | } 11 | 12 | if (item.status === "volume") { 13 | var sound = soundList[item.name]; 14 | if (sound != null) { 15 | sound.setVolume(item.volume); 16 | sound.setMaxVolume(item.volume); 17 | } 18 | } 19 | 20 | if (item.status === "max_volume") { 21 | var sound = soundList[item.name]; 22 | if (sound != null) { 23 | sound.setMaxVolume(item.volume); 24 | } 25 | } 26 | 27 | if (item.status === "url") { 28 | var sound = soundList[item.name]; 29 | 30 | if (sound == null) { 31 | var sd = new SoundPlayer(); 32 | sd.setSoundUrl(item.url); 33 | sd.setDynamic(item.dynamic); 34 | sd.setLocation(item.x, item.y, item.z); 35 | sd.setLoop(item.loop) 36 | sd.create(); 37 | sd.setVolume(item.volume); 38 | sd.play(); 39 | soundList[item.name] = sd; 40 | } else { 41 | /* console.log(item.x, item.y, item.z, item.url, item.loop, item.volume); */ 42 | sound.setLocation(item.x, item.y, item.z); 43 | sound.setSoundUrl(item.url); 44 | sound.setLoop(item.loop); 45 | sound.destroyYoutubeApi(); 46 | sound.delete(); 47 | sound.create(); 48 | sound.setVolume(item.volume); 49 | sound.play(); 50 | } 51 | } 52 | 53 | if (item.status === "distance") { 54 | var sound = soundList[item.name]; 55 | if (sound != null) { 56 | sound.setDistance(item.distance); 57 | } 58 | } 59 | 60 | if (item.status === "play") { 61 | var sound = soundList[item.name]; 62 | if (sound != null) { 63 | sound.delete(); 64 | sound.create(); 65 | sound.setVolume(item.volume); 66 | sound.setDynamic(item.dynamic); 67 | sound.setLocation(item.x, item.y, item.z); 68 | sound.play(); 69 | } 70 | } 71 | 72 | if (item.status === "soundPosition") { 73 | var sound = soundList[item.name]; 74 | if (sound != null) { 75 | sound.setLocation(item.x, item.y, item.z); 76 | } 77 | } 78 | 79 | if (item.status === "resume") { 80 | var sound = soundList[item.name]; 81 | if (sound != null) { 82 | sound.resume(); 83 | } 84 | } 85 | 86 | if (item.status === "pause") { 87 | var sound = soundList[item.name]; 88 | if (sound != null) { 89 | sound.pause(); 90 | } 91 | } 92 | 93 | if (item.status === "delete") { 94 | var sound = soundList[item.name]; 95 | if (sound != null) { 96 | sound.destroyYoutubeApi(); 97 | sound.delete(); 98 | } 99 | } 100 | }) 101 | }); 102 | 103 | function Between(loc1, loc2) { 104 | var deltaX = loc1[0] - loc2[0]; 105 | var deltaY = loc1[1] - loc2[1]; 106 | var deltaZ = loc1[2] - loc2[2]; 107 | 108 | var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); 109 | return distance; 110 | } 111 | 112 | function updateVolumeSounds() { 113 | for (var soundName in soundList) { 114 | var sound = soundList[soundName]; 115 | if (sound.isDynamic()) { 116 | var distance = Between(playerPos, sound.getLocation()); 117 | var distance_max = sound.getDistance(); 118 | if (distance < distance_max) { 119 | sound.updateVolume(distance, distance_max); 120 | continue; 121 | } 122 | sound.mute(); 123 | } 124 | } 125 | } 126 | 127 | setInterval(updateVolumeSounds, 100); -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end) 3 | 4 | ESX.RegisterServerCallback('SpotifySystem:GetMusic', function(source, cb) 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | local ShowPlayerMusic = {} 7 | MySQL.Async.fetchAll('SELECT * FROM spotify_system WHERE (owner = @owner)', { 8 | ['@owner'] = xPlayer.identifier 9 | }, function(result) 10 | for i = 1, #result, 1 do 11 | table.insert(ShowPlayerMusic, { 12 | id = result[i].id, 13 | owner = result[i].owner, 14 | name = result[i].name, 15 | url = result[i].url 16 | }) 17 | end 18 | cb(ShowPlayerMusic) 19 | end) 20 | end) 21 | 22 | RegisterServerEvent("SpotifySystem:AddMusic") 23 | AddEventHandler("SpotifySystem:AddMusic", function(name, music) 24 | local _source = source 25 | local xPlayer = ESX.GetPlayerFromId(_source) 26 | MySQL.Async.execute('INSERT INTO spotify_system (owner, name, url) VALUES (@owner, @name, @url)', 27 | { 28 | ['@owner'] = xPlayer.identifier, 29 | ['@name'] = name, 30 | ['@url'] = music 31 | }, function (rowsChanged) 32 | TriggerClientEvent('esx:showNotification', _source, "~b~"..name.."~s~ à été ajouté sur Spotify.") 33 | end) 34 | end) -------------------------------------------------------------------------------- /spotify_system.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `spotify_system` ( 2 | `id` int(11) NOT NULL, 3 | `owner` varchar(50) DEFAULT NULL, 4 | `name` varchar(50) DEFAULT NULL, 5 | `url` varchar(90) DEFAULT NULL 6 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 7 | 8 | ALTER TABLE `spotify_system` 9 | ADD PRIMARY KEY (`id`); 10 | 11 | ALTER TABLE `spotify_system` 12 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 13 | COMMIT; 14 | -------------------------------------------------------------------------------- /stream/RageUI_.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/RageUI_.ytd -------------------------------------------------------------------------------- /stream/banner_spotify.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/banner_spotify.ytd -------------------------------------------------------------------------------- /stream/casinoui_cards_blackjack.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_cards_blackjack.ytd -------------------------------------------------------------------------------- /stream/casinoui_cards_blackjack_high.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_cards_blackjack_high.ytd -------------------------------------------------------------------------------- /stream/casinoui_cards_three.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_cards_three.ytd -------------------------------------------------------------------------------- /stream/casinoui_cards_three_high.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_cards_three_high.ytd -------------------------------------------------------------------------------- /stream/casinoui_insidetrack.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_insidetrack.ytd -------------------------------------------------------------------------------- /stream/casinoui_lucky_wheel.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_lucky_wheel.ytd -------------------------------------------------------------------------------- /stream/casinoui_roulette.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_roulette.ytd -------------------------------------------------------------------------------- /stream/casinoui_roulette_high.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_roulette_high.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_angel.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_angel.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_deity.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_deity.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_diamond.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_diamond.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_evacuator.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_evacuator.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_fame.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_fame.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_impotent.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_impotent.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_knife.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_knife.ytd -------------------------------------------------------------------------------- /stream/casinoui_slots_ranger.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/casinoui_slots_ranger.ytd -------------------------------------------------------------------------------- /stream/mpawardcasino.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/mpawardcasino.ytd -------------------------------------------------------------------------------- /stream/root_cause.ytd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EagleIsCoding/SpotifySystem/cdd157850255930f5830171627f6d4fd7ece258b/stream/root_cause.ytd --------------------------------------------------------------------------------