diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dc7b4b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.vscode \ No newline at end of file diff --git a/example.lua b/example.lua index 8a134cc..1edf5c9 100644 --- a/example.lua +++ b/example.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: missing-parameter, inject-field, param-type-mismatch, need-check-nil --- --- @author Dylan MALANDAIN, Kalyptus --- @version 1.0.0 @@ -7,7 +8,7 @@ local MainMenu = RageUI.CreateMenu("Title", "SUBTITLE"); MainMenu.EnableMouse = true; -local SubMenu = RageUI.CreateSubMenu(MainMenu, "Title", "SubTitle") +local SubMenu = RageUI.CreateSubMenu(MainMenu, "Title", "SubTitle") --[[@as RageUIMenus (change return vaules to mach type?)]] local Checked = false; local ListIndex = 1; @@ -18,7 +19,7 @@ function RageUI.PoolMenus:Example() MainMenu:IsVisible(function(Items) Items:Heritage(1, 2) Items:AddButton("Sub Menu", "Sub Menu", { IsDisabled = false }, function(onSelected) - + end, SubMenu) Items:AddButton("Hello world", "Hello world.", { IsDisabled = false }, function(onSelected) @@ -34,8 +35,6 @@ function RageUI.PoolMenus:Example() Checked = IsChecked end end) - - end, function(Panels) Panels:Grid(GridX, GridY, "Top", "Bottom", "Left", "Right", function(X, Y, CharacterX, CharacterY) GridX = X; diff --git a/src/Menu.lua b/src/Menu.lua index a71dde8..cac9d8f 100644 --- a/src/Menu.lua +++ b/src/Menu.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: missing-parameter, undefined-field, inject-field, param-type-mismatch --- --- @author Dylan MALANDAIN, Kalyptus --- @version 1.0.0 @@ -8,14 +9,14 @@ ---CreateMenu ---@param Title string ---@param Subtitle string ----@param X number ----@param Y number ----@param TextureDictionary string ----@param TextureName string ----@param R number ----@param G number ----@param B number ----@param A number +---@param X number? +---@param Y number? +---@param TextureDictionary string? +---@param TextureName string? +---@param R number? +---@param G number? +---@param B number? +---@param A number? ---@return RageUIMenus ---@public function RageUI.CreateMenu(Title, Subtitle, X, Y, TextureDictionary, TextureName, R, G, B, A) @@ -79,42 +80,46 @@ function RageUI.CreateMenu(Title, Subtitle, X, Y, TextureDictionary, TextureName end end) - return setmetatable(Menu, RageUIMenus) + return setmetatable(Menu, RageUIMenus) --[[@as RageUIMenus]] end ---CreateSubMenu ----@param ParentMenu function +---@param ParentMenu function | RageUIMenus ---@param Title string ---@param Subtitle string ----@param X number ----@param Y number ----@param TextureDictionary string ----@param TextureName string ----@param R number ----@param G number ----@param B number ----@param A number ----@return RageUIMenus +---@param X number? +---@param Y number? +---@param TextureDictionary string? +---@param TextureName string? +---@param R number? +---@param G number? +---@param B number? +---@param A number? +---@return RageUIMenus | nil ---@public function RageUI.CreateSubMenu(ParentMenu, Title, Subtitle, X, Y, TextureDictionary, TextureName, R, G, B, A) - if ParentMenu ~= nil then - if ParentMenu() then - local Menu = RageUI.CreateMenu(Title or ParentMenu.Title, string.upper(Subtitle) or string.upper(ParentMenu.Subtitle), X or ParentMenu.X, Y or ParentMenu.Y) - Menu.Parent = ParentMenu - Menu.WidthOffset = ParentMenu.WidthOffset - Menu.Safezone = ParentMenu.Safezone - if ParentMenu.Sprite then - 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 } } - else - Menu.Rectangle = ParentMenu.Rectangle - end - return setmetatable(Menu, RageUIMenus) - else - return nil - end + if ParentMenu == nil then + return + end + + -- Why is this a function & why do we call it here ??? + if not ParentMenu() then + return + end + + local Menu = RageUI.CreateMenu(Title or ParentMenu.Title --[[@as string (change ParentMenu behaviour)]], string.upper(Subtitle) or string.upper(ParentMenu.Subtitle --[[@as string (change ParentMenu behaviour)]]), X or ParentMenu.X --[[@as number (change ParentMenu behaviour)]], Y or ParentMenu.Y --[[@as number (change ParentMenu behaviour)]]) + + Menu.Parent = ParentMenu --[[@as RageUIMenus]] + Menu.WidthOffset = Menu.Parent.WidthOffset + Menu.Safezone = Menu.Parent.Safezone + + if Menu.Parent.Sprite then + Menu.Sprite = { Dictionary = TextureDictionary or Menu.Parent.Sprite.Dictionary, Texture = TextureName or Menu.Parent.Sprite.Texture, Color = { R = R or Menu.Parent.Sprite.Color.R, G = G or Menu.Parent.Sprite.Color.G, B = B or Menu.Parent.Sprite.Color.B, A = A or Menu.Parent.Sprite.Color.A } } else - return nil + Menu.Rectangle = Menu.Parent.Rectangle end + + return setmetatable(Menu, RageUIMenus) end ---SetSubtitle @@ -144,7 +149,7 @@ end function RageUIMenus:AddInstructionButton(button) if type(button) == "table" and #button == 2 then table.insert(self.InstructionalButtons, button) - self.UpdateInstructionalButtons(true); + self:UpdateInstructionalButtons(true); end end @@ -153,7 +158,7 @@ function RageUIMenus:RemoveInstructionButton(button) for i = 1, #self.InstructionalButtons do if button == self.InstructionalButtons[i] then table.remove(self.InstructionalButtons, i) - self.UpdateInstructionalButtons(true); + self:UpdateInstructionalButtons(true); break end end @@ -161,14 +166,14 @@ function RageUIMenus:RemoveInstructionButton(button) if tonumber(button) then if self.InstructionalButtons[tonumber(button)] then table.remove(self.InstructionalButtons, tonumber(button)) - self.UpdateInstructionalButtons(true); + self:UpdateInstructionalButtons(true); end end end end +---@param Visible boolean function RageUIMenus:UpdateInstructionalButtons(Visible) - if not Visible then return end @@ -221,7 +226,7 @@ end ---IsVisible ---@param Item fun(Item:Items) ----@param Panel fun(Panel:Panels +---@param Panel fun(Panel:Panels) function RageUIMenus:IsVisible(Item, Panel) if (RageUI.Visible(self)) and (UpdateOnscreenKeyboard() ~= 0) and (UpdateOnscreenKeyboard() ~= 3) then RageUI.Banner() diff --git a/src/RageUI.lua b/src/RageUI.lua index 66094bd..b33ffb6 100644 --- a/src/RageUI.lua +++ b/src/RageUI.lua @@ -7,6 +7,17 @@ RageUI = {}; ---@class RageUIMenus +---@field InstructionalButtons table +---@field InstructionalScaleform number +---@field Closable boolean +---@field Parent RageUIMenus +---@field WidthOffset number +---@field Safezone number +---@field Sprite any (todo) +---@field Rectangle any (todo) +---@field X number +---@field Y number +---@field EnableMouse boolean RageUIMenus = setmetatable({}, RageUIMenus) ---@return boolean @@ -134,8 +145,8 @@ RageUI.Settings = { }, Enabled = { Controller = { - { 0, 2 }, -- Look Up and Down - { 0, 1 }, -- Look Left and Right + { 0, 2 }, -- Look Up and Down + { 0, 1 }, -- Look Left and Right { 0, 25 }, -- Aim { 0, 24 }, -- Attack }, @@ -153,20 +164,20 @@ RageUI.Settings = { { 0, 241 }, -- Scroll up { 0, 239 }, -- Cursor X { 0, 240 }, -- Cursor Y - { 0, 31 }, -- Move Up and Down - { 0, 30 }, -- Move Left and Right - { 0, 21 }, -- Sprint - { 0, 22 }, -- Jump - { 0, 23 }, -- Enter - { 0, 75 }, -- Exit Vehicle - { 0, 71 }, -- Accelerate Vehicle - { 0, 72 }, -- Vehicle Brake - { 0, 59 }, -- Move Vehicle Left and Right - { 0, 89 }, -- Fly Yaw Left - { 0, 9 }, -- Fly Left and Right - { 0, 8 }, -- Fly Up and Down - { 0, 90 }, -- Fly Yaw Right - { 0, 76 }, -- Vehicle Handbrake + { 0, 31 }, -- Move Up and Down + { 0, 30 }, -- Move Left and Right + { 0, 21 }, -- Sprint + { 0, 22 }, -- Jump + { 0, 23 }, -- Enter + { 0, 75 }, -- Exit Vehicle + { 0, 71 }, -- Accelerate Vehicle + { 0, 72 }, -- Vehicle Brake + { 0, 59 }, -- Move Vehicle Left and Right + { 0, 89 }, -- Fly Yaw Left + { 0, 9 }, -- Fly Left and Right + { 0, 8 }, -- Fly Up and Down + { 0, 90 }, -- Fly Yaw Right + { 0, 76 }, -- Vehicle Handbrake }, }, }, diff --git a/src/components/Audio.lua b/src/components/Audio.lua index b2efb01..f100c05 100644 --- a/src/components/Audio.lua +++ b/src/components/Audio.lua @@ -12,7 +12,7 @@ Audio = {} --- ---@param Library string ---@param Sound string ----@param IsLooped boolean +---@param IsLooped boolean? ---@return nil ---@public function Audio.PlaySound(Library, Sound, IsLooped) @@ -32,5 +32,3 @@ function Audio.PlaySound(Library, Sound, IsLooped) end end end - - diff --git a/src/components/Graphics.lua b/src/components/Graphics.lua index 3e947af..835b0bc 100644 --- a/src/components/Graphics.lua +++ b/src/components/Graphics.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: missing-parameter, redefined-local, undefined-field --- --- @author Dylan MALANDAIN, Kalyptus --- @version 1.0.0 @@ -124,6 +125,7 @@ function Graphics.ScreenToWorld(distance, flags) local mouse = vector2(GetControlNormal(2, 239), GetControlNormal(2, 240)) local cam3DPos, forwardDir = Graphics.ScreenRelToWorld(camPos, camRot, mouse) local direction = camPos + forwardDir * distance + ---@diagnostic disable-next-line: missing-parameter local rayHandle = StartExpensiveSynchronousShapeTestLosProbe(cam3DPos, direction, flags, 0, 0) local _, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(rayHandle) return (hit == 1 and true or false), endCoords, surfaceNormal, entityHit, (entityHit >= 1 and GetEntityType(entityHit) or 0), direction, mouse @@ -160,4 +162,4 @@ end function Graphics.World3DToScreen2D(pos) local _, sX, sY = GetScreenCoordFromWorldCoord(pos.x, pos.y, pos.z) return vector2(sX, sY) -end \ No newline at end of file +end diff --git a/src/components/Keys.lua b/src/components/Keys.lua index a69bd24..ad804e4 100644 --- a/src/components/Keys.lua +++ b/src/components/Keys.lua @@ -11,7 +11,6 @@ Keys = {}; ---@param ControlName string ---@param Description string ---@param Action function ----@return Keys ---@public function Keys.Register(Controls, ControlName, Description, Action) RegisterKeyMapping(string.format('keys-%s', ControlName), Description, "keyboard", Controls) @@ -20,4 +19,4 @@ function Keys.Register(Controls, ControlName, Description, Action) Action(); end end, false) -end \ No newline at end of file +end diff --git a/src/components/Util.lua b/src/components/Util.lua index dc424b7..c9577ad 100644 --- a/src/components/Util.lua +++ b/src/components/Util.lua @@ -5,11 +5,19 @@ --- function math.round(num, numDecimalPlaces) - return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) + return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) end function string.starts(String, Start) - return string.sub(String, 1, string.len(Start)) == Start + return string.sub(String, 1, string.len(Start)) == Start +end + +---@param value number +---@param min number +---@param max number +---@return number +function math.clamp(value, min, max) + return math.max(min, math.min(value, max)) end local up_trans = { @@ -33,6 +41,9 @@ local up_trans = { } local old_upper = string.upper + + +---@diagnostic disable-next-line: duplicate-set-field function string.upper(str) local res = old_upper(str) for k, v in pairs(up_trans) do @@ -43,4 +54,4 @@ end function string.FirstUp(str) return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2) -end \ No newline at end of file +end diff --git a/src/items/Items.lua b/src/items/Items.lua index 8f02ac3..9858fe8 100644 --- a/src/items/Items.lua +++ b/src/items/Items.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: cast-local-type, undefined-global --- --- @author Dylan MALANDAIN, Kalyptus --- @version 1.0.0 @@ -9,13 +10,16 @@ local ItemsSettings = { CheckBox = { Textures = { "shop_box_blankb", -- 1 - "shop_box_tickb", -- 2 - "shop_box_blank", -- 3 - "shop_box_tick", -- 4 + "shop_box_tickb", -- 2 + "shop_box_blank", -- 3 + "shop_box_tick", -- 4 "shop_box_crossb", -- 5 - "shop_box_cross", -- 6 + "shop_box_cross", -- 6 }, - X = 380, Y = -6, Width = 50, Height = 50 + X = 380, + Y = -6, + Width = 50, + Height = 50 }, Rectangle = { Y = 0, Width = 431, Height = 38 @@ -55,7 +59,7 @@ Items = {} ---@param Actions fun(onSelected:boolean, onActive:boolean) ---@param Submenu any ---@public ----@return void +---@return nil function Items:AddButton(Label, Description, Style, Actions, Submenu) if Submenu then Style.RightLabel = '→' @@ -135,7 +139,6 @@ function Items:CheckBox(Label, Description, Checked, Style, Actions) local Option = RageUI.Options + 1 if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then - local Active = CurrentMenu.Index == Option; local Selected = false; local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or Style.LeftBadge == nil) and 0 or 27) @@ -184,12 +187,12 @@ function Items:CheckBox(Label, Description, Checked, Style, Actions) 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) - BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) + BoxOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) end else 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, 245, 245, 245, 255, 2) - BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35) + BoxOffset = Graphics.MeasureStringWidth(Style.RightLabel, 0, 0.35) end end @@ -228,7 +231,7 @@ end --- ---@param Label string ---@public ----@return void +---@return nil function Items:AddSeparator(Label) local CurrentMenu = RageUI.CurrentMenu local Option = RageUI.Options + 1 @@ -257,10 +260,10 @@ end ---@param Label string ---@param Items table ---@param Index number ----@param Style table ----@param Description string ----@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean) ----@param Submenu any +---@param Description string? +---@param Style table +---@param Actions fun(Index:number, onSelected:boolean, onListChange:boolean, Active:boolean?, Items:table?) +---@param Submenu RageUIMenus? function Items:AddList(Label, Items, Index, Description, Style, Actions, Submenu) local CurrentMenu = RageUI.CurrentMenu; @@ -282,11 +285,11 @@ function Items:AddList(Label, Items, Index, Description, Style, Actions, Submenu 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) + RightOffset = Graphics.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) + RightOffset = Graphics.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 @@ -378,7 +381,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, Active:boolean?, Items:table?) ---@param Submenu any function Items:AddList2(Label, Items, Index, NameCB, Description, Style, Actions, Submenu) local CurrentMenu = RageUI.CurrentMenu; @@ -403,11 +406,11 @@ function Items:AddList2(Label, Items, Index, NameCB, Description, Style, Actions 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) + RightOffset = Graphics.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) + RightOffset = Graphics.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 @@ -493,7 +496,6 @@ function Items:AddList2(Label, Items, Index, NameCB, Description, Style, Actions RageUI.Options = RageUI.Options + 1 end - local list_stock = {} ---AddList @@ -536,11 +538,11 @@ function Items:AddAutoList(Label, Items, FirstIndex, Description, Style, Actions 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) + RightOffset = Graphics.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) + RightOffset = Graphics.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 @@ -633,10 +635,10 @@ local range_stock = {} ---AddList ---@param Label string ----@param Items table +---@param Range 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 Actions fun(Index:number, onSelected:boolean, onListChange:boolean, isActive:boolean, Item:any, Items:table, SetIndex: fun(newIndex:boolean)) ---@param Submenu any function Items:AddRange(Label, Range, FirstIndex, NameCB, Description, Style, Actions, Submenu) local CurrentMenu = RageUI.CurrentMenu; @@ -685,11 +687,11 @@ function Items:AddRange(Label, Range, FirstIndex, NameCB, Description, Style, Ac 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) + RightOffset = Graphics.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) + RightOffset = Graphics.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 @@ -778,61 +780,52 @@ function Items:AddRange(Label, Range, FirstIndex, NameCB, Description, Style, Ac 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) -]] +---> what is this for? Tests? +-- 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 function Items:Heritage(Mum, Dad) local CurrentMenu = RageUI.CurrentMenu; - if Mum < 0 or Mum > 21 then - Mum = 0 - end - if Dad < 0 or Dad > 23 then - Dad = 0 - end - if Mum == 21 then - Mum = "special_female_" .. (tonumber(string.sub(Mum, 2, 2)) - 1) - else - Mum = "female_" .. Mum - end - if Dad >= 21 then - Dad = "special_male_" .. (tonumber(string.sub(Dad, 2, 2)) - 1) - else - Dad = "male_" .. Dad - end + + Mum = math.clamp(Mum, 0, 21) + Dad = math.clamp(Dad, 0, 23) + + local mum = (Mum == 21) and "special_female_" .. (tonumber(string.sub(Mum, 2, 2)) - 1) or "female_" .. Mum + local dad = (Dad >= 21) and "special_male_" .. (tonumber(string.sub(Dad, 2, 2)) - 1) or "male_" .. Dad + Graphics.Sprite("pause_menu_pages_char_mom_dad", "mumdadbg", CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 431 + (CurrentMenu.WidthOffset / 1), 228) - Graphics.Sprite("char_creator_portraits", Dad, CurrentMenu.X + 195 + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 228, 228) - Graphics.Sprite("char_creator_portraits", Mum, CurrentMenu.X + 25 + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 228, 228) + Graphics.Sprite("char_creator_portraits", dad, CurrentMenu.X + 195 + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 228, 228) + Graphics.Sprite("char_creator_portraits", mum, CurrentMenu.X + 25 + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 228, 228) + RageUI.ItemOffset = RageUI.ItemOffset + 228 end +-- What even is this for?? ---Text --- --- Add items button. --- ----@param Label string ----@param Description string ----@param Style table ----@param Actions fun(onSelected:boolean, onActive:boolean) ----@param Submenu any ----@public ----@return void -function Items:AddText(Label, Text, minChar, maxChar, Description, Style, Actions) - self:AddButton(Label .. " : " .. Text or "", "Appuyez sur Entrer pour compléter le champ\n" .. Description, Style, function(onSelected, isActive) - if onSelected then - local text = Game.KeyboardInput(Label, Text, maxChar) - if text ~= nil and #text >= minChar then - Text = text - end - end - Actions(onSelected, isActive, Text) - end) -end \ No newline at end of file +-- ---@param Label string +-- ---@param Description string +-- ---@param Style table +-- ---@param Actions fun(onSelected:boolean, onActive:boolean, Text:string) +-- ---@public +-- ---@return nil +-- function Items:AddText(Label, Text, minChar, maxChar, Description, Style, Actions) +-- self:AddButton(Label .. (" : " .. (Text or "")), "Appuyez sur Entrer pour compléter le champ\n" .. Description, Style, function(onSelected, isActive) +-- if onSelected then +-- local text = Game.KeyboardInput(Label, Text, maxChar) +-- if text ~= nil and #text >= minChar then +-- Text = text +-- end +-- end +-- Actions(onSelected, isActive, Text) +-- end) +-- end diff --git a/src/items/Panels.lua b/src/items/Panels.lua index 8c119b2..1fc81be 100644 --- a/src/items/Panels.lua +++ b/src/items/Panels.lua @@ -116,7 +116,7 @@ end ---@param Action fun(X:number, Y:number, CharacterX:number, CharacterY:number) ---@param Index number ---@public ----@return void +---@return nil function Panels:Grid(StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index) UIGridPanel(GridType.Default, StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index) end @@ -128,7 +128,7 @@ end ---@param Action fun(X:number, Y:number, CharacterX:number, CharacterY:number) ---@param Index number ---@public ----@return void +---@return nil function Panels:GridHorizontal(StartedX, LeftText, RightText, Action, Index) UIGridPanel(GridType.Horizontal, StartedX, nil, nil, nil, LeftText, RightText, Action, Index) end @@ -140,12 +140,11 @@ end ---@param Action fun(X:number, Y:number, CharacterX:number, CharacterY:number) ---@param Index number ---@public ----@return void +---@return nil function Panels:GridVertical(StartedY, TopText, BottomText, Action, Index) UIGridPanel(GridType.Vertical, nil, StartedY, TopText, BottomText, nil, nil, Action, Index) end - ---@type table local Colour = { Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 112 }, @@ -164,25 +163,23 @@ local Colour = { ---@param Callback function ---@return nil ---@public ----@return void +---@return nil function Panels:Colour(Title, Colours, MinimumIndex, CurrentIndex, Callback, Index) - ---@type table local CurrentMenu = RageUI.CurrentMenu; if CurrentMenu ~= nil then if (CurrentMenu.Index == Index) then - ---@type number local Maximum = (#Colours > 9) and 9 or #Colours ---@type boolean local Hovered = Graphics.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) - ---@type number + ---@type boolean local LeftArrowHovered = Graphics.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) - ---@type number + ---@type boolean local RightArrowHovered = Graphics.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) ---@type boolean @@ -267,7 +264,6 @@ function Panels:Percent(Percent, HeaderText, MinText, MaxText, Callback, Index) if CurrentMenu ~= nil then if (CurrentMenu.Index == Index) then - ---@type boolean local Hovered = Graphics.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) @@ -320,4 +316,4 @@ function Panels:Percent(Percent, HeaderText, MinText, MaxText, Callback, Index) Callback(Hovered, Selected, Percent) end end -end \ No newline at end of file +end