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

feat(client/main): Job Outfit Management #45

Merged
merged 11 commits into from
Jan 24, 2024
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"locale",
"MySQL"
]
}
}
39 changes: 34 additions & 5 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,30 @@ local config = require 'config.client'
local JOBS = exports.qbx_core:GetJobs()
local GANGS = exports.qbx_core:GetGangs()
local isLoggedIn = LocalPlayer.state.isLoggedIn
local dynamicMenuItems = {}

lib.locale()

-- Adds item to the boss/gang menu.
---@param menuItem ContextMenuItem Requires args.type to be set to know which menu to place in.
---@return number menuId ID of the menu item added
local function addMenuItem(menuItem)
local menuId = #dynamicMenuItems + 1
if not menuItem.args.type then return end
dynamicMenuItems[menuId] = lib.table.deepclone(menuItem)
return menuId
end
exports('AddBossMenuItem', addMenuItem)
exports('AddGangMenuItem', addMenuItem)
Manason marked this conversation as resolved.
Show resolved Hide resolved

-- Remove menu item at particular id
---@param id number Menu ID to remove
local function removeMenuItem(id)
dynamicMenuItems[id] = nil
end
exports('RemoveBossMenuItem', removeMenuItem)
exports('RemoveGangMenuItem', removeMenuItem)

-- Finds nearby players and returns a table of server ids
---@return table
local function findPlayers()
Expand Down Expand Up @@ -40,7 +61,7 @@ local function manageEmployee(player, groupName, groupType)

employeeMenu[#employeeMenu + 1] = {
title = groupType == 'gang' and locale('menu.expel_gang') or locale('menu.fire_employee'),
icon = 'fa-solid fa-user-large-slash',
icon = 'user-large-slash',
onSelect = function()
lib.callback.await('qbx_management:server:fireEmployee', false, player.cid, groupType)
OpenBossMenu(groupType)
Expand Down Expand Up @@ -122,26 +143,34 @@ function OpenBossMenu(groupType)
{
title = groupType == 'gang' and locale('menu.manage_gang') or locale('menu.manage_employees'),
description = groupType == 'gang' and locale('menu.check_gang') or locale('menu.check_employee'),
icon = 'fa-solid fa-list',
icon = 'list',
onSelect = function()
employeeList(groupType)
end,
},
{
title = groupType == 'gang' and locale('menu.hire_members') or locale('menu.hire_employees'),
description = groupType == 'gang' and locale('menu.hire_gang') or locale('menu.hire_civilians'),
icon = 'fa-solid fa-hand-holding',
icon = 'hand-holding',
onSelect = function()
showHireMenu(groupType)
end,
},
}


for _, menuItem in pairs(dynamicMenuItems) do
if string.lower(menuItem.args.type) == groupType then
bossMenu[#bossMenu + 1] = menuItem
end
end

lib.registerContext({
id = 'openBossMenu',
title = groupType == 'gang' and string.upper(QBX.PlayerData.gang.label) or string.upper(QBX.PlayerData.job.label),
options = bossMenu,
})

lib.showContext('openBossMenu')
end

Expand All @@ -155,7 +184,7 @@ local function createZone(zoneInfo)
options = {
{
name = zoneInfo.groupName..'_menu',
icon = 'fa-solid fa-right-to-bracket',
icon = 'right-to-bracket',
label = zoneInfo.type == 'gang' and locale('menu.gang_menu') or locale('menu.boss_menu'),
canInteract = function()
return zoneInfo.groupName == QBX.PlayerData[zoneInfo.type].name and QBX.PlayerData[zoneInfo.type].isboss
Expand Down Expand Up @@ -218,4 +247,4 @@ end)

CreateThread(function()
if not isLoggedIn then return end
end)
end)
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"hired_to": "You've been hired into ",
"hired_into": "You hired %{who} into %{where}"
}
}
}
Loading