mirror of
https://github.com/shadowscion/Prop2Mesh.git
synced 2025-03-04 03:13:03 -05:00
additional convars
server: prop2mesh_disable_allowed 1/0 client prop2mesh_disable 1/0 prop2mesh_render_disable_obj 1/0
This commit is contained in:
parent
f9de4063ac
commit
2480cf0306
@ -37,6 +37,8 @@ end
|
||||
|
||||
]]
|
||||
if SERVER then
|
||||
CreateConVar("prop2mesh_disable_allowed", 0, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "prevents prop2mesh data from networking")
|
||||
|
||||
AddCSLuaFile("prop2mesh/cl_meshlab.lua")
|
||||
AddCSLuaFile("prop2mesh/cl_modelfixer.lua")
|
||||
AddCSLuaFile("prop2mesh/cl_editor.lua")
|
||||
@ -84,6 +86,8 @@ if SERVER then
|
||||
end, "Data")
|
||||
|
||||
elseif CLIENT then
|
||||
CreateClientConVar("prop2mesh_disable", 0, true, true)
|
||||
|
||||
if not shadowscion_standard_font then
|
||||
shadowscion_standard_font = "shadowscion_standard_font"
|
||||
surface.CreateFont(shadowscion_standard_font, {size = 13, weight = 800, font = "Tahoma"})
|
||||
|
@ -119,7 +119,11 @@ end)
|
||||
--[[
|
||||
|
||||
]]
|
||||
local allow_disable = GetConVar("prop2mesh_disable_allowed")
|
||||
|
||||
net.Receive("prop2mesh_download", function(len, pl)
|
||||
if allow_disable:GetBool() and tobool(pl:GetInfoNum("prop2mesh_disable", 0)) then return end
|
||||
|
||||
local self = net.ReadEntity()
|
||||
if not prop2mesh.isValid(self) then
|
||||
return
|
||||
@ -138,6 +142,8 @@ net.Receive("prop2mesh_download", function(len, pl)
|
||||
end)
|
||||
|
||||
net.Receive("prop2mesh_sync", function(len, pl)
|
||||
if allow_disable:GetBool() and tobool(pl:GetInfoNum("prop2mesh_disable", 0)) then return end
|
||||
|
||||
local self = net.ReadEntity()
|
||||
if not prop2mesh.isValid(self) then
|
||||
return
|
||||
|
@ -1198,16 +1198,23 @@ function PANEL:Init()
|
||||
self.progress:Dock(BOTTOM)
|
||||
self.progress:DockMargin(1, 1, 1, 1)
|
||||
self.progress:SetTall(16)
|
||||
|
||||
local disabled = GetConVar("prop2mesh_disable")
|
||||
self.progress.Paint = function(pnl, w, h)
|
||||
surface.SetDrawColor(theme.colorTree)
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
|
||||
if pnl.frac then
|
||||
surface.SetDrawColor(0, 255, 0)
|
||||
surface.DrawRect(0, 0, pnl.frac*w, h)
|
||||
|
||||
if pnl.text then
|
||||
draw.SimpleText(pnl.text, shadowscion_standard_font, w*0.5, h*0.5, theme.colorText_default, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
if disabled:GetBool() then
|
||||
surface.SetDrawColor(255, 0, 0)
|
||||
surface.DrawRect(0, 0, w*0.25, h)
|
||||
draw.SimpleText("prop2mesh is disabled...", shadowscion_standard_font, w*0.5, h*0.5, theme.colorText_kill, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
else
|
||||
surface.SetDrawColor(0, 255, 0)
|
||||
surface.DrawRect(0, 0, pnl.frac*w, h)
|
||||
if pnl.text then
|
||||
draw.SimpleText(pnl.text, shadowscion_standard_font, w*0.5, h*0.5, theme.colorText_default, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,6 +37,13 @@ local table_remove = table.remove
|
||||
|
||||
local a90 = Angle(0, -90, 0)
|
||||
|
||||
local cvar = CreateClientConVar("prop2mesh_render_disable_obj", 0, true, false)
|
||||
local disable_obj = cvar:GetBool()
|
||||
|
||||
cvars.AddChangeCallback("prop2mesh_render_disable_obj", function(cvar, old, new)
|
||||
disable_obj = tobool(new)
|
||||
end, "swapdrawdisable_obj")
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
@ -475,7 +482,50 @@ local function getVertsFromMDL(partnext, meshtex, vmins, vmaxs, direct)
|
||||
return partverts
|
||||
end
|
||||
|
||||
local function getFallbackOBJ(custom, partnext, meshtex, vmins, vmaxs, direct)
|
||||
local modeluid = tonumber(partnext.objd)
|
||||
local modelobj = custom[modeluid]
|
||||
|
||||
if not modelobj then
|
||||
return
|
||||
end
|
||||
|
||||
local omins, omaxs = Vector(), Vector()
|
||||
|
||||
local pos = partnext.pos
|
||||
local ang = partnext.ang
|
||||
local scale = partnext.scale
|
||||
|
||||
if scale then
|
||||
if scale.x == 1 and scale.y == 1 and scale.z == 1 then scale = nil end
|
||||
end
|
||||
|
||||
for line in string.gmatch(modelobj, "(.-)\n") do
|
||||
local temp = string_explode(" ", string_gsub(string_trim(line), "%s+", " "))
|
||||
local head = table_remove(temp, 1)
|
||||
|
||||
if head == "v" then
|
||||
local vert = Vector(tonumber(temp[1]), tonumber(temp[2]), tonumber(temp[3]))
|
||||
if scale then
|
||||
vert.x = vert.x * scale.x
|
||||
vert.y = vert.y * scale.y
|
||||
vert.z = vert.z * scale.z
|
||||
end
|
||||
calcbounds(omins, omaxs, vert)
|
||||
end
|
||||
end
|
||||
|
||||
pos = (omins + omaxs)*0.5
|
||||
ang = ang or Angle()
|
||||
|
||||
return getVertsFromMDL({ang = ang, pos = pos, prop = "models/hunter/blocks/cube025x025x025.mdl", scale = (omaxs - omins)/12}, meshtex, vmins, vmaxs, direct)
|
||||
end
|
||||
|
||||
local function getVertsFromOBJ(custom, partnext, meshtex, vmins, vmaxs, direct)
|
||||
if disable_obj then
|
||||
return getFallbackOBJ(custom, partnext, meshtex, vmins, vmaxs, direct)
|
||||
end
|
||||
|
||||
local modeluid = tonumber(partnext.objd)
|
||||
local modelobj = custom[modeluid]
|
||||
|
||||
|
@ -674,6 +674,41 @@ local function BuildPanel_ToolSettings(self)
|
||||
local pnl = vgui.Create("DForm")
|
||||
pnl:SetName("Tool Settings")
|
||||
|
||||
--
|
||||
local btn = pnl:Button("Reset all tool options")
|
||||
btn.DoClick = function()
|
||||
for var, _ in pairs(ConVars) do
|
||||
local convar = GetConVar("prop2mesh_" .. var)
|
||||
if convar then
|
||||
convar:Revert()
|
||||
end
|
||||
end
|
||||
timer.Simple(0.1, self.tempfixfilters)
|
||||
end
|
||||
|
||||
--
|
||||
local preset = vgui.Create("ControlPresets", pnl)
|
||||
|
||||
local cvarlist = {}
|
||||
for k, v in pairs(ConVars) do
|
||||
local name = "prop2mesh_" .. k
|
||||
cvarlist[name] = v
|
||||
preset:AddConVar(name)
|
||||
end
|
||||
|
||||
preset:SetPreset("prop2mesh")
|
||||
preset:AddOption("#preset.default", cvarlist)
|
||||
|
||||
preset.OnSelect = function(_, index, value, data)
|
||||
if not data then return end
|
||||
for k, v in pairs(data) do
|
||||
RunConsoleCommand(k, v)
|
||||
end
|
||||
timer.Simple(0.1, self.tempfixfilters)
|
||||
end
|
||||
|
||||
pnl:AddItem(preset)
|
||||
|
||||
--
|
||||
local help = pnl:Help("Danger zone")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
@ -683,6 +718,11 @@ local function BuildPanel_ToolSettings(self)
|
||||
surface.DrawLine(0, h - 1, w, h - 1)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Enable legacy mode", "prop2mesh_tool_legacymode")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Set selection alpha to 0 when done", "prop2mesh_tool_setalphazero")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
@ -693,22 +733,6 @@ local function BuildPanel_ToolSettings(self)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Enable legacy mode", "prop2mesh_tool_legacymode")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Hide legacy cubes", "prop2mesh_legacy_hide")
|
||||
cbox:SetTooltip("toggles 'prop2mesh_legacy_hide' convar")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Disable rendering", "prop2mesh_render_disable")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
--
|
||||
local help = pnl:Help("Selection filters")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
@ -785,60 +809,6 @@ local function BuildPanel_ToolSettings(self)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
local help = pnl:Help("Class filters")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
help:SetFont(help_font)
|
||||
help.Paint = function(_, w, h)
|
||||
surface.SetDrawColor(0, 0, 0, 255)
|
||||
surface.DrawLine(0, h - 1, w, h - 1)
|
||||
end
|
||||
|
||||
local scroll = vgui.Create("DScrollPanel", pnl)
|
||||
scroll:SetTall(96)
|
||||
scroll:Dock(FILL)
|
||||
pnl:AddItem(scroll)
|
||||
|
||||
local class_list_display = { "prop_physics", "gmod_wire_hologram", "starfall_hologram", "acf_armor", "sent_prop2mesh_legacy" }
|
||||
|
||||
if g_primitive then
|
||||
table.insert(class_list_display, 2, "primitive_shape")
|
||||
table.insert(class_list_display, 2, "primitive_rail_slider")
|
||||
end
|
||||
|
||||
local class_list_convar = GetConVar("prop2mesh_tool_filter_ilist")
|
||||
local class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
|
||||
local colortext_def = Color(55, 55, 55)
|
||||
local colortext_sel = Color(75, 175, 75)
|
||||
|
||||
local boxes = {}
|
||||
for k, v in ipairs(class_list_display) do
|
||||
local cbox = scroll:Add("DCheckBoxLabel")
|
||||
cbox:Dock(TOP)
|
||||
cbox:DockMargin(0, 0, 0, 5)
|
||||
cbox:SetText("Ignore " .. v)
|
||||
cbox.OnChange = function(_, val)
|
||||
class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
if val then class_list_filter[v] = true else class_list_filter[v] = nil end
|
||||
RunConsoleCommand("prop2mesh_tool_filter_ilist", table.concat(table.GetKeys(class_list_filter), ","))
|
||||
cbox:SetTextColor(val and colortext_sel or colortext_def)
|
||||
end
|
||||
cbox:SetChecked(class_list_filter[v] or false)
|
||||
cbox:SetTextColor(class_list_filter[v] and colortext_sel or colortext_def)
|
||||
cbox.key = v
|
||||
table.insert(boxes, cbox)
|
||||
end
|
||||
|
||||
self.tempfixfilters = function()
|
||||
local class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
for k, v in pairs(boxes) do
|
||||
v:SetChecked(class_list_filter[v.key] or false)
|
||||
v:SetTextColor(class_list_filter[v.key] and colortext_sel or colortext_def)
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
--
|
||||
local help = pnl:Help("Entity options")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
@ -921,17 +891,46 @@ local function BuildPanel_Profiler(self)
|
||||
return pnl
|
||||
end
|
||||
|
||||
TOOL.BuildCPanel = function(self)
|
||||
local btn = self:Button("Reset all tool options")
|
||||
btn.DoClick = function()
|
||||
for var, _ in pairs(ConVars) do
|
||||
local convar = GetConVar("prop2mesh_" .. var)
|
||||
if convar then
|
||||
convar:Revert()
|
||||
end
|
||||
end
|
||||
self.tempfixfilters()
|
||||
local function BuildPanel_AddonSettings(self)
|
||||
local pnl = vgui.Create("DForm")
|
||||
pnl:SetName("Addon Settings")
|
||||
|
||||
local help = pnl:Help("Stranger zone")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
help:SetFont(help_font)
|
||||
help.Paint = function(_, w, h)
|
||||
surface.SetDrawColor(0, 0, 0, 255)
|
||||
surface.DrawLine(0, h - 1, w, h - 1)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Disable legacy cubes", "prop2mesh_legacy_hide")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Disable obj generation", "prop2mesh_render_disable_obj")
|
||||
cbox:SetTooltip("Note: unless you rejoin, this will not apply to already generated meshes")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Disable rendering", "prop2mesh_render_disable")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
|
||||
local cbox = pnl:CheckBox("Disable everything", "prop2mesh_disable")
|
||||
cbox:SetTooltip("Note: unless you rejoin, this will not apply to already generated meshes")
|
||||
cbox.OnChange = function(_, value)
|
||||
cbox.Label:SetTextColor(value and Color(255, 0, 0) or nil)
|
||||
end
|
||||
pnl:ControlHelp("This must also be enabled on the server.")
|
||||
|
||||
return pnl
|
||||
end
|
||||
|
||||
TOOL.BuildCPanel = function(self)
|
||||
self:AddPanel(BuildPanel_AddonSettings(self))
|
||||
self:AddPanel(BuildPanel_ToolSettings(self))
|
||||
self:AddPanel(BuildPanel_Profiler(self))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user