This commit is contained in:
Hawk 2024-12-29 21:02:43 +01:00
parent 5d1209b1e9
commit b0037c93fc
No known key found for this signature in database
GPG Key ID: 2890D5366F8BAC14
363 changed files with 77333 additions and 0 deletions
resources/[standalone]
MenuAPI
PolyZone
RageUI
memorygame
menuv

View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@ -0,0 +1,41 @@
# Compiled Lua sources
luac.out
# luarocks build files
*.src.rock
*.zip
*.tar.gz
# Object files
*.o
*.os
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 MrXogos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,73 @@
CachedMenu = {}
function RegisterKey(fc, uniqid, description, key)
RegisterCommand(uniqid .. GetCurrentResourceName(), fc, false)
RegisterKeyMapping(uniqid .. GetCurrentResourceName(), description, 'keyboard', key)
end
--------------
-- Sending info about changing item in menu
--------------
RegisterKey(function()
SendNUIMessage({ type = "up" })
end, "menuapiup", "Tast op", "UP")
RegisterKey(function()
SendNUIMessage({ type = "down" })
end, "menuapidown", "Tast ned", "DOWN")
--------------
-- Sending info about selecting item
--------------
RegisterKey(function()
SendNUIMessage({ type = "enter" })
end, "menuapie", "Tast E", "E")
RegisterKey(function()
SendNUIMessage({ type = "enter" })
end, "menuapienter", "Tast ENTER", "RETURN")
--------------
-- closing menu keys
--------------
RegisterKey(function()
CloseAll()
end, "menuapiesc", "Tast ESC", "escape")
RegisterKey(function()
CloseAll()
end, "menuapiescaper", "Tast slet", "back")
--------------
--CreateThread(function()
-- Wait(200)
-- local vehicles = {
-- [1] = { label = "police car", model = "police"},
-- [2] = { label = "A FOCKING TANK?!", model = "rhino"},
-- [3] = { label = "a nice car!", model = "cerberus3"}
-- }
--
-- local menu = CreateMenu("identifier")
--
-- menu.SetMenuTitle("Vehicle spawner")
--
-- menu.SetProperties({
-- float = "right",
-- position = "middle",
-- })
--
-- for k,v in ipairs(vehicles) do
-- menu.AddItem(k, v.label, nil, { model = v.model })
-- end
--
-- menu.OnSelectEvent(function(index, data)
-- RequestModel(data.model)
-- local coords = GetEntityCoords(PlayerPedId())
-- while not HasModelLoaded(data.model) do
-- Wait(33)
-- end
-- local vehicle = CreateVehicle(data.model, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, true)
-- SetVehicleOnGroundProperly(vehicle)
-- SetModelAsNoLongerNeeded(data.model)
-- TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
-- end)
--
-- menu.Open()
--end)

View File

@ -0,0 +1,42 @@
--------------- Input related only ----------------
-- User send input froom html
RegisterNUICallback("inputmethod", function(data)
if CachedMenu[data.identifier] then
CallOn(data.identifier, "inputtext", data.message)
end
end)
-- User send input froom html
RegisterNUICallback("close", function(data)
local menu = CachedMenu[data.identifier]
if menu then
menu.self.Close()
end
end)
--------------- Menu related only ----------------
-- click on item
RegisterNUICallback("clickItem", function(data)
local identifier = data.identifier
local menuData = CachedMenu[identifier].Items[data.index]
if CachedMenu[identifier] and menuData then
local callBack = menuData.cb
if callBack then
callBack()
end
CallOn(identifier, "selectitem", data.index, menuData.data or {})
end
end)
-- calls when player select new item, and check for events & call them
RegisterNUICallback("selectNew", function(data)
local identifier = data.identifier
if CachedMenu[identifier] and CachedMenu[identifier].Items[data.index] then
CallOn(identifier, "changeitem", data.newIndex, data.oldIndex, CachedMenu[identifier].Items[data.newIndex].data or {})
end
end)
-- unregister events if resource is stopped
AddEventHandler('onResourceStop', function(resourceName)
RemoveEventsWithNameResource(resourceName)
end)

View File

@ -0,0 +1,19 @@
function ExitAllOpenedMenu()
for k,v in pairs(CachedMenu) do
if v.self.IsOpen() then
CallOn(v.self.GetIdentifier(), "exit")
end
end
SendNUIMessage({ type = "ui", status = false })
end
exports("ExitAllOpenedMenu", ExitAllOpenedMenu)
function CloseAll()
for k,v in pairs(CachedMenu) do
v.self.Close()
end
SendNUIMessage({ type = "ui", status = false })
end
exports("CloseAll", CloseAll)

View File

@ -0,0 +1,97 @@
function CreateInputMenu(identifier)
local self = {}
self.isOpen_ = false
local _menuTitle = "RCORE"
self.identifier_ = identifier
local _properties = {
float = "middle_screen",
position = "middle_screen",
ChooseText = "Accepter",
CloseText = "Luk",
}
--------------
self.GetIdentifier = function()
return self.identifier_
end
self.IsOpen = function()
return self.isOpen_
end
--------------
self.SetMenuTitle = function(title)
_menuTitle = title
end
self.GetMenuTitle = function()
return _menuTitle
end
--------------
self.SetProperties = function(properties)
_properties = {
float = properties.float or "middle_screen",
position = properties.position or "middle_screen",
ChooseText = properties.ChooseText or "Accepter",
CloseText = properties.CloseText or "Luk",
}
end
self.GetProperties = function()
return _properties
end
--------------
self.OnCloseEvent = function(cb)
On(identifier, "close", cb)
end
self.OnOpenEvent = function(cb)
On(identifier, "open", cb)
end
self.OnExitEvent = function(cb)
On(identifier, "exit", cb)
end
self.OnInputText = function(cb)
On(identifier, "inputtext", cb)
end
self.On = function(eventName, cb)
On(identifier, eventName, cb)
end
--------------
self.Open = function()
if not CachedMenu[identifier] then
CachedMenu[identifier] = {}
end
CachedMenu[identifier] = {
MenuTitle = _menuTitle,
Properties = _properties,
self = self,
}
SendNUIMessage({ type = "title_input", title = _menuTitle })
SendNUIMessage({ type = "ui_input", identifier = identifier, properties = _properties, status = true })
CallOn(identifier, "open")
self.isOpen_ = true
SetNuiFocus(true, true)
end
--------------
self.Close = function()
SendNUIMessage({ type = "ui_input", status = false })
CallOn(identifier, "close")
self.isOpen_ = false
SetNuiFocus(false, false)
end
--------------
self.Destroy = function()
SendNUIMessage({ type = "ui_input", status = false })
CallOn(identifier, "exit")
CachedMenu[identifier] = nil
Events[identifier] = nil
SetNuiFocus(false, false)
end
return self
end
exports("CreateInputMenu", CreateInputMenu)

View File

@ -0,0 +1,109 @@
function CreateMenu(identifier)
local self = {}
self.isOpen_ = false
local _menuTitle = "RCORE"
self.identifier_ = identifier
local _properties = {
float = "right",
position = "middle",
}
local items = {}
--------------
self.GetIdentifier = function()
return self.identifier_
end
self.IsOpen = function()
return self.isOpen_
end
--------------
self.SetMenuTitle = function(title)
_menuTitle = title
end
self.GetMenuTitle = function()
return _menuTitle
end
--------------
self.SetProperties = function(properties)
_properties = properties
end
self.GetProperties = function()
return _properties
end
--------------
self.OnCloseEvent = function(cb)
On(identifier, "close", cb)
end
self.OnOpenEvent = function(cb)
On(identifier, "open", cb)
end
self.OnExitEvent = function(cb)
On(identifier, "exit", cb)
end
self.OnChangeItemEvent = function(cb)
On(identifier, "changeitem", cb)
end
self.OnSelectEvent = function(cb)
On(identifier, "selectitem", cb)
end
self.On = function(eventName, cb)
On(identifier, eventName, cb)
end
--------------
self.AddItem = function(index, text, cb, data)
items[index] = {
label = text,
index = index,
data = data or {},
cb = cb,
}
end
--------------
self.Open = function()
if not CachedMenu[identifier] then
CachedMenu[identifier] = {}
end
CachedMenu[identifier] = {
MenuTitle = _menuTitle,
Properties = _properties,
Items = items,
self = self,
}
SendNUIMessage({ type = "reset" })
SendNUIMessage({ type = "title", title = _menuTitle })
for k, v in ipairs(items) do
SendNUIMessage({
type = "add",
label = v.label,
index = k,
})
end
SendNUIMessage({ type = "ui", identifier = identifier, properties = _properties, status = true })
CallOn(identifier, "open")
self.isOpen_ = true
end
--------------
self.Close = function()
SendNUIMessage({ type = "ui", status = false })
CallOn(identifier, "close")
self.isOpen_ = false
end
--------------
self.Destroy = function()
SendNUIMessage({ type = "ui", status = false })
CallOn(identifier, "exit")
CachedMenu[identifier] = nil
Events[identifier] = nil
end
return self
end
exports("CreateMenu", CreateMenu)

View File

@ -0,0 +1,64 @@
Events = {}
--OnCloseEvent, OnOpenEvent, OnChangeItemEvent, OnSelectEvent
ValidEvents = {
["close"] = true,
["open"] = true,
["changeitem"] = true,
["selectitem"] = true,
["exit"] = true,
["inputtext"] = true,
}
function ValidateEvents(eventName)
return type(eventName) == "string" and ValidEvents[string.lower(eventName)] ~= nil
end
function ValidateInvokingEvent(identifier, eventName)
return Events[identifier] ~= nil and Events[identifier][eventName] ~= nil
end
function RemoveEventsWithNameResource(nameResource)
for identifier, v in pairs(Events) do
for event, value in pairs(v) do
for resource, val in pairs(value) do
if resource == nameResource then
Events[identifier][event][resource] = nil
break
end
end
end
end
end
--Register event
--Return true if event is registered, false if is not
function On(identifier, eventName, cb)
local invokingName = GetInvokingResource() or identifier
eventName = string.lower(eventName)
if not ValidateEvents(eventName) then
return false
end
if Events[identifier] == nil then
Events[identifier] = {}
end
if Events[identifier][eventName] == nil then
Events[identifier][eventName] = {}
end
Events[identifier][eventName][invokingName] = cb
return true
end
--Call event
--@internal
function CallOn(identifier, eventName, ...)
if ValidateInvokingEvent(identifier, eventName) then
for key, value in pairs(Events[identifier][eventName]) do
if type(value) == "table" or type(value) == "function" then
value(...)
end
end
end
end

View File

@ -0,0 +1,17 @@
fx_version 'cerulean'
games { 'gta5' }
client_scripts {
"client/*.lua",
"client/exports/*.lua",
"client/system/*.lua",
"client/module/*.lua",
}
files {
"html/css/*.css",
"html/*.html",
"html/scripts/*.js",
}
ui_page "html/index.html"

View File

@ -0,0 +1,48 @@
/* https://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@ -0,0 +1,169 @@
.container {
min-width: 280px;
max-width: 371px;
width: auto;
height: auto;
background: rgb(228,228,228);
background: linear-gradient(0deg, rgba(99, 99, 99, 0.54) 0%, rgba(0, 0, 0, 0.48) 100%);
max-width: 279px !important;
padding-right: 0px !important;
padding-left: 0px !important;
margin-right: auto !important;
margin-left: auto !important;
}
.container.top{
position: absolute;
top: 20px;
}
.container.bottom{
position: absolute;
bottom: 20px;
}
.container.bottom.right{
position: absolute;
bottom: 20px;
right: 20px;
}
.container.bottom.left{
position: absolute;
bottom: 20px;
left: 20px;
}
.container.top.right{
position: absolute;
top: 20px;
right: 20px;
}
.container.top.left{
position: absolute;
top: 20px;
left: 20px;
}
.container.middle.right{
position: absolute;
bottom: 40%;
right: 20px;
}
.container.middle_screen.middle_screen{
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.container.middle.left{
position: absolute;
bottom: 40%;
left: 20px;
}
.title {
width: 100%;
padding: 1px 0px;
text-align: center;
background: rgb(13,37,91);
background: linear-gradient(94deg, rgba(13,37,91,1) 0%, rgba(101,146,247,1) 100%);
}
.title p {
font-family: Montserrat, Calibri, Arial;
font-size: 20px;
color: #fff;
font-weight: bold;
text-shadow: 1px 1px 4px #000000;
padding: 13px;
overflow-wrap: break-word;
}
.menu {
width: 100%;
padding: 9px 0px;
}
.menu p {
padding: 0;
margin: 0;
font-family: Montserrat, Calibri, Arial;
font-size: 18px;
color: #fff;
text-align: center;
text-shadow: 1px 1px 4px #000000;
}
.menu.active {
width: 100%;
background: #2f37389c;
}
.menu.active p {
font-family: Montserrat, Calibri, Arial;
color: #fff;
text-align: center;
}
.button p{
font-family: Montserrat, Calibri, Arial;
text-align: center;
position: relative;
top: 7px;
color: white;
}
.button:hover{
background: #000000a6;
transition: background-color 200ms linear;
}
.button{
position: relative;
left: 6px;
bottom: 3px;
background: #00000057;
height: 40px;
width: 121px;
float: left;
margin: 6px;
border-radius: 8px;
transition: background-color 200ms linear;
}
#input input{
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -30%);
width: 90%;
text-align: center;
}
#scrolldiv{
max-height: 14vw;
overflow: auto;
}
/* width */
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./css/style.css" media="screen" />
<script src="./scripts/vue.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat:600" rel="stylesheet">
</head>
<body>
<div id="input">
<div class="container" v-bind:class="[position, float]" v-if="visible">
<div class="title">
<p>{{titleMenu}}</p>
</div>
<br>
<form>
<input v-model="message" type="text" name="input">
</form>
<div class = "button" @click="Choose()">
<p>{{ChooseText}}</p>
</div>
<div class = "button" @click="Close()">
<p>{{CloseText}}</p>
</div>
</div>
</div>
<div id="menu">
<div class="container" v-bind:class="[position, float]" v-if="visible">
<div class="title">
<p>{{titleMenu}}</p>
</div>
<div id = "scrolldiv">
<div v-for="item, index in menu" class="menu" v-bind:class="{ 'active': item.active}">
<p>
<span v-html="item.label"></span>
</p>
</div>
</div>
</div>
</div>
<script src="./scripts/listener.js" type="text/javascript"></script>
</body>
</html>

View File

@ -0,0 +1,158 @@
var index = 0;
var AppInput = new Vue({
el: '#input',
data:
{
identifier: null,
titleMenu: "rcore",
float: "middle_screen",
position: "middle_screen",
ChooseText: "Accepte",
CloseText: "Luk",
message: "",
visible: false,
},
methods: {
Choose: function(){
$.post('https://MenuAPI/inputmethod', JSON.stringify({
identifier: this.identifier,
message: this.message,
}));
},
Close: function(){
$.post('https://MenuAPI/close', JSON.stringify({
identifier: this.identifier,
}));
},
},
});
var App = new Vue({
el: '#menu',
data:
{
identifier: null,
titleMenu: "rcore",
float: "left",
position: "middle",
visible: true,
menu: [],
},
});
function setActiveMenuIndex(index, active_){
for(var i = 0; i < App.menu.length; i++){ App.menu[i].active = false }
if(App.menu[index] != null) App.menu[index].active = active_
}
// Menu
$(function(){
function display(bool) {
App.visible = bool;
}
display(false);
window.addEventListener('message', function(event) {
var item = event.data;
if(item.type === "reset"){
App.menu = [];
}
if(item.type === "add"){
App.menu.push({
label: item.label,
number: item.index,
active: false,
});
}
if(item.type === "title"){
App.titleMenu = item.title
}
if (item.type === "ui"){
display(item.status);
if(item.properties){
App.float = item.properties.float;
App.position = item.properties.position;
}
App.identifier = item.identifier;
index = 0;
setActiveMenuIndex(0, true)
}
if(App.visible && !AppInput.visible){
if (item.type === "enter"){
$.post('https://MenuAPI/clickItem', JSON.stringify({
index: App.menu[index].number,
identifier: App.identifier,
}));
}
if (item.type === "up"){
var lastIndex = index;
index --;
if(index < 0) {
index = App.menu.length -1
document.getElementById('scrolldiv').scrollTop = 90000;
}else{
document.getElementById('scrolldiv').scrollTop -= 33;
}
setActiveMenuIndex(index, true)
$.post('https://MenuAPI/selectNew', JSON.stringify({
index: App.menu[index].number,
identifier: App.identifier,
newIndex: App.menu[index].number,
oldIndex: App.menu[lastIndex].number,
}));
}
if (item.type === "down"){
var lastIndex = index;
index ++;
if(index > App.menu.length -1) {
index = 0
document.getElementById('scrolldiv').scrollTop = 0;
}else{
document.getElementById('scrolldiv').scrollTop += 33;
}
setActiveMenuIndex(index, true)
$.post('https://MenuAPI/selectNew', JSON.stringify({
index: App.menu[index].number,
identifier: App.identifier,
newIndex: App.menu[index].number,
oldIndex: App.menu[lastIndex].number,
}));
}
}
})
});
// Input
$(function(){
function display(bool) {
AppInput.visible = bool;
}
display(false);
window.addEventListener('message', function(event) {
var item = event.data;
if(item.type === "title_input"){
AppInput.titleMenu = item.title
}
if (item.type === "ui_input"){
display(item.status);
if(item.properties){
AppInput.float = item.properties.float;
AppInput.position = item.properties.position;
AppInput.ChooseText = item.properties.ChooseText;
AppInput.CloseText = item.properties.CloseText;
}
AppInput.identifier = item.identifier;
}
})
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,70 @@
#Standalone menu API
This menu is for my projects, it is upon you if you like it and want to use it.<br>
However, it isn't really ready to use and it has only like 4 functions and single<br>
type of the menu. So use it on your own decision
### MenuAPI
**1. Functions (client side)**
------------
------------
Example
```LUA
local menu = CreateMenu("identifier")
menu.SetMenuTitle("Healing menu")
menu.SetProperties({
float = "right",
position = "top",
})
menu.AddItem(1 ,"heal me", function()
SetEntityHealth(PlayerPedId(), 200)
menu.Close()
end)
menu.Open()
```
Example with events
```LUA
local vehicles = {
[1] = { label = "police car", model = "police"},
[2] = { label = "A FOCKING TANK?!", model = "rhino"},
[3] = { label = "a nice car!", model = "cerberus3"}
}
local menu = CreateMenu("identifier")
menu.SetMenuTitle("Vehicle spawner")
menu.SetProperties({
float = "right",
position = "top",
})
for k,v in ipairs(vehicles) do
menu.AddItem(k, v.label, nil, { model = v.model })
end
menu.OnSelectEvent(function(index, data)
RequestModel(data.model)
local coords = GetEntityCoords(PlayerPedId())
while not HasModelLoaded(data.model) do
Wait(33)
end
local vehicle = CreateVehicle(data.model, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, true)
SetVehicleOnGroundProperly(vehicle)
SetModelAsNoLongerNeeded(data.model)
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
end)
menu.Open()
```

View File

@ -0,0 +1,195 @@
BoxZone = {}
-- Inherits from PolyZone
setmetatable(BoxZone, { __index = PolyZone })
-- Utility functions
local rad, cos, sin = math.rad, math.cos, math.sin
function PolyZone.rotate(origin, point, theta)
if theta == 0.0 then return point end
local p = point - origin
local pX, pY = p.x, p.y
theta = rad(theta)
local cosTheta = cos(theta)
local sinTheta = sin(theta)
local x = pX * cosTheta - pY * sinTheta
local y = pX * sinTheta + pY * cosTheta
return vector2(x, y) + origin
end
local function _calculateScaleAndOffset(options)
-- Scale and offset tables are both formatted as {forward, back, left, right, up, down}
-- or if symmetrical {forward/back, left/right, up/down}
local scale = options.scale or {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}
local offset = options.offset or {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
assert(#scale == 3 or #scale == 6, "Scale skal være af længde 3 eller 6")
assert(#offset == 3 or #offset == 6, "Offset skal være af længde 3 eller 6")
if #scale == 3 then
scale = {scale[1], scale[1], scale[2], scale[2], scale[3], scale[3]}
end
if #offset == 3 then
offset = {offset[1], offset[1], offset[2], offset[2], offset[3], offset[3]}
end
local minOffset = vector3(offset[3], offset[2], offset[6])
local maxOffset = vector3(offset[4], offset[1], offset[5])
local minScale = vector3(scale[3], scale[2], scale[6])
local maxScale = vector3(scale[4], scale[1], scale[5])
return minOffset, maxOffset, minScale, maxScale
end
local function _calculatePoints(center, length, width, minScale, maxScale, minOffset, maxOffset)
local halfLength, halfWidth = length / 2, width / 2
local min = vector3(-halfWidth, -halfLength, 0.0)
local max = vector3(halfWidth, halfLength, 0.0)
min = min * minScale - minOffset
max = max * maxScale + maxOffset
-- Box vertices
local p1 = center.xy + vector2(min.x, min.y)
local p2 = center.xy + vector2(max.x, min.y)
local p3 = center.xy + vector2(max.x, max.y)
local p4 = center.xy + vector2(min.x, max.y)
return {p1, p2, p3, p4}
end
-- Debug drawing functions
function BoxZone:TransformPoint(point)
-- Overriding TransformPoint function to take into account rotation and position offset
return PolyZone.rotate(self.startPos, point, self.offsetRot) + self.offsetPos
end
-- Initialization functions
local function _initDebug(zone, options)
if options.debugBlip then zone:addDebugBlip() end
if not options.debugPoly then
return
end
Citizen.CreateThread(function()
while not zone.destroyed do
zone:draw()
Citizen.Wait(0)
end
end)
end
local defaultMinOffset, defaultMaxOffset, defaultMinScale, defaultMaxScale = vector3(0.0, 0.0, 0.0), vector3(0.0, 0.0, 0.0), vector3(1.0, 1.0, 1.0), vector3(1.0, 1.0, 1.0)
local defaultScaleZ, defaultOffsetZ = {defaultMinScale.z, defaultMaxScale.z}, {defaultMinOffset.z, defaultMaxOffset.z}
function BoxZone:new(center, length, width, options)
local minOffset, maxOffset, minScale, maxScale = defaultMinOffset, defaultMaxOffset, defaultMinScale, defaultMaxScale
local scaleZ, offsetZ = defaultScaleZ, defaultOffsetZ
if options.scale ~= nil or options.offset ~= nil then
minOffset, maxOffset, minScale, maxScale = _calculateScaleAndOffset(options)
scaleZ, offsetZ = {minScale.z, maxScale.z}, {minOffset.z, maxOffset.z}
end
local points = _calculatePoints(center, length, width, minScale, maxScale, minOffset, maxOffset)
local min = points[1]
local max = points[3]
local size = max - min
-- Box Zones don't use the grid optimization because they are already rectangles/cubes
options.useGrid = false
-- Pre-setting all these values to avoid PolyZone:new() having to calculate them
options.min = min
options.max = max
options.size = size
options.center = center
options.area = size.x * size.y
local zone = PolyZone:new(points, options)
zone.length = length
zone.width = width
zone.startPos = center.xy
zone.offsetPos = vector2(0.0, 0.0)
zone.offsetRot = options.heading or 0.0
zone.minScale, zone.maxScale = minScale, maxScale
zone.minOffset, zone.maxOffset = minOffset, maxOffset
zone.scaleZ, zone.offsetZ = scaleZ, offsetZ
zone.isBoxZone = true
setmetatable(zone, self)
self.__index = self
return zone
end
function BoxZone:Create(center, length, width, options)
local zone = BoxZone:new(center, length, width, options)
_initDebug(zone, options)
return zone
end
-- Helper functions
function BoxZone:isPointInside(point)
if self.destroyed then
print("[PolyZone] Warning: Called isPointInside on destroyed zone {name=" .. self.name .. "}")
return false
end
local startPos = self.startPos
local actualPos = point.xy - self.offsetPos
if #(actualPos - startPos) > self.boundingRadius then
return false
end
local rotatedPoint = PolyZone.rotate(startPos, actualPos, -self.offsetRot)
local pX, pY, pZ = rotatedPoint.x, rotatedPoint.y, point.z
local min, max = self.min, self.max
local minX, minY, maxX, maxY = min.x, min.y, max.x, max.y
local minZ, maxZ = self.minZ, self.maxZ
if pX < minX or pX > maxX or pY < minY or pY > maxY then
return false
end
if (minZ and pZ < minZ) or (maxZ and pZ > maxZ) then
return false
end
return true
end
function BoxZone:getHeading()
return self.offsetRot
end
function BoxZone:setHeading(heading)
if not heading then
return
end
self.offsetRot = heading
end
function BoxZone:setCenter(center)
if not center or center == self.center then
return
end
self.center = center
self.startPos = center.xy
self.points = _calculatePoints(self.center, self.length, self.width, self.minScale, self.maxScale, self.minOffset, self.maxOffset)
end
function BoxZone:getLength()
return self.length
end
function BoxZone:setLength(length)
if not length or length == self.length then
return
end
self.length = length
self.points = _calculatePoints(self.center, self.length, self.width, self.minScale, self.maxScale, self.minOffset, self.maxOffset)
end
function BoxZone:getWidth()
return self.width
end
function BoxZone:setWidth(width)
if not width or width == self.width then
return
end
self.width = width
self.points = _calculatePoints(self.center, self.length, self.width, self.minScale, self.maxScale, self.minOffset, self.maxOffset)
end

View File

@ -0,0 +1,97 @@
CircleZone = {}
-- Inherits from PolyZone
setmetatable(CircleZone, { __index = PolyZone })
function CircleZone:draw()
local center = self.center
local debugColor = self.debugColor
local r, g, b = debugColor[1], debugColor[2], debugColor[3]
if self.useZ then
local radius = self.radius
DrawMarker(28, center.x, center.y, center.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, radius, radius, radius, r, g, b, 48, false, false, 2, nil, nil, false)
else
local diameter = self.diameter
DrawMarker(1, center.x, center.y, -200.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, diameter, diameter, 400.0, r, g, b, 96, false, false, 2, nil, nil, false)
end
end
local function _initDebug(zone, options)
if options.debugBlip then zone:addDebugBlip() end
if not options.debugPoly then
return
end
Citizen.CreateThread(function()
while not zone.destroyed do
zone:draw()
Citizen.Wait(0)
end
end)
end
function CircleZone:new(center, radius, options)
options = options or {}
local zone = {
name = tostring(options.name) or nil,
center = center,
radius = radius + 0.0,
diameter = radius * 2.0,
useZ = options.useZ or false,
debugPoly = options.debugPoly or false,
debugColor = options.debugColor or {0, 255, 0},
data = options.data or {},
isCircleZone = true,
}
if zone.useZ then
assert(type(zone.center) == "vector3", "Midten skal være vector3 hvis useZ er true {center=" .. center .. "}")
end
setmetatable(zone, self)
self.__index = self
return zone
end
function CircleZone:Create(center, radius, options)
local zone = CircleZone:new(center, radius, options)
_initDebug(zone, options)
return zone
end
function CircleZone:isPointInside(point)
if self.destroyed then
print("[PolyZone] Warning: Called isPointInside on destroyed zone {name=" .. self.name .. "}")
return false
end
local center = self.center
local radius = self.radius
if self.useZ then
return #(point - center) < radius
else
return #(point.xy - center.xy) < radius
end
end
function CircleZone:getRadius()
return self.radius
end
function CircleZone:setRadius(radius)
if not radius or radius == self.radius then
return
end
self.radius = radius
self.diameter = radius * 2.0
end
function CircleZone:getCenter()
return self.center
end
function CircleZone:setCenter(center)
if not center or center == self.center then
return
end
self.center = center
end

View File

@ -0,0 +1,369 @@
local mapMinX, mapMinY, mapMaxX, mapMaxY = -3700, -4400, 4500, 8000
local xDivisions = 34
local yDivisions = 50
local xDelta = (mapMaxX - mapMinX) / xDivisions
local yDelta = (mapMaxY - mapMinY) / yDivisions
ComboZone = {}
-- Finds all values in tblA that are not in tblB, using the "id" property
local function tblDifference(tblA, tblB)
local diff
for _, a in ipairs(tblA) do
local found = false
for _, b in ipairs(tblB) do
if b.id == a.id then
found = true
break
end
end
if not found then
diff = diff or {}
diff[#diff+1] = a
end
end
return diff
end
local function _differenceBetweenInsideZones(insideZones, newInsideZones)
local insideZonesCount, newInsideZonesCount = #insideZones, #newInsideZones
if insideZonesCount == 0 and newInsideZonesCount == 0 then
-- No zones to check
return false, nil, nil
elseif insideZonesCount == 0 and newInsideZonesCount > 0 then
-- Was in no zones last check, but in 1 or more zones now (just entered all zones in newInsideZones)
return true, copyTbl(newInsideZones), nil
elseif insideZonesCount > 0 and newInsideZonesCount == 0 then
-- Was in 1 or more zones last check, but in no zones now (just left all zones in insideZones)
return true, nil, copyTbl(insideZones)
end
-- Check for zones that were in insideZones, but are not in newInsideZones (zones the player just left)
local leftZones = tblDifference(insideZones, newInsideZones)
-- Check for zones that are in newInsideZones, but were not in insideZones (zones the player just entered)
local enteredZones = tblDifference(newInsideZones, insideZones)
local isDifferent = enteredZones ~= nil or leftZones ~= nil
return isDifferent, enteredZones, leftZones
end
local function _getZoneBounds(zone)
local center = zone.center
local radius = zone.radius or zone.boundingRadius
local minY = (center.y - radius - mapMinY) // yDelta
local maxY = (center.y + radius - mapMinY) // yDelta
local minX = (center.x - radius - mapMinX) // xDelta
local maxX = (center.x + radius - mapMinX) // xDelta
return minY, maxY, minX, maxX
end
local function _removeZoneByFunction(predicateFn, zones)
if predicateFn == nil or zones == nil or #zones == 0 then return end
for i=1, #zones do
local possibleZone = zones[i]
if possibleZone and predicateFn(possibleZone) then
table.remove(zones, i)
return possibleZone
end
end
return nil
end
local function _addZoneToGrid(grid, zone)
local minY, maxY, minX, maxX = _getZoneBounds(zone)
for y=minY, maxY do
local row = grid[y] or {}
for x=minX, maxX do
local cell = row[x] or {}
cell[#cell+1] = zone
row[x] = cell
end
grid[y] = row
end
end
local function _getGridCell(pos)
local x = (pos.x - mapMinX) // xDelta
local y = (pos.y - mapMinY) // yDelta
return x, y
end
function ComboZone:draw()
local zones = self.zones
for i=1, #zones do
local zone = zones[i]
if zone and not zone.destroyed then
zone:draw()
end
end
end
local function _initDebug(zone, options)
if options.debugBlip then zone:addDebugBlip() end
if not options.debugPoly then
return
end
Citizen.CreateThread(function()
while not zone.destroyed do
zone:draw()
Citizen.Wait(0)
end
end)
end
function ComboZone:new(zones, options)
options = options or {}
local useGrid = options.useGrid
if useGrid == nil then useGrid = true end
local grid = {}
-- Add a unique id for each zone in the ComboZone and add to grid cache
for i=1, #zones do
local zone = zones[i]
if zone then
zone.id = i
end
if useGrid then _addZoneToGrid(grid, zone) end
end
local zone = {
name = tostring(options.name) or nil,
zones = zones,
useGrid = useGrid,
grid = grid,
debugPoly = options.debugPoly or false,
data = options.data or {},
isComboZone = true,
}
setmetatable(zone, self)
self.__index = self
return zone
end
function ComboZone:Create(zones, options)
local zone = ComboZone:new(zones, options)
_initDebug(zone, options)
AddEventHandler("polyzone:pzcomboinfo", function ()
zone:printInfo()
end)
return zone
end
function ComboZone:getZones(point)
if not self.useGrid then
return self.zones
end
local grid = self.grid
local x, y = _getGridCell(point)
local row = grid[y]
if row == nil or row[x] == nil then
return nil
end
return row[x]
end
function ComboZone:AddZone(zone)
local zones = self.zones
local newIndex = #zones+1
zone.id = newIndex
zones[newIndex] = zone
if self.useGrid then
_addZoneToGrid(self.grid, zone)
end
if self.debugBlip then zone:addDebugBlip() end
end
function ComboZone:RemoveZone(nameOrFn)
local predicateFn = nameOrFn
if type(nameOrFn) == "string" then
-- Create on the fly predicate function if nameOrFn is a string (zone name)
predicateFn = function (zone) return zone.name == nameOrFn end
elseif type(nameOrFn) ~= "function" then
return nil
end
-- Remove from zones table
local zone = _removeZoneByFunction(predicateFn, self.zones)
if not zone then return nil end
-- Remove from grid cache
local grid = self.grid
local minY, maxY, minX, maxX = _getZoneBounds(zone)
for y=minY, maxY do
local row = grid[y]
if row then
for x=minX, maxX do
_removeZoneByFunction(predicateFn, row[x])
end
end
end
return zone
end
function ComboZone:isPointInside(point, zoneName)
if self.destroyed then
print("[PolyZone] Warning: Called isPointInside on destroyed zone {name=" .. self.name .. "}")
return false, {}
end
local zones = self:getZones(point)
if not zones or #zones == 0 then return false end
for i=1, #zones do
local zone = zones[i]
if zone and (zoneName == nil or zoneName == zone.name) and zone:isPointInside(point) then
return true, zone
end
end
return false, nil
end
function ComboZone:isPointInsideExhaustive(point, insideZones)
if self.destroyed then
print("[PolyZone] Warning: Called isPointInside on destroyed zone {name=" .. self.name .. "}")
return false, {}
end
if insideZones ~= nil then
insideZones = clearTbl(insideZones)
else
insideZones = {}
end
local zones = self:getZones(point)
if not zones or #zones == 0 then return false, insideZones end
for i=1, #zones do
local zone = zones[i]
if zone and zone:isPointInside(point) then
insideZones[#insideZones+1] = zone
end
end
return #insideZones > 0, insideZones
end
function ComboZone:destroy()
PolyZone.destroy(self)
local zones = self.zones
for i=1, #zones do
local zone = zones[i]
if zone and not zone.destroyed then
zone:destroy()
end
end
end
function ComboZone:onPointInOut(getPointCb, onPointInOutCb, waitInMS)
-- Localize the waitInMS value for performance reasons (default of 500 ms)
local _waitInMS = 500
if waitInMS ~= nil then _waitInMS = waitInMS end
Citizen.CreateThread(function()
local isInside = nil
local insideZone = nil
while not self.destroyed do
if not self.paused then
local point = getPointCb()
local newIsInside, newInsideZone = self:isPointInside(point)
if newIsInside ~= isInside then
onPointInOutCb(newIsInside, point, newInsideZone or insideZone)
isInside = newIsInside
insideZone = newInsideZone
end
end
Citizen.Wait(_waitInMS)
end
end)
end
function ComboZone:onPointInOutExhaustive(getPointCb, onPointInOutCb, waitInMS)
-- Localize the waitInMS value for performance reasons (default of 500 ms)
local _waitInMS = 500
if waitInMS ~= nil then _waitInMS = waitInMS end
Citizen.CreateThread(function()
local isInside, insideZones = nil, {}
local newIsInside, newInsideZones = nil, {}
while not self.destroyed do
if not self.paused then
local point = getPointCb()
newIsInside, newInsideZones = self:isPointInsideExhaustive(point, newInsideZones)
local isDifferent, enteredZones, leftZones = _differenceBetweenInsideZones(insideZones, newInsideZones)
if newIsInside ~= isInside or isDifferent then
isInside = newIsInside
insideZones = copyTbl(newInsideZones)
onPointInOutCb(isInside, point, insideZones, enteredZones, leftZones)
end
end
Citizen.Wait(_waitInMS)
end
end)
end
function ComboZone:onPlayerInOut(onPointInOutCb, waitInMS)
self:onPointInOut(PolyZone.getPlayerPosition, onPointInOutCb, waitInMS)
end
function ComboZone:onPlayerInOutExhaustive(onPointInOutCb, waitInMS)
self:onPointInOutExhaustive(PolyZone.getPlayerPosition, onPointInOutCb, waitInMS)
end
function ComboZone:addEvent(eventName, zoneName)
if self.events == nil then self.events = {} end
local internalEventName = eventPrefix .. eventName
RegisterNetEvent(internalEventName)
self.events[eventName] = AddEventHandler(internalEventName, function (...)
if self:isPointInside(PolyZone.getPlayerPosition(), zoneName) then
TriggerEvent(eventName, ...)
end
end)
end
function ComboZone:removeEvent(name)
PolyZone.removeEvent(self, name)
end
function ComboZone:addDebugBlip()
self.debugBlip = true
local zones = self.zones
for i=1, #zones do
local zone = zones[i]
if zone then zone:addDebugBlip() end
end
end
function ComboZone:printInfo()
local zones = self.zones
local polyCount, boxCount, circleCount, entityCount, comboCount = 0, 0, 0, 0, 0
for i=1, #zones do
local zone = zones[i]
if zone then
if zone.isEntityZone then entityCount = entityCount + 1
elseif zone.isCircleZone then circleCount = circleCount + 1
elseif zone.isComboZone then comboCount = comboCount + 1
elseif zone.isBoxZone then boxCount = boxCount + 1
elseif zone.isPolyZone then polyCount = polyCount + 1 end
end
end
local name = self.name ~= nil and ("\"" .. self.name .. "\"") or nil
print("-----------------------------------------------------")
print("[PolyZone] Info for ComboZone { name = " .. tostring(name) .. " }:")
print("[PolyZone] Total zones: " .. #zones)
if boxCount > 0 then print("[PolyZone] BoxZones: " .. boxCount) end
if circleCount > 0 then print("[PolyZone] CircleZones: " .. circleCount) end
if polyCount > 0 then print("[PolyZone] PolyZones: " .. polyCount) end
if entityCount > 0 then print("[PolyZone] EntityZones: " .. entityCount) end
if comboCount > 0 then print("[PolyZone] ComboZones: " .. comboCount) end
print("-----------------------------------------------------")
end
function ComboZone:setPaused(paused)
self.paused = paused
end
function ComboZone:isPaused()
return self.paused
end

View File

@ -0,0 +1,144 @@
EntityZone = {}
-- Inherits from BoxZone
setmetatable(EntityZone, { __index = BoxZone })
-- Utility functions
local deg, atan2 = math.deg, math.atan2
local function GetRotation(entity)
local fwdVector = GetEntityForwardVector(entity)
return deg(atan2(fwdVector.y, fwdVector.x))
end
local function _calculateMinAndMaxZ(entity, dimensions, scaleZ, offsetZ, pos)
local min, max = dimensions[1], dimensions[2]
local minX, minY, minZ, maxX, maxY, maxZ = min.x, min.y, min.z, max.x, max.y, max.z
-- Bottom vertices
local p1 = GetOffsetFromEntityInWorldCoords(entity, minX, minY, minZ).z
local p2 = GetOffsetFromEntityInWorldCoords(entity, maxX, minY, minZ).z
local p3 = GetOffsetFromEntityInWorldCoords(entity, maxX, maxY, minZ).z
local p4 = GetOffsetFromEntityInWorldCoords(entity, minX, maxY, minZ).z
-- Top vertices
local p5 = GetOffsetFromEntityInWorldCoords(entity, minX, minY, maxZ).z
local p6 = GetOffsetFromEntityInWorldCoords(entity, maxX, minY, maxZ).z
local p7 = GetOffsetFromEntityInWorldCoords(entity, maxX, maxY, maxZ).z
local p8 = GetOffsetFromEntityInWorldCoords(entity, minX, maxY, maxZ).z
local minZ = pos.z - math.min(p1, p2, p3, p4, p5, p6, p7, p8)
minZ = minZ * scaleZ[1] - offsetZ[1]
local maxZ = math.max(p1, p2, p3, p4, p5, p6, p7, p8) - pos.z
maxZ = maxZ * scaleZ[2] + offsetZ[2]
return pos.z - minZ, pos.z + maxZ
end
-- Initialization functions
local function _initDebug(zone, options)
if options.debugBlip then zone:addDebugBlip() end
if not options.debugPoly and not options.debugBlip then
return
end
Citizen.CreateThread(function()
local entity = zone.entity
local shouldDraw = options.debugPoly
while not zone.destroyed do
UpdateOffsets(entity, zone)
if shouldDraw then zone:draw() end
Citizen.Wait(0)
end
end)
end
function EntityZone:new(entity, options)
assert(DoesEntityExist(entity), "Objekt findes ikke")
local min, max = GetModelDimensions(GetEntityModel(entity))
local dimensions = {min, max}
local length = max.y - min.y
local width = max.x - min.x
local pos = GetEntityCoords(entity)
local zone = BoxZone:new(pos, length, width, options)
if options.useZ == true then
options.minZ, options.maxZ = _calculateMinAndMaxZ(entity, dimensions, zone.scaleZ, zone.offsetZ, pos)
else
options.minZ = nil
options.maxZ = nil
end
zone.entity = entity
zone.dimensions = dimensions
zone.useZ = options.useZ
zone.damageEventHandlers = {}
zone.isEntityZone = true
setmetatable(zone, self)
self.__index = self
return zone
end
function EntityZone:Create(entity, options)
local zone = EntityZone:new(entity, options)
_initDebug(zone, options)
return zone
end
function UpdateOffsets(entity, zone)
local pos = GetEntityCoords(entity)
local rot = GetRotation(entity)
zone.offsetPos = pos.xy - zone.startPos
zone.offsetRot = rot - 90.0
if zone.useZ then
zone.minZ, zone.maxZ = _calculateMinAndMaxZ(entity, zone.dimensions, zone.scaleZ, zone.offsetZ, pos)
end
if zone.debugBlip then SetBlipCoords(zone.debugBlip, pos.x, pos.y, 0.0) end
end
-- Helper functions
function EntityZone:isPointInside(point)
local entity = self.entity
if entity == nil then
print("[PolyZone] Error: Called isPointInside on Entity zone with no entity {name=" .. self.name .. "}")
return false
end
UpdateOffsets(entity, self)
return BoxZone.isPointInside(self, point)
end
function EntityZone:onEntityDamaged(onDamagedCb)
local entity = self.entity
if not entity then
print("[PolyZone] Error: Called onEntityDamage on Entity Zone with no entity {name=" .. self.name .. "}")
return
end
self.damageEventHandlers[#self.damageEventHandlers + 1] = AddEventHandler('gameEventTriggered', function (name, args)
if self.destroyed or self.paused then
return
end
if name == 'CEventNetworkEntityDamage' then
local victim, attacker, victimDied, weaponHash, isMelee = args[1], args[2], args[4], args[5], args[10]
--print(entity, victim, attacker, victimDied, weaponHash, isMelee)
if victim ~= entity then return end
onDamagedCb(victimDied == 1, attacker, weaponHash, isMelee == 1)
end
end)
end
function EntityZone:destroy()
for i=1, #self.damageEventHandlers do
print("Destroying damageEventHandler:", self.damageEventHandlers[i])
RemoveEventHandler(self.damageEventHandlers[i])
end
self.damageEventHandlers = {}
PolyZone.destroy(self)
end
function EntityZone:addDebugBlip()
local blip = PolyZone.addDebugBlip(self)
self.debugBlip = blip
return blip
end

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2021 Michael Afrin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,51 @@
# PolyZone
PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
![PolyZone around the prison](https://i.imgur.com/InKNaoL.jpg)
## Download
Click [here](https://github.com/mkafrin/PolyZone/releases) to go to the releases page and download the latest release
## Using PolyZone in a Script
In order to use PolyZone in your script, you must _at least_ include PolyZone's client.lua directly in your __resource.lua or fxmanifest.lua. You can do that by using FiveM's @ syntax for importing resource files:
```lua
client_scripts {
'@PolyZone/client.lua',
'your_scripts_client.lua',
}
```
This will allow you to create PolyZones in your script, but will not import other zones, such as CircleZone, BoxZone, etc. All the other zones are extra, and require their own explicit imports. Here is a `client_scripts` value that will include all the zones. Note the relative order of these imports, as the ordering is necessary! Many zones rely on each other, for example EntityZone inherits from BoxZone, and all zones inherit from PolyZone (client.lua).
```lua
client_scripts {
'@PolyZone/client.lua',
'@PolyZone/BoxZone.lua',
'@PolyZone/EntityZone.lua',
'@PolyZone/CircleZone.lua',
'@PolyZone/ComboZone.lua',
'your_scripts_client.lua'
}
```
## Documentation
For additional information on how to use PolyZone, please take a look at the [wiki](https://github.com/mkafrin/PolyZone/wiki)
## Troubleshooting and Support
For help troubleshooting issues you've encountered (that aren't in the FAQ), or to suggest new features, use the [issues page](https://github.com/mkafrin/PolyZone/issues). Just a reminder though, I do this in my free time and so there is no guarantee an issue will be fixed or a feature will be added. In lieu of my limited time, I will prioritize issues and bugs over features.
## FAQ - Frequently Asked Questions
**I'm getting the error `attempt to index a nil value` when creating a zone, what's wrong?**
> Did you include all the necessary scripts in your \_\_resource.lua or fxmanifest.lua? Remember some zones require other zones, like EntityZone.lua requires BoxZone.lua and BoxZone.lua requires client.lua.
**I'm getting no errors, but I can't see my zone in the right place when I turn on debug drawing**
> If you are using them, is minZ and maxZ set correctly? Or if you are using a CircleZone with useZ=true, is your center's Z value correct? If using a PolyZone, did you manually select all your points, or use the creation script? If you did it manually, the ordering of the points could be causing issues. Are you using the correct option to enable debug drawing? For PolyZones, you can use `debugPoly` and `debugGrid`, but for other zones, `debugPoly` is the only one that works.
**Is PolyZone faster than a distance check?**
> There's a page in the wiki for that, [here](https://github.com/mkafrin/PolyZone/wiki/Is-PolyZone-faster-than-a-distance-check%3F).
## License
**Please see the LICENSE file. That file will always overrule anything mentioned in the README.md or wiki**

View File

@ -0,0 +1,599 @@
eventPrefix = '__PolyZone__:'
PolyZone = {}
local defaultColorWalls = {0, 255, 0}
local defaultColorOutline = {255, 0, 0}
local defaultColorGrid = {255, 255, 255}
-- Utility functions
local abs = math.abs
local function _isLeft(p0, p1, p2)
local p0x = p0.x
local p0y = p0.y
return ((p1.x - p0x) * (p2.y - p0y)) - ((p2.x - p0x) * (p1.y - p0y))
end
local function _wn_inner_loop(p0, p1, p2, wn)
local p2y = p2.y
if (p0.y <= p2y) then
if (p1.y > p2y) then
if (_isLeft(p0, p1, p2) > 0) then
return wn + 1
end
end
else
if (p1.y <= p2y) then
if (_isLeft(p0, p1, p2) < 0) then
return wn - 1
end
end
end
return wn
end
function addBlip(pos)
local blip = AddBlipForCoord(pos.x, pos.y, 0.0)
SetBlipColour(blip, 7)
SetBlipDisplay(blip, 8)
SetBlipScale(blip, 1.0)
SetBlipAsShortRange(blip, true)
return blip
end
function clearTbl(tbl)
-- Only works with contiguous (array-like) tables
if tbl == nil then return end
for i=1, #tbl do
tbl[i] = nil
end
return tbl
end
function copyTbl(tbl)
-- Only a shallow copy, and only works with contiguous (array-like) tables
if tbl == nil then return end
local ret = {}
for i=1, #tbl do
ret[i] = tbl[i]
end
return ret
end
-- Winding Number Algorithm - https://geomalgorithms.com/a03-_inclusion.html
local function _windingNumber(point, poly)
local wn = 0 -- winding number counter
-- loop through all edges of the polygon
for i = 1, #poly - 1 do
wn = _wn_inner_loop(poly[i], poly[i + 1], point, wn)
end
-- test last point to first point, completing the polygon
wn = _wn_inner_loop(poly[#poly], poly[1], point, wn)
-- the point is outside only when this winding number wn===0, otherwise it's inside
return wn ~= 0
end
-- Detects intersection between two lines
local function _isIntersecting(a, b, c, d)
-- Store calculations in local variables for performance
local ax_minus_cx = a.x - c.x
local bx_minus_ax = b.x - a.x
local dx_minus_cx = d.x - c.x
local ay_minus_cy = a.y - c.y
local by_minus_ay = b.y - a.y
local dy_minus_cy = d.y - c.y
local denominator = ((bx_minus_ax) * (dy_minus_cy)) - ((by_minus_ay) * (dx_minus_cx))
local numerator1 = ((ay_minus_cy) * (dx_minus_cx)) - ((ax_minus_cx) * (dy_minus_cy))
local numerator2 = ((ay_minus_cy) * (bx_minus_ax)) - ((ax_minus_cx) * (by_minus_ay))
-- Detect coincident lines
if denominator == 0 then return numerator1 == 0 and numerator2 == 0 end
local r = numerator1 / denominator
local s = numerator2 / denominator
return (r >= 0 and r <= 1) and (s >= 0 and s <= 1)
end
-- https://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area#Lua
local function _calculatePolygonArea(points)
local function det2(i,j)
return points[i].x*points[j].y-points[j].x*points[i].y
end
local sum = #points>2 and det2(#points,1) or 0
for i=1,#points-1 do sum = sum + det2(i,i+1)end
return abs(0.5 * sum)
end
-- Debug drawing functions
function _drawWall(p1, p2, minZ, maxZ, r, g, b, a)
local bottomLeft = vector3(p1.x, p1.y, minZ)
local topLeft = vector3(p1.x, p1.y, maxZ)
local bottomRight = vector3(p2.x, p2.y, minZ)
local topRight = vector3(p2.x, p2.y, maxZ)
DrawPoly(bottomLeft,topLeft,bottomRight,r,g,b,a)
DrawPoly(topLeft,topRight,bottomRight,r,g,b,a)
DrawPoly(bottomRight,topRight,topLeft,r,g,b,a)
DrawPoly(bottomRight,topLeft,bottomLeft,r,g,b,a)
end
function PolyZone:TransformPoint(point)
-- No point transform necessary for regular PolyZones, unlike zones like Entity Zones, whose points can be rotated and offset
return point
end
function PolyZone:draw()
local zDrawDist = 45.0
local oColor = self.debugColors.outline or defaultColorOutline
local oR, oG, oB = oColor[1], oColor[2], oColor[3]
local wColor = self.debugColors.walls or defaultColorWalls
local wR, wG, wB = wColor[1], wColor[2], wColor[3]
local plyPed = PlayerPedId()
local plyPos = GetEntityCoords(plyPed)
local minZ = self.minZ or plyPos.z - zDrawDist
local maxZ = self.maxZ or plyPos.z + zDrawDist
local points = self.points
for i=1, #points do
local point = self:TransformPoint(points[i])
DrawLine(point.x, point.y, minZ, point.x, point.y, maxZ, oR, oG, oB, 164)
if i < #points then
local p2 = self:TransformPoint(points[i+1])
DrawLine(point.x, point.y, maxZ, p2.x, p2.y, maxZ, oR, oG, oB, 184)
_drawWall(point, p2, minZ, maxZ, wR, wG, wB, 48)
end
end
if #points > 2 then
local firstPoint = self:TransformPoint(points[1])
local lastPoint = self:TransformPoint(points[#points])
DrawLine(firstPoint.x, firstPoint.y, maxZ, lastPoint.x, lastPoint.y, maxZ, oR, oG, oB, 184)
_drawWall(firstPoint, lastPoint, minZ, maxZ, wR, wG, wB, 48)
end
end
function PolyZone.drawPoly(poly)
PolyZone.draw(poly)
end
-- Debug drawing all grid cells that are completly within the polygon
local function _drawGrid(poly)
local minZ = poly.minZ
local maxZ = poly.maxZ
if not minZ or not maxZ then
local plyPed = PlayerPedId()
local plyPos = GetEntityCoords(plyPed)
minZ = plyPos.z - 46.0
maxZ = plyPos.z - 45.0
end
local lines = poly.lines
local color = poly.debugColors.grid or defaultColorGrid
local r, g, b = color[1], color[2], color[3]
for i=1, #lines do
local line = lines[i]
local min = line.min
local max = line.max
DrawLine(min.x + 0.0, min.y + 0.0, maxZ + 0.0, max.x + 0.0, max.y + 0.0, maxZ + 0.0, r, g, b, 196)
end
end
local function _pointInPoly(point, poly)
local x = point.x
local y = point.y
local min = poly.min
local minX = min.x
local minY = min.y
local max = poly.max
-- Checks if point is within the polygon's bounding box
if x < minX or
x > max.x or
y < minY or
y > max.y then
return false
end
-- Checks if point is within the polygon's height bounds
local minZ = poly.minZ
local maxZ = poly.maxZ
local z = point.z
if (minZ and z < minZ) or (maxZ and z > maxZ) then
return false
end
-- Returns true if the grid cell associated with the point is entirely inside the poly
local grid = poly.grid
if grid then
local gridDivisions = poly.gridDivisions
local size = poly.size
local gridPosX = x - minX
local gridPosY = y - minY
local gridCellX = (gridPosX * gridDivisions) // size.x
local gridCellY = (gridPosY * gridDivisions) // size.y
local gridCellValue = grid[gridCellY + 1][gridCellX + 1]
if gridCellValue == nil and poly.lazyGrid then
gridCellValue = _isGridCellInsidePoly(gridCellX, gridCellY, poly)
grid[gridCellY + 1][gridCellX + 1] = gridCellValue
end
if gridCellValue then return true end
end
return _windingNumber(point, poly.points)
end
-- Grid creation functions
-- Calculates the points of the rectangle that make up the grid cell at grid position (cellX, cellY)
local function _calculateGridCellPoints(cellX, cellY, poly)
local gridCellWidth = poly.gridCellWidth
local gridCellHeight = poly.gridCellHeight
local min = poly.min
-- min added to initial point, in order to shift the grid cells to the poly's starting position
local x = cellX * gridCellWidth + min.x
local y = cellY * gridCellHeight + min.y
return {
vector2(x, y),
vector2(x + gridCellWidth, y),
vector2(x + gridCellWidth, y + gridCellHeight),
vector2(x, y + gridCellHeight),
vector2(x, y)
}
end
function _isGridCellInsidePoly(cellX, cellY, poly)
gridCellPoints = _calculateGridCellPoints(cellX, cellY, poly)
local polyPoints = {table.unpack(poly.points)}
-- Connect the polygon to its starting point
polyPoints[#polyPoints + 1] = polyPoints[1]
-- If none of the points of the grid cell are in the polygon, the grid cell can't be in it
local isOnePointInPoly = false
for i=1, #gridCellPoints - 1 do
local cellPoint = gridCellPoints[i]
local x = cellPoint.x
local y = cellPoint.y
if _windingNumber(cellPoint, poly.points) then
isOnePointInPoly = true
-- If we are drawing the grid (poly.lines ~= nil), we need to go through all the points,
-- and therefore can't break out of the loop early
if poly.lines then
if not poly.gridXPoints[x] then poly.gridXPoints[x] = {} end
if not poly.gridYPoints[y] then poly.gridYPoints[y] = {} end
poly.gridXPoints[x][y] = true
poly.gridYPoints[y][x] = true
else break end
end
end
if isOnePointInPoly == false then
return false
end
-- If any of the grid cell's lines intersects with any of the polygon's lines
-- then the grid cell is not completely within the poly
for i=1, #gridCellPoints - 1 do
local gridCellP1 = gridCellPoints[i]
local gridCellP2 = gridCellPoints[i+1]
for j=1, #polyPoints - 1 do
if _isIntersecting(gridCellP1, gridCellP2, polyPoints[j], polyPoints[j+1]) then
return false
end
end
end
return true
end
local function _calculateLinesForDrawingGrid(poly)
local lines = {}
for x, tbl in pairs(poly.gridXPoints) do
local yValues = {}
-- Turn dict/set of values into array
for y, _ in pairs(tbl) do yValues[#yValues + 1] = y end
if #yValues >= 2 then
table.sort(yValues)
local minY = yValues[1]
local lastY = yValues[1]
for i=1, #yValues do
local y = yValues[i]
-- Checks for breaks in the grid. If the distance between the last value and the current one
-- is greater than the size of a grid cell, that means the line between them must go outside the polygon.
-- Therefore, a line must be created between minY and the lastY, and a new line started at the current y
if y - lastY > poly.gridCellHeight + 0.01 then
lines[#lines+1] = {min=vector2(x, minY), max=vector2(x, lastY)}
minY = y
elseif i == #yValues then
-- If at the last point, create a line between minY and the last point
lines[#lines+1] = {min=vector2(x, minY), max=vector2(x, y)}
end
lastY = y
end
end
end
-- Setting nil to allow the GC to clear it out of memory, since we no longer need this
poly.gridXPoints = nil
-- Same as above, but for gridYPoints instead of gridXPoints
for y, tbl in pairs(poly.gridYPoints) do
local xValues = {}
for x, _ in pairs(tbl) do xValues[#xValues + 1] = x end
if #xValues >= 2 then
table.sort(xValues)
local minX = xValues[1]
local lastX = xValues[1]
for i=1, #xValues do
local x = xValues[i]
if x - lastX > poly.gridCellWidth + 0.01 then
lines[#lines+1] = {min=vector2(minX, y), max=vector2(lastX, y)}
minX = x
elseif i == #xValues then
lines[#lines+1] = {min=vector2(minX, y), max=vector2(x, y)}
end
lastX = x
end
end
end
poly.gridYPoints = nil
return lines
end
-- Calculate for each grid cell whether it is entirely inside the polygon, and store if true
local function _createGrid(poly, options)
poly.gridArea = 0.0
poly.gridCellWidth = poly.size.x / poly.gridDivisions
poly.gridCellHeight = poly.size.y / poly.gridDivisions
Citizen.CreateThread(function()
-- Calculate all grid cells that are entirely inside the polygon
local isInside = {}
local gridCellArea = poly.gridCellWidth * poly.gridCellHeight
for y=1, poly.gridDivisions do
Citizen.Wait(0)
isInside[y] = {}
for x=1, poly.gridDivisions do
if _isGridCellInsidePoly(x-1, y-1, poly) then
poly.gridArea = poly.gridArea + gridCellArea
isInside[y][x] = true
end
end
end
poly.grid = isInside
poly.gridCoverage = poly.gridArea / poly.area
-- A lot of memory is used by this pre-calc. Force a gc collect after to clear it out
collectgarbage("collect")
if options.debugGrid then
local coverage = string.format("%.2f", poly.gridCoverage * 100)
print("[PolyZone] Debug: Grid Coverage at " .. coverage .. "% with " .. poly.gridDivisions
.. " divisions. Optimal coverage for memory usage and startup time is 80-90%")
Citizen.CreateThread(function()
poly.lines = _calculateLinesForDrawingGrid(poly)
-- A lot of memory is used by this pre-calc. Force a gc collect after to clear it out
collectgarbage("collect")
end)
end
end)
end
-- Initialization functions
local function _calculatePoly(poly, options)
if not poly.min or not poly.max or not poly.size or not poly.center or not poly.area then
local minX, minY = math.maxinteger, math.maxinteger
local maxX, maxY = math.mininteger, math.mininteger
for _, p in ipairs(poly.points) do
minX = math.min(minX, p.x)
minY = math.min(minY, p.y)
maxX = math.max(maxX, p.x)
maxY = math.max(maxY, p.y)
end
poly.min = vector2(minX, minY)
poly.max = vector2(maxX, maxY)
poly.size = poly.max - poly.min
poly.center = (poly.max + poly.min) / 2
poly.area = _calculatePolygonArea(poly.points)
end
poly.boundingRadius = math.sqrt(poly.size.y * poly.size.y + poly.size.x * poly.size.x) / 2
if poly.useGrid and not poly.lazyGrid then
if options.debugGrid then
poly.gridXPoints = {}
poly.gridYPoints = {}
poly.lines = {}
end
_createGrid(poly, options)
elseif poly.useGrid then
local isInside = {}
for y=1, poly.gridDivisions do
isInside[y] = {}
end
poly.grid = isInside
poly.gridCellWidth = poly.size.x / poly.gridDivisions
poly.gridCellHeight = poly.size.y / poly.gridDivisions
end
end
local function _initDebug(poly, options)
if options.debugBlip then poly:addDebugBlip() end
local debugEnabled = options.debugPoly or options.debugGrid
if not debugEnabled then
return
end
Citizen.CreateThread(function()
while not poly.destroyed do
poly:draw()
if options.debugGrid and poly.lines then
_drawGrid(poly)
end
Citizen.Wait(0)
end
end)
end
function PolyZone:new(points, options)
if not points then
print("[PolyZone] Error: Passed nil points table to PolyZone:Create() {name=" .. options.name .. "}")
return
end
if #points < 3 then
print("[PolyZone] Warning: Passed points table with less than 3 points to PolyZone:Create() {name=" .. options.name .. "}")
end
options = options or {}
local useGrid = options.useGrid
if useGrid == nil then useGrid = true end
local lazyGrid = options.lazyGrid
if lazyGrid == nil then lazyGrid = true end
local poly = {
name = tostring(options.name) or nil,
points = points,
center = options.center,
size = options.size,
max = options.max,
min = options.min,
area = options.area,
minZ = tonumber(options.minZ) or nil,
maxZ = tonumber(options.maxZ) or nil,
useGrid = useGrid,
lazyGrid = lazyGrid,
gridDivisions = tonumber(options.gridDivisions) or 30,
debugColors = options.debugColors or {},
debugPoly = options.debugPoly or false,
debugGrid = options.debugGrid or false,
data = options.data or {},
isPolyZone = true,
}
if poly.debugGrid then poly.lazyGrid = false end
_calculatePoly(poly, options)
setmetatable(poly, self)
self.__index = self
return poly
end
function PolyZone:Create(points, options)
local poly = PolyZone:new(points, options)
_initDebug(poly, options)
return poly
end
function PolyZone:isPointInside(point)
if self.destroyed then
print("[PolyZone] Warning: Called isPointInside on destroyed zone {name=" .. self.name .. "}")
return false
end
return _pointInPoly(point, self)
end
function PolyZone:destroy()
self.destroyed = true
if self.debugPoly or self.debugGrid then
print("[PolyZone] Debug: Destroying zone {name=" .. self.name .. "}")
end
end
-- Helper functions
function PolyZone.getPlayerPosition()
return GetEntityCoords(PlayerPedId())
end
HeadBone = 0x796e;
function PolyZone.getPlayerHeadPosition()
return GetPedBoneCoords(PlayerPedId(), HeadBone);
end
function PolyZone.ensureMetatable(zone)
if zone.isComboZone then
setmetatable(zone, ComboZone)
elseif zone.isEntityZone then
setmetatable(zone, EntityZone)
elseif zone.isBoxZone then
setmetatable(zone, BoxZone)
elseif zone.isCircleZone then
setmetatable(zone, CircleZone)
elseif zone.isPolyZone then
setmetatable(zone, PolyZone)
end
end
function PolyZone:onPointInOut(getPointCb, onPointInOutCb, waitInMS)
-- Localize the waitInMS value for performance reasons (default of 500 ms)
local _waitInMS = 500
if waitInMS ~= nil then _waitInMS = waitInMS end
Citizen.CreateThread(function()
local isInside = false
while not self.destroyed do
if not self.paused then
local point = getPointCb()
local newIsInside = self:isPointInside(point)
if newIsInside ~= isInside then
onPointInOutCb(newIsInside, point)
isInside = newIsInside
end
end
Citizen.Wait(_waitInMS)
end
end)
end
function PolyZone:onPlayerInOut(onPointInOutCb, waitInMS)
self:onPointInOut(PolyZone.getPlayerPosition, onPointInOutCb, waitInMS)
end
function PolyZone:addEvent(eventName)
if self.events == nil then self.events = {} end
local internalEventName = eventPrefix .. eventName
RegisterNetEvent(internalEventName)
self.events[eventName] = AddEventHandler(internalEventName, function (...)
if self:isPointInside(PolyZone.getPlayerPosition()) then
TriggerEvent(eventName, ...)
end
end)
end
function PolyZone:removeEvent(eventName)
if self.events and self.events[eventName] then
RemoveEventHandler(self.events[eventName])
self.events[eventName] = nil
end
end
function PolyZone:addDebugBlip()
return addBlip(self.center or self:getBoundingBoxCenter())
end
function PolyZone:setPaused(paused)
self.paused = paused
end
function PolyZone:isPaused()
return self.paused
end
function PolyZone:getBoundingBoxMin()
return self.min
end
function PolyZone:getBoundingBoxMax()
return self.max
end
function PolyZone:getBoundingBoxSize()
return self.size
end
function PolyZone:getBoundingBoxCenter()
return self.center
end

View File

@ -0,0 +1,111 @@
local function handleInput(useZ, heading, length, width, center)
if not useZ then
local scaleDelta, headingDelta = 0.2, 5
BlockWeaponWheelThisFrame()
DisableControlAction(0, 36, true)
if IsDisabledControlPressed(0, 36) then -- ctrl held down
scaleDelta, headingDelta = 0.05, 1
end
DisableControlAction(0, 81, true)
if IsDisabledControlJustPressed(0, 81) then
if IsControlPressed(0, 19) then -- alt held down
return heading, length, math.max(0.0, width - scaleDelta), center
end
if IsControlPressed(0, 21) then -- shift held down
return heading, math.max(0.0, length - scaleDelta), width, center
end
return (heading - headingDelta) % 360, length, width, center
end
DisableControlAction(0, 99, true)
if IsDisabledControlJustPressed(0, 99) then
if IsControlPressed(0, 19) then -- alt held down
return heading, length, math.max(0.0, width + scaleDelta), center
end
if IsControlPressed(0, 21) then -- shift held down
return heading, math.max(0.0, length + scaleDelta), width, center
end
return (heading + headingDelta) % 360, length, width, center
end
end
local rot = GetGameplayCamRot(2)
center = handleArrowInput(center, rot.z)
return heading, length, width, center
end
function handleZ(minZ, maxZ)
local delta = 0.2
DisableControlAction(0, 36, true)
if IsDisabledControlPressed(0, 36) then -- ctrl held down
delta = 0.05
end
BlockWeaponWheelThisFrame()
DisableControlAction(0, 81, true)
if IsDisabledControlJustPressed(0, 81) then
if IsControlPressed(0, 19) then -- alt held down
return minZ - delta, maxZ
end
if IsControlPressed(0, 21) then -- shift held down
return minZ, maxZ - delta
end
return minZ - delta, maxZ - delta
end
DisableControlAction(0, 99, true)
if IsDisabledControlJustPressed(0, 99) then
if IsControlPressed(0, 19) then -- alt held down
return minZ + delta, maxZ
end
if IsControlPressed(0, 21) then -- shift held down
return minZ, maxZ + delta
end
return minZ + delta, maxZ + delta
end
return minZ, maxZ
end
function boxStart(name, heading, length, width, minHeight, maxHeight)
local center = GetEntityCoords(PlayerPedId())
createdZone = BoxZone:Create(center, length, width, {name = tostring(name)})
local useZ, minZ, maxZ = false, center.z - 1.0, center.z + 3.0
if minHeight then
minZ = center.z - minHeight
createdZone.minZ = minZ
end
if maxHeight then
maxZ = center.z + maxHeight
createdZone.maxZ = maxZ
end
Citizen.CreateThread(function()
while createdZone do
if IsControlJustPressed(0, 20) then -- Z pressed
useZ = not useZ
if useZ then
createdZone.debugColors.walls = {255, 0, 0}
else
createdZone.debugColors.walls = {0, 255, 0}
end
end
heading, length, width, center = handleInput(useZ, heading, length, width, center)
if useZ then
minZ, maxZ = handleZ(minZ, maxZ)
createdZone.minZ = minZ
createdZone.maxZ = maxZ
end
createdZone:setLength(length)
createdZone:setWidth(width)
createdZone:setHeading(heading)
createdZone:setCenter(center)
Wait(0)
end
end)
end
function boxFinish()
TriggerServerEvent("polyzone:printBox",
{name=createdZone.name, center=createdZone.center, length=createdZone.length, width=createdZone.width, heading=createdZone.offsetRot, minZ=createdZone.minZ, maxZ=createdZone.maxZ})
end

View File

@ -0,0 +1,51 @@
local function handleInput(radius, center, useZ)
local delta = 0.05
BlockWeaponWheelThisFrame()
DisableControlAction(0, 36, true)
DisableControlAction(0, 81, true)
if IsDisabledControlPressed(0, 36) then -- ctrl held down
delta = 0.01
end
if IsDisabledControlJustPressed(0, 81) then
if IsControlPressed(0, 19) then -- alt held down
return radius, vector3(center.x, center.y, center.z - delta), useZ
end
return math.max(0.0, radius - delta), center, useZ
end
DisableControlAction(0, 99, true)
if IsDisabledControlJustPressed(0, 99) then
if IsControlPressed(0, 19) then -- alt held down
return radius, vector3(center.x, center.y, center.z + delta), useZ
end
return radius + delta, center, useZ
end
if IsControlJustPressed(0, 20) then -- Z pressed
return radius, center, not useZ
end
local rot = GetGameplayCamRot(2)
center = handleArrowInput(center, rot.z)
return radius, center, useZ
end
function circleStart(name, radius, useZ)
local center = GetEntityCoords(PlayerPedId())
useZ = useZ or false
createdZone = CircleZone:Create(center, radius, {name = tostring(name), useZ = useZ})
Citizen.CreateThread(function()
while createdZone do
radius, center, useZ = handleInput(radius, center, useZ)
createdZone:setRadius(radius)
createdZone:setCenter(center)
createdZone.useZ = useZ
Wait(0)
end
end)
end
function circleFinish()
TriggerServerEvent("polyzone:printCircle",
{name=createdZone.name, center=createdZone.center, radius=createdZone.radius, useZ=createdZone.useZ})
end

View File

@ -0,0 +1,60 @@
local minZ, maxZ = nil, nil
local function handleInput(center)
local rot = GetGameplayCamRot(2)
center = handleArrowInput(center, rot.z)
return center
end
function polyStart(name)
local coords = GetEntityCoords(PlayerPedId())
createdZone = PolyZone:Create({vector2(coords.x, coords.y)}, {name = tostring(name), useGrid=false})
Citizen.CreateThread(function()
while createdZone do
-- Have to convert the point to a vector3 prior to calling handleInput,
-- then convert it back to vector2 afterwards
lastPoint = createdZone.points[#createdZone.points]
lastPoint = vector3(lastPoint.x, lastPoint.y, 0.0)
lastPoint = handleInput(lastPoint)
createdZone.points[#createdZone.points] = lastPoint.xy
Wait(0)
end
end)
minZ, maxZ = coords.z, coords.z
end
function polyFinish()
TriggerServerEvent("polyzone:printPoly",
{name=createdZone.name, points=createdZone.points, minZ=minZ, maxZ=maxZ})
end
RegisterNetEvent("polyzone:pzadd")
AddEventHandler("polyzone:pzadd", function()
if createdZone == nil or createdZoneType ~= 'poly' then
return
end
local coords = GetEntityCoords(PlayerPedId())
if (coords.z > maxZ) then
maxZ = coords.z
end
if (coords.z < minZ) then
minZ = coords.z
end
createdZone.points[#createdZone.points + 1] = vector2(coords.x, coords.y)
end)
RegisterNetEvent("polyzone:pzundo")
AddEventHandler("polyzone:pzundo", function()
if createdZone == nil or createdZoneType ~= 'poly' then
return
end
createdZone.points[#createdZone.points] = nil
if #createdZone.points == 0 then
TriggerEvent("polyzone:pzcancel")
end
end)

View File

@ -0,0 +1,68 @@
RegisterCommand("pzcreate", function(src, args)
local zoneType = args[1]
if zoneType == nil then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Mig", "Vælg venligst en type: poly, circle, box!"}
})
return
end
if zoneType ~= 'poly' and zoneType ~= 'circle' and zoneType ~= 'box' then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Mig", "Zone-type kan kun være følgende: poly, circle eller box"}
})
return
end
local name = nil
if #args >= 2 then name = args[2]
else name = GetUserInput("Navn på zone:") end
if name == nil or name == "" then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Mig", "Tilføj et navn!"}
})
return
end
TriggerEvent("polyzone:pzcreate", zoneType, name, args)
end)
RegisterCommand("pzadd", function(src, args)
TriggerEvent("polyzone:pzadd")
end)
RegisterCommand("pzundo", function(src, args)
TriggerEvent("polyzone:pzundo")
end)
RegisterCommand("pzfinish", function(src, args)
TriggerEvent("polyzone:pzfinish")
end)
RegisterCommand("pzlast", function(src, args)
TriggerEvent("polyzone:pzlast")
end)
RegisterCommand("pzcancel", function(src, args)
TriggerEvent("polyzone:pzcancel")
end)
RegisterCommand("pzcomboinfo", function (src, args)
TriggerEvent("polyzone:pzcomboinfo")
end)
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/pzcreate', 'Starter oprettelse af PolyZone, med en af følgende typer: circle, box, poly', {
{name="zoneType", help="Zone Type (circle, box, poly)"},
})
TriggerEvent('chat:addSuggestion', '/pzadd', 'Tilføj punkt til zone.', {})
TriggerEvent('chat:addSuggestion', '/pzundo', 'Annuller sidste punkt.', {})
TriggerEvent('chat:addSuggestion', '/pzfinish', 'Færdiggør og print zone.', {})
TriggerEvent('chat:addSuggestion', '/pzlast', 'Starter oprettelse af sidste zone (Virker kun med BoxZone og CircleZone)', {})
TriggerEvent('chat:addSuggestion', '/pzcancel', 'Annuller zone-oprettelse.', {})
TriggerEvent('chat:addSuggestion', '/pzcomboinfo', 'Giver dig nyttig information på alle ComboZones', {})
end)

View File

@ -0,0 +1,157 @@
lastCreatedZoneType = nil
lastCreatedZone = nil
createdZoneType = nil
createdZone = nil
drawZone = false
RegisterNetEvent("polyzone:pzcreate")
AddEventHandler("polyzone:pzcreate", function(zoneType, name, args)
if createdZone ~= nil then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Me", "A shape is already being created!"}
})
return
end
if zoneType == 'poly' then
polyStart(name)
elseif zoneType == "circle" then
local radius = nil
if #args >= 3 then radius = tonumber(args[3])
else radius = tonumber(GetUserInput("Enter radius:")) end
if radius == nil then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Me", "CircleZone requires a radius (must be a number)!"}
})
return
end
circleStart(name, radius)
elseif zoneType == "box" then
local length = nil
if #args >= 3 then length = tonumber(args[3])
else length = tonumber(GetUserInput("Enter length:")) end
if length == nil or length < 0.0 then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Me", "BoxZone requires a length (must be a positive number)!"}
})
return
end
local width = nil
if #args >= 4 then width = tonumber(args[4])
else width = tonumber(GetUserInput("Enter width:")) end
if width == nil or width < 0.0 then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0},
multiline = true,
args = {"Me", "BoxZone requires a width (must be a positive number)!"}
})
return
end
boxStart(name, 0, length, width)
else
return
end
createdZoneType = zoneType
drawZone = true
drawThread()
end)
RegisterNetEvent("polyzone:pzfinish")
AddEventHandler("polyzone:pzfinish", function()
if createdZone == nil then
return
end
if createdZoneType == 'poly' then
polyFinish()
elseif createdZoneType == "circle" then
circleFinish()
elseif createdZoneType == "box" then
boxFinish()
end
TriggerEvent('chat:addMessage', {
color = { 0, 255, 0},
multiline = true,
args = {"Me", "Check your server root folder for polyzone_created_zones.txt to get the zone!"}
})
lastCreatedZoneType = createdZoneType
lastCreatedZone = createdZone
drawZone = false
createdZone = nil
createdZoneType = nil
end)
RegisterNetEvent("polyzone:pzlast")
AddEventHandler("polyzone:pzlast", function()
if createdZone ~= nil or lastCreatedZone == nil then
return
end
if lastCreatedZoneType == 'poly' then
TriggerEvent('chat:addMessage', {
color = { 0, 255, 0},
multiline = true,
args = {"Mig", "Kommandoen understøtter kun BoxZone og CircleZone for nu!"}
})
end
local name = GetUserInput("Indtast navn (Eller efterlad tom og brug sidste zones navn):")
if name == nil then
return
elseif name == "" then
name = lastCreatedZone.name
end
createdZoneType = lastCreatedZoneType
if createdZoneType == 'box' then
local minHeight, maxHeight
if lastCreatedZone.minZ then
minHeight = lastCreatedZone.center.z - lastCreatedZone.minZ
end
if lastCreatedZone.maxZ then
maxHeight = lastCreatedZone.maxZ - lastCreatedZone.center.z
end
boxStart(name, lastCreatedZone.offsetRot, lastCreatedZone.length, lastCreatedZone.width, minHeight, maxHeight)
elseif createdZoneType == 'circle' then
circleStart(name, lastCreatedZone.radius, lastCreatedZone.useZ)
end
drawZone = true
drawThread()
end)
RegisterNetEvent("polyzone:pzcancel")
AddEventHandler("polyzone:pzcancel", function()
if createdZone == nil then
return
end
TriggerEvent('chat:addMessage', {
color = {255, 0, 0},
multiline = true,
args = {"Mig", "Zone-oprettelse annulleret!"}
})
drawZone = false
createdZone = nil
createdZoneType = nil
end)
-- Drawing
function drawThread()
Citizen.CreateThread(function()
while drawZone do
if createdZone then
createdZone:draw()
end
Wait(0)
end
end)
end

View File

@ -0,0 +1,55 @@
-- GetUserInput function inspired by vMenu (https://github.com/TomGrobbe/vMenu/blob/master/vMenu/CommonFunctions.cs)
function GetUserInput(windowTitle, defaultText, maxInputLength)
-- Create the window title string.
local resourceName = string.upper(GetCurrentResourceName())
local textEntry = resourceName .. "_WINDOW_TITLE"
if windowTitle == nil then
windowTitle = "Indtast:"
end
AddTextEntry(textEntry, windowTitle)
-- Display the input box.
DisplayOnscreenKeyboard(1, textEntry, "", defaultText or "", "", "", "", maxInputLength or 30)
Wait(0)
-- Wait for a result.
while true do
local keyboardStatus = UpdateOnscreenKeyboard();
if keyboardStatus == 3 then -- not displaying input field anymore somehow
return nil
elseif keyboardStatus == 2 then -- cancelled
return nil
elseif keyboardStatus == 1 then -- finished editing
return GetOnscreenKeyboardResult()
else
Wait(0)
end
end
end
function handleArrowInput(center, heading)
delta = 0.05
DisableControlAction(0, 36, true)
if IsDisabledControlPressed(0, 36) then -- ctrl held down
delta = 0.01
end
DisableControlAction(0, 27, true)
if IsDisabledControlPressed(0, 27) then -- arrow up
local newCenter = PolyZone.rotate(center.xy, vector2(center.x, center.y + delta), heading)
return vector3(newCenter.x, newCenter.y, center.z)
end
if IsControlPressed(0, 173) then -- arrow down
local newCenter = PolyZone.rotate(center.xy, vector2(center.x, center.y - delta), heading)
return vector3(newCenter.x, newCenter.y, center.z)
end
if IsControlPressed(0, 174) then -- arrow left
local newCenter = PolyZone.rotate(center.xy, vector2(center.x - delta, center.y), heading)
return vector3(newCenter.x, newCenter.y, center.z)
end
if IsControlPressed(0, 175) then -- arrow right
local newCenter = PolyZone.rotate(center.xy, vector2(center.x + delta, center.y), heading)
return vector3(newCenter.x, newCenter.y, center.z)
end
return center
end

View File

@ -0,0 +1,76 @@
RegisterNetEvent("polyzone:printPoly")
AddEventHandler("polyzone:printPoly", function(zone)
file = io.open('polyzone_created_zones.txt', "a")
io.output(file)
local output = parsePoly(zone)
io.write(output)
io.close(file)
end)
RegisterNetEvent("polyzone:printCircle")
AddEventHandler("polyzone:printCircle", function(zone)
file = io.open('polyzone_created_zones.txt', "a")
io.output(file)
local output = parseCircle(zone)
io.write(output)
io.close(file)
end)
RegisterNetEvent("polyzone:printBox")
AddEventHandler("polyzone:printBox", function(zone)
file = io.open('polyzone_created_zones.txt', "a")
io.output(file)
local output = parseBox(zone)
io.write(output)
io.close(file)
end)
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function printoutHeader(name)
return "--Navn: " .. name .. " | " .. os.date("!%Y-%m-%dT%H:%M:%SZ\n")
end
function parsePoly(zone)
local printout = printoutHeader(zone.name)
printout = printout .. "PolyZone:Create({\n"
for i=1, #zone.points do
if i ~= #zone.points then
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) .."),\n"
else
printout = printout .. " vector2(" .. tostring(zone.points[i].x) .. ", " .. tostring(zone.points[i].y) ..")\n"
end
end
printout = printout .. "}, {\n name=\"" .. zone.name .. "\",\n --minZ = " .. zone.minZ .. ",\n --maxZ = " .. zone.maxZ .. "\n})\n\n"
return printout
end
function parseCircle(zone)
local printout = printoutHeader(zone.name)
printout = printout .. "CircleZone:Create("
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."), "
printout = printout .. tostring(zone.radius) .. ", "
printout = printout .. "{\n name=\"" .. zone.name .. "\",\n useZ=" .. tostring(zone.useZ) .. ",\n --debugPoly=true\n})\n\n"
return printout
end
function parseBox(zone)
local printout = printoutHeader(zone.name)
printout = printout .. "BoxZone:Create("
printout = printout .. "vector3(" .. tostring(round(zone.center.x, 2)) .. ", " .. tostring(round(zone.center.y, 2)) .. ", " .. tostring(round(zone.center.z, 2)) .."), "
printout = printout .. tostring(zone.length) .. ", "
printout = printout .. tostring(zone.width) .. ", "
printout = printout .. "{\n name=\"" .. zone.name .. "\",\n heading=" .. zone.heading .. ",\n --debugPoly=true"
if zone.minZ then
printout = printout .. ",\n minZ=" .. tostring(round(zone.minZ, 2))
end
if zone.maxZ then
printout = printout .. ",\n maxZ=" .. tostring(round(zone.maxZ, 2))
end
printout = printout .. "\n})\n\n"
return printout
end

View File

@ -0,0 +1,20 @@
games {'gta5'}
fx_version 'cerulean'
description 'Define zones of different shapes and test whether a point is inside or outside of the zone'
version '2.6.0'
client_scripts {
'client.lua',
'BoxZone.lua',
'EntityZone.lua',
'CircleZone.lua',
'ComboZone.lua',
'creation/client/*.lua'
}
server_scripts {
'creation/server/*.lua',
'server.lua'
}

View File

@ -0,0 +1,10 @@
local eventPrefix = '__PolyZone__:'
function triggerZoneEvent(eventName, ...)
TriggerClientEvent(eventPrefix .. eventName, -1, ...)
end
RegisterNetEvent("PolyZone:TriggerZoneEvent")
AddEventHandler("PolyZone:TriggerZoneEvent", triggerZoneEvent)
exports("TriggerZoneEvent", triggerZoneEvent)

View File

@ -0,0 +1,98 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Dylan Malandain.
--- DateTime: 29/10/2019 02:40
---
---@class RageUI
RageUI = {}
---@class Item
RageUI.Item = {}
---@class Panel
RageUI.Panel = {}
---@class Window
RageUI.Window = {}
---@class RMenu
RMenu = setmetatable({}, RMenu)
---@type table
local TotalMenus = {}
---Add
---@param Type string
---@param Name string
---@param Menu table
---@return RMenu
---@public
function RMenu.Add(Type, Name, Menu)
if RMenu[Type] ~= nil then
RMenu[Type][Name] = {
Menu = Menu
}
else
RMenu[Type] = {}
RMenu[Type][Name] = {
Menu = Menu
}
end
return table.insert(TotalMenus, Menu)
end
---Get
---@param Type string
---@param Name string
---@return table
---@public
function RMenu:Get(Type, Name)
if self[Type] ~= nil and self[Type][Name] ~= nil then
return self[Type][Name].Menu
end
end
---GetType
---@param Type string
---@return table
---@public
function RMenu:GetType(Type)
if self[Type] ~= nil then
return self[Type]
end
end
---Settings
---@param Type string
---@param Name string
---@param Settings string
---@param Value any optional
---@return void
---@public
function RMenu:Settings(Type, Name, Settings, Value)
if Value ~= nil then
self[Type][Name][Settings] = Value
else
return self[Type][Name][Settings]
end
end
---Delete
---@param Type string
---@param Name string
---@return void
---@public
function RMenu:Delete(Type, Name)
self[Type][Name] = nil
collectgarbage()
end
---DeleteType
---@param Type string
---@return void
---@public
function RMenu:DeleteType(Type)
self[Type] = nil
collectgarbage()
end

View File

@ -0,0 +1,35 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Dylan Malandain.
--- DateTime: 24/07/2019 03:38
---
---PlaySound
---
--- Reference : N/A
---
---@param Library string
---@param Sound string
---@param IsLooped boolean
---@return nil
---@public
function RageUI.PlaySound(Library, Sound, IsLooped)
local audioId
if not IsLooped then
PlaySoundFrontend(-1, Sound, Library, true)
else
if not audioId then
CreateThread(function()
audioId = GetSoundId()
PlaySoundFrontend(audioId, Sound, Library, true)
Wait(0.01)
StopSound(audioId)
ReleaseSoundId(audioId)
audioId = nil
end)
end
end
end

View File

@ -0,0 +1,30 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@class Enum
local enums = {
__index = function(table, key)
if rawget(table.enums, key) then
return key
end
end
}
---Enum
---@param t table
---@return Enum
function RageUI.Enum(t)
local e = { enums = t }
return setmetatable(e, enums)
end

View File

@ -0,0 +1,44 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@class Keys
Keys = {};
---Register
---@param Controls string
---@param ControlName string
---@param Description string
---@param Action function
---@return Keys
---@public
function Keys.Register(Controls, ControlName, Description, Action)
local _Keys = {
CONTROLS = Controls
}
RegisterKeyMapping(string.format('rageui-%s', ControlName), Description, "keyboard", Controls)
RegisterCommand(string.format('rageui-%s', ControlName), function(source, args)
if (Action ~= nil) then
Action();
end
end, false)
return setmetatable(_Keys, Keys)
end
---Exists
---@param Controls string
---@return boolean
function Keys:Exists(Controls)
return self.CONTROLS == Controls and true or false
end

View File

@ -0,0 +1,18 @@
---RenderRectangle
---
--- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/UIResRectangle.lua#L84
---
---@param X number
---@param Y number
---@param Width number
---@param Height number
---@param R number
---@param G number
---@param B number
---@param A number
---@return nil
---@public
function RenderRectangle(X, Y, Width, Height, R, G, B, A)
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
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)
end

View File

@ -0,0 +1,27 @@
---RenderSprite
---
--- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/Sprite.lua#L90
---
---@param TextureDictionary string
---@param TextureName string
---@param X number
---@param Y number
---@param Width number
---@param Height number
---@param Heading number
---@param R number
---@param G number
---@param B number
---@param A number
---@return nil
---@public
function RenderSprite(TextureDictionary, TextureName, X, Y, Width, Height, Heading, R, G, B, A)
---@type number
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
if not HasStreamedTextureDictLoaded(TextureDictionary) then
RequestStreamedTextureDict(TextureDictionary, true)
end
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)
end

View File

@ -0,0 +1,155 @@
---StringToArray
---
--- Reference : Frazzle <3
---
---@param str string
function StringToArray(str)
local charCount = #str
local strCount = math.ceil(charCount / 99)
local strings = {}
for i = 1, strCount do
local start = (i - 1) * 99 + 1
local clamp = math.clamp(#string.sub(str, start), 0, 99)
local finish = ((i ~= 1) and (start - 1) or 0) + clamp
strings[i] = string.sub(str, start, finish)
end
return strings
end
---AddText
---
--- Reference : Frazzle <3
---
---@param str string
function AddText(str)
local str = tostring(str)
local charCount = #str
if charCount < 100 then
AddTextComponentSubstringPlayerName(str)
else
local strings = StringToArray(str)
for s = 1, #strings do
AddTextComponentSubstringPlayerName(strings[s])
end
end
end
---GetLineCount
---
--- Reference : Frazzle <3
---
---@param Text string
---@param X number
---@param Y number
---@param Font number
---@param Scale number
---@param R number
---@param G number
---@param B number
---@param A number
---@param Alignment string
---@param DropShadow boolean
---@param Outline boolean
---@param WordWrap number
---@return function
---@public
function GetLineCount(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap)
---@type table
local Text, X, Y = tostring(Text), (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080
SetTextFont(Font or 0)
SetTextScale(1.0, Scale or 0)
SetTextColour(tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
if DropShadow then
SetTextDropShadow()
end
if Outline then
SetTextOutline()
end
if Alignment ~= nil then
if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
SetTextCentre(true)
elseif Alignment == 2 or Alignment == "Right" then
SetTextRightJustify(true)
end
end
if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then
if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
SetTextWrap(X - ((WordWrap / 1920) / 2), X + ((WordWrap / 1920) / 2))
elseif Alignment == 2 or Alignment == "Right" then
SetTextWrap(0, X)
else
SetTextWrap(X, X + (WordWrap / 1920))
end
else
if Alignment == 2 or Alignment == "Right" then
SetTextWrap(0, X)
end
end
BeginTextCommandLineCount("CELL_EMAIL_BCON")
AddText(Text)
return GetTextScreenLineCount(X, Y)
end
---RenderText
---
--- Reference : https://github.com/iTexZoz/NativeUILua_Reloaded/blob/master/UIElements/UIResText.lua#L189
---
---@param Text string
---@param X number
---@param Y number
---@param Font number
---@param Scale number
---@param R number
---@param G number
---@param B number
---@param A number
---@param Alignment string
---@param DropShadow boolean
---@param Outline boolean
---@param WordWrap number
---@return nil
---@public
function RenderText(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap)
---@type table
local Text, X, Y = tostring(Text), (tonumber(X) or 0) / 1920, (tonumber(Y) or 0) / 1080
SetTextFont(Font or 0)
SetTextScale(1.0, Scale or 0)
SetTextColour(tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
if DropShadow then
SetTextDropShadow()
end
if Outline then
SetTextOutline()
end
if Alignment ~= nil then
if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
SetTextCentre(true)
elseif Alignment == 2 or Alignment == "Right" then
SetTextRightJustify(true)
end
end
if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then
if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
SetTextWrap(X - ((WordWrap / 1920) / 2), X + ((WordWrap / 1920) / 2))
elseif Alignment == 2 or Alignment == "Right" then
SetTextWrap(0, X)
else
SetTextWrap(X, X + (WordWrap / 1920))
end
else
if Alignment == 2 or Alignment == "Right" then
SetTextWrap(0, X)
end
end
BeginTextCommandDisplayText("CELL_EMAIL_BCON")
AddText(Text)
EndTextCommandDisplayText(X, Y)
end

View File

@ -0,0 +1,64 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@class Visual
Visual = Visual or {};
local function AddLongString(txt)
for i = 100, string.len(txt), 99 do
local sub = string.sub(txt, i, i + 99)
AddTextComponentSubstringPlayerName(sub)
end
end
function Visual.Popup()
end
function Visual.Radar()
end
function Visual.Subtitle(text, time)
ClearPrints()
BeginTextCommandPrint("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandPrint(time and math.ceil(time) or 0, true)
end
function Visual.FloatingHelpText(text, sound, loop)
BeginTextCommandDisplayHelp("jamyfafi")
AddTextComponentSubstringPlayerName(text)
if string.len(text) > 99 then
AddLongString(text)
end
EndTextCommandDisplayHelp(0, loop or 0, sound or true, -1)
end
function Visual.Prompt(text, spinner)
BeginTextCommandBusyspinnerOn("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandBusyspinnerOn(spinner or 1)
end
function Visual.PromptDuration(duration, text, spinner)
CreateThread(function()
Wait(0)
Visual.Prompt(text, spinner)
Wait(duration)
if (BusyspinnerIsOn()) then
BusyspinnerOff();
end
end)
end

View File

@ -0,0 +1,20 @@
fx_version 'cerulean'
games { 'gta5' };
name 'RageUI';
description 'RageUI, and a project specially created to replace the NativeUILua-Reloaded library. This library allows to create menus similar to the one of Grand Theft Auto online.'
client_scripts {
"RMenu.lua",
"menu/RageUI.lua",
"menu/Menu.lua",
"menu/MenuController.lua",
"components/*.lua",
"menu/elements/*.lua",
"menu/items/*.lua",
"menu/panels/*.lua",
"menu/windows/*.lua",
}

View File

@ -0,0 +1,385 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Dylan Malandain.
--- DateTime: 21/04/2019 21:20
---
---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
---@return RageUIMenus
---@public
function RageUI.CreateMenu(Title, Subtitle, X, Y, TextureDictionary, TextureName, R, G, B, A)
---@type table
local Menu = {}
Menu.Display = {};
Menu.InstructionalButtons = {}
Menu.Display.Header = true;
Menu.Display.Glare = true;
Menu.Display.Subtitle = true;
Menu.Display.Background = true;
Menu.Display.Navigation = true;
Menu.Display.InstructionalButton = true;
Menu.Title = Title or ""
Menu.TitleFont = 6
Menu.TitleScale = 1.0
Menu.Subtitle = string.upper(Subtitle) or nil
Menu.SubtitleHeight = -37
Menu.Description = nil
Menu.DescriptionHeight = RageUI.Settings.Items.Description.Background.Height
Menu.X = X or 0
Menu.Y = Y or 0
Menu.Parent = nil
Menu.WidthOffset = RageUI.UI.Style[RageUI.UI.Current].Width
Menu.Open = false
Menu.Controls = RageUI.Settings.Controls
Menu.Index = 1
Menu.Sprite = { Dictionary = TextureDictionary or "commonmenu", Texture = TextureName or "interaction_bgd", Color = { R = R, G = G, B = B, A = A } }
Menu.Rectangle = nil
Menu.Pagination = { Minimum = 1, Maximum = 10, Total = 10 }
Menu.Safezone = true
Menu.SafeZoneSize = nil
Menu.EnableMouse = false
Menu.Options = 0
Menu.Closable = true
Menu.InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS")
Menu.CursorStyle = 1
if string.starts(Menu.Subtitle, "~") then
Menu.PageCounterColour = string.sub(Menu.Subtitle, 1, 3)
else
Menu.PageCounterColour = ""
end
if Menu.Subtitle ~= "" then
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)
if SubtitleLineCount > 1 then
Menu.SubtitleHeight = 18 * SubtitleLineCount
else
Menu.SubtitleHeight = 0
end
end
CreateThread(function()
if not HasScaleformMovieLoaded(Menu.InstructionalScaleform) then
Menu.InstructionalScaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS")
while not HasScaleformMovieLoaded(Menu.InstructionalScaleform) do
Wait(0)
end
end
end)
CreateThread(function()
local ScaleformMovie = RequestScaleformMovie("MP_MENU_GLARE")
while not HasScaleformMovieLoaded(ScaleformMovie) do
Wait(0)
end
end)
return setmetatable(Menu, RageUI.Menus)
end
---CreateSubMenu
---@param ParentMenu function
---@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
---@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, RageUI.Menus)
else
return nil
end
else
return nil
end
end
function RageUI.Menus:DisplayHeader(boolean)
self.Display.Header = boolean;
return self.Display.Header;
end
function RageUI.Menus:DisplayGlare(boolean)
self.Display.Glare = boolean;
return self.Display.Glare;
end
function RageUI.Menus:DisplaySubtitle(boolean)
self.Display.Subtitle = boolean;
return self.Display.Subtitle;
end
function RageUI.Menus:DisplayNavigation(boolean)
self.Display.Navigation = boolean;
return self.Display.Navigation;
end
function RageUI.Menus:DisplayInstructionalButton(boolean)
self.Display.InstructionalButton = boolean;
return self.Display.InstructionalButton;
end
---SetTitle
---@param Title string
---@return nil
---@public
function RageUI.Menus:SetTitle(Title)
self.Title = Title
end
function RageUI.Menus:SetStyleSize(Value)
local witdh
if Value >= 0 and Value <= 100 then
witdh = Value
else
witdh = 100
end
self.WidthOffset = witdh
end
---GetStyleSize
---@return any
---@public
function RageUI.Menus:GetStyleSize()
if (self.WidthOffset == 100) then
return "RageUI"
elseif (self.WidthOffset == 0) then
return "NativeUI";
else
return self.WidthOffset;
end
end
---SetStyleSize
---@param Int string
---@return void
---@public
function RageUI.Menus:SetCursorStyle(Int)
self.CursorStyle = Int or 1 or 0
SetMouseCursorSprite(Int)
end
---ResetCursorStyle
---@return void
---@public
function RageUI.Menus:ResetCursorStyle()
self.CursorStyle = 1
SetMouseCursorSprite(1)
end
---UpdateCursorStyle
---@return void
---@public
function RageUI.Menus:UpdateCursorStyle()
SetMouseCursorSprite(self.CursorStyle)
end
---RefreshIndex
---@return void
---@public
function RageUI.Menus:RefreshIndex()
self.Index = 1
end
---SetSubtitle
---@param Subtitle string
---@return nil
---@public
function RageUI.Menus:SetSubtitle(Subtitle)
self.Subtitle = string.upper(Subtitle) or string.upper(self.Subtitle)
if string.starts(self.Subtitle, "~") then
self.PageCounterColour = string.sub(self.Subtitle, 1, 3)
else
self.PageCounterColour = ""
end
if self.Subtitle ~= "" then
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)
if SubtitleLineCount > 1 then
self.SubtitleHeight = 18 * SubtitleLineCount
else
self.SubtitleHeight = 0
end
else
self.SubtitleHeight = -37
end
end
---PageCounter
---@param Subtitle string
---@return nil
---@public
function RageUI.Menus:SetPageCounter(Subtitle)
self.PageCounter = Subtitle
end
---EditSpriteColor
---@param Colors table
---@return nil
---@public
function RageUI.Menus:EditSpriteColor(color)
if self.Sprite.Dictionary == "commonmenu" then
self.Sprite.Color = color
end
end
---SetPosition
---@param X number
---@param Y number
---@return nil
---@public
function RageUI.Menus:SetPosition(X, Y)
self.X = tonumber(X) or self.X
self.Y = tonumber(Y) or self.Y
end
---SetTotalItemsPerPage
---@param Value number
---@return nil
---@public
function RageUI.Menus:SetTotalItemsPerPage(Value)
self.Pagination.Total = tonumber(Value) or self.Pagination.Total
end
---SetRectangleBanner
---@param R number
---@param G number
---@param B number
---@param A number
---@return nil
---@public
function RageUI.Menus:SetRectangleBanner(R, G, B, A)
self.Rectangle = { R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255 }
self.Sprite = nil
end
---SetSpriteBanner
---@param TextureDictionary string
---@param Texture string
---@return nil
---@public
function RageUI.Menus:SetSpriteBanner(TextureDictionary, Texture)
self.Sprite = { Dictionary = TextureDictionary or "commonmenu", Texture = Texture or "interaction_bgd" }
self.Rectangle = nil
end
function RageUI.Menus:Closable(boolean)
if type(boolean) == "boolean" then
self.Closable = boolean
else
error("Type is not boolean")
end
end
function RageUI.Menus:AddInstructionButton(button)
if type(button) == "table" and #button == 2 then
table.insert(self.InstructionalButtons, button)
self.UpdateInstructionalButtons(true);
end
end
function RageUI.Menus:RemoveInstructionButton(button)
if type(button) == "table" then
for i = 1, #self.InstructionalButtons do
if button == self.InstructionalButtons[i] then
table.remove(self.InstructionalButtons, i)
self.UpdateInstructionalButtons(true);
break
end
end
else
if tonumber(button) then
if self.InstructionalButtons[tonumber(button)] then
table.remove(self.InstructionalButtons, tonumber(button))
self.UpdateInstructionalButtons(true);
end
end
end
end
function RageUI.Menus:UpdateInstructionalButtons(Visible)
if not Visible then
return
end
BeginScaleformMovieMethod(self.InstructionalScaleform, "CLEAR_ALL")
EndScaleformMovieMethod()
BeginScaleformMovieMethod(self.InstructionalScaleform, "TOGGLE_MOUSE_BUTTONS")
ScaleformMovieMethodAddParamInt(0)
EndScaleformMovieMethod()
BeginScaleformMovieMethod(self.InstructionalScaleform, "CREATE_CONTAINER")
EndScaleformMovieMethod()
BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT")
ScaleformMovieMethodAddParamInt(0)
PushScaleformMovieMethodParameterButtonName(GetControlInstructionalButton(2, 176, 0))
PushScaleformMovieMethodParameterString(GetLabelText("HUD_INPUT2"))
EndScaleformMovieMethod()
if self.Closable then
BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT")
ScaleformMovieMethodAddParamInt(1)
PushScaleformMovieMethodParameterButtonName(GetControlInstructionalButton(2, 177, 0))
PushScaleformMovieMethodParameterString(GetLabelText("HUD_INPUT3"))
EndScaleformMovieMethod()
end
local count = 2
if (self.InstructionalButtons ~= nil) then
for i = 1, #self.InstructionalButtons do
if self.InstructionalButtons[i] then
if #self.InstructionalButtons[i] == 2 then
BeginScaleformMovieMethod(self.InstructionalScaleform, "SET_DATA_SLOT")
ScaleformMovieMethodAddParamInt(count)
PushScaleformMovieMethodParameterButtonName(self.InstructionalButtons[i][1])
PushScaleformMovieMethodParameterString(self.InstructionalButtons[i][2])
EndScaleformMovieMethod()
count = count + 1
end
end
end
end
BeginScaleformMovieMethod(self.InstructionalScaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
ScaleformMovieMethodAddParamInt(-1)
EndScaleformMovieMethod()
end

View File

@ -0,0 +1,350 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
RageUI.LastControl = false
local ControlActions = {
'Left',
'Right',
'Select',
'Click',
}
---GoUp
---@param Options number
---@return nil
---@public
function RageUI.GoUp(Options)
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
Options = CurrentMenu.Options
if CurrentMenu() then
if (Options ~= 0) then
if Options > CurrentMenu.Pagination.Total then
if CurrentMenu.Index <= CurrentMenu.Pagination.Minimum then
if CurrentMenu.Index == 1 then
CurrentMenu.Pagination.Minimum = Options - (CurrentMenu.Pagination.Total - 1)
CurrentMenu.Pagination.Maximum = Options
CurrentMenu.Index = Options
else
CurrentMenu.Pagination.Minimum = (CurrentMenu.Pagination.Minimum - 1)
CurrentMenu.Pagination.Maximum = (CurrentMenu.Pagination.Maximum - 1)
CurrentMenu.Index = CurrentMenu.Index - 1
end
else
CurrentMenu.Index = CurrentMenu.Index - 1
end
else
if CurrentMenu.Index == 1 then
CurrentMenu.Pagination.Minimum = Options - (CurrentMenu.Pagination.Total - 1)
CurrentMenu.Pagination.Maximum = Options
CurrentMenu.Index = Options
else
CurrentMenu.Index = CurrentMenu.Index - 1
end
end
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].UpDown.audioName, Audio[Audio.Use].UpDown.audioRef)
RageUI.LastControl = true
if (CurrentMenu.onIndexChange ~= nil) then
CreateThread(function()
CurrentMenu.onIndexChange(CurrentMenu.Index)
end)
end
else
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Error.audioName, Audio[Audio.Use].Error.audioRef)
end
end
end
end
---GoDown
---@param Options number
---@return nil
---@public
function RageUI.GoDown(Options)
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
Options = CurrentMenu.Options
if CurrentMenu() then
if (Options ~= 0) then
if Options > CurrentMenu.Pagination.Total then
if CurrentMenu.Index >= CurrentMenu.Pagination.Maximum then
if CurrentMenu.Index == Options then
CurrentMenu.Pagination.Minimum = 1
CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total
CurrentMenu.Index = 1
else
CurrentMenu.Pagination.Maximum = (CurrentMenu.Pagination.Maximum + 1)
CurrentMenu.Pagination.Minimum = CurrentMenu.Pagination.Maximum - (CurrentMenu.Pagination.Total - 1)
CurrentMenu.Index = CurrentMenu.Index + 1
end
else
CurrentMenu.Index = CurrentMenu.Index + 1
end
else
if CurrentMenu.Index == Options then
CurrentMenu.Pagination.Minimum = 1
CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total
CurrentMenu.Index = 1
else
CurrentMenu.Index = CurrentMenu.Index + 1
end
end
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].UpDown.audioName, Audio[Audio.Use].UpDown.audioRef)
RageUI.LastControl = false
if (CurrentMenu.onIndexChange ~= nil) then
CreateThread(function()
CurrentMenu.onIndexChange(CurrentMenu.Index)
end)
end
else
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Error.audioName, Audio[Audio.Use].Error.audioRef)
end
end
end
end
function RageUI.GoActionControl(Controls, Action)
if Controls[Action or 'Left'].Enabled then
for Index = 1, #Controls[Action or 'Left'].Keys do
if not Controls[Action or 'Left'].Pressed then
if IsDisabledControlJustPressed(Controls[Action or 'Left'].Keys[Index][1], Controls[Action or 'Left'].Keys[Index][2]) then
Controls[Action or 'Left'].Pressed = true
CreateThread(function()
Controls[Action or 'Left'].Active = true
Wait(0.01)
Controls[Action or 'Left'].Active = false
Wait(175)
while Controls[Action or 'Left'].Enabled and IsDisabledControlPressed(Controls[Action or 'Left'].Keys[Index][1], Controls[Action or 'Left'].Keys[Index][2]) do
Controls[Action or 'Left'].Active = true
Wait(1)
Controls[Action or 'Left'].Active = false
Wait(124)
end
Controls[Action or 'Left'].Pressed = false
if (Action ~= ControlActions[5]) then
Wait(10)
end
end)
break
end
end
end
end
end
function RageUI.GoActionControlSlider(Controls, Action)
if Controls[Action].Enabled then
for Index = 1, #Controls[Action].Keys do
if not Controls[Action].Pressed then
if IsDisabledControlJustPressed(Controls[Action].Keys[Index][1], Controls[Action].Keys[Index][2]) then
Controls[Action].Pressed = true
CreateThread(function()
Controls[Action].Active = true
Wait(1)
Controls[Action].Active = false
while Controls[Action].Enabled and IsDisabledControlPressed(Controls[Action].Keys[Index][1], Controls[Action].Keys[Index][2]) do
Controls[Action].Active = true
Wait(1)
Controls[Action].Active = false
end
Controls[Action].Pressed = false
end)
break
end
end
end
end
end
---Controls
---@return nil
---@public
function RageUI.Controls()
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
if CurrentMenu.Open then
local Controls = CurrentMenu.Controls;
---@type number
local Options = CurrentMenu.Options
RageUI.Options = CurrentMenu.Options
if CurrentMenu.EnableMouse then
DisableAllControlActions(2)
end
if not IsInputDisabled(2) then
for Index = 1, #Controls.Enabled.Controller do
EnableControlAction(Controls.Enabled.Controller[Index][1], Controls.Enabled.Controller[Index][2], true)
end
else
for Index = 1, #Controls.Enabled.Keyboard do
EnableControlAction(Controls.Enabled.Keyboard[Index][1], Controls.Enabled.Keyboard[Index][2], true)
end
end
if Controls.Up.Enabled then
for Index = 1, #Controls.Up.Keys do
if not Controls.Up.Pressed then
if IsDisabledControlJustPressed(Controls.Up.Keys[Index][1], Controls.Up.Keys[Index][2]) then
Controls.Up.Pressed = true
CreateThread(function()
RageUI.GoUp(Options)
Wait(175)
while Controls.Up.Enabled and IsDisabledControlPressed(Controls.Up.Keys[Index][1], Controls.Up.Keys[Index][2]) do
RageUI.GoUp(Options)
Wait(50)
end
Controls.Up.Pressed = false
end)
break
end
end
end
end
if Controls.Down.Enabled then
for Index = 1, #Controls.Down.Keys do
if not Controls.Down.Pressed then
if IsDisabledControlJustPressed(Controls.Down.Keys[Index][1], Controls.Down.Keys[Index][2]) then
Controls.Down.Pressed = true
CreateThread(function()
RageUI.GoDown(Options)
Wait(175)
while Controls.Down.Enabled and IsDisabledControlPressed(Controls.Down.Keys[Index][1], Controls.Down.Keys[Index][2]) do
RageUI.GoDown(Options)
Wait(50)
end
Controls.Down.Pressed = false
end)
break
end
end
end
end
for i = 1, #ControlActions do
RageUI.GoActionControl(Controls, ControlActions[i])
end
RageUI.GoActionControlSlider(Controls, 'SliderLeft')
RageUI.GoActionControlSlider(Controls, 'SliderRight')
if Controls.Back.Enabled then
for Index = 1, #Controls.Back.Keys do
if not Controls.Back.Pressed then
if IsDisabledControlJustPressed(Controls.Back.Keys[Index][1], Controls.Back.Keys[Index][2]) then
Controls.Back.Pressed = true
Wait(10)
break
end
end
end
end
end
end
end
end
---Navigation
---@return nil
---@public
function RageUI.Navigation()
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() and (CurrentMenu.Display.Navigation) then
if CurrentMenu.EnableMouse then
SetMouseCursorActiveThisFrame()
end
if RageUI.Options > CurrentMenu.Pagination.Total then
---@type boolean
local UpHovered = false
---@type boolean
local DownHovered = false
if not CurrentMenu.SafeZoneSize then
CurrentMenu.SafeZoneSize = { X = 0, Y = 0 }
if CurrentMenu.Safezone then
CurrentMenu.SafeZoneSize = RageUI.GetSafeZoneBounds()
SetScriptGfxAlign(76, 84)
SetScriptGfxAlignParams(0, 0, 0, 0)
end
end
if CurrentMenu.EnableMouse then
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)
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)
if CurrentMenu.Controls.Click.Active then
if UpHovered then
RageUI.GoUp(RageUI.Options)
elseif DownHovered then
RageUI.GoDown(RageUI.Options)
end
end
if UpHovered then
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)
else
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)
end
if DownHovered then
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)
else
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)
end
else
RenderRectangle(CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + RageUI.Settings.Items.Navigation.Rectangle.Y, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200)
RenderRectangle(CurrentMenu.X, CurrentMenu.Y + RageUI.Settings.Items.Navigation.Rectangle.Height + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + RageUI.Settings.Items.Navigation.Rectangle.Y, RageUI.Settings.Items.Navigation.Rectangle.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Navigation.Rectangle.Height, 0, 0, 0, 200)
end
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)
RageUI.ItemOffset = RageUI.ItemOffset + (RageUI.Settings.Items.Navigation.Rectangle.Height * 2)
end
end
end
end
---GoBack
---@return nil
---@public
function RageUI.GoBack()
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Back.audioName, Audio[Audio.Use].Back.audioRef)
if CurrentMenu.Parent ~= nil then
if CurrentMenu.Parent() then
RageUI.NextMenu = CurrentMenu.Parent
else
RageUI.NextMenu = nil
RageUI.Visible(CurrentMenu, false)
end
else
RageUI.NextMenu = nil
RageUI.Visible(CurrentMenu, false)
end
end
end

View File

@ -0,0 +1,618 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
function math.round(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end
function string.starts(String, Start)
return string.sub(String, 1, string.len(Start)) == Start
end
---@class RageUIMenus
RageUI.Menus = setmetatable({}, RageUI.Menus)
---@type table
---@return boolean
RageUI.Menus.__call = function()
return true
end
---@type table
RageUI.Menus.__index = RageUI.Menus
---@type table
RageUI.CurrentMenu = nil
---@type table
RageUI.NextMenu = nil
---@type number
RageUI.Options = 0
---@type number
RageUI.ItemOffset = 0
---@type number
RageUI.StatisticPanelCount = 0
---@class UISize
RageUI.UI = {
Current = "NativeUI",
Style = {
RageUI = {
Width = 0
},
NativeUI = {
Width = 0
}
}
}
---@class Settings
RageUI.Settings = {
Debug = false,
Controls = {
Up = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 172 },
{ 1, 172 },
{ 2, 172 },
{ 0, 241 },
{ 1, 241 },
{ 2, 241 },
},
},
Down = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 173 },
{ 1, 173 },
{ 2, 173 },
{ 0, 242 },
{ 1, 242 },
{ 2, 242 },
},
},
Left = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 174 },
{ 1, 174 },
{ 2, 174 },
},
},
Right = {
Enabled = true,
Pressed = false,
Active = false,
Keys = {
{ 0, 175 },
{ 1, 175 },
{ 2, 175 },
},
},
SliderLeft = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 174 },
{ 1, 174 },
{ 2, 174 },
},
},
SliderRight = {
Enabled = true,
Pressed = false,
Active = false,
Keys = {
{ 0, 175 },
{ 1, 175 },
{ 2, 175 },
},
},
Select = {
Enabled = true,
Pressed = false,
Active = false,
Keys = {
{ 0, 201 },
{ 1, 201 },
{ 2, 201 },
},
},
Back = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 177 },
{ 1, 177 },
{ 2, 177 },
{ 0, 199 },
{ 1, 199 },
{ 2, 199 },
},
},
Click = {
Enabled = true,
Active = false,
Pressed = false,
Keys = {
{ 0, 24 },
},
},
Enabled = {
Controller = {
{ 0, 2 }, -- Look Up and Down
{ 0, 1 }, -- Look Left and Right
{ 0, 25 }, -- Aim
{ 0, 24 }, -- Attack
},
Keyboard = {
{ 0, 201 }, -- Select
{ 0, 195 }, -- X axis
{ 0, 196 }, -- Y axis
{ 0, 187 }, -- Down
{ 0, 188 }, -- Up
{ 0, 189 }, -- Left
{ 0, 190 }, -- Right
{ 0, 202 }, -- Back
{ 0, 217 }, -- Select
{ 0, 242 }, -- Scroll down
{ 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
},
},
},
Audio = {
Id = nil,
Use = "NativeUI",
RageUI = {
UpDown = {
audioName = "HUD_FREEMODE_SOUNDSET",
audioRef = "NAV_UP_DOWN",
},
LeftRight = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "NAV_LEFT_RIGHT",
},
Select = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "SELECT",
},
Back = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "BACK",
},
Error = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "ERROR",
},
Slider = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "CONTINUOUS_SLIDER",
Id = nil
},
},
NativeUI = {
UpDown = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "NAV_UP_DOWN",
},
LeftRight = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "NAV_LEFT_RIGHT",
},
Select = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "SELECT",
},
Back = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "BACK",
},
Error = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "ERROR",
},
Slider = {
audioName = "HUD_FRONTEND_DEFAULT_SOUNDSET",
audioRef = "CONTINUOUS_SLIDER",
Id = nil
},
}
},
Items = {
Title = {
Background = { Width = 431, Height = 107 },
Text = { X = 215, Y = 20, Scale = 1.15 },
},
Subtitle = {
Background = { Width = 431, Height = 37 },
Text = { X = 8, Y = 3, Scale = 0.35 },
PreText = { X = 425, Y = 3, Scale = 0.35 },
},
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 0, Width = 431 },
Navigation = {
Rectangle = { Y = 4, Width = 431, Height = 18 },
Offset = 5,
Arrows = { Dictionary = "commonmenu", Texture = "shop_arrows_upanddown", X = 190, Y = 0, Width = 45, Height = 45 },
},
Description = {
Bar = { Y = 8, Width = 431, Height = 4 },
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 8, Width = 431, Height = 30 },
Text = { X = 8, Y = 10, Scale = 0.35 },
},
},
Panels = {
Grid = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 275 },
Grid = { Dictionary = "pause_menu_pages_char_mom_dad", Texture = "nose_grid", X = 115.5, Y = 47.5, Width = 200, Height = 200 },
Circle = { Dictionary = "mpinventory", Texture = "in_world_circle", X = 115.5, Y = 47.5, Width = 20, Height = 20 },
Text = {
Top = { X = 215.5, Y = 15, Scale = 0.35 },
Bottom = { X = 215.5, Y = 250, Scale = 0.35 },
Left = { X = 57.75, Y = 130, Scale = 0.35 },
Right = { X = 373.25, Y = 130, Scale = 0.35 },
},
},
Percentage = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 76 },
Bar = { X = 9, Y = 50, Width = 413, Height = 10 },
Text = {
Left = { X = 25, Y = 15, Scale = 0.35 },
Middle = { X = 215.5, Y = 15, Scale = 0.35 },
Right = { X = 398, Y = 15, Scale = 0.35 },
},
},
},
}
function RageUI.SetScaleformParams(scaleform, data)
data = data or {}
for k, v in pairs(data) do
PushScaleformMovieFunction(scaleform, v.name)
if v.param then
for _, par in pairs(v.param) do
if math.type(par) == "integer" then
PushScaleformMovieFunctionParameterInt(par)
elseif type(par) == "boolean" then
PushScaleformMovieFunctionParameterBool(par)
elseif math.type(par) == "float" then
PushScaleformMovieFunctionParameterFloat(par)
elseif type(par) == "string" then
PushScaleformMovieFunctionParameterString(par)
end
end
end
if v.func then
v.func()
end
PopScaleformMovieFunctionVoid()
end
end
function RageUI.IsMouseInBounds(X, Y, Width, Height)
local MX, MY = math.round(GetControlNormal(2, 239) * 1920) / 1920, math.round(GetControlNormal(2, 240) * 1080) / 1080
X, Y = X / 1920, Y / 1080
Width, Height = Width / 1920, Height / 1080
return (MX >= X and MX <= X + Width) and (MY > Y and MY < Y + Height)
end
function RageUI.GetSafeZoneBounds()
local SafeSize = GetSafeZoneSize()
SafeSize = math.round(SafeSize, 2)
SafeSize = (SafeSize * 100) - 90
SafeSize = 10 - SafeSize
local W, H = 1920, 1080
return { X = math.round(SafeSize * ((W / H) * 5.4)), Y = math.round(SafeSize * 5.4) }
end
function RageUI.Visible(Menu, Value)
if Menu ~= nil and Menu() then
if Value == true or Value == false then
if Value then
if RageUI.CurrentMenu ~= nil then
if RageUI.CurrentMenu.Closed ~= nil then
RageUI.CurrentMenu.Closed()
end
RageUI.CurrentMenu.Open = not Value
Menu:UpdateInstructionalButtons(Value);
Menu:UpdateCursorStyle();
end
RageUI.CurrentMenu = Menu
else
RageUI.CurrentMenu = nil
end
Menu.Open = Value
RageUI.Options = 0
RageUI.ItemOffset = 0
RageUI.LastControl = false
else
return Menu.Open
end
end
end
function RageUI.CloseAll()
if RageUI.CurrentMenu ~= nil then
local parent = RageUI.CurrentMenu.Parent
while parent ~= nil do
parent.Index = 1
parent.Pagination.Minimum = 1
parent.Pagination.Maximum = parent.Pagination.Total
parent = parent.Parent
end
RageUI.CurrentMenu.Index = 1
RageUI.CurrentMenu.Pagination.Minimum = 1
RageUI.CurrentMenu.Pagination.Maximum = RageUI.CurrentMenu.Pagination.Total
RageUI.CurrentMenu.Open = false
RageUI.CurrentMenu = nil
end
RageUI.Options = 0
RageUI.ItemOffset = 0
ResetScriptGfxAlign()
end
function RageUI.Banner()
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and (CurrentMenu.Display.Header) then
RageUI.ItemsSafeZone(CurrentMenu)
if CurrentMenu.Sprite.Dictionary then
RenderSprite(CurrentMenu.Sprite.Dictionary, CurrentMenu.Sprite.Texture, CurrentMenu.X, CurrentMenu.Y, RageUI.Settings.Items.Title.Background.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Title.Background.Height, nil)
else
RenderRectangle(CurrentMenu.X, CurrentMenu.Y, RageUI.Settings.Items.Title.Background.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Title.Background.Height, CurrentMenu.Rectangle.R, CurrentMenu.Rectangle.G, CurrentMenu.Rectangle.B, CurrentMenu.Rectangle.A)
end
if (CurrentMenu.Display.Glare) then
local ScaleformMovie = RequestScaleformMovie("MP_MENU_GLARE")
---@type number
local Glarewidth = RageUI.Settings.Items.Title.Background.Width
---@type number
local Glareheight = RageUI.Settings.Items.Title.Background.Height
---@type number
local GlareX = CurrentMenu.X / 1920 + (CurrentMenu.SafeZoneSize.X / (64.399 - (CurrentMenu.WidthOffset * 0.065731)))
---@type number
local GlareY = CurrentMenu.Y / 1080 + CurrentMenu.SafeZoneSize.Y / 33.195020746888
RageUI.SetScaleformParams(ScaleformMovie, {
{ name = "SET_DATA_SLOT", param = { GetGameplayCamRelativeHeading() } }
})
DrawScaleformMovie(ScaleformMovie, GlareX, GlareY, Glarewidth / 430, Glareheight / 100, 255, 255, 255, 255, 0)
end
RenderText(CurrentMenu.Title, CurrentMenu.X + RageUI.Settings.Items.Title.Text.X + (CurrentMenu.WidthOffset / 2), CurrentMenu.Y + RageUI.Settings.Items.Title.Text.Y, CurrentMenu.TitleFont, CurrentMenu.TitleScale, 255, 255, 255, 255, 1)
RageUI.ItemOffset = RageUI.ItemOffset + RageUI.Settings.Items.Title.Background.Height
end
end
end
function RageUI.Subtitle()
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and (CurrentMenu.Display.Subtitle) then
RageUI.ItemsSafeZone(CurrentMenu)
if CurrentMenu.Subtitle ~= "" then
RenderRectangle(CurrentMenu.X, CurrentMenu.Y + RageUI.ItemOffset, RageUI.Settings.Items.Subtitle.Background.Width + CurrentMenu.WidthOffset, RageUI.Settings.Items.Subtitle.Background.Height + CurrentMenu.SubtitleHeight, 0, 0, 0, 255)
RenderText(CurrentMenu.Subtitle, CurrentMenu.X + RageUI.Settings.Items.Subtitle.Text.X, CurrentMenu.Y + RageUI.Settings.Items.Subtitle.Text.Y + RageUI.ItemOffset, 0, RageUI.Settings.Items.Subtitle.Text.Scale, 245, 245, 245, 255, nil, false, false, RageUI.Settings.Items.Subtitle.Background.Width + CurrentMenu.WidthOffset)
if CurrentMenu.Index > CurrentMenu.Options or CurrentMenu.Index < 0 then
CurrentMenu.Index = 1
end
if (CurrentMenu ~= nil) then
if (CurrentMenu.Index > CurrentMenu.Pagination.Total) then
local offset = CurrentMenu.Index - CurrentMenu.Pagination.Total
CurrentMenu.Pagination.Minimum = 1 + offset
CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total + offset
else
CurrentMenu.Pagination.Minimum = 1
CurrentMenu.Pagination.Maximum = CurrentMenu.Pagination.Total
end
end
if CurrentMenu.PageCounter == nil then
RenderText(CurrentMenu.PageCounterColour .. CurrentMenu.Index .. " / " .. CurrentMenu.Options, CurrentMenu.X + RageUI.Settings.Items.Subtitle.PreText.X + CurrentMenu.WidthOffset, CurrentMenu.Y + RageUI.Settings.Items.Subtitle.PreText.Y + RageUI.ItemOffset, 0, RageUI.Settings.Items.Subtitle.PreText.Scale, 245, 245, 245, 255, 2)
else
RenderText(CurrentMenu.PageCounter, CurrentMenu.X + RageUI.Settings.Items.Subtitle.PreText.X + CurrentMenu.WidthOffset, CurrentMenu.Y + RageUI.Settings.Items.Subtitle.PreText.Y + RageUI.ItemOffset, 0, RageUI.Settings.Items.Subtitle.PreText.Scale, 245, 245, 245, 255, 2)
end
RageUI.ItemOffset = RageUI.ItemOffset + RageUI.Settings.Items.Subtitle.Background.Height
end
end
end
end
function RageUI.Background()
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() and (CurrentMenu.Display.Background) then
RageUI.ItemsSafeZone(CurrentMenu)
SetScriptGfxDrawOrder(0)
RenderSprite(RageUI.Settings.Items.Background.Dictionary, RageUI.Settings.Items.Background.Texture, CurrentMenu.X, CurrentMenu.Y + RageUI.Settings.Items.Background.Y + CurrentMenu.SubtitleHeight, RageUI.Settings.Items.Background.Width + CurrentMenu.WidthOffset, RageUI.ItemOffset, 0, 0, 0, 0, 255)
SetScriptGfxDrawOrder(1)
end
end
end
function RageUI.Description()
local CurrentMenu = RageUI.CurrentMenu;
local Description = RageUI.Settings.Items.Description;
if CurrentMenu ~= nil and CurrentMenu.Description ~= nil then
if CurrentMenu() then
RageUI.ItemsSafeZone(CurrentMenu)
RenderRectangle(CurrentMenu.X, CurrentMenu.Y + Description.Bar.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Description.Bar.Width + CurrentMenu.WidthOffset, Description.Bar.Height, 0, 0, 0, 255)
RenderSprite(Description.Background.Dictionary, Description.Background.Texture, CurrentMenu.X, CurrentMenu.Y + Description.Background.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Description.Background.Width + CurrentMenu.WidthOffset, CurrentMenu.DescriptionHeight, 0, 0, 0, 255)
RenderText(CurrentMenu.Description, CurrentMenu.X + Description.Text.X, CurrentMenu.Y + Description.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, Description.Text.Scale, 255, 255, 255, 255, nil, false, false, Description.Background.Width + CurrentMenu.WidthOffset - 8.0)
RageUI.ItemOffset = RageUI.ItemOffset + CurrentMenu.DescriptionHeight + Description.Bar.Y
end
end
end
function RageUI.Render()
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
if CurrentMenu.Safezone then
ResetScriptGfxAlign()
end
if (CurrentMenu.Display.InstructionalButton) then
if not CurrentMenu.InitScaleform then
CurrentMenu:UpdateInstructionalButtons(true)
CurrentMenu.InitScaleform = true
end
DrawScaleformMovieFullscreen(CurrentMenu.InstructionalScaleform, 255, 255, 255, 255, 0)
end
CurrentMenu.Options = RageUI.Options
CurrentMenu.SafeZoneSize = nil
RageUI.Controls()
RageUI.Options = 0
RageUI.StatisticPanelCount = 0
RageUI.ItemOffset = 0
if CurrentMenu.Controls.Back.Enabled and CurrentMenu.Closable then
if CurrentMenu.Controls.Back.Pressed then
CurrentMenu.Controls.Back.Pressed = false
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Back.audioName, Audio[Audio.Use].Back.audioRef)
if CurrentMenu.Closed ~= nil then
collectgarbage()
CurrentMenu.Closed()
end
if CurrentMenu.Parent ~= nil then
if CurrentMenu.Parent() then
RageUI.NextMenu = CurrentMenu.Parent
CurrentMenu:UpdateCursorStyle()
else
RageUI.NextMenu = nil
RageUI.Visible(CurrentMenu, false)
end
else
RageUI.NextMenu = nil
RageUI.Visible(CurrentMenu, false)
end
end
end
if RageUI.NextMenu ~= nil then
if RageUI.NextMenu() then
RageUI.Visible(CurrentMenu, false)
RageUI.Visible(RageUI.NextMenu, true)
CurrentMenu.Controls.Select.Active = false
RageUI.NextMenu = nil
RageUI.LastControl = false
end
end
end
end
end
function RageUI.ItemsDescription(CurrentMenu, Description, Selected)
---@type table
if Description ~= "" or Description ~= nil then
local SettingsDescription = RageUI.Settings.Items.Description;
if Selected and CurrentMenu.Description ~= Description then
CurrentMenu.Description = Description or nil
---@type number
local DescriptionLineCount = GetLineCount(CurrentMenu.Description, CurrentMenu.X + SettingsDescription.Text.X, CurrentMenu.Y + SettingsDescription.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsDescription.Text.Scale, 255, 255, 255, 255, nil, false, false, SettingsDescription.Background.Width + (CurrentMenu.WidthOffset - 5.0))
if DescriptionLineCount > 1 then
CurrentMenu.DescriptionHeight = SettingsDescription.Background.Height * DescriptionLineCount
else
CurrentMenu.DescriptionHeight = SettingsDescription.Background.Height + 7
end
end
end
end
function RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton)
---@type boolean
local Hovered = false
Hovered = RageUI.IsMouseInBounds(CurrentMenu.X + CurrentMenu.SafeZoneSize.X, CurrentMenu.Y + SettingsButton.Rectangle.Y + CurrentMenu.SafeZoneSize.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.Rectangle.Width + CurrentMenu.WidthOffset, SettingsButton.Rectangle.Height)
if Hovered and not Selected then
RenderRectangle(CurrentMenu.X, CurrentMenu.Y + SettingsButton.Rectangle.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.Rectangle.Width + CurrentMenu.WidthOffset, SettingsButton.Rectangle.Height, 255, 255, 255, 20)
if CurrentMenu.Controls.Click.Active then
CurrentMenu.Index = Option
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Error.audioName, Audio[Audio.Use].Error.audioRef)
end
end
return Hovered;
end
function RageUI.ItemsSafeZone(CurrentMenu)
if not CurrentMenu.SafeZoneSize then
CurrentMenu.SafeZoneSize = { X = 0, Y = 0 }
if CurrentMenu.Safezone then
CurrentMenu.SafeZoneSize = RageUI.GetSafeZoneBounds()
SetScriptGfxAlign(76, 84)
SetScriptGfxAlignParams(0, 0, 0, 0)
end
end
end
function RageUI.CurrentIsEqualTo(Current, To, Style, DefaultStyle)
return Current == To and Style or DefaultStyle or {};
end
function RageUI.IsVisible(Menu, Items, Panels)
if (RageUI.Visible(Menu)) and (UpdateOnscreenKeyboard() ~= 0) and (UpdateOnscreenKeyboard() ~= 3) then
RageUI.Banner()
RageUI.Subtitle()
if (Items ~= nil) then
Items()
end
RageUI.Background();
RageUI.Navigation();
RageUI.Description();
if (Panels ~= nil) then
Panels()
end
RageUI.Render()
end
end
---SetStyleAudio
---@param StyleAudio string
---@return void
---@public
function RageUI.SetStyleAudio(StyleAudio)
RageUI.Settings.Audio.Use = StyleAudio or "RageUI"
end
function RageUI.GetStyleAudio()
return RageUI.Settings.Audio.Use or "RageUI"
end

View File

@ -0,0 +1,286 @@
RageUI.BadgeStyle = {
-- DEFAULT BADGE
None = function()
return {
BadgeTexture = "",
BadgeDictionary = "commonmenu"
}
end,
BronzeMedal = function()
return {
BadgeTexture = "mp_medal_bronze",
}
end,
GoldMedal = function()
return {
BadgeTexture = "mp_medal_gold",
}
end,
SilverMedal = function()
return {
BadgeTexture = "medal_silver",
}
end,
Alert = function()
return {
BadgeTexture = "mp_alerttriangle",
}
end,
Crown = function(Selected)
return {
BadgeTexture = "mp_hostcrown",
BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 }
}
end,
Ammo = function(Selected)
return {
BadgeTexture = Selected and "shop_ammo_icon_b" or "shop_ammo_icon_a",
}
end,
Armour = function(Selected)
return {
BadgeTexture = Selected and "shop_armour_icon_b" or "shop_armour_icon_a",
}
end,
Barber = function(Selected)
return {
BadgeTexture = Selected and "shop_barber_icon_b" or "shop_barber_icon_a",
}
end,
Clothes = function(Selected)
return {
BadgeTexture = Selected and "shop_clothing_icon_b" or "shop_clothing_icon_a",
}
end,
Franklin = function(Selected)
return {
BadgeTexture = Selected and "shop_franklin_icon_b" or "shop_franklin_icon_a",
}
end,
Bike = function(Selected)
return {
BadgeTexture = Selected and "shop_garage_bike_icon_b" or "shop_garage_bike_icon_a",
}
end,
Car = function(Selected)
return {
BadgeTexture = Selected and "shop_garage_icon_b" or "shop_garage_icon_a",
}
end,
Boat = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_boat_black" or "mp_specitem_boat",
BadgeDictionary = "mpinventory"
}
end,
Heli = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_heli_black" or "mp_specitem_heli",
BadgeDictionary = "mpinventory"
}
end,
Plane = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_plane_black" or "mp_specitem_plane",
BadgeDictionary = "mpinventory"
}
end,
BoatPickup = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_boatpickup_black" or "mp_specitem_boatpickup",
BadgeDictionary = "mpinventory"
}
end,
Card = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_keycard_black" or "mp_specitem_keycard",
BadgeDictionary = "mpinventory"
}
end,
Gun = function(Selected)
return {
BadgeTexture = Selected and "shop_gunclub_icon_b" or "shop_gunclub_icon_a",
}
end,
Heart = function(Selected)
return {
BadgeTexture = Selected and "shop_health_icon_b" or "shop_health_icon_a",
}
end,
Makeup = function(Selected)
return {
BadgeTexture = Selected and "shop_makeup_icon_b" or "shop_makeup_icon_a",
}
end,
Mask = function(Selected)
return {
BadgeTexture = Selected and "shop_mask_icon_b" or "shop_mask_icon_a",
}
end,
Michael = function(Selected)
return {
BadgeTexture = Selected and "shop_michael_icon_b" or "shop_michael_icon_a",
}
end,
Star = function()
return {
BadgeTexture = "shop_new_star",
}
end,
Tattoo = function(Selected)
return {
BadgeTexture = Selected and "shop_tattoos_icon_b" or "shop_tattoos_icon_a",
}
end,
Trevor = function(Selected)
return {
BadgeTexture = Selected and "shop_trevor_icon_b" or "shop_trevor_icon_a",
}
end,
Lock = function(Selected)
return {
BadgeTexture = "shop_lock",
BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 }
}
end,
Tick = function(Selected)
return {
BadgeTexture = "shop_tick_icon",
BadgeColour = Selected and { R = 0, G = 0, B = 0, A = 255 } or { R = 255, G = 255, B = 255, A = 255 }
}
end,
Key = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_cuffkeys_black" or "mp_specitem_cuffkeys",
BadgeDictionary = "mpinventory"
}
end,
Coke = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_coke_black" or "mp_specitem_coke",
BadgeDictionary = "mpinventory"
}
end,
Heroin = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_heroin_black" or "mp_specitem_heroin",
BadgeDictionary = "mpinventory"
}
end,
Meth = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_meth_black" or "mp_specitem_meth",
BadgeDictionary = "mpinventory"
}
end,
Weed = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_weed_black" or "mp_specitem_weed",
BadgeDictionary = "mpinventory"
}
end,
Package = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_package_black" or "mp_specitem_package",
BadgeDictionary = "mpinventory"
}
end,
Cash = function(Selected)
return {
BadgeTexture = Selected and "mp_specitem_cash_black" or "mp_specitem_cash",
BadgeDictionary = "mpinventory"
}
end,
RP = function(Selected)
return {
BadgeTexture = "mp_anim_rp",
BadgeDictionary = "mphud"
}
end,
LSPD = function()
return {
BadgeTexture = "mpgroundlogo_cops",
BadgeDictionary = "3dtextures"
}
end,
Vagos = function()
return {
BadgeTexture = "mpgroundlogo_vagos",
BadgeDictionary = "3dtextures"
}
end,
Bikers = function()
return {
BadgeTexture = "mpgroundlogo_bikers",
BadgeDictionary = "3dtextures"
}
end,
-- CASINO
Badbeat = function()
return {
BadgeTexture = "badbeat",
BadgeDictionary = "mpawardcasino"
}
end,
CashingOut = function()
return {
BadgeTexture = "cashingout",
BadgeDictionary = "mpawardcasino"
}
end,
FullHouse = function()
return {
BadgeTexture = "fullhouse",
BadgeDictionary = "mpawardcasino"
}
end,
HighRoller = function()
return {
BadgeTexture = "highroller",
BadgeDictionary = "mpawardcasino"
}
end,
HouseKeeping = function()
return {
BadgeTexture = "housekeeping",
BadgeDictionary = "mpawardcasino"
}
end,
LooseCheng = function()
return {
BadgeTexture = "loosecheng",
BadgeDictionary = "mpawardcasino"
}
end,
LuckyLucky = function()
return {
BadgeTexture = "luckylucky",
BadgeDictionary = "mpawardcasino"
}
end,
PlayToWin = function()
return {
BadgeTexture = "playtowin",
BadgeDictionary = "mpawardcasino"
}
end,
StraightFlush = function()
return {
BadgeTexture = "straightflush",
BadgeDictionary = "mpawardcasino"
}
end,
StrongArmTactics = function()
return {
BadgeTexture = "strongarmtactics",
BadgeDictionary = "mpawardcasino"
}
end,
TopPair = function()
return {
BadgeTexture = "toppair",
BadgeDictionary = "mpawardcasino"
}
end,
}

View File

@ -0,0 +1,225 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Dylan Malandain.
--- DateTime: 24/07/2019 02:26
---
RageUI.ItemsColour = {
PureWhite = { 255, 255, 255, 255 },
White = { 240, 240, 240, 255 },
Black = { 0, 0, 0, 255 },
Grey = { 155, 155, 155, 255 },
GreyLight = { 205, 205, 205, 255 },
GreyDark = { 77, 77, 77, 255 },
Red = { 224, 50, 50, 255 },
RedLight = { 240, 153, 153, 255 },
RedDark = { 112, 25, 25, 255 },
Blue = { 93, 182, 229, 255 },
BlueLight = { 174, 219, 242, 255 },
BlueDark = { 47, 92, 115, 255 },
Yellow = { 240, 200, 80, 255 },
YellowLight = { 254, 235, 169, 255 },
YellowDark = { 126, 107, 41, 255 },
Orange = { 255, 133, 85, 255 },
OrangeLight = { 255, 194, 170, 255 },
OrangeDark = { 127, 66, 42, 255 },
Green = { 114, 204, 114, 255 },
GreenLight = { 185, 230, 185, 255 },
GreenDark = { 57, 102, 57, 255 },
Purple = { 132, 102, 226, 255 },
PurpleLight = { 192, 179, 239, 255 },
PurpleDark = { 67, 57, 111, 255 },
Pink = { 203, 54, 148, 255 },
RadarHealth = { 53, 154, 71, 255 },
RadarArmour = { 93, 182, 229, 255 },
RadarDamage = { 235, 36, 39, 255 },
NetPlayer1 = { 194, 80, 80, 255 },
NetPlayer2 = { 156, 110, 175, 255 },
NetPlayer3 = { 255, 123, 196, 255 },
NetPlayer4 = { 247, 159, 123, 255 },
NetPlayer5 = { 178, 144, 132, 255 },
NetPlayer6 = { 141, 206, 167, 255 },
NetPlayer7 = { 113, 169, 175, 255 },
NetPlayer8 = { 211, 209, 231, 255 },
NetPlayer9 = { 144, 127, 153, 255 },
NetPlayer10 = { 106, 196, 191, 255 },
NetPlayer11 = { 214, 196, 153, 255 },
NetPlayer12 = { 234, 142, 80, 255 },
NetPlayer13 = { 152, 203, 234, 255 },
NetPlayer14 = { 178, 98, 135, 255 },
NetPlayer15 = { 144, 142, 122, 255 },
NetPlayer16 = { 166, 117, 94, 255 },
NetPlayer17 = { 175, 168, 168, 255 },
NetPlayer18 = { 232, 142, 155, 255 },
NetPlayer19 = { 187, 214, 91, 255 },
NetPlayer20 = { 12, 123, 86, 255 },
NetPlayer21 = { 123, 196, 255, 255 },
NetPlayer22 = { 171, 60, 230, 255 },
NetPlayer23 = { 206, 169, 13, 255 },
NetPlayer24 = { 71, 99, 173, 255 },
NetPlayer25 = { 42, 166, 185, 255 },
NetPlayer26 = { 186, 157, 125, 255 },
NetPlayer27 = { 201, 225, 255, 255 },
NetPlayer28 = { 240, 240, 150, 255 },
NetPlayer29 = { 237, 140, 161, 255 },
NetPlayer30 = { 249, 138, 138, 255 },
NetPlayer31 = { 252, 239, 166, 255 },
NetPlayer32 = { 240, 240, 240, 255 },
SimpleBlipDefault = { 159, 201, 166, 255 },
MenuBlue = { 140, 140, 140, 255 },
MenuGreyLight = { 140, 140, 140, 255 },
MenuBlueExtraDark = { 40, 40, 40, 255 },
MenuYellow = { 240, 160, 0, 255 },
MenuYellowDark = { 240, 160, 0, 255 },
MenuGreen = { 240, 160, 0, 255 },
MenuGrey = { 140, 140, 140, 255 },
MenuGreyDark = { 60, 60, 60, 255 },
MenuHighlight = { 30, 30, 30, 255 },
MenuStandard = { 140, 140, 140, 255 },
MenuDimmed = { 75, 75, 75, 255 },
MenuExtraDimmed = { 50, 50, 50, 255 },
BriefTitle = { 95, 95, 95, 255 },
MidGreyMp = { 100, 100, 100, 255 },
NetPlayer1Dark = { 93, 39, 39, 255 },
NetPlayer2Dark = { 77, 55, 89, 255 },
NetPlayer3Dark = { 124, 62, 99, 255 },
NetPlayer4Dark = { 120, 80, 80, 255 },
NetPlayer5Dark = { 87, 72, 66, 255 },
NetPlayer6Dark = { 74, 103, 83, 255 },
NetPlayer7Dark = { 60, 85, 88, 255 },
NetPlayer8Dark = { 105, 105, 64, 255 },
NetPlayer9Dark = { 72, 63, 76, 255 },
NetPlayer10Dark = { 53, 98, 95, 255 },
NetPlayer11Dark = { 107, 98, 76, 255 },
NetPlayer12Dark = { 117, 71, 40, 255 },
NetPlayer13Dark = { 76, 101, 117, 255 },
NetPlayer14Dark = { 65, 35, 47, 255 },
NetPlayer15Dark = { 72, 71, 61, 255 },
NetPlayer16Dark = { 85, 58, 47, 255 },
NetPlayer17Dark = { 87, 84, 84, 255 },
NetPlayer18Dark = { 116, 71, 77, 255 },
NetPlayer19Dark = { 93, 107, 45, 255 },
NetPlayer20Dark = { 6, 61, 43, 255 },
NetPlayer21Dark = { 61, 98, 127, 255 },
NetPlayer22Dark = { 85, 30, 115, 255 },
NetPlayer23Dark = { 103, 84, 6, 255 },
NetPlayer24Dark = { 35, 49, 86, 255 },
NetPlayer25Dark = { 21, 83, 92, 255 },
NetPlayer26Dark = { 93, 98, 62, 255 },
NetPlayer27Dark = { 100, 112, 127, 255 },
NetPlayer28Dark = { 120, 120, 75, 255 },
NetPlayer29Dark = { 152, 76, 93, 255 },
NetPlayer30Dark = { 124, 69, 69, 255 },
NetPlayer31Dark = { 10, 43, 50, 255 },
NetPlayer32Dark = { 95, 95, 10, 255 },
Bronze = { 180, 130, 97, 255 },
Silver = { 150, 153, 161, 255 },
Gold = { 214, 181, 99, 255 },
Platinum = { 166, 221, 190, 255 },
Gang1 = { 29, 100, 153, 255 },
Gang2 = { 214, 116, 15, 255 },
Gang3 = { 135, 125, 142, 255 },
Gang4 = { 229, 119, 185, 255 },
SameCrew = { 252, 239, 166, 255 },
Freemode = { 45, 110, 185, 255 },
PauseBg = { 0, 0, 0, 255 },
Friendly = { 93, 182, 229, 255 },
Enemy = { 194, 80, 80, 255 },
Location = { 240, 200, 80, 255 },
Pickup = { 114, 204, 114, 255 },
PauseSingleplayer = { 114, 204, 114, 255 },
FreemodeDark = { 22, 55, 92, 255 },
InactiveMission = { 154, 154, 154, 255 },
Damage = { 194, 80, 80, 255 },
PinkLight = { 252, 115, 201, 255 },
PmMitemHighlight = { 252, 177, 49, 255 },
ScriptVariable = { 0, 0, 0, 255 },
Yoga = { 109, 247, 204, 255 },
Tennis = { 241, 101, 34, 255 },
Golf = { 214, 189, 97, 255 },
ShootingRange = { 112, 25, 25, 255 },
FlightSchool = { 47, 92, 115, 255 },
NorthBlue = { 93, 182, 229, 255 },
SocialClub = { 234, 153, 28, 255 },
PlatformBlue = { 11, 55, 123, 255 },
PlatformGreen = { 146, 200, 62, 255 },
PlatformGrey = { 234, 153, 28, 255 },
FacebookBlue = { 66, 89, 148, 255 },
IngameBg = { 0, 0, 0, 255 },
Darts = { 114, 204, 114, 255 },
Waypoint = { 164, 76, 242, 255 },
Michael = { 101, 180, 212, 255 },
Franklin = { 171, 237, 171, 255 },
Trevor = { 255, 163, 87, 255 },
GolfP1 = { 240, 240, 240, 255 },
GolfP2 = { 235, 239, 30, 255 },
GolfP3 = { 255, 149, 14, 255 },
GolfP4 = { 246, 60, 161, 255 },
WaypointLight = { 210, 166, 249, 255 },
WaypointDark = { 82, 38, 121, 255 },
PanelLight = { 0, 0, 0, 255 },
MichaelDark = { 72, 103, 116, 255 },
FranklinDark = { 85, 118, 85, 255 },
TrevorDark = { 127, 81, 43, 255 },
ObjectiveRoute = { 240, 200, 80, 255 },
PausemapTint = { 0, 0, 0, 255 },
PauseDeselect = { 100, 100, 100, 255 },
PmWeaponsPurchasable = { 45, 110, 185, 255 },
PmWeaponsLocked = { 240, 240, 240, 255 },
ScreenBg = { 0, 0, 0, 255 },
Chop = { 224, 50, 50, 255 },
PausemapTintHalf = { 0, 0, 0, 255 },
NorthBlueOfficial = { 0, 71, 133, 255 },
ScriptVariable2 = { 0, 0, 0, 255 },
H = { 33, 118, 37, 255 },
HDark = { 37, 102, 40, 255 },
T = { 234, 153, 28, 255 },
TDark = { 225, 140, 8, 255 },
HShard = { 20, 40, 0, 255 },
ControllerMichael = { 48, 255, 255, 255 },
ControllerFranklin = { 48, 255, 0, 255 },
ControllerTrevor = { 176, 80, 0, 255 },
ControllerChop = { 127, 0, 0, 255 },
VideoEditorVideo = { 53, 166, 224, 255 },
VideoEditorAudio = { 162, 79, 157, 255 },
VideoEditorText = { 104, 192, 141, 255 },
HbBlue = { 29, 100, 153, 255 },
HbYellow = { 234, 153, 28, 255 },
VideoEditorScore = { 240, 160, 1, 255 },
VideoEditorAudioFadeout = { 59, 34, 57, 255 },
VideoEditorTextFadeout = { 41, 68, 53, 255 },
VideoEditorScoreFadeout = { 82, 58, 10, 255 },
HeistBackground = { 37, 102, 40, 255 },
VideoEditorAmbient = { 240, 200, 80, 255 },
VideoEditorAmbientFadeout = { 80, 70, 34, 255 },
Gb = { 255, 133, 85, 255 },
G = { 255, 194, 170, 255 },
B = { 255, 133, 85, 255 },
LowFlow = { 240, 200, 80, 255 },
LowFlowDark = { 126, 107, 41, 255 },
G1 = { 247, 159, 123, 255 },
G2 = { 226, 134, 187, 255 },
G3 = { 239, 238, 151, 255 },
G4 = { 113, 169, 175, 255 },
G5 = { 160, 140, 193, 255 },
G6 = { 141, 206, 167, 255 },
G7 = { 181, 214, 234, 255 },
G8 = { 178, 144, 132, 255 },
G9 = { 0, 132, 114, 255 },
G10 = { 216, 85, 117, 255 },
G11 = { 30, 100, 152, 255 },
G12 = { 43, 181, 117, 255 },
G13 = { 233, 141, 79, 255 },
G14 = { 137, 210, 215, 255 },
G15 = { 134, 125, 141, 255 },
Adversary = { 109, 34, 33, 255 },
DegenRed = { 255, 0, 0, 255 },
DegenYellow = { 255, 255, 0, 255 },
DegenGreen = { 0, 255, 0, 255 },
DegenCyan = { 0, 255, 255, 255 },
DegenBlue = { 0, 0, 255, 255 },
DegenMagenta = { 255, 0, 255, 255 },
Stunt1 = { 38, 136, 234, 255 },
Stunt2 = { 224, 50, 50, 255 },
}

View File

@ -0,0 +1,69 @@
RageUI.PanelColour = {
HairCut = {
{ 22, 19, 19 }, -- 0
{ 30, 28, 25 }, -- 1
{ 76, 56, 45 }, -- 2
{ 69, 34, 24 }, -- 3
{ 123, 59, 31 }, -- 4
{ 149, 68, 35 }, -- 5
{ 165, 87, 50 }, -- 6
{ 175, 111, 72 }, -- 7
{ 159, 105, 68 }, -- 8
{ 198, 152, 108 }, -- 9
{ 213, 170, 115 }, -- 10
{ 223, 187, 132 }, -- 11
{ 202, 164, 110 }, -- 12
{ 238, 204, 130 }, -- 13
{ 229, 190, 126 }, -- 14
{ 250, 225, 167 }, -- 15
{ 187, 140, 96 }, -- 16
{ 163, 92, 60 }, -- 17
{ 144, 52, 37 }, -- 18
{ 134, 21, 17 }, -- 19
{ 164, 24, 18 }, -- 20
{ 195, 33, 24 }, -- 21
{ 221, 69, 34 }, -- 22
{ 229, 71, 30 }, -- 23
{ 208, 97, 56 }, -- 24
{ 113, 79, 38 }, -- 25
{ 132, 107, 95 }, -- 26
{ 185, 164, 150 }, -- 27
{ 218, 196, 180 }, -- 28
{ 247, 230, 217 }, -- 29
{ 102, 72, 93 }, -- 30
{ 162, 105, 138 }, -- 31
{ 171, 174, 11 }, -- 32
{ 239, 61, 200 }, -- 33
{ 255, 69, 152 }, -- 34
{ 255, 178, 191 }, -- 35
{ 12, 168, 146 }, -- 36
{ 8, 146, 165 }, -- 37
{ 11, 82, 134 }, -- 38
{ 118, 190, 117 }, -- 39
{ 52, 156, 104 }, -- 40
{ 22, 86, 85 }, -- 41
{ 152, 177, 40 }, -- 42
{ 127, 162, 23 }, -- 43
{ 241, 200, 98 }, -- 44
{ 238, 178, 16 }, -- 45
{ 224, 134, 14 }, -- 46
{ 247, 157, 15 }, -- 47
{ 243, 143, 16 }, -- 48
{ 231, 70, 15 }, -- 49
{ 255, 101, 21 }, -- 50
{ 254, 91, 34 }, -- 51
{ 252, 67, 21 }, -- 52
{ 196, 12, 15 }, -- 53
{ 143, 10, 14 }, -- 54
{ 44, 27, 22 }, -- 55
{ 80, 51, 37 }, -- 56
{ 98, 54, 37 }, -- 57
{ 60, 31, 24 }, -- 58
{ 69, 43, 32 }, -- 59
{ 8, 10, 14 }, -- 60
{ 212, 185, 158 }, -- 61
{ 212, 185, 158 }, -- 62
{ 213, 170, 115 }, -- 63
},
}

View File

@ -0,0 +1,117 @@
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
LeftBadge = { Y = -2, Width = 40, Height = 40 },
RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 },
RightText = { X = 420, Y = 4, Scale = 0.35 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---ButtonWithStyle
---@param Label string
---@param Description string
---@param Style table
---@param Enabled boolean
---@param Callback function
---@param Submenu table
---@return nil
---@public
function RageUI.Button(Label, Description, Style, Enabled, Callback, Submenu)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type boolean
local Selected = CurrentMenu.Index == Option
RageUI.ItemsSafeZone(CurrentMenu)
local LeftBadgeOffset = ((Style.LeftBadge == RageUI.BadgeStyle.None or tonumber(Style.LeftBadge) == nil) and 0 or 27)
local RightBadgeOffset = ((Style.RightBadge == RageUI.BadgeStyle.None or tonumber(Style.RightBadge) == nil) and 0 or 32)
local Hovered = false;
if Style.Color ~= nil then
if Style.Color.BackgroundColor ~= nil then
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])
end
end
---@type boolean
if CurrentMenu.EnableMouse == true then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
if Selected then
if Style.Color == nil then
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)
end
if Style.Color ~= nil and Style.Color.HightLightColor ~= nil then
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])
else
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)
end
end
if type(Style) == 'table' then
if Style.LeftBadge ~= nil then
if Style.LeftBadge ~= RageUI.BadgeStyle.None and tonumber(Style.LeftBadge) ~= nil then
RenderSprite(RageUI.GetBadgeDictionary(Style.LeftBadge, Selected), RageUI.GetBadgeTexture(Style.LeftBadge, Selected), CurrentMenu.X, CurrentMenu.Y + SettingsButton.LeftBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.LeftBadge.Width, SettingsButton.LeftBadge.Height, RageUI.GetBadgeColour(Style.LeftBadge, Selected))
end
end
if Style.RightBadge ~= nil then
if Style.RightBadge ~= RageUI.BadgeStyle.None and tonumber(Style.RightBadge) ~= nil then
RenderSprite(RageUI.GetBadgeDictionary(Style.RightBadge, Selected), RageUI.GetBadgeTexture(Style.RightBadge, Selected), CurrentMenu.X + SettingsButton.RightBadge.X + CurrentMenu.WidthOffset, CurrentMenu.Y + SettingsButton.RightBadge.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, SettingsButton.RightBadge.Width, SettingsButton.RightBadge.Height, 0, RageUI.GetBadgeColour(Style.RightBadge, Selected))
end
end
end
if Enabled == true or Enabled == nil then
if Selected then
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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, Style.RightLabelOpacity or 255, 2)
end
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)
else
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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, Style.RightLabelOpacity or 255, 2)
end
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)
end
else
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)
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected);
if (Enabled) then
if Selected and (CurrentMenu.Controls.Select.Active or (Hovered and CurrentMenu.Controls.Click.Active)) then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
if (Callback.onSelected ~= nil) and (Selected) then
Callback.onSelected();
end
if Submenu ~= nil then
if Submenu() then
RageUI.NextMenu = Submenu
end
end
end
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,183 @@
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
LeftBadge = { Y = -2, Width = 40, Height = 40 },
RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 },
RightText = { X = 420, Y = 4, Scale = 0.35 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---@type table
local SettingsCheckbox = {
Dictionary = "commonmenu", Textures = {
"shop_box_blankb", -- 1
"shop_box_tickb", -- 2
"shop_box_blank", -- 3
"shop_box_tick", -- 4
"shop_box_crossb", -- 5
"shop_box_cross", -- 6
},
X = 380, Y = -6, Width = 50, Height = 50
}
RageUI.CheckboxStyle = {
Tick = 1,
Cross = 2
}
---StyleCheckBox
---@param Selected number
---@param Checked boolean
---@param Box number
---@param BoxSelect number
---@return nil
local function StyleCheckBox(Selected, Checked, Box, BoxSelect, OffSet)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if OffSet == nil then
OffSet = 0
end
if Selected then
if Checked then
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)
else
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)
end
else
if Checked then
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)
else
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)
end
end
end
function RageUI.Checkbox(Label, Description, Checked, Style, Actions)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type number
local Selected = CurrentMenu.Index == Option
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 BoxOffset = 0
RageUI.ItemsSafeZone(CurrentMenu)
local Hovered = false;
---@type boolean
if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
if Selected then
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)
end
if type(Style) == "table" then
if Style.Enabled == true or Style.Enabled == nil then
if Selected then
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)
else
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)
end
if type(Style) == 'table' then
if Style.LeftBadge ~= nil then
if Style.LeftBadge ~= RageUI.BadgeStyle.None then
local BadgeData = Style.LeftBadge(Selected)
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)
end
end
if Style.RightBadge ~= nil then
if Style.RightBadge ~= RageUI.BadgeStyle.None then
local BadgeData = Style.RightBadge(Selected)
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)
end
end
end
else
---@type table
local LeftBadge = RageUI.BadgeStyle.Lock
---@type number
local LeftBadgeOffset = ((LeftBadge == RageUI.BadgeStyle.None or LeftBadge == nil) and 0 or 27)
if Selected then
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)
else
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)
end
if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then
local BadgeData = LeftBadge(Selected)
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)
end
end
if Style.Enabled == true or Style.Enabled == nil then
if Selected then
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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)
BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
end
else
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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)
BoxOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
end
end
end
BoxOffset = RightBadgeOffset + BoxOffset
if Style.Style ~= nil then
if Style.Style == RageUI.CheckboxStyle.Tick then
StyleCheckBox(Selected, Checked, 2, 4, BoxOffset)
elseif Style.Style == RageUI.CheckboxStyle.Cross then
StyleCheckBox(Selected, Checked, 5, 6, BoxOffset)
else
StyleCheckBox(Selected, Checked, 2, 4, BoxOffset)
end
else
StyleCheckBox(Selected, Checked, 2, 4, BoxOffset)
end
if Selected and (CurrentMenu.Controls.Select.Active or (Hovered and CurrentMenu.Controls.Click.Active)) and (Style.Enabled == true or Style.Enabled == nil) then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
Checked = not Checked
if (Checked) then
if (Actions.onChecked ~= nil) then
Actions.onChecked();
end
else
if (Actions.onUnChecked ~= nil) then
Actions.onUnChecked();
end
end
end
else
error("UICheckBox Style is not a `table`")
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected)
if (Actions.onSelected ~= nil) and (Selected) then
Actions.onSelected(Checked);
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,158 @@
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
LeftBadge = { Y = -2, Width = 40, Height = 40 },
RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 },
RightText = { X = 420, Y = 4, Scale = 0.35 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---@type table
local SettingsList = {
LeftArrow = { Dictionary = "commonmenu", Texture = "arrowleft", X = 378, Y = 3, Width = 30, Height = 30 },
RightArrow = { Dictionary = "commonmenu", Texture = "arrowright", X = 400, Y = 3, Width = 30, Height = 30 },
Text = { X = 403, Y = 3, Scale = 0.35 },
}
function RageUI.List(Label, Items, Index, Description, Style, Enabled, Actions, Submenu)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type number
local Selected = CurrentMenu.Index == Option
---@type boolean
local LeftArrowHovered, RightArrowHovered = false, false
RageUI.ItemsSafeZone(CurrentMenu)
local Hovered = false;
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
---@type boolean
if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
local ListText = (type(Items[Index]) == "table") and string.format("← %s →", Items[Index].Name) or string.format("← %s →", Items[Index]) or "NIL"
if Selected then
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)
end
if Enabled == true or Enabled == nil then
if Selected then
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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)
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
end
else
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
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)
end
end
end
RightOffset = RightBadgeOffset * 1.3 + RightOffset
if Enabled == true or Enabled == nil then
if Selected then
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)
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)
else
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)
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)
end
else
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)
if Selected then
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)
else
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)
end
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(Selected)
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)
end
end
if Style.RightBadge ~= nil then
if Style.RightBadge ~= RageUI.BadgeStyle.None then
local BadgeData = Style.RightBadge(Selected)
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)
end
end
end
else
---@type table
local LeftBadge = RageUI.BadgeStyle.Lock
---@type number
if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then
local BadgeData = LeftBadge(Selected)
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)
end
end
else
error("UICheckBox Style is not a `table`")
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected);
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
Index = Index - 1
if Index < 1 then
Index = #Items
end
if (Actions.onListChange ~= nil) then
Actions.onListChange(Index, Items[Index]);
end
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
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
Index = Index + 1
if Index > #Items then
Index = 1
end
if (Actions.onListChange ~= nil) then
Actions.onListChange(Index, Items[Index]);
end
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
end
if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
if (Actions.onSelected ~= nil) then
Actions.onSelected(Index, Items[Index]);
end
if Submenu ~= nil and type(Submenu) == "table" then
RageUI.NextMenu = Submenu[Index]
end
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,46 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 29 },
Text = { X = 8, Y = 0, Scale = 0.33 },
}
function RageUI.Separator(Label)
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() then
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
if (Label ~= nil) then
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)
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
if (CurrentMenu.Index == Option) then
if (RageUI.LastControl) then
CurrentMenu.Index = Option - 1
if (CurrentMenu.Index < 1) then
CurrentMenu.Index = RageUI.CurrentMenu.Options
end
else
CurrentMenu.Index = Option + 1
end
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,173 @@
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
LeftBadge = { Y = -2, Width = 40, Height = 40 },
RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 },
RightText = { X = 420, Y = 4, Scale = 0.35 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---@type table
local SettingsSlider = {
Background = { X = 250, Y = 14.5, Width = 150, Height = 9 },
Slider = { X = 250, Y = 14.5, Width = 75, Height = 9 },
Divider = { X = 323.5, Y = 9, Width = 2.5, Height = 20 },
LeftArrow = { Dictionary = "commonmenutu", Texture = "arrowleft", X = 235, Y = 11.5, Width = 15, Height = 15 },
RightArrow = { Dictionary = "commonmenutu", Texture = "arrowright", X = 400, Y = 11.5, Width = 15, Height = 15 },
}
function RageUI.Slider(Label, ProgressStart, ProgressMax, IncrementQty, Description, Divider, Style, Enabled, Actions)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
local Audio = RageUI.Settings.Audio
if CurrentMenu ~= nil then
if CurrentMenu() then
local Items = {}
for i = 1, ProgressMax do
table.insert(Items, i)
end
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type number
local Selected = CurrentMenu.Index == Option
---@type boolean
local LeftArrowHovered, RightArrowHovered = false, false
RageUI.ItemsSafeZone(CurrentMenu)
local Hovered = false;
--if type(Style) == "table" then
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)
--end
local RightOffset = 0
---@type boolean
if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
if Selected then
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)
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)
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)
end
if Enabled == true or Enabled == nil then
if Selected then
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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)
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
end
else
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
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)
end
end
end
RightOffset = RightOffset + RightBadgeOffset
if Enabled == true or Enabled == nil then
if Selected then
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)
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)
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)
else
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)
end
else
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)
if Selected then
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)
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)
end
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(Selected)
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)
end
end
if Style.RightBadge ~= nil then
if Style.RightBadge ~= RageUI.BadgeStyle.None then
local BadgeData = Style.RightBadge(Selected)
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)
end
end
end
else
---@type table
local LeftBadge = RageUI.BadgeStyle.Lock
if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then
local BadgeData = LeftBadge(Selected)
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)
end
end
else
error("UICheckBox Style is not a `table`")
end
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)
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)
if Divider then
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)
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected);
if Enabled == true or Enabled == nil then
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
ProgressStart = ProgressStart - IncrementQty or 1
if ProgressStart < 1 then
ProgressStart = #Items
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ProgressStart);
end
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
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
ProgressStart = ProgressStart + IncrementQty or 1
if ProgressStart > #Items then
ProgressStart = 1
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ProgressStart);
end
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
end
if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then
if (Actions.onSelected ~= nil) then
Actions.onSelected(ProgressStart);
end
if Style.MuteOnSelected ~= nil then
if Style.MuteOnSelected ~= true then
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
end
else
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
end
end
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,118 @@
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---@type table
local SettingsSlider = {
Background = { X = 250, Y = 14.5, Width = 150, Height = 9 },
Slider = { X = 250, Y = 14.5, Width = 75, Height = 9 },
Divider = { X = 323.5, Y = 9, Width = 2.5, Height = 20 },
LeftArrow = { Dictionary = "mpleaderboard", Texture = "leaderboard_female_icon", X = 215, Y = 0, Width = 40, Height = 40 },
RightArrow = { Dictionary = "mpleaderboard", Texture = "leaderboard_male_icon", X = 395, Y = 0, Width = 40, Height = 40 },
}
local Items = {}
for i = 1, 10 do
table.insert(Items, i)
end
function RageUI.UISliderHeritage(Label, ItemIndex, Description, Actions, Value)
local CurrentMenu = RageUI.CurrentMenu;
local Audio = RageUI.Settings.Audio
if CurrentMenu ~= nil then
if CurrentMenu() then
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type number
local value = Value or 0.1
local Selected = CurrentMenu.Index == Option
---@type boolean
local LeftArrowHovered, RightArrowHovered = false, false
RageUI.ItemsSafeZone(CurrentMenu)
local Hovered = false;
local RightOffset = 0
---@type boolean
if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
if Selected then
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)
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)
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)
end
RightOffset = RightOffset
if Selected then
RenderText(Label, CurrentMenu.X + SettingsButton.Text.X, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 0, 0, 0, 255)
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)
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)
else
RenderText(Label, CurrentMenu.X + SettingsButton.Text.X, CurrentMenu.Y + SettingsButton.Text.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, 0, SettingsButton.Text.Scale, 245, 245, 245, 255)
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)
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)
end
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)
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)
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)
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected);
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
ItemIndex = ItemIndex - value
if ItemIndex < 0.1 then
ItemIndex = 0.0
else
RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true)
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ItemIndex / 10, ItemIndex);
end
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
ItemIndex = ItemIndex + value
if ItemIndex > #Items then
ItemIndex = 10
else
RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true)
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ItemIndex / 10, ItemIndex);
end
end
if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then
if (Actions.onSelected ~= nil) then
Actions.onSelected(ItemIndex / 10, ItemIndex);
end
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef, false)
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,186 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Dylan Malandain.
--- DateTime: 21/11/2019 01:33
---
---@type table
local SettingsButton = {
Rectangle = { Y = 0, Width = 431, Height = 38 },
Text = { X = 8, Y = 3, Scale = 0.33 },
LeftBadge = { Y = -2, Width = 40, Height = 40 },
RightBadge = { X = 385, Y = -2, Width = 40, Height = 40 },
RightText = { X = 420, Y = 4, Scale = 0.35 },
SelectedSprite = { Dictionary = "commonmenu", Texture = "gradient_nav", Y = 0, Width = 431, Height = 38 },
}
---@type table
local SettingsSlider = {
Background = { X = 250, Y = 14.5, Width = 150, Height = 9 },
Slider = { X = 250, Y = 14.5, Width = 150, Height = 9 },
LeftArrow = { Dictionary = "commonmenutu", Texture = "arrowleft", X = 235, Y = 11.5, Width = 15, Height = 15 },
RightArrow = { Dictionary = "commonmenutu", Texture = "arrowright", X = 400, Y = 11.5, Width = 15, Height = 15 },
}
---Slider
---@param Label string
---@param ProgressStart number
---@param ProgressMax number
---@param Description string
---@param Enabled boolean
---@param Callback function
function RageUI.SliderProgress(Label, ProgressStart, ProgressMax, Description, Style, Enabled, Actions)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
local Audio = RageUI.Settings.Audio
if CurrentMenu ~= nil then
if CurrentMenu() then
local Items = {}
for i = 1, ProgressMax do
table.insert(Items, i)
end
---@type number
local Option = RageUI.Options + 1
if CurrentMenu.Pagination.Minimum <= Option and CurrentMenu.Pagination.Maximum >= Option then
---@type number
local Selected = CurrentMenu.Index == Option
---@type boolean
local LeftArrowHovered, RightArrowHovered = false, false
RageUI.ItemsSafeZone(CurrentMenu)
local Hovered = false;
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
---@type boolean
if CurrentMenu.EnableMouse == true and (CurrentMenu.CursorStyle == 0) or (CurrentMenu.CursorStyle == 1) then
Hovered = RageUI.ItemsMouseBounds(CurrentMenu, Selected, Option, SettingsButton);
end
if Selected then
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)
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)
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)
end
if Enabled == true or Enabled == nil then
if Selected then
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
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)
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
end
else
if Style.RightLabel ~= nil and Style.RightLabel ~= "" then
RightOffset = MeasureStringWidth(Style.RightLabel, 0, 0.35)
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)
end
end
end
RightOffset = RightOffset + RightBadgeOffset
if Enabled == true or Enabled == nil then
if Selected then
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)
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)
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)
else
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)
end
else
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)
if Selected then
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)
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)
end
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(Selected)
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)
end
end
if Style.RightBadge ~= nil then
if Style.RightBadge ~= RageUI.BadgeStyle.None then
local BadgeData = Style.RightBadge(Selected)
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)
end
end
end
else
---@type table
local LeftBadge = RageUI.BadgeStyle.Lock
if LeftBadge ~= RageUI.BadgeStyle.None and LeftBadge ~= nil then
local BadgeData = LeftBadge(Selected)
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)
end
end
else
error("UICheckBox Style is not a `table`")
end
if (type(Style.ProgressBackgroundColor) == "table") then
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)
else
error("Style ProgressBackgroundColor is not a table or undefined")
end
if (type(Style.ProgressColor) == "table") then
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)
else
error("Style ProgressColor is not a table or undefined")
end
RageUI.ItemOffset = RageUI.ItemOffset + SettingsButton.Rectangle.Height
RageUI.ItemsDescription(CurrentMenu, Description, Selected);
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
ProgressStart = ProgressStart - 1
if ProgressStart < 1 then
ProgressStart = #Items
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ProgressStart);
end
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
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
ProgressStart = ProgressStart + 1
if ProgressStart > #Items then
ProgressStart = 1
end
if (Actions.onSliderChange ~= nil) then
Actions.onSliderChange(ProgressStart);
end
RageUI.PlaySound(Audio[Audio.Use].LeftRight.audioName, Audio[Audio.Use].LeftRight.audioRef)
end
if Selected and (CurrentMenu.Controls.Select.Active or ((Hovered and CurrentMenu.Controls.Click.Active) and (not LeftArrowHovered and not RightArrowHovered))) then
if (Actions.onSelected ~= nil) then
Actions.onSelected(ProgressStart);
end
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
end
end
RageUI.Options = RageUI.Options + 1
end
end
end

View File

@ -0,0 +1,100 @@
---@type table
local Colour = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 112 },
LeftArrow = { Dictionary = "commonmenu", Texture = "arrowleft", X = 7.5, Y = 15, Width = 30, Height = 30 },
RightArrow = { Dictionary = "commonmenu", Texture = "arrowright", X = 393.5, Y = 15, Width = 30, Height = 30 },
Header = { X = 215.5, Y = 15, Scale = 0.35 },
Box = { X = 15, Y = 55, Width = 44.5, Height = 44.5 },
SelectedRectangle = { X = 15, Y = 47, Width = 44.5, Height = 8 },
}
---ColourPanel
---@param Title string
---@param Colours thread
---@param MinimumIndex number
---@param CurrentIndex number
---@param Callback function
---@return nil
---@public
function RageUI.ColourPanel(Title, Colours, MinimumIndex, CurrentIndex, Action, Index)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() and (CurrentMenu.Index == Index) then
---@type number
local Maximum = (#Colours > 9) and 9 or #Colours
---@type boolean
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)
---@type number
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)
---@type number
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)
---@type boolean
local Selected = false
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)
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)
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)
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)
for Index = 1, Maximum do
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]))
end
RenderText((Title and Title or "") .. " (" .. CurrentIndex .. " of " .. #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)
if Hovered or LeftArrowHovered or RightArrowHovered then
if RageUI.Settings.Controls.Click.Active then
Selected = true
if LeftArrowHovered then
CurrentIndex = CurrentIndex - 1
if CurrentIndex < 1 then
CurrentIndex = #Colours
MinimumIndex = #Colours - Maximum + 1
elseif CurrentIndex < MinimumIndex then
MinimumIndex = MinimumIndex - 1
end
elseif RightArrowHovered then
CurrentIndex = CurrentIndex + 1
if CurrentIndex > #Colours then
CurrentIndex = 1
MinimumIndex = 1
elseif CurrentIndex > MinimumIndex + Maximum - 1 then
MinimumIndex = MinimumIndex + 1
end
elseif Hovered then
for Index = 1, Maximum do
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
CurrentIndex = MinimumIndex + Index - 1
end
end
end
if (Action.onColorChange ~= nil) then
Action.onColorChange(MinimumIndex, CurrentIndex)
end
end
end
RageUI.ItemOffset = RageUI.ItemOffset + Colour.Background.Height + Colour.Background.Y
if (Hovered or LeftArrowHovered or RightArrowHovered) and RageUI.Settings.Controls.Click.Active then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Select.audioName, Audio[Audio.Use].Select.audioRef)
end
end
end
end

View File

@ -0,0 +1,127 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
local GridType = RageUI.Enum {
Default = 1,
Horizontal = 2,
Vertical = 3
}
local GridSprite = {
[GridType.Default] = { Dictionary = "pause_menu_pages_char_mom_dad", Texture = "nose_grid", },
[GridType.Horizontal] = { Dictionary = "RageUI", Texture = "horizontal_grid", },
[GridType.Vertical] = { Dictionary = "RageUI", Texture = "vertical_grid", },
}
local Grid = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 275 },
Grid = { X = 115.5, Y = 47.5, Width = 200, Height = 200 },
Circle = { Dictionary = "mpinventory", Texture = "in_world_circle", X = 115.5, Y = 47.5, Width = 20, Height = 20 },
Text = {
Top = { X = 215.5, Y = 15, Scale = 0.35 },
Bottom = { X = 215.5, Y = 250, Scale = 0.35 },
Left = { X = 57.75, Y = 130, Scale = 0.35 },
Right = { X = 373.25, Y = 130, Scale = 0.35 },
},
}
local function UIGridPanel(Type, StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index)
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and ((CurrentMenu.Index == Index)) then
local X = Type == GridType.Default and StartedX or Type == GridType.Horizontal and StartedX or Type == GridType.Vertical and 0.5
local Y = Type == GridType.Default and StartedY or Type == GridType.Horizontal and 0.5 or Type == GridType.Vertical and StartedY
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)
local Selected = false
local CircleX = CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20
local CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20
if X < 0.0 or X > 1.0 then
X = 0.0
end
if Y < 0.0 or Y > 1.0 then
Y = 0.0
end
CircleX = CircleX + ((Grid.Grid.Width - 40) * X) - (Grid.Circle.Width / 2)
CircleY = CircleY + ((Grid.Grid.Height - 40) * Y) - (Grid.Circle.Height / 2)
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)
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)
RenderSprite(Grid.Circle.Dictionary, Grid.Circle.Texture, CircleX, CircleY, Grid.Circle.Width, Grid.Circle.Height)
if (Type == GridType.Default) then
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)
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)
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)
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)
end
if (Type == GridType.Vertical) then
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)
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)
end
if (Type == GridType.Horizontal) then
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)
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)
end
if Hovered then
if IsDisabledControlPressed(0, 24) then
Selected = true
CircleX = math.round(GetControlNormal(2, 239) * 1920) - CurrentMenu.SafeZoneSize.X - (Grid.Circle.Width / 2)
CircleY = math.round(GetControlNormal(2, 240) * 1080) - CurrentMenu.SafeZoneSize.Y - (Grid.Circle.Height / 2)
if CircleX > (CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20 + Grid.Grid.Width - 40) then
CircleX = CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20 + Grid.Grid.Width - 40
elseif CircleX < (CurrentMenu.X + Grid.Grid.X + 20 - (Grid.Circle.Width / 2)) then
CircleX = CurrentMenu.X + Grid.Grid.X + 20 - (Grid.Circle.Width / 2)
end
if CircleY > (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 + Grid.Grid.Height - 40) then
CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 + Grid.Grid.Height - 40
elseif CircleY < (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 - (Grid.Circle.Height / 2)) then
CircleY = CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20 - (Grid.Circle.Height / 2)
end
X = math.round((CircleX - (CurrentMenu.X + Grid.Grid.X + (CurrentMenu.WidthOffset / 2) + 20) + (Grid.Circle.Width / 2)) / (Grid.Grid.Width - 40), 2)
Y = math.round((CircleY - (CurrentMenu.Y + Grid.Grid.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset + 20) + (Grid.Circle.Height / 2)) / (Grid.Grid.Height - 40), 2)
if (X ~= StartedX) and (Y ~= StartedY) then
Action.onPositionChange(X, Y)
end
StartedX = X;
StartedY = Y;
if X > 1.0 then
X = 1.0
end
if Y > 1.0 then
Y = 1.0
end
end
end
RageUI.ItemOffset = RageUI.ItemOffset + Grid.Background.Height + Grid.Background.Y
if Hovered and Selected then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true)
if (Action.onSelected ~= nil) then
Action.onSelected(X, Y);
end
end
end
end
end
function RageUI.Grid(StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index)
UIGridPanel(GridType.Default, StartedX, StartedY, TopText, BottomText, LeftText, RightText, Action, Index)
end
function RageUI.GridHorizontal(StartedX, LeftText, RightText, Action, Index)
UIGridPanel(GridType.Horizontal, StartedX, nil, nil, nil, LeftText, RightText, Action, Index)
end
function RageUI.GridVertical(StartedY, TopText, BottomText, Action, Index)
UIGridPanel(GridType.Vertical, nil, StartedY, TopText, BottomText, nil, nil, Action, Index)
end

View File

@ -0,0 +1,81 @@
local Percentage = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 76 },
Bar = { X = 9, Y = 50, Width = 413, Height = 10 },
Text = {
Left = { X = 25, Y = 15, Scale = 0.35 },
Middle = { X = 215.5, Y = 15, Scale = 0.35 },
Right = { X = 398, Y = 15, Scale = 0.35 },
},
}
---PercentagePanel
---@param Percent number
---@param HeaderText string
---@param MinText string
---@param MaxText string
---@param Callback function
---@param Index number
---@return nil
---@public
function RageUI.PercentagePanel(Percent, HeaderText, MinText, MaxText, Action, Index)
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then
---@type boolean
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)
---@type boolean
local Selected = false
---@type number
local Progress = Percentage.Bar.Width
if Percent < 0.0 then
Percent = 0.0
elseif Percent > 1.0 then
Percent = 1.0
end
Progress = Progress * Percent
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)
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)
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)
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)
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)
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)
if Hovered then
if IsDisabledControlPressed(0, 24) then
Selected = true
Progress = math.round(GetControlNormal(2, 239) * 1920) - CurrentMenu.SafeZoneSize.X - (CurrentMenu.X + Percentage.Bar.X + (CurrentMenu.WidthOffset / 2))
if Progress < 0 then
Progress = 0
elseif Progress > (Percentage.Bar.Width) then
Progress = Percentage.Bar.Width
end
Percent = math.round(Progress / Percentage.Bar.Width, 2)
if (Action.onProgressChange ~= nil) then
Action.onProgressChange(Percent)
end
end
end
RageUI.ItemOffset = RageUI.ItemOffset + Percentage.Background.Height + Percentage.Background.Y
if Hovered and Selected then
local Audio = RageUI.Settings.Audio
RageUI.PlaySound(Audio[Audio.Use].Slider.audioName, Audio[Audio.Use].Slider.audioRef, true)
if (Action.onSelected ~= nil) then
Action.onSelected(Percent)
end
end
end
end
end

View File

@ -0,0 +1,68 @@
local Statistics = {
Background = { Dictionary = "commonmenu", Texture = "gradient_bgd", Y = 4, Width = 431, Height = 42 },
Text = {
Left = { X = -40, Y = 15, Scale = 0.35 },
},
Bar = { Right = 8, Y = 27, Width = 200, Height = 10, OffsetRatio = 0.5 },
Divider = {
[1] = { X = 200, Y = 27, Width = 2, Height = 10 },
[2] = { X = 200, Y = 27, Width = 2, Height = 10 },
[3] = { X = 200, Y = 27, Width = 2, Height = 10 },
[4] = { X = 200, Y = 27, Width = 2, Height = 10 },
[5] = { X = 200, Y = 27, Width = 2, Height = 10 },
}
}
function RageUI.StatisticPanel(Percent, Text, Index)
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then
---@type number
local BarWidth = Statistics.Bar.Width + CurrentMenu.WidthOffset * Statistics.Bar.OffsetRatio
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)
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)
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)
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)
for i = 1, #Statistics.Divider, 1 do
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)
end
RageUI.StatisticPanelCount = RageUI.StatisticPanelCount + 1
end
end
end
function RageUI.StatisticPanelAdvanced(Text, Percent, RGBA1, Percent2, RGBA2, RGBA3, Index)
local CurrentMenu = RageUI.CurrentMenu
if CurrentMenu ~= nil then
if CurrentMenu() and (Index == nil or (CurrentMenu.Index == Index)) then
RGBA1 = RGBA1 or { 255, 255, 255, 255 }
local BarWidth = Statistics.Bar.Width + CurrentMenu.WidthOffset * Statistics.Bar.OffsetRatio
---@type number
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)
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)
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)
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])
RGBA2 = RGBA2 or { 0, 153, 204, 255 }
RGBA3 = RGBA3 or { 185, 0, 0, 255 }
if Percent2 and Percent2 > 0 then
local X = CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset + Percent * BarWidth
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])
elseif Percent2 and Percent2 < 0 then
local X = CurrentMenu.X + RageUI.Settings.Items.Title.Background.Width - BarWidth - Statistics.Bar.Right + CurrentMenu.WidthOffset + Percent * BarWidth
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])
end
for i = 1, #Statistics.Divider, 1 do
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)
end
RageUI.StatisticPanelCount = RageUI.StatisticPanelCount + 1
end
end
end

View File

@ -0,0 +1,52 @@
---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@type table
local Heritage = {
Background = { Dictionary = "pause_menu_pages_char_mom_dad", Texture = "mumdadbg", Width = 431, Height = 228 },
Mum = { Dictionary = "char_creator_portraits", X = 25, Width = 228, Height = 228 },
Dad = { Dictionary = "char_creator_portraits", X = 195, Width = 228, Height = 228 },
}
---@type Window
function RageUI.Window.Heritage(Mum, Dad)
---@type table
local CurrentMenu = RageUI.CurrentMenu;
if CurrentMenu ~= nil then
if CurrentMenu() then
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
RenderSprite(Heritage.Background.Dictionary, Heritage.Background.Texture, CurrentMenu.X, CurrentMenu.Y + CurrentMenu.SubtitleHeight + RageUI.ItemOffset, Heritage.Background.Width + (CurrentMenu.WidthOffset / 1), Heritage.Background.Height)
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)
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)
RageUI.ItemOffset = RageUI.ItemOffset + Heritage.Background.Height
end
end
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,25 @@
# memorygame
Memory game like NoPixel for any framework
Inspired by - https://codepen.io/torbenxxx/pen/MWJBzWP
Join My Discord - https://discord.gg/VGYkkAYVv2
# Usage
Put the folder in your resources and start in resources.cfg
``ensure memorygame``
# How to use export
```
-- correctBlocks = Number of correct blocks the player needs to click
-- incorrectBlocks = number of incorrect blocks after which the game will fail
-- timetoShow = time in secs for which the right blocks will be shown
-- timetoLose = maximum time after timetoshow expires for player to select the right blocks
exports["memorygame"]:thermiteminigame(10, 3, 3, 10,
function() -- success
print("success")
end,
function() -- failure
print("failure")
end)
```

View File

@ -0,0 +1,43 @@
local successCb
local failCb
local resultReceived = false
RegisterNUICallback('ThermiteResult', function(data, cb)
SetNuiFocus(false, false)
resultReceived = true
if data.success then
successCb()
else
failCb()
end
cb('ok')
end)
RegisterCommand('thermite', function(source, args)
exports["memorygame"]:thermiteminigame(10, 3, 3, 10,
function() -- success
print("success")
end,
function() -- failure
print("failure")
end)
end)
exports('thermiteminigame', function(correctBlocks, incorrectBlocks, timetoShow, timetoLose, success, fail)
-- correctBlocks = Number of correct blocks the player needs to click
-- incorrectBlocks = number of incorrect blocks after which the game will fail
-- timetoShow = time in secs for which the right blocks will be shown
-- timetoLose = maximum time after timetoshow expires for player to select the right blocks
resultReceived = false
successCb = success
failCb = fail
SetNuiFocus(true, true)
SendNUIMessage({
action = "Start",
correct = correctBlocks,
incorrect = incorrectBlocks,
showtime = timetoShow,
losetime = timetoLose + timetoShow,
})
end)

View File

@ -0,0 +1,23 @@
fx_version 'cerulean'
game 'gta5'
author 'Snipe'
description 'Thermite Game Like NoPixel'
version '1.0.0'
server_scripts {
--'server/server.lua',
}
client_scripts {
'client/main.lua',
}
ui_page {
'html/index.html'
}
files {
'html/index.html',
'html/style.css',
'html/app.js'
}

View File

@ -0,0 +1,142 @@
window.timeBlocksShows = 0; //4.5sec
window.timeUntilLose = 0; //12sec
window.correctBlocksNum = 0;
window.maxIncorrectBlocksNum = 0;
window.allBlocksNum = 36;
window.activateClicking = false;
ThermiteNew = {}
$(document).ready(function(){
$(".container").hide()
})
$(document).ready(function(){
ThermiteNew.Start = function(data) {
$(".container").show()
$(".grid").removeClass("won");
$(".grid").removeClass("won");
$(".grid").removeClass("lost");
hideAllBlocks();
window.maxIncorrectBlocksNum = data.incorrect;
window.correctBlocksNum = data.correct;
window.timeBlocksShows = data.showtime;
window.timeUntilLose = data.losetime;
window.gridCorrectBlocks = generateRandomNumberBetween(1, 36, data.correct);
window.activateClicking = false;
showCorrectBlocks();
setTimeout(()=>{
hideAllBlocks();
window.activateClicking = true;
}, timeBlocksShows*1000);
setTimeout(()=>{
isGameForeited();
}, timeUntilLose*1000);
}
window.addEventListener('message', function(event){
var action = event.data.action;
switch(action) {
case "Start":
ThermiteNew.Start(event.data);
break;
}
});
})
$(document.body).on("click", ".block", onBlockClick);
function generateRandomNumberBetween(min=1,max=window.allBlocksNum,length = window.correctBlocksNum){
var arr = [];
while(arr.length < length){
var r = Math.floor(Math.random() * (max+1-min)) + min;
if(arr.indexOf(r) === -1) arr.push(r);
}
return arr;
}
function onBlockClick(e){
if(!activateClicking){
return;
}
let clickedBlock = e.target;
let blockNum = clickedBlock.classList.value.match(/(?:block-)(\d+)/)[1];
blockNum = Number(blockNum);
let correctBlocks = window.gridCorrectBlocks;
let correct = correctBlocks.indexOf(blockNum) !== -1;
clickedBlock.classList.add("clicked");
if(correct){
clickedBlock.classList.remove("incorrect");
clickedBlock.classList.add("correct");
}
else{
clickedBlock.classList.add("incorrect");
clickedBlock.classList.remove("correct");
}
checkWinOrLost();
}
function showCorrectBlocks(){
$(".block").each((i,ele)=>{
let blockNum = ele.classList.value.match(/(?:block-)(\d+)/)[1];
blockNum = Number(blockNum);
let correctBlocks = window.gridCorrectBlocks;
let correct = correctBlocks.indexOf(blockNum) !== -1;
if(correct){
ele.classList.add("show");
}
});
}
function hideAllBlocks(){
$(".block").each((i,ele)=>{
ele.classList.remove("show");
ele.classList.remove("correct");
ele.classList.remove("incorrect");
ele.classList.remove("clicked");
});
}
function checkWinOrLost(){
if(isGameWon()){
hideAllBlocks()
window.activateClicking = false;
$(".container").hide()
$.post('https://memorygame/ThermiteResult', JSON.stringify({
success: true
}));
}
if(isGameLost()){
hideAllBlocks();
$(".container").hide()
window.activateClicking = false;
$.post('https://memorygame/ThermiteResult', JSON.stringify({
success: false
}));
}
}
function isGameWon(){
return $(".correct").length >= (window.correctBlocksNum);
}
function isGameLost(){
return $(".incorrect").length >= window.maxIncorrectBlocksNum;
};
function isGameForeited(){
if (window.activateClicking ){
hideAllBlocks();
$(".container").hide()
window.activateClicking = false;
$.post('https://memorygame/ThermiteResult', JSON.stringify({
success: false
}));
}
}

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Exo Thermite Minigame by Snipe</title>
<meta name="description" content="Exo Thermite Minigame by Snipe">
<!-- <link rel="canonical" href="index.html" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div class = "container">
<div class="grid">
<div class="block block-1"></div>
<div class="block block-2"></div>
<div class="block block-3"></div>
<div class="block block-4"></div>
<div class="block block-5"></div>
<div class="block block-6"></div>
<div class="block block-7"></div>
<div class="block block-8"></div>
<div class="block block-9"></div>
<div class="block block-10"></div>
<div class="block block-11"></div>
<div class="block block-12"></div>
<div class="block block-13"></div>
<div class="block block-14"></div>
<div class="block block-15"></div>
<div class="block block-16"></div>
<div class="block block-17"></div>
<div class="block block-18"></div>
<div class="block block-19"></div>
<div class="block block-20"></div>
<div class="block block-21"></div>
<div class="block block-22"></div>
<div class="block block-23"></div>
<div class="block block-24"></div>
<div class="block block-25"></div>
<div class="block block-26"></div>
<div class="block block-27"></div>
<div class="block block-28"></div>
<div class="block block-29"></div>
<div class="block block-30"></div>
<div class="block block-31"></div>
<div class="block block-32"></div>
<div class="block block-33"></div>
<div class="block block-34"></div>
<div class="block block-35"></div>
<div class="block block-36"></div>
</div>
<script src="./app.js"></script>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
/* :root {
--block-color: #394D61;
--bg-color: #16181C;
} */
.container {
position: relative;
top: 20vh;
display:none;
}
/* body{
background-color: var(--bg-color);
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
} */
div.grid{
display: none;
margin: 20px auto;
width: 600px;
height: 600px;
background: #2D3139;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr;
gap: 20px;
padding: 10px;
}
.grid.won .block{
background: #2a8040;
}
.grid.lost .block{
background: #F22300;
}
.block{
background: #394D61;
width: 100%;
height: 100%;
border-radius: 1px;
cursor: pointer;
}
.block.show,.block.correct{
background: #bfbfbf;
}
.block.incorrect{
background: #F22300;
}
.grid.lost .show.block {
background: #6d9070;
}
.grid.lost .block {
background: #bd5151;
}
.grid.lost .block.clicked.incorrect {
background: #F22300;
}
.grid.lost .block.clicked.correct {
background: #bfbfbf;
}

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,124 @@
# MenuV | Standalone Menu for FiveM | NUI Menu
[![N|CoreV](https://i.imgur.com/iq1llQG.jpg)](https://github.com/ThymonA/menuv)
[![Issues](https://img.shields.io/github/issues/ThymonA/menuv.svg?style=for-the-badge)](https://github.com/ThymonA/menuv/issues)
[![License](https://img.shields.io/github/license/ThymonA/menuv.svg?style=for-the-badge)](https://github.com/ThymonA/menuv/blob/master/LICENSE)
[![Forks](https://img.shields.io/github/forks/ThymonA/menuv.svg?style=for-the-badge)](https://github.com/ThymonA/menuv)
[![Stars](https://img.shields.io/github/stars/ThymonA/menuv.svg?style=for-the-badge)](https://github.com/ThymonA/menuv)
[![Discord](https://img.shields.io/badge/discord-Tigo%239999-7289da?style=for-the-badge&logo=discord)](https://discordapp.com/users/733686533873467463)
---
**[MenuV](https://github.com/ThymonA/menuv)** is a library written for **[FiveM](https://fivem.net/)** and only uses NUI functionalities. This library allows you to create menus in **[FiveM](https://fivem.net/)**. This project is open-source and you must respect the [license](https://github.com/ThymonA/menuv/blob/master/LICENSE) and the hard work.
## Features
- Support for simple buttons, sliders, checkboxes, lists and confirms
- Support for emojis on items
- Support for custom colors (RGB)
- Support for all screen resolutions.
- Item descriptions
- Rebindable keys
- Event-based callbacks
- Uses `2 msec` while menu open and idle.
- Documentation on [menuv.fivem.io/api/](https://menuv.fivem.io/api/)
- Themes: **[default](https://i.imgur.com/KSkeiQm.png)** or **[native](https://i.imgur.com/KSkeiQm.png)**
## Compile files
**[MenuV](https://github.com/ThymonA/menuv)** uses **[VueJS](https://vuejs.org/v2/guide/installation.html#NPM)** and **[TypeScript](https://www.npmjs.com/package/typescript)** with **[NodeJS](https://nodejs.org/en/)**. If you want to use the **`master`** files, you need to build the hole project by doing:
```sh
npm install
```
After you have downloaded/loaded all dependencies, you can build **[MenuV](https://github.com/ThymonA/menuv)** files by executing the following command:
```sh
npm run build
```
After the command is executed you will see a `build` folder containing all the resource files.
Copy those files to a resource folder called `menuv` or create a symbolic link like that:
### Windows
```batch
mklink /J "repositoryPath\build" "fxResourcesPath\menuv"
```
### Linux
```sh
ln -s "repositoryPath\build" "fxResourcesPath\menuv"
```
You can also check this tutorial on how to make a link:
[https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/](https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/)
**When your downloading a [release](https://github.com/ThymonA/menuv/releases), you don't have to follow this step, because all [release](https://github.com/ThymonA/menuv/releases) version are build version.**
## How to use?
> ⚠️ **example.lua** can't be added in the **menuv** fxmanifest, you must make an seperate resource like: **[menuv_example](https://github.com/ThymonA/menuv/tree/master/example)**
1. Add `start menuv` to your **server.cfg** before the resources that's uses **menuv**
2. To use **[MenuV](https://github.com/ThymonA/menuv)** you must add **@menuv/menuv.lua** in your **fxmanifest.lua** file.
```lua
client_scripts {
'@menuv/menuv.lua',
'example.lua'
}
```
### Create a menu
Create a menu by calling the **MenuV:CreateMenu** function.
```ts
MenuV:CreateMenu(title: string, subtitle: string, position: string, red: number, green: number, blue: number, texture: string, disctionary: string, namespace: string, theme: string)
```
**Example:**
```lua
local menu = MenuV:CreateMenu('MenuV', 'Welcome to MenuV', 'topleft', 255, 0, 0, 'size-125', 'default', 'menuv', 'example_namespace', 'native')
```
### Create menu items
Create a item by calling **AddButton**, **AddConfirm**, **AddRange**, **AddCheckbox** or **AddSlider** in the created menu
```ts
/** CREATE A BUTTON */
menu:AddButton({ icon: string, label: string, description: string, value: any, disabled: boolean });
/** CREATE A CONFIRM */
menu:AddConfirm({ icon: string, label: string, description: string, value: boolean, disabled: boolean });
/** CREATE A RANGE */
menu:AddRange({ icon: string, label: string, description: string, value: number, min: number, max: number, disabled: boolean });
/** CREATE A CHECKBOX */
menu:AddCheckbox({ icon: string, label: string, description: string, value: boolean, disabled: boolean });
/** CREATE A SLIDER */
menu:AddSlider({ icon: string, label: string, description: string, value: number, values: [] { label: string, value: any, description: string }, disabled: boolean });
```
To see example in practice, see [example.lua](https://github.com/ThymonA/menuv/blob/master/example/example.lua)
### Events
In **[MenuV](https://github.com/ThymonA/menuv)** you can register event-based callbacks on menu and/or items.
```ts
/** REGISTER A EVENT ON MENU */
menu:On(event: string, callback: function);
/** REGISTER A EVENT ON ANY ITEM */
item:On(event: string, callback: function);
```
## Documentation
Read **[MenuV documentation](https://menuv.fivem.io/api/)**
## License
Project is written by **[ThymonA](https://github.com/ThymonA/)** and published under
**GNU General Public License v3.0**
[Read License](https://github.com/ThymonA/menuv/blob/master/LICENSE)
## Screenshot
**How is this menu made?** see **[example.lua](https://github.com/ThymonA/menuv/blob/master/example/example.lua)**
Default | Native
:-------|:--------
![MenuV Default](https://i.imgur.com/xGagIBm.png) | ![MenuV Native](https://i.imgur.com/KSkeiQm.png)
[Default Theme](https://i.imgur.com/xGagIBm.png) | [Native Theme](https://i.imgur.com/KSkeiQm.png)

View File

@ -0,0 +1 @@
1.4.1

View File

@ -0,0 +1,48 @@
----------------------- [ MenuV ] -----------------------
-- GitHub: https://github.com/ThymonA/menuv/
-- License: GNU General Public License v3.0
-- https://choosealicense.com/licenses/gpl-3.0/
-- Author: Thymon Arens <contact@arens.io>
-- Name: MenuV
-- Version: 1.4.1
-- Description: FiveM menu library for creating menu's
----------------------- [ MenuV ] -----------------------
Config = {
Language = 'da',
HideInterval = 250,
Sounds = {
UP = {
type = 'native',
name = 'NAV_UP_DOWN',
library = 'HUD_FREEMODE_SOUNDSET'
},
DOWN = {
type = 'native',
name = 'NAV_UP_DOWN',
library = 'HUD_FREEMODE_SOUNDSET'
},
LEFT = {
type = 'native',
name = 'NAV_LEFT_RIGHT',
library = 'HUD_FRONTEND_DEFAULT_SOUNDSET'
},
RIGHT = {
type = 'native',
name = 'NAV_LEFT_RIGHT',
library = 'HUD_FRONTEND_DEFAULT_SOUNDSET'
},
ENTER = {
type = 'native',
name = 'SELECT',
library = 'HUD_FRONTEND_DEFAULT_SOUNDSET'
},
CLOSE = {
type = 'native',
name = 'BACK',
library = 'HUD_FRONTEND_DEFAULT_SOUNDSET'
}
}
}
_G.Config = Config
_ENV.Config = Config

View File

@ -0,0 +1,487 @@
/*
----------------------- [ MenuV ] -----------------------
-- GitHub: https://github.com/ThymonA/menuv/
-- License: GNU General Public License v3.0
-- https://choosealicense.com/licenses/gpl-3.0/
-- Author: Thymon Arens <contact@arens.io>
-- Name: MenuV
-- Version: 1.4.1
-- Description: FiveM menu library for creating menu's
----------------------- [ MenuV ] -----------------------
*/
@import url('https://fonts.googleapis.com/css2?family=Epilogue:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
html,
body {
overflow: hidden;
font-family: 'Epilogue', sans-serif;
color: white;
background-color: transparent;
}
* .hide,
html .hide,
body .hide,
div .hide,
.menuv.default.hide {
display: none !important;
opacity: 0;
}
.menuv.default {
min-width: 20em;
max-width: 20em;
max-height: 90vh;
margin-top: 1em;
margin-left: 1em;
font-size: 0.85em;
}
.menuv.default.topcenter {
margin-left: auto;
margin-right: auto;
}
.menuv.default.topright {
margin-right: 1em;
margin-left: auto;
}
.menuv.default.centerleft {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.menuv.default.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.menuv.default.centerright {
position: absolute;
top: 50%;
right: 1em;
transform: translateY(-50%);
}
.menuv.default.bottomleft {
position: absolute;
bottom: 1em;
}
.menuv.default.bottomcenter {
position: absolute;
bottom: 1em;
left: 50%;
transform: translateX(-50%);
}
.menuv.default.bottomright {
position: absolute;
bottom: 1em;
right: 1em;
}
.menuv.default.size-100 {
zoom: 1;
}
.menuv.default.size-110 {
zoom: 1.1;
}
.menuv.default.size-125 {
zoom: 1.25;
}
.menuv.default.size-150 {
zoom: 1.50;
}
.menuv.default.size-175 {
zoom: 1.75;
}
.menuv.default.size-200 {
zoom: 2;
}
.menuv.default .menuv-header {
height: 3.5em;
max-height: 3.5em;
line-height: 3.5em;
width: 100%;
text-align: center;
letter-spacing: 0.25em;
font-size: 1.5em;
font-weight: 700;
background-color: black;
overflow: hidden;
}
.menuv.default .menuv-header strong {
position: relative;
z-index: 1;
color: white;
}
.menuv.default .menuv-header .menuv-bg-icon {
display: flex;
position: fixed;
max-height: 3.5em;
max-width: 3.5em;
overflow: hidden;
top: 0.6em;
margin-left: 9.8em;
}
.menuv.default .menuv-header .menuv-bg-icon i,
.menuv.default .menuv-header .menuv-bg-icon svg {
font-size: 5em;
opacity: 0.5;
color: blue;
}
.menuv.default .menuv-subheader {
background-color: blue;
text-align: left;
font-weight: 700;
font-size: 0.9em;
line-height: 2.5em;
text-transform: uppercase;
padding-left: 1em;
height: 2.5em;
max-height: 2.5em;
}
.menuv.default .menuv-items {
background-color: rgba(0, 0, 0, 0.65);
padding-top: 0.5em;
padding-bottom: 0.5em;
max-height: 50.75vh;
overflow: hidden;
color: white;
}
.menuv.default.size-100 .menuv-items {
max-height: 66.1vh;
}
.menuv.default.size-110 .menuv-items {
max-height: 59.2vh;
}
.menuv.default.size-125 .menuv-items {
max-height: 50.2vh;
}
.menuv.default.size-150 .menuv-items {
max-height: 45.8vh;
}
.menuv.default.size-175 .menuv-items {
max-height: 39vh;
}
.menuv.default.size-200 .menuv-items {
max-height: 32.2vh;
}
.menuv.default .menuv-items .menuv-item {
padding: 0.25em 0.50em;
margin: 0;
font-size: 0.9em;
max-height: auto;
height: auto;
min-height: 2em;
vertical-align: middle;
line-height: normal;
color: white;
width: 100%;
min-width: 20em;
max-width: 30em;
border-top: none !important;
}
.menuv.default .menuv-items .menuv-item i,
.menuv.default .menuv-items .menuv-item svg {
float: right;
margin-top: 0.125em;
font-size: 1.2em;
}
.menuv.default .menuv-items .menuv-item.active {
padding-right: 0;
padding-left: 0;
}
.menuv.default .menuv-items .menuv-item.disabled {
opacity: 0.75;
background: #383838;
text-decoration: line-through;
}
.menuv.default .menuv-items .menuv-item.active i,
.menuv.default .menuv-items .menuv-item.active svg {
color: black;
}
.menuv.default .menuv-items .item-title {
word-break: break-all;
}
.menuv.default .menuv-items .menuv-item.active .item-title {
font-weight: bold;
}
.menuv.default .menuv-items span.menuv-icon {
margin-left: 2.5px;
margin-right: 5px;
border-right: 1px solid white;
padding-right: 5px;
float: left;
width: 2em;
text-align: center;
}
.menuv.default .menuv-items .flex-left {
justify-content: left;
}
.menuv.default .menuv-items span.menuv-title {
word-break: break-all;
display: inline-block;
overflow: hidden;
max-height: 2em;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 14em;
}
.menuv.default .menuv-items .item-icon {
width: 2.5em;
max-width: 2.5em;
margin-right: 5px;
}
.menuv.default .menuv-items .menuv-item {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
border-top: none !important;
}
.menuv.default .menuv-items .menuv-item.active span.menuv-icon {
border-right: 1px solid black;
}
.menuv.default .menuv-items span.menuv-options {
float: right;
font-size: 0.9em;
line-height: 1.85em;
text-transform: uppercase;
}
.menuv.default .menuv-items .menuv-item.active span.menuv-options {
font-weight: 700;
}
.menuv.default .menuv-items span.menuv-options i,
.menuv.default .menuv-items span.menuv-options svg {
float: unset;
font-size: unset;
}
.menuv.default .menuv-items span.menuv-options i:first-child,
.menuv.default .menuv-items span.menuv-options svg:first-child {
margin-right: 0.25em;
}
.menuv.default .menuv-items span.menuv-options i:last-child,
.menuv.default .menuv-items span.menuv-options svg:last-child {
margin-left: 0.25em;
}
.menuv.default .menuv-items span.menuv-options span.menuv-btn {
background-color: white;
color: black;
padding: 0.25em 0.5em;
margin: 0.125em;
font-weight: bold;
font-weight: 500;
border-radius: 0.125em;
}
.menuv.default .menuv-items .menuv-item span.menuv-options span.menuv-btn {
background-color: transparent;
color: white;
}
.menuv.default .menuv-items .menuv-item.active span.menuv-options span.menuv-btn {
background-color: black;
color: white;
}
.menuv.default .menuv-items span.menuv-options span.menuv-btn.active {
background-color: blue;
color: white;
font-weight: 700;
}
.menuv.default .menuv-items .menuv-item.active span.menuv-options span.menuv-btn.active {
background-color: blue;
color: white;
}
.menuv.default .menuv-items input[type="range"] {
display: flex;
float: right;
-webkit-appearance: none;
max-width: 6.5em;
}
.menuv.default .menuv-items input[type="range"]:focus {
outline: none;
}
.menuv.default .menuv-items input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: 0px 0px 0px #000000;
background: blue;
border-radius: 0;
border: 0px solid #000000;
}
.menuv.default .menuv-items .menuv-item.active input[type="range"]::-webkit-slider-runnable-track {
background: black;
}
.menuv.default .menuv-items input[type="range"]::-webkit-slider-thumb {
box-shadow: 0px 0px 0px #000000;
height: 18px;
width: 5px;
border-radius: 0;
border: 1px solid white;
background: rgba(255, 255, 255, 1);
cursor: pointer;
-webkit-appearance: none;
margin-top: -7px;
}
.menuv.default .menuv-items .menuv-item.active input[type="range"]::-webkit-slider-thumb {
background: blue;
border: 1px solid rgba(0, 0, 255, 0.25);
}
.menuv.default .menuv-items input[type="range"]:focus::-webkit-slider-runnable-track {
background: blue;
}
.menuv.default .menuv-items .menuv-item.active input[type="range"]:focus::-webkit-slider-runnable-track {
background: black;
}
.menuv.default .menuv-items .menuv-desc {
display: none;
opacity: 0;
background-color: rgba(0, 0, 0, 0.65);
color: white;
position: absolute;
width: 100%;
max-width: 17.5em;
margin-left: 17.5em;
margin-top: -0.25em;
font-weight: 400;
font-size: 0.9em;
padding: 0.75em 1em;
line-height: 1.25em;
border-left: 0.375em solid blue;
}
.menuv.default .menuv-items .menuv-item.active .menuv-desc {
display: initial;
opacity: 1;
}
.menuv.default .menuv-items .menuv-desc strong {
color: white;
}
.menuv.default .menuv-items .menuv-desc table {
margin-left: -0.75em;
width: calc(100% + 0.75em);
}
.menuv.default .menuv-items .menuv-desc table th {
color: white;
padding: 2px 5px;
}
.menuv.default .menuv-items .menuv-desc table td {
padding: 2px 5px;
}
.menuv.default .menuv-items .menuv-label {
float: right;
font-size: 1.125em;
font-weight: 800;
}
.menuv.default .menuv-pagination {
padding: 0.5em;
max-width: 20em;
width: 100%;
text-align: center;
position: relative;
border-top: 2px solid white;
margin-top: 1em;
}
.menuv.default .menuv-pagination .menu-pagination-option {
display: inline-block;
height: 1.5em;
width: 3em;
background-color: white;
color: black;
text-align: center;
border-radius: 2.5px;
margin-left: 0.25em;
margin-right: 0.25em;
font-size: 0.8em;
}
.menuv.default .menuv-pagination .menu-pagination-option.active {
background-color: red;
color: white;
}
.menuv.default .menuv-pagination .menu-pagination-ellipsis {
display: inline-block;
height: 1.5em;
width: 1.5em;
background-color: transparent;
color: white;
text-align: center;
}
.menuv.default .menuv-description {
background-color: rgba(0, 0, 0, 0.65);
width: 100%;
max-width: 20em;
padding: 0.5em 1em;
margin-top: 0.5em;
text-align: center;
text-transform: uppercase;
}
.menuv.default .menuv-description strong {
color: white;
font-size: 0.8em;
font-weight: 400;
}

View File

@ -0,0 +1,507 @@
/*
----------------------- [ MenuV ] -----------------------
-- GitHub: https://github.com/ThymonA/menuv/
-- License: GNU General Public License v3.0
-- https://choosealicense.com/licenses/gpl-3.0/
-- Author: Thymon Arens <contact@arens.io>
-- Name: MenuV
-- Version: 1.4.1
-- Description: FiveM menu library for creating menu's
----------------------- [ MenuV ] -----------------------
*/
@font-face {
font-family: 'SignPainter';
font-style: normal;
font-weight: normal;
src: local('../fonts/SignPainter'), url('../fonts/SignPainterHouseScript.woff') format('woff');
}
@font-face {
font-family: 'TTCommons';
font-style: normal;
font-weight: normal;
src: local('../fonts/TTCommons'), url('../fonts/TTCommons.woff') format('woff');
}
html,
body {
overflow: hidden;
color: white;
background-color: transparent;
}
* .hide,
html .hide,
body .hide,
div .hide,
.menuv.native.hide {
display: none !important;
opacity: 0;
}
.menuv.native {
min-width: 30em;
max-width: 30em;
max-height: 90vh;
margin-top: 1em;
margin-left: 1em;
font-size: 0.85em;
}
.menuv.native.topcenter {
margin-left: auto;
margin-right: auto;
}
.menuv.native.topright {
margin-right: 1em;
margin-left: auto;
}
.menuv.native.centerleft {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.menuv.native.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.menuv.native.centerright {
position: absolute;
top: 50%;
right: 1em;
transform: translateY(-50%);
}
.menuv.native.bottomleft {
position: absolute;
bottom: 1em;
}
.menuv.native.bottomcenter {
position: absolute;
bottom: 1em;
left: 50%;
transform: translateX(-50%);
}
.menuv.native.bottomright {
position: absolute;
bottom: 1em;
right: 1em;
}
.menuv.native.size-100 {
zoom: 1;
}
.menuv.native.size-110 {
zoom: 1.1;
}
.menuv.native.size-125 {
zoom: 1.25;
}
.menuv.native.size-150 {
zoom: 1.50;
}
.menuv.native.size-175 {
zoom: 1.75;
}
.menuv.native.size-200 {
zoom: 2;
}
.menuv.native .menuv-header {
height: 2em;
max-height: 4.25em;
line-height: 2.25em;
width: 100%;
text-align: center;
letter-spacing: auto;
font-size: 3.5em;
font-weight: normal;
font-family: 'SignPainter';
background-color: black;
overflow: hidden;
}
.menuv.native .menuv-header strong {
position: relative;
z-index: 1;
color: white;
max-width: 1em;
font-weight: normal;
}
.menuv.native .menuv-header .menuv-bg-icon {
display: flex;
position: fixed;
max-height: 4.25em;
max-width: 4.25em;
overflow: hidden;
top: 0.6em;
margin-left: 9.8em;
}
.menuv.native .menuv-header .menuv-bg-icon i,
.menuv.native .menuv-header .menuv-bg-icon svg {
font-size: 5em;
opacity: 0.5;
color: blue;
}
.menuv.native .menuv-subheader {
background-color: black !important;
text-align: left;
font-weight: 500;
font-size: 1.125em;
line-height: auto;
text-transform: uppercase;
padding-top: 0.125em;
padding-bottom: 0.375em;
padding-left: 0.5em;
height: auto;
color: #2e69bb !important;
}
.menuv.native .menuv-items {
background-color: rgba(0, 0, 0, 0.65);
padding-bottom: 0.5em;
max-height: 50.75vh;
overflow: hidden;
color: white;
}
.menuv.native.size-100 .menuv-items {
max-height: 66.1vh;
}
.menuv.native.size-110 .menuv-items {
max-height: 59.2vh;
}
.menuv.native.size-125 .menuv-items {
max-height: 50.2vh;
}
.menuv.native.size-150 .menuv-items {
max-height: 45.8vh;
}
.menuv.native.size-175 .menuv-items {
max-height: 39vh;
}
.menuv.native.size-200 .menuv-items {
max-height: 32.2vh;
}
.menuv.native .menuv-items .menuv-item {
padding: 0.25em 0.50em;
margin: 0;
font-size: 1em;
max-height: auto;
height: auto;
line-height: 1.25em;
color: white;
width: 100%;
min-width: 100%;
max-width: 30em;
}
.menuv.native .menuv-items .flex-left {
justify-content: left;
}
.menuv.native .menuv-items .item-title {
font-family: 'TTCommons';
font-weight: 400;
font-size: 1.35em;
padding-top: 0.25em;
word-break: break-all;
}
.menuv.native .menuv-items .item-icon {
width: 2.5em;
max-width: 2.5em;
margin-right: 5px;
}
.menuv.native .menuv-items .menuv-item.disabled .item-icon {
text-decoration: none !important;
}
.menuv.native .menuv-items .menuv-item i,
.menuv.native .menuv-items .menuv-item svg {
float: right;
margin-top: 0.125em;
font-size: 1.2em;
}
.menuv.native .menuv-items .menuv-item.active {
padding-right: 0;
padding-left: 0;
}
.menuv.native .menuv-items .menuv-item.disabled {
opacity: 0.75;
background: #383838;
}
.menuv.native .menuv-items .menuv-item.active i,
.menuv.native .menuv-items .menuv-item.active svg {
color: black;
}
.menuv.native .menuv-items span.menuv-icon {
margin-left: 2.5px;
margin-right: 5px;
border-right: 1px solid white;
padding-right: 5px;
float: left;
width: 2em;
text-align: center;
}
.menuv.native .menuv-items span.menuv-title {
word-break: break-all;
display: inline-block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 1.25em;
font-weight: 600;
letter-spacing: normal;
padding: none;
margin: none;
}
.menuv.native .menuv-items .menuv-item.active span.menuv-icon {
border-right: 1px solid black;
}
.menuv.native .menuv-items .menuv-item {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
border-top: none !important;
}
.menuv.native .menuv-items span.menuv-options {
float: right;
font-size: 0.9em;
vertical-align: middle;
text-transform: uppercase;
}
.menuv.native .menuv-items .menuv-item.active span.menuv-options {
font-weight: 700;
}
.menuv.native .menuv-items span.menuv-options i,
.menuv.native .menuv-items span.menuv-options svg {
float: unset;
font-size: unset;
}
.menuv.native .menuv-items span.menuv-options i:first-child,
.menuv.native .menuv-items span.menuv-options svg:first-child {
margin-right: 0.25em;
}
.menuv.native .menuv-items span.menuv-options i:last-child,
.menuv.native .menuv-items span.menuv-options svg:last-child {
margin-left: 0.25em;
}
.menuv.native .menuv-items span.menuv-options span.menuv-btn {
background-color: white;
color: black;
padding: 0.25em 0.5em;
margin: 0.125em;
font-weight: bold;
font-weight: 500;
border-radius: 0.125em;
}
.menuv.native .menuv-items .menuv-item span.menuv-options span.menuv-btn {
background-color: transparent;
color: white;
}
.menuv.native .menuv-items .menuv-item.active span.menuv-options span.menuv-btn {
background-color: black;
color: white;
}
.menuv.native .menuv-items span.menuv-options span.menuv-btn.active {
background-color: blue;
color: white;
font-weight: 700;
}
.menuv.native .menuv-items .menuv-item.active span.menuv-options span.menuv-btn.active {
background-color: blue;
color: white;
}
.menuv.native .menuv-items input[type="range"] {
display: flex;
float: right;
-webkit-appearance: none;
max-width: 6.5em;
margin-top: 0.15em;
}
.menuv.native .menuv-items input[type="range"]:focus {
outline: none;
}
.menuv.native .menuv-items input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: 0px 0px 0px #000000;
background: blue;
border-radius: 0;
border: 0px solid #000000;
}
.menuv.native .menuv-items .menuv-item.active input[type="range"]::-webkit-slider-runnable-track {
background: black;
}
.menuv.native .menuv-items input[type="range"]::-webkit-slider-thumb {
box-shadow: 0px 0px 0px #000000;
height: 18px;
width: 5px;
border-radius: 0;
border: 1px solid white;
background: rgba(255, 255, 255, 1);
cursor: pointer;
-webkit-appearance: none;
margin-top: -7px;
}
.menuv.native .menuv-items .menuv-item.active input[type="range"]::-webkit-slider-thumb {
background: blue;
border: 1px solid rgba(0, 0, 255, 0.25);
}
.menuv.native .menuv-items input[type="range"]:focus::-webkit-slider-runnable-track {
background: blue;
}
.menuv.native .menuv-items .menuv-item.active input[type="range"]:focus::-webkit-slider-runnable-track {
background: black;
}
.menuv.native .menuv-items .menuv-desc {
display: none;
opacity: 0;
background-color: rgba(0, 0, 0, 0.65);
color: white;
position: absolute;
width: 100%;
max-width: 17.5em;
margin-left: 17.5em;
margin-top: -0.25em;
font-weight: 400;
font-size: 0.9em;
padding: 0.75em 1em;
line-height: 1.25em;
border-left: 0.375em solid blue;
}
.menuv.native .menuv-items .menuv-item.active .menuv-desc {
display: initial;
opacity: 1;
}
.menuv.native .menuv-items .menuv-desc strong {
color: white;
}
.menuv.native .menuv-items .menuv-desc table {
margin-left: -0.75em;
width: calc(100% + 0.75em);
}
.menuv.native .menuv-items .menuv-desc table th {
color: white;
padding: 2px 5px;
}
.menuv.native .menuv-items .menuv-desc table td {
padding: 2px 5px;
}
.menuv.native .menuv-items .menuv-label {
float: right;
font-size: 1.125em;
font-weight: 800;
}
.menuv.native .menuv-pagination {
padding: 0.5em;
max-width: 20em;
width: 100%;
text-align: center;
position: relative;
border-top: 2px solid white;
margin-top: 1em;
}
.menuv.native .menuv-pagination .menu-pagination-option {
display: inline-block;
height: 1.5em;
width: 3em;
background-color: white;
color: black;
text-align: center;
border-radius: 2.5px;
margin-left: 0.25em;
margin-right: 0.25em;
font-size: 0.8em;
}
.menuv.native .menuv-pagination .menu-pagination-option.active {
background-color: red;
color: white;
}
.menuv.native .menuv-pagination .menu-pagination-ellipsis {
display: inline-block;
height: 1.5em;
width: 1.5em;
background-color: transparent;
color: white;
text-align: center;
}
.menuv.native .menuv-description {
border-top: 2px solid black;
background-color: rgba(0, 0, 0, 0.65);
width: 100%;
max-width: 30em;
padding: 0.5em 1em;
margin-top: 0.5em;
text-align: left;
}
.menuv.native .menuv-description strong {
color: white;
font-family: 'TTCommons';
font-weight: 400;
font-size: 1.15em;
}

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
/*!
* vue-scrollto v2.20.0
* (c) 2019 Randjelovic Igor
* @license MIT
*/
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Released under the MIT License.
*/

View File

@ -0,0 +1 @@
<!doctype html><html class="no-js" lang=""><head><meta charset="utf-8"><title>MenuV</title><meta name="description" content=""><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="cache-control" content="max-age=0"/><meta http-equiv="cache-control" content="no-cache"/><meta http-equiv="expires" content="0"/><meta http-equiv="pragma" content="no-cache"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" crossorigin="anonymous"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" crossorigin="anonymous"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.1/css/bulma.min.css" crossorigin="anonymous"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" crossorigin="anonymous"/><link rel="stylesheet" href="./assets/css/main.css"><link rel="stylesheet" href="./assets/css/native_theme.css"></head><body><div id="menuv"></div><script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" crossorigin="anonymous"></script><script src="./assets/js/menuv.js"></script></body></html>

View File

@ -0,0 +1,37 @@
----------------------- [ MenuV ] -----------------------
-- GitHub: https://github.com/ThymonA/menuv/
-- License: GNU General Public License v3.0
-- https://choosealicense.com/licenses/gpl-3.0/
-- Author: Thymon Arens <contact@arens.io>
-- Name: MenuV
-- Version: 1.4.1
-- Description: FiveM menu library for creating menu's
----------------------- [ MenuV ] -----------------------
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
name 'MenuV'
version '1.4.1'
description 'FiveM menu library for creating menu\'s'
author 'ThymonA'
contact 'contact@arens.io'
url 'https://github.com/ThymonA/menuv/'
files {
'menuv.lua',
'menuv/components/*.lua',
'dist/*.html',
'dist/assets/css/*.css',
'dist/assets/js/*.js',
'dist/assets/fonts/*.woff',
'languages/*.json'
}
ui_page 'dist/menuv.html'
client_scripts {
'config.lua',
'menuv/components/utilities.lua',
'menuv/menuv.lua'
}

View File

@ -0,0 +1,22 @@
{
"language": "da",
"translators": [
{
"name": "Hawk",
"emails": ["hawk@privacy.thnght.pro"],
"github": "https://github.com/ThaNightHawk"
}
],
"translations": {
"keyboard": "Tastatur",
"controller": "Controller",
"keybind_key_up": "Op i en menu",
"keybind_key_down": "Ned i en menu",
"keybind_key_left": "Venstre i en menu",
"keybind_key_right": "Højre i en menu",
"keybind_key_enter": "Bekræft vald i menu",
"keybind_key_close": "Luk menu",
"keybind_key_close_all": "Luk alle menuer",
"open_menu": "Åben menu '%s' med denne tast"
}
}

View File

@ -0,0 +1,22 @@
{
"language": "en",
"translators": [
{
"name": "ThymonA",
"emails": ["contact@thymonarens.nl"],
"github": "https://github.com/ThymonA"
}
],
"translations": {
"keyboard": "Keyboard",
"controller": "Controller",
"keybind_key_up": "Up in a menu",
"keybind_key_down": "Down in a menu",
"keybind_key_left": "Left in a menu",
"keybind_key_right": "Right in a menu",
"keybind_key_enter": "Confirm item in menu",
"keybind_key_close": "Closing a menu",
"keybind_key_close_all": "Close all menus (including parents)",
"open_menu": "Open menu '%s' with this key"
}
}

View File

@ -0,0 +1,22 @@
{
"language": "fr",
"translators": [
{
"name": "Korioz",
"emails": ["pro.korioz@protonmail.com"],
"github": "https://github.com/Korioz"
}
],
"translations": {
"keyboard": "Clavier",
"controller": "Manette",
"keybind_key_up": "Haut dans un menu",
"keybind_key_down": "Bas dans un menu",
"keybind_key_left": "Gauche dans un menu",
"keybind_key_right": "Droite dans un menu",
"keybind_key_enter": "Confirmer dans un menu",
"keybind_key_close": "Fermer un menu",
"keybind_key_close_all": "Fermer tout les menus",
"open_menu": "Ouvrir menu '%s'"
}
}

Some files were not shown because too many files have changed in this diff Show More