Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade linked icon support #47

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)

local headerShown = false
local sendData = nil
Expand All @@ -20,12 +20,10 @@ local function openMenu(data, sort, skipFirst)
if sort then data = sortData(data, skipFirst) end
for _,v in pairs(data) do
if v["icon"] then
local img = "qb-inventory/html/"
if QBCore.Shared.Items[tostring(v["icon"])] then
if not string.find(QBCore.Shared.Items[tostring(v["icon"])].image, "images/") then
img = img.."images/"
if not string.find(QBCore.Shared.Items[tostring(v["icon"])].image, "//") and not string.find(v["icon"], "//") then
v["icon"] = "nui://qb-inventory/html/images/"..QBCore.Shared.Items[tostring(v["icon"])].image
end
v["icon"] = img..QBCore.Shared.Items[tostring(v["icon"])].image
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const openMenu = (data = null) => {
const getButtonRender = (header, message = null, id, isMenuHeader, isDisabled, icon) => {
return `
<div class="${isMenuHeader ? "title" : "button"} ${isDisabled ? "disabled" : ""}" id="${id}">
<div class="icon"> <img src=nui://${icon} width=30px onerror="this.onerror=null; this.remove();"> <i class="${icon}" onerror="this.onerror=null; this.remove();"></i> </div>
<div class="icon"> <img src=${icon} width=30px onerror="this.onerror=null; this.remove();"> <i class="${icon}" onerror="this.onerror=null; this.remove();"></i> </div>
<div class="column">
<div class="header"> ${header}</div>
${message ? `<div class="text">${message}</div>` : ""}
Expand Down
Loading