mirror of
https://github.com/TeamUlysses/ulx.git
synced 2025-03-04 03:03:13 -05:00
Improve sandbox settings menu:
- Add missing sandbox settings from the Gmod admin menu (new replicated cvars), reorder and rename to make them more consistent - Improve layout, general sandbox settings are now laid out with dock and now scrollable, sandbox limits are more spaced out so longer limit names can be visible - Fix sbox_persist being a string, not an on/off setting. (Sorry for making your persisted props to always save to a "<map>_1.txt" file) - Attempting fix for sandbox settings wigging out when edited from the gmod admin menu
This commit is contained in:
parent
3b957bef5e
commit
67a332977a
@ -4,29 +4,47 @@
|
||||
xgui.prepareDataType( "sboxlimits" )
|
||||
local sbox_settings = xlib.makepanel{ parent=xgui.null }
|
||||
|
||||
xlib.makecheckbox{ x=10, y=10, label="Enable Noclip", repconvar="rep_sbox_noclip", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=30, label="Enable Godmode", repconvar="rep_sbox_godmode", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=50, label="Enable PvP Damage", repconvar="rep_sbox_playershurtplayers", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=70, label="Spawn With Weapons", repconvar="rep_sbox_weapons", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=90, label="Limited Physgun", repconvar="rep_physgun_limited", parent=sbox_settings }
|
||||
local sidepanel = xlib.makescrollpanel{ x=5, y=5, w=160, h=322, spacing=4, parent=sbox_settings }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,0,0,0}, label="Give weapons on spawn", convar=xlib.ifListenHost("sbox_weapons"), repconvar=xlib.ifNotListenHost("rep_sbox_weapons"), parent=sidepanel }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,5,0,0}, label="Players have god mode", convar=xlib.ifListenHost("sbox_godmode"), repconvar=xlib.ifNotListenHost("rep_sbox_godmode"), parent=sidepanel }
|
||||
|
||||
xlib.makecheckbox{ x=10, y=130, label="Persist Props", repconvar="rep_sbox_persist", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=150, label="Bone Manip. Misc", repconvar="rep_sbox_bonemanip_misc", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=170, label="Bone Manip. NPC", repconvar="rep_sbox_bonemanip_npc", parent=sbox_settings }
|
||||
xlib.makecheckbox{ x=10, y=190, label="Bone Manip. Player", repconvar="rep_sbox_bonemanip_player", parent=sbox_settings }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,20,0,0}, label="Allow PvP", convar=xlib.ifListenHost("sbox_playershurtplayers"), repconvar=xlib.ifNotListenHost("rep_sbox_playershurtplayers"), parent=sidepanel }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,5,0,0}, label="Allow noclip", convar=xlib.ifListenHost("sbox_noclip"), repconvar=xlib.ifNotListenHost("rep_sbox_noclip"), parent=sidepanel }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,5,0,0}, label="Bone manip. NPCs", convar=xlib.ifListenHost("sbox_bonemanip_npc"), repconvar=xlib.ifNotListenHost("rep_sbox_bonemanip_npc"), parent=sidepanel }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,5,0,0}, label="Bone manip. players", convar=xlib.ifListenHost("sbox_bonemanip_player"), repconvar=xlib.ifNotListenHost("rep_sbox_bonemanip_player"), parent=sidepanel }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,5,0,0}, label="Bone manip. everything", convar=xlib.ifListenHost("sbox_bonemanip_misc"), repconvar=xlib.ifNotListenHost("rep_sbox_bonemanip_misc"), parent=sidepanel }
|
||||
|
||||
xlib.makelabel{ x=5, y=247, w=140, wordwrap=true, label="NOTE: The non-ulx cvars configurable in XGUI are provided for easy access only and DO NOT SAVE when the server is shut down or crashes.", parent=sbox_settings }
|
||||
sbox_settings.plist = xlib.makelistlayout{ x=140, y=5, h=322, w=440, spacing=1, padding=2, parent=sbox_settings }
|
||||
xlib.makecheckbox{ dock=TOP, dockmargin={0,20,0,0}, label="Limited physgun", convar=xlib.ifListenHost("physgun_limited"), repconvar=xlib.ifNotListenHost("rep_physgun_limited"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Max beam range", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=128, max=8192, convar=xlib.ifListenHost("physgun_maxrange"), repconvar=xlib.ifNotListenHost("rep_physgun_maxrange"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Teleport Distance", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=0, max=10000, convar=xlib.ifListenHost("physgun_teleportDistance"), repconvar=xlib.ifNotListenHost("rep_physgun_teleportDistance"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Max Prop Speed", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=0, max=10000, convar=xlib.ifListenHost("physgun_maxSpeed"), repconvar=xlib.ifNotListenHost("rep_physgun_maxSpeed"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Max Angular Speed", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=0, max=10000, convar=xlib.ifListenHost("physgun_maxAngular"), repconvar=xlib.ifNotListenHost("rep_physgun_maxAngular"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Time To Arrive", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=0, max=2, decimal=2, convar=xlib.ifListenHost("physgun_timeToArrive"), repconvar=xlib.ifNotListenHost("rep_physgun_timeToArrive"), parent=sidepanel }
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,5,0,0}, label="Time To Arrive (Ragdolls)", parent=sidepanel }
|
||||
xlib.makeslider{ dock=TOP, dockmargin={0,2,5,0}, label="<--->", w=125, min=0, max=2, decimal=2, convar=xlib.ifListenHost("physgun_timeToArriveRagdoll"), repconvar=xlib.ifNotListenHost("rep_physgun_timeToArriveRagdoll"), parent=sidepanel }
|
||||
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,20,0,0}, w=138, label="Persistence file:", parent=sidepanel }
|
||||
xlib.maketextbox{ h=25, dock=TOP, dockmargin={0,5,5,0}, label="Persist Props", convar=xlib.ifListenHost("sbox_persist"), repconvar=xlib.ifNotListenHost("rep_sbox_persist"), parent=sidepanel }
|
||||
|
||||
xlib.makelabel{ dock=TOP, dockmargin={0,20,0,0}, w=138, wordwrap=true, label="NOTE: Sandbox settings are provided for convience and are not saved after the server restarts or crashes.", parent=sidepanel }
|
||||
|
||||
sbox_settings.plist = xlib.makelistlayout{ x=170, y=5, h=322, w=410, spacing=1, padding=2, parent=sbox_settings }
|
||||
|
||||
function sbox_settings.processLimits()
|
||||
sbox_settings.plist:Clear()
|
||||
for g, limits in ipairs( xgui.data.sboxlimits ) do
|
||||
if #limits > 0 then
|
||||
local panel = xlib.makepanel{ h=5+math.ceil( #limits/2 )*25 }
|
||||
local panel = xlib.makepanel{ dockpadding={ 0,0,0,5 } }
|
||||
local i=0
|
||||
for _, cvar in ipairs( limits ) do
|
||||
local cvardata = string.Explode( " ", cvar ) --Split the cvarname and max slider value number
|
||||
xgui.queueFunctionCall( xlib.makeslider, "sboxlimits", { x=10+(i%2*205), y=5+math.floor(i/2)*25, w=200, label="Max " .. cvardata[1]:sub(9), min=0, max=cvardata[2], repconvar="rep_"..cvardata[1], parent=panel, fixclip=true } )
|
||||
xgui.queueFunctionCall( xlib.makelabel, "sboxlimits", { x=10+(i%2*195), y=5+math.floor(i/2)*40, w=185, label="Max " .. cvardata[1]:sub(9), parent=panel } )
|
||||
xgui.queueFunctionCall( xlib.makeslider, "sboxlimits", { x=10+(i%2*195), y=20+math.floor(i/2)*40, w=185, label="<--->", min=0, max=cvardata[2], convar=xlib.ifListenHost(cvardata[1]), repconvar=xlib.ifNotListenHost("rep_"..cvardata[1]), parent=panel, fixclip=true } )
|
||||
i = i + 1
|
||||
end
|
||||
sbox_settings.plist:Add( xlib.makecat{ label=limits.title .. " (" .. #limits .. " limit" .. ((#limits > 1) and "s" or "") .. ")", contents=panel, expanded=( g==1 ) } )
|
||||
|
@ -5,16 +5,24 @@ local function init()
|
||||
if ULib.isSandbox() then --Only execute the following code if it's a sandbox gamemode
|
||||
xgui.addDataType( "sboxlimits", function() return xgui.sboxLimits end, "xgui_gmsettings", 0, -20 )
|
||||
|
||||
ULib.replicatedWritableCvar( "physgun_limited", "rep_physgun_limited", GetConVarNumber( "physgun_limited" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_noclip", "rep_sbox_noclip", GetConVarNumber( "sbox_noclip" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_godmode", "rep_sbox_godmode", GetConVarNumber( "sbox_godmode" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_playershurtplayers", "rep_sbox_playershurtplayers", GetConVarNumber( "sbox_playershurtplayers" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_weapons", "rep_sbox_weapons", GetConVarNumber( "sbox_weapons" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_godmode", "rep_sbox_godmode", GetConVarNumber( "sbox_godmode" ), false, false, "xgui_gmsettings" )
|
||||
|
||||
ULib.replicatedWritableCvar( "sbox_persist", "rep_sbox_persist", GetConVarNumber( "sbox_persist" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_bonemanip_misc", "rep_sbox_bonemanip_misc", GetConVarNumber( "sbox_bonemanip_misc" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_playershurtplayers", "rep_sbox_playershurtplayers", GetConVarNumber( "sbox_playershurtplayers" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_noclip", "rep_sbox_noclip", GetConVarNumber( "sbox_noclip" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_bonemanip_npc", "rep_sbox_bonemanip_npc", GetConVarNumber( "sbox_bonemanip_npc" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_bonemanip_player", "rep_sbox_bonemanip_player", GetConVarNumber( "sbox_bonemanip_player" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "sbox_bonemanip_misc", "rep_sbox_bonemanip_misc", GetConVarNumber( "sbox_bonemanip_misc" ), false, false, "xgui_gmsettings" )
|
||||
|
||||
ULib.replicatedWritableCvar( "physgun_limited", "rep_physgun_limited", GetConVarNumber( "physgun_limited" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_maxrange", "rep_physgun_maxrange", GetConVarNumber( "physgun_maxrange" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_teleportDistance", "rep_physgun_teleportDistance", GetConVarNumber( "physgun_teleportDistance" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_maxSpeed", "rep_physgun_maxSpeed", GetConVarNumber( "physgun_maxSpeed" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_maxAngular", "rep_physgun_maxAngular", GetConVarNumber( "physgun_maxAngular" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_timeToArrive", "rep_physgun_timeToArrive", GetConVarNumber( "physgun_timeToArrive" ), false, false, "xgui_gmsettings" )
|
||||
ULib.replicatedWritableCvar( "physgun_timeToArriveRagdoll", "rep_physgun_timeToArriveRagdoll", GetConVarString( "physgun_timeToArriveRagdoll" ), false, false, "xgui_gmsettings" )
|
||||
|
||||
ULib.replicatedWritableCvar( "sbox_persist", "rep_sbox_persist", GetConVarNumber( "sbox_persist" ), false, false, "xgui_gmsettings" )
|
||||
|
||||
--Process the list of known Sandbox Cvar Limits and check if they exist
|
||||
xgui.sboxLimits = {}
|
||||
|
Loading…
Reference in New Issue
Block a user