Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = nil;
- Citizen.CreateThread(function() while ESX == nil do TriggerEvent("\101\115\120\58\103\101\116\83\104\97\114\101\100\79\98\106\101\99\116", function(a) ESX = a end) Citizen.Wait(1000) end end) LynxEvo = {}
- LynxEvo.debug = false;
- local
- function c(d) local e = {}
- local f = GetGameTimer() / 200;
- e.r = math.floor(math.sin(f * d + 0) * 127 + 128) e.g = math.floor(math.sin(f * d + 2) * 127 + 128) e.b = math.floor(math.sin(f * d + 4) * 127 + 128) return e end;
- local h = {}
- local j = {
- up = 172,
- down = 173,
- left = 174,
- right = 175,
- select = 176,
- back = 177
- }
- local k = 0;
- local l = nil;
- local m = nil;
- local n = 0.23;
- local o = 0.11;
- local p = 0.03;
- local q = 1.0;
- local s = 0.041;
- local t = 0;
- local u = 0.370;
- local v = 0.005;
- local w = 0.005;
- local A = "\51\52\66\121\84\101\32\67\111\109\109\117\110\105\116\121"
- local
- function B(C) if LynxEvo.debug then Citizen.Trace("[LynxEvo] "..tostring(C)) end end;
- local
- function D(E, F, value) if E and h[E] then h[E][F] = value;
- B(E..
- " menu property changed: { "..tostring(F)..
- ", "..tostring(value)..
- " }") end end;
- local
- function G(E) if E and h[E] then
- return h[E].visible
- else return false end end;
- local
- function H(E, I, J) if E and h[E] then D(E, "visible", I) if not J and h[E] then D(E, "currentOption", 1) end;
- if I then
- if E~ = m and G(m) then H(m, false) end;
- m = E end end end;
- local
- function K(C, x, y, L, M, N, O, P, Q) SetTextColour(M.r, M.g, M.b, M.a) SetTextFont(L) SetTextScale(N, N) if P then SetTextDropShadow(2, 2, 0, 0, 0) end;
- if h[m] then
- if O then SetTextCentre(O) elseif Q then SetTextWrap(h[m].x, h[m].x + n - v) SetTextRightJustify(true) end end;
- SetTextEntry("STRING") AddTextComponentString(C) DrawText(x, y) end;
- local
- function R(x, y, S, height, M) DrawRect(x, y, S, height, M.r, M.g, M.b, M.a) end;
- local
- function T() if h[m] then local x = h[m].x + n / 2;
- local y = h[m].y + o / 2;
- if h[m].titleBackgroundSprite then DrawSprite(h[m].titleBackgroundSprite.dict, h[m].titleBackgroundSprite.name, x, y, n, o, 0., 255, 255, 255, 255)
- else R(x, y, n, o, h[m].titleBackgroundColor) end;
- K(h[m].title, x, y - o / 2 + p, h[m].titleFont, h[m].titleColor, q, true) end end;
- local
- function U() if h[m] then local x = h[m].x + n / 2;
- local y = h[m].y + o + s / 2;
- local V = {
- r = h[m].titleBackgroundColor.r,
- g = h[m].titleBackgroundColor.g,
- b = h[m].titleBackgroundColor.b,
- a = 255
- }
- R(x, y, n, s, h[m].subTitleBackgroundColor) K(h[m].subTitle, h[m].x + v, y - s / 2 + w, t, V, u, false) if k > h[m].maxOptionCount then K(tostring(h[m].currentOption)..
- " / "..tostring(k), h[m].x + n, y - s / 2 + w, t, V, u, false, false, true) end end end;
- local
- function W(C, X) local x = h[m].x + n / 2;
- local Y = nil;
- if h[m].currentOption <= h[m].maxOptionCount and k <= h[m].maxOptionCount then Y = k elseif k > h[m].currentOption - h[m].maxOptionCount and k <= h[m].currentOption then Y = k - (h[m].currentOption - h[m].maxOptionCount) end;
- if Y then local y = h[m].y + o + s + s * Y - s / 2;
- local Z = nil;
- local a0 = nil;
- local a1 = nil;
- local P = false;
- if h[m].currentOption == k then Z = h[m].menuFocusBackgroundColor;
- a0 = h[m].menuFocusTextColor;
- a1 = h[m].menuFocusTextColor
- else Z = h[m].menuBackgroundColor;
- a0 = h[m].menuTextColor;
- a1 = h[m].menuSubTextColor;
- P = true end;
- R(x, y, n, s, Z) K(C, h[m].x + v, y - s / 2 + w, t, a0, u, false, P) if X then K(X, h[m].x + v, y - s / 2 + w, t, a1, u, false, P, true) end end end;
- function LynxEvo.CreateMenu(E, a2) h[E] = {}
- h[E].title = a2;
- h[E].subTitle = A;
- h[E].visible = false;
- h[E].previousMenu = nil;
- h[E].aboutToBeClosed = false;
- h[E].x = 0.75;
- h[E].y = 0.19;
- h[E].currentOption = 1;
- h[E].maxOptionCount = 10;
- h[E].titleFont = 1;
- h[E].titleColor = {
- r = 255,
- g = 255,
- b = 255,
- a = 255
- }
- Citizen.CreateThread(function() while true do Citizen.Wait(0) local a3 = c(1.0) h[E].titleBackgroundColor = {
- r = a3.r,
- g = a3.g,
- b = a3.b,
- a = 105
- }
- h[E].
- menuFocusBackgroundColor = {
- r = 255,
- g = 255,
- b = 255,
- a = 100
- }
- end end) h[E].titleBackgroundSprite = nil;
- h[E].menuTextColor = {
- r = 255,
- g = 255,
- b = 255,
- a = 255
- }
- h[E].menuSubTextColor = {
- r = 189,
- g = 189,
- b = 189,
- a = 255
- }
- h[E].menuFocusTextColor = {
- r = 255,
- g = 255,
- b = 255,
- a = 255
- }
- h[E].menuBackgroundColor = {
- r = 0,
- g = 0,
- b = 0,
- a = 100
- }
- h[E].subTitleBackgroundColor = {
- r = h[E].menuBackgroundColor.r,
- g = h[E].menuBackgroundColor.g,
- b = h[E].menuBackgroundColor.b,
- a = 255
- }
- h[E].buttonPressedSound = {
- name = "~h~~r~> ~s~SELECT",
- set = "HUD_FRONTEND_DEFAULT_SOUNDSET"
- }
- B(tostring(E)..
- " menu created") end;
- function LynxEvo.CreateSubMenu(E, a4, a5) if h[a4] then LynxEvo.CreateMenu(E, h[a4].title) if a5 then D(E, "subTitle", a5)
- else D(E, "subTitle", h[a4].subTitle) end;
- D(E, "previousMenu", a4) D(E, "x", h[a4].x) D(E, "y", h[a4].y) D(E, "maxOptionCount", h[a4].maxOptionCount) D(E, "titleFont", h[a4].titleFont) D(E, "titleColor", h[a4].titleColor) D(E, "titleBackgroundColor", h[a4].titleBackgroundColor) D(E, "titleBackgroundSprite", h[a4].titleBackgroundSprite) D(E, "menuTextColor", h[a4].menuTextColor) D(E, "menuSubTextColor", h[a4].menuSubTextColor) D(E, "menuFocusTextColor", h[a4].menuFocusTextColor) D(E, "menuFocusBackgroundColor", h[a4].menuFocusBackgroundColor) D(E, "menuBackgroundColor", h[a4].menuBackgroundColor) D(E, "subTitleBackgroundColor", h[a4].subTitleBackgroundColor)
- else B("Failed to create "..tostring(E)..
- " submenu: "..tostring(a4)..
- " parent menu doesn't exist") end end;
- function LynxEvo.CurrentMenu() return m end;
- function LynxEvo.OpenMenu(E) if E and h[E] then PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true) H(E, true) if h[E].titleBackgroundSprite then RequestStreamedTextureDict(h[E].titleBackgroundSprite.dict, false) while not HasStreamedTextureDictLoaded(h[E].titleBackgroundSprite.dict) do Citizen.Wait(0) end end;
- B(tostring(E)..
- " menu opened")
- else B("Failed to open "..tostring(E)..
- " menu: it doesn't exist") end end;
- function LynxEvo.IsMenuOpened(E) return G(E) end;
- function LynxEvo.IsAnyMenuOpened() for E, _ in pairs(h) do
- if G(E) then
- return true end end;
- return false end;
- function LynxEvo.IsMenuAboutToBeClosed() if h[m] then
- return h[m].aboutToBeClosed
- else return false end end;
- function LynxEvo.CloseMenu() if h[m] then
- if h[m].aboutToBeClosed then h[m].aboutToBeClosed = false;
- H(m, false) B(tostring(m)..
- " menu closed") PlaySoundFrontend(-1, "QUIT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true) k = 0;
- m = nil;
- l = nil
- else h[m].aboutToBeClosed =
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement