This commit is contained in:
lifestorm
2024-08-04 23:12:27 +03:00
parent 0e770b2b49
commit ba1fc01b16
7084 changed files with 2173495 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Gary Tate
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,11 @@
# Bodygroup Manager
## Installation
- Download the folder as a .zip
- Place inside of your schema/plugins folder
## Preview
![Example](https://i.imgur.com/6bqX51s.png)
## Support
- Gary#1170

View File

@@ -0,0 +1,20 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local net = net
local vgui = vgui
net.Receive("ixBodygroupView", function()
local target = net.ReadEntity()
local proxyColors = net.ReadTable()
local panel = vgui.Create("ixBodygroupView")
panel:SetViewModel(target:GetModel())
panel:SetTarget(target, proxyColors)
end)

View File

@@ -0,0 +1,191 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
local PANEL = {}
function PANEL:Init()
--self:SetText("Bodygroup Manager")
self:SetSize(SScaleMin(800 / 3), SScaleMin(800 / 3))
self:Center()
self:SetTitle("Bodygroup Manager")
DFrameFixer(self)
self.clipboard = self:Add("DButton")
self.clipboard:Dock(BOTTOM)
self.clipboard:DockMargin(0, SScaleMin(4 / 3), 0, 0)
self.clipboard:SetText("Save Changes")
self.clipboard:SetFont("MenuFontBoldNoClamp")
self.clipboard:SetTall(SScaleMin(50 / 3))
self.clipboard.DoClick = function()
LocalPlayer():NotifyLocalized("You have set this character's bodygroups.")
local bodygroups = {}
for _, v in pairs(self.bodygroupIndex) do
table.insert(bodygroups, v.index, v.value)
end
local color = self.colorPicker:GetValue()
net.Start("ixBodygroupTableSet")
net.WriteEntity(self.target)
net.WriteTable(bodygroups)
net.WriteTable(color)
net.SendToServer()
end
self.model = self:Add("ixModelPanel")
self.model.rotating = true
self.model:Dock(FILL)
self.model:SetFOV(35)
self.model:SetModel(Model("models/props_junk/watermelon01.mdl"))
self.bodygroupPanel = self:Add("DScrollPanel")
self.bodygroupPanel:Dock(RIGHT)
self.bodygroupPanel:DockMargin(0, SScaleMin(7 / 3), 0, 0)
self.bodygroupPanel:SetWide(self:GetWide() - SScaleMin(300 / 3))
self.bodygroups = {}
PLUGIN.viewer = self
end
function PANEL:SetTarget(target, proxyColors)
self.target = target
self:PopulateBodygroupOptions(proxyColors)
self:SetTitle(target:GetName())
self.model.Entity.overrideProxyColors = proxyColors
end
function PANEL:PopulateBodygroupOptions(proxyColors)
self.bodygroupBox = {}
self.bodygroupName = {}
self.bodygroupPrevious = {}
self.bodygroupNext = {}
self.bodygroupIndex = {}
for k, v in pairs(self.target:GetBodyGroups()) do
-- Disregard the model bodygroup.
if !(v.id == 0) then
local index = v.id
self.bodygroupBox[v.id] = self.bodygroupPanel:Add("DPanel")
self.bodygroupBox[v.id]:Dock(TOP)
self.bodygroupBox[v.id]:DockMargin(0, SScaleMin(25 / 3), SScaleMin(25 / 3), 0)
self.bodygroupBox[v.id]:SetHeight(SScaleMin(50 / 3))
self.bodygroupBox[v.id].Paint = function(self, w, h)
surface.SetDrawColor(Color(40, 40, 40, 100))
surface.DrawRect(0, 0, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawOutlinedRect(0, 0, w, h)
end
local hairBg = self.model.Entity:FindBodygroupByName("hair")
self.bodygroupName[v.id] = self.bodygroupBox[v.id]:Add("DLabel")
self.bodygroupName[v.id].index = v.id
self.bodygroupName[v.id]:SetText(v.name:gsub("^%l", string.utf8upper))
self.bodygroupName[v.id]:SetFont("TitlesFontNoClamp")
self.bodygroupName[v.id]:Dock(LEFT)
self.bodygroupName[v.id]:DockMargin(SScaleMin(30 / 3), 0, 0, 0)
self.bodygroupName[v.id]:SetWidth(SScaleMin(200 / 3))
self.bodygroupNext[v.id] = self.bodygroupBox[v.id]:Add("DButton")
self.bodygroupNext[v.id].index = v.id
self.bodygroupNext[v.id]:Dock(RIGHT)
self.bodygroupNext[v.id]:SetFont("MenuFontNoClamp")
self.bodygroupNext[v.id]:SetText("Next")
self.bodygroupNext[v.id]:SetWide(SScaleMin(100 / 3))
self.bodygroupNext[v.id].DoClick = function()
local index = v.id
if (self.model.Entity:GetBodygroupCount(index) - 1) <= self.bodygroupIndex[index].value then
return
end
self.bodygroupIndex[index].value = self.bodygroupIndex[index].value + 1
self.bodygroupIndex[index]:SetText(self.bodygroupIndex[index].value)
self.model.Entity:SetBodygroup(index, self.bodygroupIndex[index].value)
local hairValue = self.bodygroupIndex[hairBg] and self.bodygroupIndex[hairBg].value
self.model:SetCorrectHair(v.name == "headwear" and hairValue)
end
self.bodygroupIndex[v.id] = self.bodygroupBox[v.id]:Add("DLabel")
self.bodygroupIndex[v.id].index = v.id
self.bodygroupIndex[v.id].value = self.target:GetBodygroup(index)
self.bodygroupIndex[v.id]:SetText(self.bodygroupIndex[v.id].value)
self.bodygroupIndex[v.id]:SetFont("TitlesFontNoClamp")
self.bodygroupIndex[v.id]:Dock(RIGHT)
self.bodygroupIndex[v.id]:SetContentAlignment(5)
self.bodygroupPrevious[v.id] = self.bodygroupBox[v.id]:Add("DButton")
self.bodygroupPrevious[v.id].index = v.id
self.bodygroupPrevious[v.id]:Dock(RIGHT)
self.bodygroupPrevious[v.id]:SetFont("MenuFontNoClamp")
self.bodygroupPrevious[v.id]:SetText("Previous")
self.bodygroupPrevious[v.id]:SetWide(SScaleMin(100 / 3))
self.bodygroupPrevious[v.id].DoClick = function()
local index = v.id
if 0 == self.bodygroupIndex[index].value then
return
end
self.bodygroupIndex[index].value = self.bodygroupIndex[index].value - 1
self.bodygroupIndex[index]:SetText(self.bodygroupIndex[index].value)
self.model.Entity:SetBodygroup(index, self.bodygroupIndex[index].value)
local hairValue = self.bodygroupIndex[hairBg] and self.bodygroupIndex[hairBg].value
self.model:SetCorrectHair(v.name == "headwear" and hairValue)
end
self.model.Entity:SetBodygroup(index, self.target:GetBodygroup(index))
local hairValue = self.bodygroupIndex[hairBg] and self.bodygroupIndex[hairBg].value
self.model:SetCorrectHair(v.name == "headwear" and hairValue)
end
end
local hairColor = self.bodygroupPanel:Add("DPanel")
hairColor:Dock(TOP)
hairColor:DockMargin(0, SScaleMin(25 / 3), SScaleMin(25 / 3), 0)
hairColor:SetHeight(SScaleMin(50 / 3))
hairColor.Paint = function(this, w, h)
surface.SetDrawColor(Color(40, 40, 40, 100))
surface.DrawRect(0, 0, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawOutlinedRect(0, 0, w, h)
end
self.colorPicker = hairColor:Add("ixSettingsRowColor")
self.colorPicker:Dock(FILL)
self.colorPicker:SetText("Hair Color")
if proxyColors["HairColor"] then
self.colorPicker:SetValue(proxyColors["HairColor"])
end
self.colorPicker.OnValueChanged = function(this, newColor)
proxyColors["HairColor"] = Color(newColor.r, newColor.g, newColor.b)
self.model.Entity.GetProxyColors = function()
return proxyColors
end
end
end
function PANEL:SetViewModel(model)
self.playerModel = model
if model then
self.model:SetModel(Model(model))
end
end
vgui.Register("ixBodygroupView", PANEL, "DFrame")

View File

@@ -0,0 +1,48 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local ix = ix
local bit = bit
local net = net
local PLUGIN = PLUGIN
PLUGIN.name = "Bodygroup Manager"
PLUGIN.author = "Gary Tate"
PLUGIN.description = "Allows players and administration to have an easier time customising bodygroups."
ix.lang.AddTable("english", {
cmdEditBodygroup = "Dostosuj bodygroupy celu."
})
ix.lang.AddTable("spanish", {
cmdEditBodygroup = "Personalizar los bodygroups de un objetivo."
})
ix.lang.AddTable("polish", {
cmdEditBodygroup = "Dostosuj bodygroupy celu."
})
ix.command.Add("CharEditBodygroup", {
description = "cmdEditBodygroup",
adminOnly = true,
arguments = {
bit.bor(ix.type.player, ix.type.optional)
},
OnRun = function(self, client, target)
net.Start("ixBodygroupView")
net.WriteEntity(target or client)
net.WriteTable(target:GetCharacter():GetProxyColors() or {})
net.Send(client)
end
})
ix.util.Include("sv_hooks.lua")
ix.util.Include("cl_hooks.lua")

View File

@@ -0,0 +1,79 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local util = util
local ix = ix
local string = string
local net = net
local IsValid = IsValid
local pairs = pairs
local tonumber = tonumber
util.AddNetworkString("ixBodygroupView")
util.AddNetworkString("ixBodygroupTableSet")
ix.log.AddType("bodygroupEditor", function(client, target)
return string.format("%s has changed %s's bodygroups.", client:GetName(), target:GetName())
end)
net.Receive("ixBodygroupTableSet", function(length, client)
if (!ix.command.HasAccess(client, "CharEditBodygroup") and !client:IsCombine()) then return end
local target = net.ReadEntity()
if (client:IsCombine() and !ix.command.HasAccess(client, "CharEditBodygroup") and target != client) then return end
if (!IsValid(target) or !target:IsPlayer() or !target:GetCharacter()) then
return
end
local bodygroups = net.ReadTable()
local groups = {}
for k, v in pairs(bodygroups) do
target:SetBodygroup(tonumber(k) or 0, tonumber(v) or 0)
groups[tonumber(k) or 0] = tonumber(v) or 0
local hairBG = client:FindBodygroupByName( "hair" )
if k != hairBG then continue end
if !client:GetModel():find("models/willardnetworks/citizens/") then continue end
local curHeadwearBG = client:GetBodygroup(client:FindBodygroupByName( "headwear" ))
local curHairBG = client:GetBodygroup(hairBG)
local hairBgLength = 0
for _, v2 in pairs(client:GetBodyGroups()) do
if v2.name != "hair" then continue end
if !v2.submodels then continue end
if !istable(v2.submodels) then continue end
hairBgLength = #v2.submodels
break
end
if (curHeadwearBG != 0) then
if curHairBG != 0 then
client:SetBodygroup(hairBG, hairBgLength)
end
end
end
target:GetCharacter():SetData("groups", groups)
local hairColor = net.ReadTable()
local charProxies = target:GetCharacter():GetProxyColors() or {}
charProxies["HairColor"] = Color(hairColor.r, hairColor.g, hairColor.b)
target:GetCharacter():SetProxyColors(charProxies)
ix.log.Add(client, "bodygroupEditor", target)
end)