diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 953296d2..535c24e7 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -154,9 +154,10 @@ end ---@param notifyType? string The type of notification to show ---@param length? number The length of the notification ---@param title? string The title of the notification +---@param position? string The position of the notification ---@return nil -function ESX.ShowNotification(message, notifyType, length, title) - return IsResourceFound('esx_notify') and exports['esx_notify']:Notify(notifyType, length, message, title) +function ESX.ShowNotification(message, notifyType, length, title, position) + return IsResourceFound('esx_notify') and exports['esx_notify']:Notify(notifyType, length, message, title, position) end function ESX.TextUI(...) diff --git a/[core]/es_extended/server/classes/player.lua b/[core]/es_extended/server/classes/player.lua index a2359e0a..ee8f0a3e 100644 --- a/[core]/es_extended/server/classes/player.lua +++ b/[core]/es_extended/server/classes/player.lua @@ -103,7 +103,7 @@ ---@field setMeta fun(index: string, value: any, subValue?: any) # Set metadata value(s). ---@field clearMeta fun(index: string, subValues?: string|table) # Clear metadata value(s). --- Notification Functions ----@field showNotification fun(msg: string, notifyType?: string, length?: number) # Show a simple notification. +---@field showNotification fun(msg: string, notifyType?: string, length?: number, title?: string, position?: string) # Show a simple notification. ---@field showAdvancedNotification fun(sender: string, subject: string, msg: string, textureDict: string, iconType: string, flash: boolean, saveToBrief: boolean, hudColorIndex: number) # Show advanced notification. ---@field showHelpNotification fun(msg: string, thisFrame?: boolean, beep?: boolean, duration?: number) # Show help notification. --- Misc Functions @@ -793,11 +793,10 @@ function CreateExtendedPlayer(playerId, identifier, ssn, group, accounts, invent return nil, nil end - function self.showNotification(msg, notifyType, length) - self.triggerEvent("esx:showNotification", msg, notifyType, length) + function self.showNotification(msg, notifyType, length, title, position) + self.triggerEvent("esx:showNotification", msg, notifyType, length, title, position) end - function self.showAdvancedNotification(sender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex) self.triggerEvent("esx:showAdvancedNotification", sender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex) end diff --git a/[core]/esx_notify/Config.lua b/[core]/esx_notify/Config.lua index e56a8901..21b40d59 100644 --- a/[core]/esx_notify/Config.lua +++ b/[core]/esx_notify/Config.lua @@ -1,3 +1,4 @@ Config = {} -Config.notificationSoundEnabled = true \ No newline at end of file +Config.notificationSoundEnabled = true +Config.position = "middle-right" -- top-right, top-left, top-middle, bottom-right, bottom-left, bottom-middle, middle-left, middle-right \ No newline at end of file diff --git a/[core]/esx_notify/Notify.lua b/[core]/esx_notify/Notify.lua index 0061974e..d690fbd6 100644 --- a/[core]/esx_notify/Notify.lua +++ b/[core]/esx_notify/Notify.lua @@ -1,16 +1,28 @@ local Debug = ESX.GetConfig().EnableDebug +local possiblePosition = { + ["top-right"] = true, + ["top-left"] = true, + ["top-middle"] = true, + ["bottom-right"] = true, + ["bottom-left"] = true, + ["bottom-middle"] = true, + ["middle-left"] = true, + ["middle-right"] = true +} ---@param notificatonType string the notification type ---@param length number the length of the notification ---@param message any the message :D ---@param title string optional title for the notification -local function Notify(notificatonType, length, message, title) +---@param position string optional position for the notification +local function Notify(notificatonType, length, message, title, position) if Debug then print("1 ".. tostring(notificatonType)) print("2 "..tostring(length)) print("3 "..message) print("4 "..tostring(title)) + print("5 "..tostring(position)) end if type(notificatonType) ~= "string" then @@ -21,11 +33,16 @@ local function Notify(notificatonType, length, message, title) length = 3000 end + if not possiblePosition[position] then + position = Config.position or "middle-right" + end + if Debug then - print("5 ".. tostring(notificatonType)) - print("6 "..tostring(length)) - print("7 "..message) - print("8 "..tostring(title)) + print("6 ".. tostring(notificatonType)) + print("7 "..tostring(length)) + print("8 "..message) + print("9 "..tostring(title)) + print("10 "..tostring(position)) end if type(message) == "string" then @@ -37,7 +54,8 @@ local function Notify(notificatonType, length, message, title) length = length or 5000, message = message or "ESX-Notify", title = title or "New Notification", - notificationSoundEnabled = Config.notificationSoundEnabled + position = position, + notificationSoundEnabled = Config.notificationSoundEnabled or false })) end @@ -67,5 +85,5 @@ if Debug then RegisterCommand("notify4", function() ESX.ShowNotification("You Did something ~r~WRONG~s~!", "warning", 3000, "~y~Warning~s~") - end) -end + end) +end \ No newline at end of file diff --git a/[core]/esx_notify/nui/css/style.css b/[core]/esx_notify/nui/css/style.css index acb1b142..6d02c9a1 100644 --- a/[core]/esx_notify/nui/css/style.css +++ b/[core]/esx_notify/nui/css/style.css @@ -1,196 +1,337 @@ @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap"); :root { - --background: rgba(20, 20, 20, 0.9); - --text-color: #ffffff; - --text-secondary: rgba(255, 255, 255, 0.7); - --success-color: #2ecc71; - --success-border: #1f9c4d; - --error-color: #e74c3c; - --error-border: #c0392b; - --info-color: #3498db; - --info-border: #2980b9; - --warning-color: #f39c12; - --warning-border: #d35400; + --background: rgba(20, 20, 20, 0.9); + --text-color: #ffffff; + --text-secondary: rgba(255, 255, 255, 0.7); + --success-color: #2ecc71; + --success-border: #1f9c4d; + --error-color: #e74c3c; + --error-border: #c0392b; + --info-color: #3498db; + --info-border: #2980b9; + --warning-color: #f39c12; + --warning-border: #d35400; } * { - margin: 0; - padding: 0; - box-sizing: border-box; + margin: 0; + padding: 0; + box-sizing: border-box; } body { - width: 100vw; - height: 100vh; - font-family: "Poppins", sans-serif; - overflow: hidden; + width: 100vw; + height: 100vh; + font-family: "Poppins", sans-serif; + overflow: hidden; } -#root { - position: fixed; - right: 2rem; - top: 50%; - transform: translateY(-50%); - display: flex; - flex-direction: column; - align-items: flex-end; - gap: 10px; - max-height: 80vh; - z-index: 1000; +.notification-container { + position: fixed; + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 10px; + max-height: 80vh; + z-index: 1000; +} + +#middle-right { + right: 2rem; + top: 50%; + transform: translateY(-50%); +} + +#middle-left { + left: 2rem; + top: 50%; + transform: translateY(-50%); +} + +#top-right { + right: 2rem; + top: 2rem; +} + +#top-left { + left: 2rem; + top: 2rem; +} + +#top-middle { + left: 50%; + top: 2rem; + transform: translateX(-50%); +} + +#bottom-right { + right: 2rem; + bottom: 2rem; +} + +#bottom-left { + left: 2rem; + bottom: 2rem; +} + +#bottom-middle { + left: 50%; + bottom: 2rem; + transform: translateX(-50%); } .notify { - display: flex; - width: 300px; - background: var(--background); - border-radius: 8px; - overflow: hidden; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); - position: relative; - padding: 12px; - align-items: center; - border-left: 4px solid #555; + display: flex; + width: 300px; + background: var(--background); + border-radius: 8px; + overflow: hidden; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + position: relative; + padding: 12px; + align-items: center; + border-left: 4px solid #555; } .notify-success { - border-left-color: var(--success-border); + border-left-color: var(--success-border); } .notify-error { - border-left-color: var(--error-border); + border-left-color: var(--error-border); } .notify-info { - border-left-color: var(--info-border); + border-left-color: var(--info-border); } .notify-warning { - border-left-color: var(--warning-border); + border-left-color: var(--warning-border); } .notify-icon-container { - margin-right: 12px; - display: flex; - align-items: center; - justify-content: center; + margin-right: 12px; + display: flex; + align-items: center; + justify-content: center; } .hexagon { - position: relative; - width: 40px; - height: 40px; - display: flex; - align-items: center; - justify-content: center; - clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); - background: linear-gradient(145deg, var(--icon-color), rgba(0, 0, 0, 0.7)); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); + position: relative; + width: 40px; + height: 40px; + display: flex; + align-items: center; + justify-content: center; + clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); + background: linear-gradient(145deg, var(--icon-color), rgba(0, 0, 0, 0.7)); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); } .hexagon::before { - content: ""; - position: absolute; - top: 3px; - left: 3px; - right: 3px; - bottom: 3px; - background: var(--background); - clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); - z-index: 1; + content: ""; + position: absolute; + top: 3px; + left: 3px; + right: 3px; + bottom: 3px; + background: var(--background); + clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); + z-index: 1; } .hexagon::after { - content: ""; - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - background: linear-gradient(145deg, var(--icon-color) 10%, transparent 70%); - opacity: 0.4; - clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); - z-index: 2; + content: ""; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(145deg, var(--icon-color) 10%, transparent 70%); + opacity: 0.4; + clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); + z-index: 2; } .hexagon .material-symbols-outlined { - color: var(--icon-color); - font-size: 20px; - position: relative; - z-index: 3; - filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5)); - display: flex; - align-items: center; - justify-content: center; - height: 24px; - width: 24px; - margin-top: -1px; + color: var(--icon-color); + font-size: 20px; + position: relative; + z-index: 3; + filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5)); + display: flex; + align-items: center; + justify-content: center; + height: 24px; + width: 24px; + margin-top: -1px; } .notify-content { - flex: 1; - position: relative; - padding-bottom: 8px; + flex: 1; + position: relative; + padding-bottom: 8px; } .notify-title { - color: var(--text-color); - font-size: 14px; - font-weight: 600; - margin-bottom: 2px; + color: var(--text-color); + font-size: 14px; + font-weight: 600; + margin-bottom: 2px; } .notify-text { - color: var(--text-secondary); - font-size: 12px; - font-weight: 400; + color: var(--text-secondary); + font-size: 12px; + font-weight: 400; } .notify-progress { - position: absolute; - bottom: 0; - left: 0; - height: 2px; - width: 100%; - border-radius: 1px; + position: absolute; + bottom: 0; + left: 0; + height: 2px; + width: 100%; + border-radius: 1px; } .material-symbols-outlined { - font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 48; + font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 48; } .notify-warning .material-symbols-outlined, .notify-error .material-symbols-outlined { - margin-top: -2px; + margin-top: -2px; } -.fadeIn { - animation: fadeIn 0.3s ease-in-out; +#top-right .fadeIn, +#bottom-right .fadeIn, +#middle-right .fadeIn { + animation: fadeIn-right 0.3s ease-in-out; +} + +#top-left .fadeIn, +#bottom-left .fadeIn, +#middle-left .fadeIn { + animation: fadeIn-left 0.3s ease-in-out; +} + +#top-middle .fadeIn { + animation: fadeIn-top 0.3s ease-in-out; +} + +#bottom-middle .fadeIn { + animation: fadeIn-bottom 0.3s ease-in-out; } .fadeOut { - animation: fadeOut 0.5s ease-in-out; - opacity: 0; + opacity: 0; } -@keyframes fadeIn { - from { - opacity: 0; - transform: translateX(50px); - } - to { - opacity: 1; - transform: translateX(0); - } +#top-right .fadeOut, +#bottom-right .fadeOut, +#middle-right .fadeOut { + animation: fadeOut-right 0.5s ease-in-out; } -@keyframes fadeOut { - from { - opacity: 1; - transform: translateX(0); - } - to { - opacity: 0; - transform: translateX(50px); - } +#top-left .fadeOut, +#bottom-left .fadeOut, +#middle-left .fadeOut { + animation: fadeOut-left 0.5s ease-in-out; +} + +#top-middle .fadeOut { + animation: fadeOut-top 0.5s ease-in-out; +} +#bottom-middle .fadeOut { + animation: fadeOut-bottom 0.5s ease-in-out; +} + +@keyframes fadeIn-right { + from { + opacity: 0; + transform: translateX(50px); + } + to { + opacity: 1; + transform: translateX(0); + } +} + +@keyframes fadeIn-left { + from { + opacity: 0; + transform: translateX(-50px); + } + to { + opacity: 1; + transform: translateX(0); + } +} + +@keyframes fadeIn-top { + from { + opacity: 0; + transform: translateY(-50px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes fadeIn-bottom { + from { + opacity: 0; + transform: translateY(50px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes fadeOut-right { + from { + opacity: 1; + transform: translateX(0); + } + to { + opacity: 0; + transform: translateX(50px); + } +} + +@keyframes fadeOut-left { + from { + opacity: 1; + transform: translateX(0); + } + to { + opacity: 0; + transform: translateX(-50px); + } +} + +@keyframes fadeOut-top { + from { + opacity: 1; + transform: translateY(0); + } + to { + opacity: 0; + transform: translateY(-50px); + } +} + +@keyframes fadeOut-bottom { + from { + opacity: 1; + transform: translateY(0); + } + to { + opacity: 0; + transform: translateY(50px); + } } diff --git a/[core]/esx_notify/nui/index.html b/[core]/esx_notify/nui/index.html index 76a62faa..9bdb502c 100644 --- a/[core]/esx_notify/nui/index.html +++ b/[core]/esx_notify/nui/index.html @@ -1,15 +1,39 @@ -
- - - -