From 205db873ef46d89976e2109abf7b61a50c5f7191 Mon Sep 17 00:00:00 2001 From: TrAsKiN Date: Sun, 20 Feb 2022 13:26:23 +0100 Subject: [PATCH 1/3] Use active resolution --- src/RageUI.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RageUI.lua b/src/RageUI.lua index 5fb8f11..82a21bb 100644 --- a/src/RageUI.lua +++ b/src/RageUI.lua @@ -250,7 +250,7 @@ function RageUI.GetSafeZoneBounds() SafeSize = (SafeSize * 100) - 90 SafeSize = 10 - SafeSize - local W, H = 1920, 1080 + local W, H = GetActiveScreenResolution() return { X = math.round(SafeSize * ((W / H) * 5.4)), Y = math.round(SafeSize * 5.4) } end From 13424cde4164b73e18de666d3dce5fb5867791e4 Mon Sep 17 00:00:00 2001 From: TrAsKiN Date: Sun, 20 Feb 2022 13:26:47 +0100 Subject: [PATCH 2/3] Add missing texture --- stream/RageUI_.ytd | Bin 0 -> 2405 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 stream/RageUI_.ytd diff --git a/stream/RageUI_.ytd b/stream/RageUI_.ytd new file mode 100644 index 0000000000000000000000000000000000000000..68c0a9620f421b1f4e291b0adeb617ee21c3f323 GIT binary patch literal 2405 zcmaJ>X;4!M62?`~^#E@i5dncg2NjT0q67iu5CsD2AYgRlP!18f*(7fe6!8igAp(JT zfG7gNL_p+-Tt*3(4#-UgA&KM=LdgB{-l$t!HC0=?-CfR#a$KW;!3;wzVbG zEqj~Ql_J=_!?NwGpt@YL)A+p|Z#yGYabIE{XYwgl!bw9s&BP}4Zcmxf3%Z5TZ@)u2 zFKgI!47qZ7sBV*g5?M%*`iY!+>t~X8fZI^7iMi~2{$BIsNgZy+Gw#hAQcAORTELkU zr-Krln7U%o53D~DAk@~-fMH<~+B;}ap8?qAY$B~NDWG{?)7%q#{fXP1pNCsZR~nnH zw>#pRUAet-4F_FT=?v!h-d#0$a9yOy>T6j|2__%*99gq%gZGTk^_WZHQ{MW@fT(Ar zl$iPIeYW{l$GrMilhrtGf%ij#M*89s7Ue6`Og6@arj>s$DSwE)JEQT1_$^+m%r^1wdJR3WS$cv=bHo8j1WIK7qv-0xD$|*v5&8)~yecHi~ZAfHxG`2}qpYL;=4XZy)AtJ8m-FR(UoXg5F zmiZ9cvb*FhBJpfMG8m*PA`l43Hck}$dxZX`cFd_R5*VWnm&JI1E_jpJ9->3L~IICT?$jsmNJZEjV zA>@6%VB=8fuvCsYZQbqzSu|hVmiY5yoCzvXe+4On4*dRK{QR4(IqSAEWjEI5;=Zc> zf!Q_POOHzLYYo_0p-&%g=>U2E>WUb%cOnyhGDq9*%!TAxUC1a!18TU`4V^$qOjG@? z$WNsx(4W*k`oX{KCl1aT@KVl|QW9c{XdJP3S8m@Wj@a#3|22`{9O4nXt9K@w!z!9K z7LB49mpI5u8+Bf2qC=rhK0YC*CLoQmILe7|?*vB=JIZ7Y$UZ%;t*EYo(^DT+J>4sK zQe9q#y-vS(#T< z(o*mcYk$ErZJ_T>@VqOH&E3eN(;cuAUy$&K^lek2Bh;o;&d0l%awzCQOjz1Ta-MZv z9ExM?j+$rQKD&i2n>Usw;DC~R$(6`tW5HE>k20sD{K zTbDS4K>uzopKowCb_m0cq4L2eWt0a_(U*3wpt44j=_LV=GtPy+{=A)r#Ed&4F1gT* zF~;4JUj6VSxa8et{H-O-+qX3jFJPt*F&38jb=;VU87{~^dhV;R%x2J0Xm^#EP5AJN)xF(pT&O_Ua@MT|MNYxvupirpRQcT&_hbEK*o*E zv;*1POQxvU4GcK^%dFYD;pqE1&CMil0Eq@=v^{Dy{F7~XJ7XstV<*>vCzpa*26G0u zH-KF9GSx23F0ZgV58kKY+p`(r*S|}(N;5^{%}oB%aVi{;gIF-2INV4TYAC9v=B0MjAlCN*GL44;YMUNHEQ30ao_}3XzFHYS=mb?rf@_NyD)jNWFYmjsok59z=MF=T}8cR_+#-(=?dU0&eS@LOUR zCo2ywVZlR@5xEtE+DqDz!|;h$oko=ScV;T`cBn~c>5ut^l znu%JS1swB^M<|~p!G*a<%cd4dfBVYwPd1|ivXG()%bVS&Aj1BEm_d1ty7QI%PHC}y z$c!3q+LS&YtDL7RPbD%JRl!uWQaF0YBLK?fHwehPHsGw1LzsF+W5d!afrT)k6}Sh) z6JdE)Q_RxxAg3JVmPxHX!UR58noN}B-l&g{bRa(dWoK-AKzFIeLBuHJ(wm>LG3?j8| z>DArma1}CS;x%e_wf`&X{Q2qLeDN+1+`~Swadv$~Po1Ga6mZ;$PX{Kx^p!Fx^v5!q zPTb;mdTJhlM>*y6gh@w=6-4rs(m-g?ugG%I!L$X#O$IT3N|{W6uA#T|Y3`ob;RbjR^2e8WtR>AcRcXs G(f Date: Thu, 27 Oct 2022 16:36:55 +0200 Subject: [PATCH 3/3] Update New items : - AutoList : List with auto-stock of Items, auto gestion of Index and callback SetIndex to set Index - Range : AutoList in a range and callback to set Label of list Item in Menu Updates : - Added new letters (letters with accent) to string.upper function in Util.lua --- src/Menu.lua | 4 +- src/components/Util.lua | 29 ++++ src/items/Items.lua | 304 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 333 insertions(+), 4 deletions(-) diff --git a/src/Menu.lua b/src/Menu.lua index 847ee9f..a71dde8 100644 --- a/src/Menu.lua +++ b/src/Menu.lua @@ -230,7 +230,9 @@ function RageUIMenus:IsVisible(Item, Panel) RageUI.Background(); RageUI.Navigation(); RageUI.Description(); - Panel(Panels); + if Panel and type(Panel) == "function" then + Panel(Panels); + end RageUI.PoolMenus.Timer = 1 RageUI.Render() end diff --git a/src/components/Util.lua b/src/components/Util.lua index 5363067..91cdc09 100644 --- a/src/components/Util.lua +++ b/src/components/Util.lua @@ -10,4 +10,33 @@ end function string.starts(String, Start) return string.sub(String, 1, string.len(Start)) == Start +end + +local up_trans = { + ["é"] = "É", + ["è"] = "È", + ["â"] = "Â", + ["ê"] = "Ê", + ["î"] = "Î", + ["ô"] = "Ô", + ["û"] = "Û", + ["ä"] = "Ä", + ["ë"] = "Ë", + ["ï"] = "Ï", + ["ö"] = "Ö", + ["ü"] = "Ü", + ["à"] = "À", + ["æ"] = "Æ", + ["ç"] = "Ç", + ["œ"] = "Œ", + ["ù"] = "Ù", +} + +local old_upper = string.upper +function string.upper(str) + local res = old_upper(str) + for k, v in pairs(up_trans) do + res = string.gsub(res, k, v) + end + return res end \ No newline at end of file diff --git a/src/items/Items.lua b/src/items/Items.lua index d3d4c3d..979f712 100644 --- a/src/items/Items.lua +++ b/src/items/Items.lua @@ -251,7 +251,7 @@ end ---@param Index number ---@param Style table ---@param Description string ----@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean)) +---@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean) ---@param Submenu any function Items:AddList(Label, Items, Index, Description, Style, Actions, Submenu) local CurrentMenu = RageUI.CurrentMenu; @@ -346,11 +346,301 @@ function Items:AddList(Label, Items, Index, Description, Style, Actions, Submenu Audio.PlaySound(RageUI.Settings.Audio.LeftRight.audioName, RageUI.Settings.Audio.LeftRight.audioRef) end local Selected = (CurrentMenu.Controls.Select.Active) - Actions(Index, Selected, onListChange, Active) + Actions(Index, Selected, onListChange, Active, Items) if (Selected) then Audio.PlaySound(RageUI.Settings.Audio.Select.audioName, RageUI.Settings.Audio.Select.audioRef) - if Submenu ~= nil and type(Submenu) == "table" then + --if Submenu ~= nil and type(Submenu) == "table" then + -- RageUI.NextMenu = Submenu[Index] + --end + if Submenu ~= nil and type(Submenu) == "table" and Submenu[Index]() then RageUI.NextMenu = Submenu[Index] + elseif Submenu ~= nil and Submenu() then + RageUI.NextMenu = Submenu + end + end + end + end + end + RageUI.Options = RageUI.Options + 1 +end + + +local list_stock = {} + +---AddList +---@param Label string +---@param Items table +---@param Style table +---@param Description string +---@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean, isActive:boolean, Items:table, SetIndex: fun(newIndex:boolean)) +---@param Submenu any +function Items:AddAutoList(Label, Items, FirstIndex, Description, Style, Actions, Submenu) + local CurrentMenu = RageUI.CurrentMenu; + local ItemID = Label .. "_" .. #Items + + if not list_stock[CurrentMenu] then + list_stock[CurrentMenu] = {} + end + + local Option = RageUI.Options + 1 + + if not list_stock[CurrentMenu][ItemID] then + list_stock[CurrentMenu][ItemID] = FirstIndex and FirstIndex or 1 + end + + local Index = list_stock[CurrentMenu][ItemID] + + if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then + local Active = CurrentMenu.Index == Option; + local onListChange = false; + RageUI.ItemsSafeZone(CurrentMenu) + local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) + local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) + local RightOffset = 0 + local ListText = (type(Items[Index]) == "table") and string.format("← %s →", Items[Index].Name) or string.format("← %s →", Items[Index]) or "NIL" + + if (Active) then + Graphics.Sprite("commonmenu", "gradient_nav", CurrentMenu.X, CurrentMenu.Y + 0 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 431 + CurrentMenu.WidthOffset, 38) + end + + if (not Style.IsDisabled) then + if Active then + if Style.RightLabel ~= nil and Style.RightLabel ~= "" then + Graphics.Text(Style.RightLabel, CurrentMenu.X + 420 - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + 4 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 0, 0, 0, 255, 2) + RightOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) + end + else + if Style.RightLabel ~= nil and Style.RightLabel ~= "" then + RightOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) + Graphics.Text(Style.RightLabel, CurrentMenu.X + 420 - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + 4 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 245, 245, 245, 255, 2) + end + end + end + RightOffset = RightBadgeOffset * 1.3 + RightOffset + if (not Style.IsDisabled) then + if (Active) then + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 0, 0, 0, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 0, 0, 0, 255, 2) + else + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 245, 245, 245, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 245, 245, 245, 255, 2) + end + else + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 163, 159, 148, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 163, 159, 148, 255, 2) + end + + if type(Style) == "table" then + if Style.Enabled == true or Style.Enabled == nil then + if type(Style) == 'table' then + if Style.LeftBadge ~= nil then + if Style.LeftBadge ~= RageUI.BadgeStyle.None then + local BadgeData = Style.LeftBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 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) + end + end + + if Style.RightBadge ~= nil then + if Style.RightBadge ~= RageUI.BadgeStyle.None then + local BadgeData = Style.RightBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + 385 + CurrentMenu.WidthOffset, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 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) + end + end + end + else + local LeftBadge = RageUI.BadgeStyle.Lock + if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then + local BadgeData = LeftBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) + end + end + else + error("UICheckBox Style is not a `table`") + end + + RageUI.ItemOffset = RageUI.ItemOffset + 38 + + if (Active) then + RageUI.ItemsDescription(Description); + if (not Style.IsDisabled) then + if (CurrentMenu.Controls.Left.Active) and not (CurrentMenu.Controls.Right.Active) then + Index = Index - 1 + if Index < 1 then + Index = #Items + end + onListChange = true + list_stock[CurrentMenu][ItemID] = Index + Audio.PlaySound(RageUI.Settings.Audio.LeftRight.audioName, RageUI.Settings.Audio.LeftRight.audioRef) + elseif (CurrentMenu.Controls.Right.Active) and not (CurrentMenu.Controls.Left.Active) then + Index = Index + 1 + if Index > #Items then + Index = 1 + end + onListChange = true + list_stock[CurrentMenu][ItemID] = Index + Audio.PlaySound(RageUI.Settings.Audio.LeftRight.audioName, RageUI.Settings.Audio.LeftRight.audioRef) + end + local Selected = (CurrentMenu.Controls.Select.Active) + Actions(Index, Selected, onListChange, Active, Items, function(newIndex) + if newIndex <= #Items and newIndex > 1 then + list_stock[CurrentMenu][ItemID] = newIndex + end + end) + if (Selected) then + Audio.PlaySound(RageUI.Settings.Audio.Select.audioName, RageUI.Settings.Audio.Select.audioRef) + if Submenu ~= nil and type(Submenu) == "table" and Submenu[Index]() then + RageUI.NextMenu = Submenu[Index] + elseif Submenu ~= nil and Submenu() then + RageUI.NextMenu = Submenu + end + end + end + end + end + RageUI.Options = RageUI.Options + 1 +end + +local range_stock = {} + +---AddList +---@param Label string +---@param Items table +---@param Style table +---@param Description string +---@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean, isActive:boolean, Items:table, SetIndex: fun(newIndex:boolean)) +---@param Submenu any +function Items:AddRange(Label, Range, NameCB, Description, Style, Actions, Submenu) + local CurrentMenu = RageUI.CurrentMenu; + local ItemID = Label .. "_" .. #Range + + if not range_stock[CurrentMenu] then + range_stock[CurrentMenu] = {} + end + + if not list_stock[CurrentMenu] then + list_stock[CurrentMenu] = {} + end + + local Option = RageUI.Options + 1 + + if not range_stock[CurrentMenu][ItemID] then + local items = {} + for i = Range[1] and Range[1] or 1, Range[2] and Range[2] or 2 do + table.insert(items, i) + end + range_stock[CurrentMenu][ItemID] = items + end + + if not list_stock[CurrentMenu][ItemID] then + list_stock[CurrentMenu][ItemID] = 1 + end + + local Items = range_stock[CurrentMenu][ItemID] + local Index = list_stock[CurrentMenu][ItemID] + + if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then + local Active = CurrentMenu.Index == Option; + local onListChange = false; + RageUI.ItemsSafeZone(CurrentMenu) + local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) + local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or Style.RightBadge == nil) and 0 or 32) + local RightOffset = 0 + local IndexName = NameCB(Index, Items[Index]) + local ListText = IndexName and string.format("← %s →", IndexName) or string.format("← %s →", Items[Index]) or "NIL" + + if (Active) then + Graphics.Sprite("commonmenu", "gradient_nav", CurrentMenu.X, CurrentMenu.Y + 0 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 431 + CurrentMenu.WidthOffset, 38) + end + + if (not Style.IsDisabled) then + if Active then + if Style.RightLabel ~= nil and Style.RightLabel ~= "" then + Graphics.Text(Style.RightLabel, CurrentMenu.X + 420 - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + 4 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 0, 0, 0, 255, 2) + RightOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) + end + else + if Style.RightLabel ~= nil and Style.RightLabel ~= "" then + RightOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) + Graphics.Text(Style.RightLabel, CurrentMenu.X + 420 - RightBadgeOffset + CurrentMenu.WidthOffset, CurrentMenu.Y + 4 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 245, 245, 245, 255, 2) + end + end + end + RightOffset = RightBadgeOffset * 1.3 + RightOffset + if (not Style.IsDisabled) then + if (Active) then + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 0, 0, 0, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 0, 0, 0, 255, 2) + else + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 245, 245, 245, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset - RightOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 245, 245, 245, 255, 2) + end + else + Graphics.Text(Label, CurrentMenu.X + 8 + LeftBadgeOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.33, 163, 159, 148, 255) + Graphics.Text(ListText, CurrentMenu.X + 403 + 15 + CurrentMenu.WidthOffset, CurrentMenu.Y + 3 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, 0.35, 163, 159, 148, 255, 2) + end + + if type(Style) == "table" then + if Style.Enabled == true or Style.Enabled == nil then + if type(Style) == 'table' then + if Style.LeftBadge ~= nil then + if Style.LeftBadge ~= RageUI.BadgeStyle.None then + local BadgeData = Style.LeftBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 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) + end + end + + if Style.RightBadge ~= nil then + if Style.RightBadge ~= RageUI.BadgeStyle.None then + local BadgeData = Style.RightBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X + 385 + CurrentMenu.WidthOffset, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 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) + end + end + end + else + local LeftBadge = RageUI.BadgeStyle.Lock + if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then + local BadgeData = LeftBadge(Active) + Graphics.Sprite(BadgeData.BadgeDictionary or "commonmenu", BadgeData.BadgeTexture or "", CurrentMenu.X, CurrentMenu.Y + -2 + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 40, 40, 0, BadgeData.BadgeColour.R or 255, BadgeData.BadgeColour.G or 255, BadgeData.BadgeColour.B or 255, BadgeData.BadgeColour.A or 255) + end + end + else + error("UICheckBox Style is not a `table`") + end + + RageUI.ItemOffset = RageUI.ItemOffset + 38 + + if (Active) then + RageUI.ItemsDescription(Description); + if (not Style.IsDisabled) then + if (CurrentMenu.Controls.Left.Active) and not (CurrentMenu.Controls.Right.Active) then + Index = Index - 1 + if Index < 1 then + Index = #Items + end + onListChange = true + list_stock[CurrentMenu][ItemID] = Index + Audio.PlaySound(RageUI.Settings.Audio.LeftRight.audioName, RageUI.Settings.Audio.LeftRight.audioRef) + elseif (CurrentMenu.Controls.Right.Active) and not (CurrentMenu.Controls.Left.Active) then + Index = Index + 1 + if Index > #Items then + Index = 1 + end + onListChange = true + list_stock[CurrentMenu][ItemID] = Index + Audio.PlaySound(RageUI.Settings.Audio.LeftRight.audioName, RageUI.Settings.Audio.LeftRight.audioRef) + end + local Selected = (CurrentMenu.Controls.Select.Active) + Actions(Index, Selected, onListChange, Active, Items, function(newIndex) + if newIndex <= #Items and newIndex > 1 then + list_stock[CurrentMenu][ItemID] = newIndex + end + end) + if (Selected) then + Audio.PlaySound(RageUI.Settings.Audio.Select.audioName, RageUI.Settings.Audio.Select.audioRef) + if Submenu ~= nil and type(Submenu) == "table" and Submenu[Index]() then + RageUI.NextMenu = Submenu[Index] + elseif Submenu ~= nil and Submenu() then + RageUI.NextMenu = Submenu end end end @@ -359,6 +649,14 @@ function Items:AddList(Label, Items, Index, Description, Style, Actions, Submenu RageUI.Options = RageUI.Options + 1 end +--[[ + Items:AddRange("bla", { 5, 10 }, function(Index, Value) return Index .. " : " .. Value end, nil, { IsDisabled = false }, function(Index, onSelected, onListChange, isActive, Items, SetIndex) + if (onListChange) then + print(Items[Index]) + end + end) +]] + ---Heritage ---@param Mum number ---@param Dad number