Skip to content

Commit

Permalink
admin: Resource settings button is only displayed if there are settin…
Browse files Browse the repository at this point in the history
…gs (#490)
  • Loading branch information
T-MaxWiese-T authored May 23, 2024
1 parent 6713b07 commit 0224ef5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions [admin]/admin/client/gui/admin_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
aTab2.ResourceInclMaps = guiCreateCheckBox ( 0.03, 0.91, 0.15, 0.04, "Include Maps", false, true, aTab2.Tab )
aTab2.ResourceRefresh = guiCreateButton ( 0.20, 0.915, 0.18, 0.04, "Refresh list", true, aTab2.Tab, "listresources" )
aTab2.ResourceSettings = guiCreateButton ( 0.40, 0.05, 0.20, 0.04, "Settings", true, aTab2.Tab )
guiSetVisible ( aTab2.ResourceSettings, false)
aTab2.ResourceStart = guiCreateButton ( 0.40, 0.10, 0.20, 0.04, "Start", true, aTab2.Tab, "start" )
aTab2.ResourceRestart = guiCreateButton ( 0.40, 0.15, 0.20, 0.04, "Restart", true, aTab2.Tab, "restart" )
aTab2.ResourceStop = guiCreateButton ( 0.40, 0.20, 0.20, 0.04, "Stop", true, aTab2.Tab, "stop" )
Expand Down Expand Up @@ -1059,6 +1060,10 @@ function aClientClick ( button )
elseif ( source == aTab2.ResourceList ) then
guiSetVisible ( aTab2.ResourceFailture, false )
if ( guiGridListGetSelectedItem ( aTab2.ResourceList ) ~= -1 ) then
local resName = guiGridListGetItemText(aTab2.ResourceList, guiGridListGetSelectedItem( aTab2.ResourceList ), 1)
if resName then
triggerServerEvent("aAdmin", localPlayer, "resourcelist", resName)
end
guiSetText(aTab2.ResourceName, "Full Name: " .. guiGridListGetItemText(aTab2.ResourceList, guiGridListGetSelectedItem ( aTab2.ResourceList ), 4))
guiSetText(aTab2.ResourceAuthor, "Author: " .. guiGridListGetItemText(aTab2.ResourceList, guiGridListGetSelectedItem ( aTab2.ResourceList ), 5))
guiSetText(aTab2.ResourceVersion, "Version: " .. guiGridListGetItemText(aTab2.ResourceList, guiGridListGetSelectedItem ( aTab2.ResourceList ), 6))
Expand Down Expand Up @@ -1192,6 +1197,16 @@ function aClientClick ( button )
end
end

addEvent ("setVisibilityOfSettingsButton", true)
function setVisibilityOfSettingsButton (hasResourceSetting)
if hasResourceSetting then
guiSetVisible(aTab2.ResourceSettings, true)
else
guiSetVisible(aTab2.ResourceSettings, false)
end
end
addEventHandler ( "setVisibilityOfSettingsButton", resourceRoot, setVisibilityOfSettingsButton)

function aClientRender ()
if ( guiGetVisible ( aAdminForm ) ) then
if ( getTickCount() >= aLastCheck ) then
Expand Down
11 changes: 11 additions & 0 deletions [admin]/admin/server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,17 @@ addEventHandler ( "aAdmin", root, function ( action, ... )
end
end
triggerClientEvent ( source, "aAdminSettings", root, cmd, resName, tableOut )
elseif (action == "resourcelist") then
local resName = arg[1]
local count = true
_, count = aGetResourceSettings(resName, count)
if count then
local hasResourceSetting
if count ~= 0 then
hasResourceSetting = true
end
triggerClientEvent ( source, "setVisibilityOfSettingsButton", resourceRoot, hasResourceSetting)
end
elseif ( action == "sync" ) then
local type = arg[1]
local tableOut = {}
Expand Down

0 comments on commit 0224ef5

Please sign in to comment.