Skip to content

Commit 11b0c91

Browse files
committed
Sort Faceposer flexes and groups like they appear in the model file
1 parent d646069 commit 11b0c91

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools

garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/faceposer.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,15 @@ function TOOL.BuildCPanel( CPanel, faceEntity )
354354

355355
local min, max = faceEntity:GetFlexBounds( i )
356356

357-
flexGroups[ group ] = flexGroups[ group ] or {}
358-
table.insert( flexGroups[ group ], { name = name, id = i, min = min, max = max, default = GenerateDefaultFlexValue( faceEntity, i ) } )
357+
flexGroups[ group ] = flexGroups[ group ] or { sortId = table.Count( flexGroups ), items = {} }
358+
table.insert( flexGroups[ group ].items, { name = name, id = i, min = min, max = max, default = GenerateDefaultFlexValue( faceEntity, i ) } )
359359
end
360360
end
361361

362362
local flexControllers = {}
363363
local moreThanOneGroup = table.Count( flexGroups ) > 1
364-
for group, items in pairs( flexGroups ) do
364+
for group, groupData in SortedPairsByMemberValue( flexGroups, "sortId" ) do
365+
local items = groupData.items
365366

366367
local groupForm = vgui.Create( "DForm", CPanel )
367368
groupForm:SetLabel( string.NiceName( group ) )
@@ -376,7 +377,7 @@ function TOOL.BuildCPanel( CPanel, faceEntity )
376377

377378
CPanel:AddItem( groupForm )
378379

379-
for id, item in pairs( items ) do
380+
for id, item in SortedPairsByMemberValue( items, "id" ) do
380381
local ctrl = groupForm:NumSlider( string.NiceName( item.name ), "faceposer_flex" .. item.id, item.min, item.max )
381382
ctrl:SetDefaultValue( item.default )
382383
ctrl:SetHeight( 11 ) -- This makes the controls all bunched up like how we want

0 commit comments

Comments
 (0)