From 7a7dc4bd39e2b072d48fb0c8c962d4a792190300 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Sun, 28 Jan 2024 19:51:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Run=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/[esx]/esx_textui/TextUI.lua | 25 +++++++------ .../resources/[esx]/esx_textui/fxmanifest.lua | 2 +- .../[esx]/esx_textui/nui/css/style.css | 23 +++++------- .../resources/[esx]/esx_textui/nui/index.html | 5 ++- .../[esx]/esx_textui/nui/js/script.js | 36 +++++++++---------- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/server-data/resources/[esx]/esx_textui/TextUI.lua b/server-data/resources/[esx]/esx_textui/TextUI.lua index 578c97722..e7fff219f 100644 --- a/server-data/resources/[esx]/esx_textui/TextUI.lua +++ b/server-data/resources/[esx]/esx_textui/TextUI.lua @@ -1,25 +1,30 @@ Debug = ESX.GetConfig().EnableDebug - +local isShowing = false ---@param message string ---@param typ string local function TextUI(message, typ) + isShowing = true SendNUIMessage({ - action = 'show', - message = message and message or 'ESX-TextUI', - type = type(typ) == "string" and typ or 'info' + action = "show", + message = message and message or "ESX-TextUI", + type = type(typ) == "string" and typ or "info", }) end local function HideUI() + if not isShowing then + return + end + isShowing = false SendNUIMessage({ - action = 'hide' + action = "hide", }) end -exports('TextUI', TextUI) -exports('HideUI', HideUI) -RegisterNetEvent('ESX:TextUI', TextUI) -RegisterNetEvent('ESX:HideUI', HideUI) +exports("TextUI", TextUI) +exports("HideUI", HideUI) +RegisterNetEvent("ESX:TextUI", TextUI) +RegisterNetEvent("ESX:HideUI", HideUI) if Debug then RegisterCommand("textui:error", function() @@ -37,4 +42,4 @@ if Debug then RegisterCommand("textui:hide", function() ESX.HideUI() end) -end +end \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_textui/fxmanifest.lua b/server-data/resources/[esx]/esx_textui/fxmanifest.lua index de41cf0d1..8710958a9 100644 --- a/server-data/resources/[esx]/esx_textui/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_textui/fxmanifest.lua @@ -1,7 +1,7 @@ fx_version 'adamant' game 'gta5' author 'ESX-Framework' -version '0.0.4' +version '1.0.0' description 'ESX TextUI' lua54 'yes' client_scripts { 'TextUI.lua' } diff --git a/server-data/resources/[esx]/esx_textui/nui/css/style.css b/server-data/resources/[esx]/esx_textui/nui/css/style.css index 5f8d27265..d8f62c2e8 100644 --- a/server-data/resources/[esx]/esx_textui/nui/css/style.css +++ b/server-data/resources/[esx]/esx_textui/nui/css/style.css @@ -24,8 +24,8 @@ body { min-width: 15%; width: fit-content; height: 50px; - background: rgba(5,5,5,.9); - border-radius: .5rem; + background: rgba(5, 5, 5, 0.9); + border-radius: 0.5rem; animation: growDown 300ms ease-in-out; align-items: center; } @@ -43,8 +43,8 @@ body { } .innerText { - padding-left: .4rem; - padding-right: .4rem; + padding-left: 0.4rem; + padding-right: 0.4rem; padding-top: 12.5px; width: 100%; height: 100%; @@ -56,27 +56,22 @@ body { .innerText .text { display: inline-block; - margin-left: .5rem; + margin-left: 0.5rem; margin-top: 4px; } - @keyframes growDown { 0% { transform: scaleY(0); } 80% { - transform: scaleY(1.1) + transform: scaleY(1.1); } 100% { - transform: scaleY(1) + transform: scaleY(1); } } .material-symbols-outlined { - font-variation-settings: - 'FILL' 0, - 'wght' 400, - 'GRAD' 0, - 'opsz' 48 -} + font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 48; +} \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_textui/nui/index.html b/server-data/resources/[esx]/esx_textui/nui/index.html index 970028830..a41199db2 100644 --- a/server-data/resources/[esx]/esx_textui/nui/index.html +++ b/server-data/resources/[esx]/esx_textui/nui/index.html @@ -3,9 +3,8 @@ - + -
@@ -27,4 +26,4 @@
- + \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_textui/nui/js/script.js b/server-data/resources/[esx]/esx_textui/nui/js/script.js index b83b850d7..c50478ad9 100644 --- a/server-data/resources/[esx]/esx_textui/nui/js/script.js +++ b/server-data/resources/[esx]/esx_textui/nui/js/script.js @@ -15,8 +15,8 @@ const types = { ["info"]: { ["message"]: "infoMessage", ["id"]: "notifyInfo", - } -} + }, +}; // the color codes example `i ~r~love~s~ donuts` const codes = { @@ -28,42 +28,41 @@ const codes = { "~c~": "grey", "~m~": "#212121", "~u~": "black", - "~o~": "orange" -} + "~o~": "orange", +}; -w.addEventListener('message', (event) => { +w.addEventListener("message", (event) => { if (event.data.action === "show") { if (lastType) { doc.getElementById(lastType).style.display = "none"; notification({ type: event.data.type, - message: event.data.message + message: event.data.message, }); } else { notification({ type: event.data.type, - message: event.data.message + message: event.data.message, }); } - } else - if (event.data.action === "hide") { + } else if (event.data.action === "hide") { if (lastType !== "") { - doc.getElementById(lastType).style.display = "none" + doc.getElementById(lastType).style.display = "none"; } else { - console.log("There isn't a textUI displaying!?") + console.log("There isn't a textUI displaying!?"); } } }); const replaceColors = (str, obj) => { - let strToReplace = str + let strToReplace = str; for (let id in obj) { - strToReplace = strToReplace.replace(new RegExp(id, 'g'), obj[id]) + strToReplace = strToReplace.replace(new RegExp(id, "g"), obj[id]); } - return strToReplace -} + return strToReplace; +}; notification = (data) => { for (color in codes) { @@ -79,7 +78,6 @@ notification = (data) => { } doc.getElementById(types[data.type]["id"]).style.display = "block"; - lastType = types[data.type]["id"] - doc.getElementById(types[data.type]["message"]).innerHTML = data["message"] - -} + lastType = types[data.type]["id"]; + doc.getElementById(types[data.type]["message"]).innerHTML = data["message"]; +}; \ No newline at end of file