From a8404844461b7ca07eacd5e27d88e63aed28dbe0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 17 Oct 2020 04:11:41 +0300 Subject: [PATCH 1/2] Hands preview. Requires seq_admire sequence to be present in the hands model. --- lua/autorun/lf_playermodel_selector.lua | 78 +++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/lua/autorun/lf_playermodel_selector.lua b/lua/autorun/lf_playermodel_selector.lua index 36193cf..8538e8f 100644 --- a/lua/autorun/lf_playermodel_selector.lua +++ b/lua/autorun/lf_playermodel_selector.lua @@ -555,7 +555,12 @@ function Menu.Setup() Menu.Right = Frame:Add( "DPropertySheet" ) Menu.Right:Dock( RIGHT ) Menu.Right:SetSize( 430, 0 ) - + + Menu.Right.OnActiveTabChanged = function( self, oldTab, newTab ) + Menu.IsHandsTabActive = newTab.IsHandsTab + + timer.Simple( 0, function() Menu.UpdateFromConvars() end ) + end local modeltab = Menu.Right:Add( "DPropertySheet" ) Menu.Right:AddSheet( "Model", modeltab, "icon16/user.png" ) @@ -654,8 +659,10 @@ function Menu.Setup() Menu.ModelPopulate() ------------------------------------------------------------- - local handtab = Menu.Right:Add( "DPropertySheet" ) - Menu.Right:AddSheet( "Hands", handtab, "icon16/attach.png" ) + local handtab = Menu.Right:Add( "DPropertySheet" ) + local htb = Menu.Right:AddSheet( "Hands", handtab, "icon16/attach.png" ) + + htb.Tab.IsHandsTab = true local t = handtab:Add( "DLabel" ) t:SetPos( 129, 1 ) @@ -1431,6 +1438,12 @@ function Menu.Setup() return string.Implode( " ", newname ) end + function Menu.PlayHandsPreviewAnimation( panel, playermodel ) + local iSeq = panel.Entity:LookupSequence( "seq_admire" ) + + if ( iSeq > 0 ) then panel.Entity:ResetSequence( iSeq ) end + end + function Menu.PlayPreviewAnimation( panel, playermodel ) if ( !panel or !IsValid( panel.Entity ) ) then return end @@ -1451,9 +1464,11 @@ function Menu.Setup() -- Updating function Menu.UpdateBodyGroups( pnl, val ) + local handsTabActive = Menu.IsHandsTabActive + if ( pnl.type == "bgroup" ) then - mdl.Entity:SetBodygroup( pnl.typenum, math.Round( val ) ) + if ( not handsTabActive ) then mdl.Entity:SetBodygroup( pnl.typenum, math.Round( val ) ) end local str = string.Explode( " ", GetConVar( "cl_playerbodygroups" ):GetString() ) if ( #str < pnl.typenum + 1 ) then for i = 1, pnl.typenum + 1 do str[ i ] = str[ i ] or 0 end end @@ -1462,7 +1477,7 @@ function Menu.Setup() elseif ( pnl.type == "flex" ) then - mdl.Entity:SetFlexWeight( pnl.typenum, math.Round( val, 2 ) ) + if ( not handsTabActive ) then mdl.Entity:SetFlexWeight( pnl.typenum, math.Round( val, 2 ) ) end local str = string.Explode( " ", GetConVar( "cl_playerflexes" ):GetString() ) if ( #str < pnl.typenum + 1 ) then for i = 1, pnl.typenum + 1 do str[ i ] = str[ i ] or 0 end end @@ -1471,7 +1486,7 @@ function Menu.Setup() elseif ( pnl.type == "skin" ) then - mdl.Entity:SetSkin( math.Round( val ) ) + if ( not handsTabActive ) then mdl.Entity:SetSkin( math.Round( val ) ) end RunConsoleCommand( "cl_playerskin", math.Round( val ) ) end @@ -1569,6 +1584,26 @@ function Menu.Setup() end function Menu.UpdateFromConvars() + if ( Menu.IsHandsTabActive ) then + local model = LocalPlayer():GetInfo( "cl_playerhands" ) + + if ( model == "" ) then + model = LocalPlayer():GetInfo( "cl_playermodel" ) + end + + local mdlhands = player_manager.TranslatePlayerHands( model ) + + util.PrecacheModel( mdlhands.model ) + mdl:SetModel( mdlhands.model ) + + mdl.Entity:SetSkin( mdlhands.skin ) + mdl.Entity:SetBodyGroups( mdlhands.body ) + mdl.Entity.GetPlayerColor = function() return Vector( GetConVar( "cl_playercolor" ):GetString() ) end + + Menu.PlayHandsPreviewAnimation( mdl, model ) + + return + end local model = LocalPlayer():GetInfo( "cl_playermodel" ) local modelname = player_manager.TranslatePlayerModel( model ) @@ -1611,9 +1646,40 @@ function Menu.Setup() function mdl:DragMouseRelease() self.Pressed = false end + function mdl:RunAnimation() -- override to restart hands animation + if ( Menu.IsHandsTabActive and self.Entity:GetCycle() > 0.99 ) then + self.Entity:SetCycle( 0 ) + end + + self.Entity:FrameAdvance( ( RealTime() - self.LastPaint ) * self.m_fAnimSpeed ) + end + + local handsang = Angle( 0, 180, 0 ) + function mdl:LayoutEntity( Entity ) if ( self.bAnimated ) then self:RunAnimation() end + if ( Menu.IsHandsTabActive ) then + self.WasHandsTab = true + + self:SetFOV( 65 ) + + self.Angles = handsang + self.Pos = vector_origin + + Entity:SetAngles( self.Angles ) + Entity:SetPos( self.Pos ) + + return + elseif ( self.WasHandsTab ) then -- reset position on tab switch + self.WasHandsTab = false + + self:SetFOV( 36 ) + + self.Pos = Vector( -100, 0, -61 ) + self.Angles = Angle( 0, 0, 0 ) + end + if ( self.Pressed == MOUSE_LEFT ) then local mx, my = gui.MousePos() self.Angles = self.Angles - Angle( 0, ( self.PressX or mx ) - mx, 0 ) From 1249ed2175e89de19d194871b67f0e2520c7c0a8 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Fri, 16 Oct 2020 21:17:08 -0400 Subject: [PATCH 2/2] Update lf_playermodel_selector.lua --- lua/autorun/lf_playermodel_selector.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/autorun/lf_playermodel_selector.lua b/lua/autorun/lf_playermodel_selector.lua index 8538e8f..4239272 100644 --- a/lua/autorun/lf_playermodel_selector.lua +++ b/lua/autorun/lf_playermodel_selector.lua @@ -353,7 +353,7 @@ end if CLIENT then -local Version = "3.3 (Fesiug edit 1)" +local Version = "3.3 (Edit 2)" local Menu = { } local Frame local default_animations = { "idle_all_01", "menu_walk", "pose_standing_02", "pose_standing_03", "idle_fist" } @@ -1350,6 +1350,7 @@ function Menu.Setup() local intro = [[Created by LibertyForce.
Thank you for installing this addon! Enjoying it?
Modified by Fesiug. You can now customize your hands!
+ Modified by YuRaNnNzZZ. You can see your selected hands!
Please leave a LIKE on the workshop page.]] if !game.SinglePlayer() and !LocalPlayer():IsSuperAdmin() then intro = [[This server is running Enhanced PlayerModel Selector by LibertyForce. Enjoying it?
@@ -1786,4 +1787,4 @@ for k, v in pairs( fav ) do end -end \ No newline at end of file +end