mirror of
https://github.com/shadowscion/Prop2Mesh.git
synced 2025-03-04 03:13:03 -05:00
redo tool class filter
This commit is contained in:
parent
83a24c8773
commit
b5962bd2f0
@ -84,6 +84,11 @@ if SERVER then
|
||||
end, "Data")
|
||||
|
||||
elseif CLIENT then
|
||||
if not shadowscion_standard_font then
|
||||
shadowscion_standard_font = "shadowscion_standard_font"
|
||||
surface.CreateFont(shadowscion_standard_font, {size = 13, weight = 800, font = "Tahoma"})
|
||||
end
|
||||
|
||||
include("prop2mesh/sh_netstream.lua")
|
||||
include("prop2mesh/cl_meshlab.lua")
|
||||
include("prop2mesh/cl_modelfixer.lua")
|
||||
|
@ -236,8 +236,6 @@ end
|
||||
|
||||
]]
|
||||
local theme = {}
|
||||
theme.font = "prop2mesheditor"
|
||||
surface.CreateFont(theme.font, { size = 15, weight = 400, font = "Roboto Mono" })
|
||||
|
||||
theme.colorText_add = Color(100, 200, 100)
|
||||
theme.colorText_edit = Color(100, 100, 255)
|
||||
@ -251,14 +249,14 @@ local wireframe = Material("models/wireframe")
|
||||
local TreeAddNode, NodeAddNode
|
||||
function TreeAddNode(self, text, icon, font)
|
||||
local node = DTree.AddNode(self, string.lower(text), icon)
|
||||
node.Label:SetFont(font or theme.font)
|
||||
node.Label:SetFont(font or shadowscion_standard_font)
|
||||
node.Label:SetTextColor(theme.colorText_default)
|
||||
node.AddNode = NodeAddNode
|
||||
return node
|
||||
end
|
||||
function NodeAddNode(self, text, icon, font)
|
||||
local node = DTree_Node.AddNode(self, string.lower(text), icon)
|
||||
node.Label:SetFont(font or theme.font)
|
||||
node.Label:SetFont(font or shadowscion_standard_font)
|
||||
node.Label:SetTextColor(theme.colorText_default)
|
||||
node.AddNode = NodeAddNode
|
||||
return node
|
||||
@ -427,7 +425,7 @@ local function registerString(partnode, name, key)
|
||||
text:SetSize(cellWidth, h)
|
||||
end
|
||||
|
||||
text:SetFont(theme.font)
|
||||
text:SetFont(shadowscion_standard_font)
|
||||
text.OnValueChange = function(self, val)
|
||||
if not tostring(val) then
|
||||
self:SetText(partnode.new[key])
|
||||
@ -494,7 +492,7 @@ local function registerVector(partnode, name, key)
|
||||
end
|
||||
|
||||
for i, v in ipairs({x, y, z}) do
|
||||
v:SetFont(theme.font)
|
||||
v:SetFont(shadowscion_standard_font)
|
||||
v:SetNumeric(true)
|
||||
v.OnValueChange = function(self, val)
|
||||
if not tonumber(val) then
|
||||
@ -542,7 +540,7 @@ local function registerBoolean(partnode, name, key)
|
||||
|
||||
x:SetValue(partnode.new[key] == 1)
|
||||
x:SetTextColor(theme.colorText_default)
|
||||
x:SetFont(theme.font)
|
||||
x:SetFont(shadowscion_standard_font)
|
||||
end
|
||||
|
||||
local function registerFloat(partnode, name, key, min, max)
|
||||
@ -553,7 +551,7 @@ local function registerFloat(partnode, name, key, min, max)
|
||||
x:Dock(LEFT)
|
||||
x:DockMargin(24, 0, 4, 0)
|
||||
x:SetText(name)
|
||||
x:SetFont(theme.font)
|
||||
x:SetFont(shadowscion_standard_font)
|
||||
x:SetTextColor(theme.colorText_default)
|
||||
|
||||
local s = vgui.Create("DNumSlider", node)
|
||||
@ -563,7 +561,7 @@ local function registerFloat(partnode, name, key, min, max)
|
||||
s.Scratch:SetVisible(false)
|
||||
s.Label:SetVisible(false)
|
||||
s.Label:SetTextColor(theme.colorText_default)
|
||||
s.TextArea:SetFont(theme.font)
|
||||
s.TextArea:SetFont(shadowscion_standard_font)
|
||||
s:SetWide(128)
|
||||
s:DockMargin(24, 0, 4, 0)
|
||||
s:Dock(LEFT)
|
||||
@ -639,7 +637,7 @@ local function registerSubmodels(partnode)
|
||||
x:SetValue(new[i] == 1)
|
||||
x:SetToolTip(string.format("tris: %d\nmat: %s", #submeshes[i].triangles, submeshes[i].material))
|
||||
x:SetTextColor(theme.colorText_default)
|
||||
x:SetFont(theme.font)
|
||||
x:SetFont(shadowscion_standard_font)
|
||||
end
|
||||
end
|
||||
|
||||
@ -807,7 +805,7 @@ local function setGlobalValue(frame, conroot, mod, key, value, name, force)
|
||||
frame.btnConfirm:DoClick()
|
||||
end, "No")
|
||||
|
||||
pnl.lblTitle:SetFont(theme.font)
|
||||
pnl.lblTitle:SetFont(shadowscion_standard_font)
|
||||
pnl.lblTitle:SetTextColor(color_white)
|
||||
|
||||
local time = SysTime()
|
||||
@ -840,7 +838,7 @@ local function conmenu(frame, conroot)
|
||||
frame.btnConfirm:DoClick()
|
||||
end, "No", function() end)
|
||||
|
||||
pnl.lblTitle:SetFont(theme.font)
|
||||
pnl.lblTitle:SetFont(shadowscion_standard_font)
|
||||
pnl.lblTitle:SetTextColor(color_white)
|
||||
|
||||
local time = SysTime()
|
||||
@ -867,7 +865,7 @@ local function conmenu(frame, conroot)
|
||||
frame.btnConfirm:DoClick()
|
||||
end)
|
||||
|
||||
pnl.lblTitle:SetFont(theme.font)
|
||||
pnl.lblTitle:SetFont(shadowscion_standard_font)
|
||||
pnl.lblTitle:SetTextColor(color_white)
|
||||
|
||||
local time = SysTime()
|
||||
@ -949,7 +947,7 @@ local function setEntityActual(self, ent)
|
||||
self.Entity:CallOnRemove("prop2mesh_editor_close", function()
|
||||
self:Remove()
|
||||
end)
|
||||
self.lblTitle:SetFont(theme.font)
|
||||
self.lblTitle:SetFont(shadowscion_standard_font)
|
||||
self:SetTitle(tostring(self.Entity))
|
||||
self:RemakeTree()
|
||||
end
|
||||
@ -1130,7 +1128,7 @@ function PANEL:Init()
|
||||
self.btnConfirm = vgui.Create("DButton", self)
|
||||
self.btnConfirm:Dock(BOTTOM)
|
||||
self.btnConfirm:DockMargin(0, 2, 0, 0)
|
||||
self.btnConfirm:SetFont(theme.font)
|
||||
self.btnConfirm:SetFont(shadowscion_standard_font)
|
||||
self.btnConfirm:SetText("Confirm changes")
|
||||
self.btnConfirm.DoClick = function()
|
||||
if not IsValid(self.Entity) then
|
||||
@ -1209,7 +1207,7 @@ function PANEL:Init()
|
||||
surface.DrawRect(0, 0, pnl.frac*w, h)
|
||||
|
||||
if pnl.text then
|
||||
draw.SimpleText(pnl.text, theme.font, w*0.5, h*0.5, theme.colorText_default, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
draw.SimpleText(pnl.text, shadowscion_standard_font, w*0.5, h*0.5, theme.colorText_default, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1382,7 +1380,7 @@ function PANEL:RemakeTree()
|
||||
import.ShowIcons = HideIcons
|
||||
|
||||
local btnImport = vgui.Create("DButton", import)
|
||||
btnImport:SetFont(theme.font)
|
||||
btnImport:SetFont(shadowscion_standard_font)
|
||||
btnImport:SetText("Open file browser")
|
||||
btnImport:SizeToContents()
|
||||
btnImport:Dock(LEFT)
|
||||
@ -1404,7 +1402,7 @@ function PANEL:RemakeTree()
|
||||
|
||||
for k, v in ipairs(condata) do
|
||||
local root = v.objd and objlist or mdllist
|
||||
local name = v.prop or v.holo or v.objn or v.objd or (v.primitive and "primitive_" .. v.primitive.shape)
|
||||
local name = v.prop or v.holo or v.objn or v.objd or (v.primitive and "primitive_" .. v.primitive.construct)
|
||||
local part = root:AddNode(string.format("[%d] %s", k, string.GetFileFromFilename(name)))
|
||||
part:SetIcon("icon16/brick.png")
|
||||
|
||||
@ -1420,7 +1418,7 @@ end
|
||||
function PANEL:OpenFileBrowser(title, folder, wildcards, attachmentNode, menuCallback)
|
||||
local frame = vgui.Create("DFrame", self)
|
||||
|
||||
frame.lblTitle:SetFont(theme.font)
|
||||
frame.lblTitle:SetFont(shadowscion_standard_font)
|
||||
frame:SetTitle(title)
|
||||
frame:SetSize(self:GetWide()*0.75, self:GetTall()*0.5)
|
||||
frame:Center()
|
||||
|
@ -198,7 +198,11 @@ local function getVertsFromPrimitive(partnext, meshtex, vmins, vmaxs, direct)
|
||||
if partnext.vsmooth == 1 and partnext.primitive then
|
||||
partnext.primitive.modv = string.gsub(partnext.primitive.modv or "", "(normals=%d+)", "")
|
||||
end
|
||||
local submeshes = prop2mesh.primitive.primitive_build(partnext.primitive)
|
||||
if meshtex then partnext.primitive.skipUV = true end
|
||||
|
||||
local submeshes = prop2mesh.primitive.construct_get(partnext.primitive.construct, partnext.primitive, true, true)
|
||||
submeshes = submeshes.triangle
|
||||
|
||||
if not submeshes then
|
||||
return
|
||||
end
|
||||
@ -719,7 +723,7 @@ local function setmessage(text)
|
||||
|
||||
local green = Color(255, 255, 0)
|
||||
local black = Color(0,0,0)
|
||||
local font = "prop2mesheditor"
|
||||
local font = shadowscion_standard_font or "Default"
|
||||
|
||||
message.Paint = function(self, w, h)
|
||||
draw.SimpleTextOutlined(self.text, font, 0, 0, green, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, black)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -80,22 +80,11 @@ function prop2mesh.sanitizeCustom(partlist) -- remove unused obj data
|
||||
partlist.custom = custom
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
]]
|
||||
local getBodygroupMask = prop2mesh.getBodygroupMask
|
||||
|
||||
entclass.prop_physics = function(partlist, ent, worldpos, worldang)
|
||||
local part = { prop = ent:GetModel() }
|
||||
local function basic_info(partlist, ent, worldpos, worldang)
|
||||
local part = {}
|
||||
|
||||
part.pos, part.ang = WorldToLocal(ent:GetPos(), ent:GetAngles(), worldpos, worldang)
|
||||
|
||||
local bodygroup = getBodygroupMask(ent)
|
||||
if bodygroup ~= 0 then
|
||||
part.bodygroup = bodygroup
|
||||
end
|
||||
|
||||
local scale
|
||||
if ent.GetScale then scale = ent:GetScale() else scale = ent:GetManipulateBoneScale(0) end
|
||||
if isvector(scale) and scale.x ~= 1 or scale.y ~= 1 or scale.z ~= 1 then
|
||||
@ -122,6 +111,25 @@ entclass.prop_physics = function(partlist, ent, worldpos, worldang)
|
||||
end
|
||||
end
|
||||
|
||||
return part
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
]]
|
||||
local getBodygroupMask = prop2mesh.getBodygroupMask
|
||||
|
||||
entclass.prop_physics = function(partlist, ent, worldpos, worldang)
|
||||
local part = basic_info(partlist, ent, worldpos, worldang)
|
||||
|
||||
part.prop = ent:GetModel()
|
||||
|
||||
local bodygroup = getBodygroupMask(ent)
|
||||
if bodygroup ~= 0 then
|
||||
part.bodygroup = bodygroup
|
||||
end
|
||||
|
||||
partlist[#partlist + 1] = part
|
||||
end
|
||||
|
||||
@ -247,48 +255,30 @@ entclass.sent_prop2mesh_legacy = function(partlist, ent, worldpos, worldang)
|
||||
end
|
||||
|
||||
entclass.primitive_shape = function(partlist, ent, worldpos, worldang)
|
||||
local vars = ent:GetNetworkVars()
|
||||
local part = { shape = vars._primitive_shape }
|
||||
if not ent._primitive_GetVars then return end
|
||||
|
||||
local typevars = ent:Get_primitive_typevars(part.type)
|
||||
for k, v in pairs(typevars) do
|
||||
part[string.gsub(k, "_primitive_", "")] = vars[k]
|
||||
end
|
||||
local vars = ent:_primitive_GetVars(nil, true)
|
||||
if not vars or next(vars) == nil then return end
|
||||
|
||||
if next(part) == nil then
|
||||
return
|
||||
end
|
||||
vars.construct = vars.shape
|
||||
vars.shape = nil
|
||||
|
||||
part = { primitive = part }
|
||||
|
||||
part.pos, part.ang = WorldToLocal(ent:GetPos(), ent:GetAngles(), worldpos, worldang)
|
||||
|
||||
local scale
|
||||
if ent.GetScale then scale = ent:GetScale() else scale = ent:GetManipulateBoneScale(0) end
|
||||
if isvector(scale) and scale.x ~= 1 or scale.y ~= 1 or scale.z ~= 1 then
|
||||
part.scale = scale
|
||||
end
|
||||
|
||||
local clips = ent.ClipData or ent.EntityMods and ent.EntityMods.clips
|
||||
if clips then
|
||||
local pclips = {}
|
||||
for _, clip in ipairs(clips) do
|
||||
if not clip.n or not clip.d then
|
||||
goto badclip
|
||||
end
|
||||
if clip.inside then
|
||||
part.vinside = 1
|
||||
end
|
||||
local normal = clip.n:Forward()
|
||||
pclips[#pclips + 1] = { n = normal, d = clip.d + normal:Dot(ent.OBBCenterOrg or ent:OBBCenter()) }
|
||||
|
||||
::badclip::
|
||||
end
|
||||
if next(pclips) then
|
||||
part.clips = pclips
|
||||
end
|
||||
end
|
||||
local part = basic_info(partlist, ent, worldpos, worldang)
|
||||
part.primitive = vars
|
||||
|
||||
partlist[#partlist + 1] = part
|
||||
end
|
||||
|
||||
entclass.primitive_rail_slider = function(partlist, ent, worldpos, worldang)
|
||||
if not ent._primitive_GetVars then return end
|
||||
|
||||
local vars = ent:_primitive_GetVars(nil, true)
|
||||
if not vars or next(vars) == nil then return end
|
||||
|
||||
vars.construct = "rail_slider"
|
||||
|
||||
local part = basic_info(partlist, ent, worldpos, worldang)
|
||||
part.primitive = vars
|
||||
|
||||
partlist[#partlist + 1] = part
|
||||
end
|
||||
|
@ -732,6 +732,60 @@ local function BuildPanel_ToolSettings(self)
|
||||
pnl:ControlHelp("Ignore entities with mass above this value.")
|
||||
|
||||
--
|
||||
local class_list_convar = GetConVar("prop2mesh_tool_filter_ilist")
|
||||
local class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
local class_list_display = { "prop_physics", "gmod_wire_hologram", "starfall_hologram", "acf_armor", "sent_prop2mesh_legacy" }
|
||||
|
||||
local combo = vgui.Create("DComboBox", pnl)
|
||||
pnl:AddItem(combo)
|
||||
|
||||
local id = combo:SetText("Class filters")
|
||||
combo:SetFont(help_font)
|
||||
combo:SetSortItems(false)
|
||||
|
||||
combo.OnMenuOpened = function(_, menu)
|
||||
menu:GetChild(menu:ChildCount()):SetFont("DermaDefaultBold")
|
||||
end
|
||||
|
||||
combo.OnSelect = function(_, id, value, func)
|
||||
combo:SetText("Class filters")
|
||||
if isfunction(func) then func(id, value, true) end
|
||||
end
|
||||
|
||||
local function onChoose(id, value, cmd)
|
||||
class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
if class_list_filter[value] == true then class_list_filter[value] = nil else class_list_filter[value] = true end
|
||||
if cmd then RunConsoleCommand("prop2mesh_tool_filter_ilist", table.concat(table.GetKeys(class_list_filter), ",")) end
|
||||
combo.ChoiceIcons[id] = class_list_filter[value] and "icon16/cross.png" or nil
|
||||
end
|
||||
|
||||
local choices = {}
|
||||
for k, v in SortedPairsByValue(class_list_display) do
|
||||
local id = combo:AddChoice(v, onChoose, nil, class_list_filter[v] and "icon16/cross.png")
|
||||
choices[id] = v
|
||||
end
|
||||
|
||||
if g_primitive then
|
||||
combo:AddSpacer()
|
||||
|
||||
local v = "primitive_shape"
|
||||
choices[combo:AddChoice(v, onChoose, nil, class_list_filter[v] and "icon16/cross.png")] = v
|
||||
|
||||
local v = "primitive_rail_slider"
|
||||
choices[combo:AddChoice(v, onChoose, nil, class_list_filter[v] and "icon16/cross.png")] = v
|
||||
end
|
||||
|
||||
combo:AddSpacer()
|
||||
combo:AddChoice("cancel")
|
||||
|
||||
self.tempfixfilters = function()
|
||||
local class_list_filter = GetClientFilters(class_list_convar:GetString())
|
||||
for id, value in pairs(choices) do
|
||||
combo.ChoiceIcons[id] = class_list_filter[value] and "icon16/cross.png" or nil
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
local help = pnl:Help("Class filters")
|
||||
help:DockMargin(0, 0, 0, 0)
|
||||
help:SetFont(help_font)
|
||||
@ -740,19 +794,18 @@ local function BuildPanel_ToolSettings(self)
|
||||
surface.DrawLine(0, h - 1, w, h - 1)
|
||||
end
|
||||
|
||||
--[[
|
||||
pnl:CheckBox("Ignore props", "prop2mesh_tool_filter_iprop")
|
||||
pnl:CheckBox("Ignore holos", "prop2mesh_tool_filter_iholo")
|
||||
pnl:CheckBox("Ignore acf armor", "prop2mesh_tool_filter_ipacf")
|
||||
pnl:CheckBox("Ignore legacy p2m", "prop2mesh_tool_filter_ilp2m")
|
||||
]]
|
||||
|
||||
local scroll = vgui.Create("DScrollPanel", pnl)
|
||||
scroll:SetTall(96)
|
||||
scroll:Dock(FILL)
|
||||
pnl:AddItem(scroll)
|
||||
|
||||
local class_list_display = { "prop_physics", "primitive_shape", "gmod_wire_hologram", "starfall_hologram", "acf_armor", "sent_prop2mesh_legacy" }
|
||||
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())
|
||||
|
||||
@ -784,6 +837,7 @@ local function BuildPanel_ToolSettings(self)
|
||||
v:SetTextColor(class_list_filter[v.key] and colortext_sel or colortext_def)
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
--
|
||||
local help = pnl:Help("Entity options")
|
||||
|
Loading…
Reference in New Issue
Block a user