Skip to content

Commit

Permalink
Uploaded to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Fesiug committed Oct 14, 2020
1 parent f22c5b7 commit 087e21e
Show file tree
Hide file tree
Showing 6 changed files with 1,881 additions and 16 deletions.
190 changes: 190 additions & 0 deletions Upload.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
:: Place this file in your addon folder and run it.
:: The "addon.json" is generated automatically.
:: After uploading, the UID must be entered. It is stored in "workshop_id.cmd"
:: Do not remove the generated "workshop_id.cmd"!
:: If the GarrysMod path is incorrect then change it!
:: By Mohamed RACHID.

@echo off

:: Configuration:
set GarrysMod=C:\Program Files (x86)\Steam\steamapps\common\GarrysMod

:: Note: a '+' is prepended for replacements in variables to avoid empty variables, which do not handle replacements.

:: Find path from addon path if GarrysMod path is missing.
if not exist "%GarrysMod%\bin\gmad.exe" goto fixpath
if not exist "%GarrysMod%\bin\gmpublish.exe" goto fixpath
goto name
:fixpath
set GarrysMod=%CD%\..\..\..
if not exist "%GarrysMod%\bin\gmad.exe" goto nobin
if not exist "%GarrysMod%\bin\gmpublish.exe" goto nobin
goto name

:: Get the addon name:
:name
set i=0
:nameloop
echo set name=%%CD:~-%i%%%> Upload.temp.cmd
call Upload.temp.cmd
set /A i=i+1
:: loop until first found backslash
if not "%name:~0,1%"=="\" goto nameloop
del Upload.temp.cmd
set name=%name:~1%

:: Create addon.json if missing
:json
cls
if exist "addon.json" goto gma
echo.
set /P title=Please enter the title of the addon (no accents):
set title=+%title%
set title=%title:"='%
set title=%title:~1%
echo.
echo List of allowed types:
echo - effects
echo - gamemode
echo - map
echo - model
echo - npc
echo - ServerContent
echo - tool
echo - vehicle
echo - weapon
set /P type=Please enter the type of the addon (case-sensitive):
set type=+%type%
set type=%type:"=%
set type=%type:~1%
echo.
echo List of allowed tags:
echo - build
echo - cartoon
echo - comic
echo - fun
echo - movie
echo - realism
echo - roleplay
echo - scenic
echo - water
set /P tag1=Please enter the tag 1 of 2 of the addon (optional, case-sensitive):
set tag1=+%tag1%
set tag1=%tag1:"=%
set tag1=%tag1:~1%
set tag2=
if "%tag1%"=="" goto jsontagprocess
set /P tag2=Please enter the tag 2 of 2 of the addon (optional, case-sensitive):
set tag2=+%tag2%
set tag2=%tag2:"=%
set tag2=%tag2:~1%
:jsontagprocess
if "%tag1%"=="" goto jsontag0
if "%tag2%"=="" goto jsontag1
goto jsontag2
:jsontag0
set tags=
goto jsontagok
:jsontag1
set tags="%tag1%"
goto jsontagok
:jsontag2
set tags="%tag1%","%tag2%"
goto jsontagok
:jsontagok
echo {> addon.json
echo "title" : "%title%",>> addon.json
echo "type" : "%type%",>> addon.json
echo "tags" : [%tags%],>> addon.json
echo "ignore":>> addon.json
echo [>> addon.json
echo "*.cmd",>> addon.json
echo "*.ini",>> addon.json
echo "*.lnk",>> addon.json
echo "*.url",>> addon.json
echo "%name%.jpg",>> addon.json
echo "%name%.png">> addon.json
echo ]>> addon.json
echo }>> addon.json
cls
type addon.json
echo.
echo If you need to modify this generated addon.json, close this window now.
pause

:: Create GMA archive
:gma
set target=%GarrysMod%\%name%.gma
del "%target%"> NUL 2>&1
echo.
"%GarrysMod%\bin\gmad.exe" create -out "%target%" -folder "%CD%\\"
if not exist "%target%" goto nogma
echo.
echo If no problem happened, press any key to continue...
pause> NUL

:: Upload GMA
cls
set thumbnail=
if exist "%name%.jpg" set thumbnail=-icon "%CD%\%name%.jpg"
set WorkshopId=
call workshop_id.cmd> NUL 2>&1
if "%WorkshopId%"=="" goto new
goto update
:new
if not exist "%name%.jpg" goto noicon
"%GarrysMod%\bin\gmpublish.exe" create -addon "%target%" %thumbnail%
if errorlevel 1 goto uperror
echo.
set /P WorkshopId=Enter the displayed UID:
echo set WorkshopId=%WorkshopId%> workshop_id.cmd
goto finished
:update
echo.
echo What have you changed? (single line)
set /P changes=
set changes=+%changes%
set changes=%changes:"='%
set changes=%changes:~1%
"%GarrysMod%\bin\gmpublish.exe" update -addon "%target%" %thumbnail% -id "%WorkshopId%" -changes "%changes%"
if errorlevel 1 goto uperror
goto finished
:finished
goto end

:: Error: Missing binaries!
:nobin
cls
echo.
echo gma.exe or gmpublish.exe could not be located.
echo Please edit this file and fix the path to Garry's Mod.
goto end

:: Error: GMA not created!
:nogma
echo.
echo The GMA file could not be created because of an error.
goto end

:: Error: Icon missing in new GMA!
:noicon
echo.
echo The thumbnail file is missing. It is required for new addons.
echo Please make a picture of 512x512 pixels.
echo Save it in the folder of the addon as JPEG and name it:
echo %name%.jpg
echo Choose quality 100 if you can.
goto end

:: Error: GMA not uploaded!
:uperror
echo.
echo The addon could not be uploaded.
goto end

:: End
:end
del "%target%"> NUL 2>&1
pause

30 changes: 15 additions & 15 deletions addon.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"description": "Description",
"ignore": [
"*.psd",
"*.vcproj",
"*.svn*",
"*.git*"
],
"tags": [
"roleplay",
"scenic"
],
"title": "Enhanced PlayerModel Selector",
"type": "tool",
"workshopid": 504945881.0
}
"title" : "Enhanced PlayerModel Selector Fesiug's Edit",
"type" : "tool",
"tags" : [],
"ignore":
[
"*.cmd",
"*.ini",
"*.lnk",
"*.url",
".gitattributes",
".gitignore",
"enhanced_playermodel_selector.jpg",
"enhanced_playermodel_selector.pdn"
]
}
Binary file added enhanced_playermodel_selector.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,550 changes: 1,550 additions & 0 deletions enhanced_playermodel_selector.pdn

Large diffs are not rendered by default.

126 changes: 125 additions & 1 deletion lua/autorun/lf_playermodel_selector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ local function UpdatePlayerModel( ply )

timer.Simple( 0.1, function() if ply.SetupHands and isfunction( ply.SetupHands ) then ply:SetupHands() end end )
timer.Simple( 0.2, function()
if ply:GetInfo( "cl_playerhands" ) != "" then mdlname = ply:GetInfo( "cl_playerhands" ) end
local mdlhands = player_manager.TranslatePlayerHands( mdlname )


local hands_ent = ply:GetHands()
if hands_ent and mdlhands and istable( mdlhands ) then
if hands_ent:GetModel() != mdlhands.model then
Expand Down Expand Up @@ -276,6 +279,18 @@ hook.Add( "PlayerSpawn", "lf_playermodel_force_hook1", function( ply )
end
end )

hook.Add( "PlayerSetHandsModel", "lf_fe_hands_select2", function( ply, ent )
if ply:GetInfo( "cl_playerhands" ) and ply:GetInfo( "cl_playerhands" ) != "" then
local info = player_manager.TranslatePlayerHands(ply:GetInfo( "cl_playerhands" ))

timer.Simple(0.5, function()
ent:SetModel( info.model )
ent:SetSkin( info.skin )
ent:SetBodyGroups( info.body )
end)
end
end )

local function ForceSetModel( ply, mdl )
if GetConVar( "sv_playermodel_selector_force" ):GetBool() and Allowed( ply ) and tobool( ply:GetInfoNum( "cl_playermodel_selector_force", 0 ) ) then
if !ply.lf_playermodel_spawned then
Expand Down Expand Up @@ -336,7 +351,7 @@ end
if CLIENT then


local Version = "3.3"
local Version = "3.3 (Fesiug edit 1)"
local Menu = { }
local Frame
local default_animations = { "idle_all_01", "menu_walk", "pose_standing_02", "pose_standing_03", "idle_fist" }
Expand Down Expand Up @@ -380,6 +395,8 @@ hook.Add( "PostGamemodeLoaded", "lf_playermodel_sboxcvars", function()
if !ConVarExists( "cl_playerskin" ) then CreateConVar( "cl_playerskin", "0", { FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD }, "The skin to use, if the model has any" ) end
if !ConVarExists( "cl_playerbodygroups" ) then CreateConVar( "cl_playerbodygroups", "0", { FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD }, "The bodygroups to use, if the model has any" ) end
if !ConVarExists( "cl_playerflexes" ) then CreateConVar( "cl_playerflexes", "0", { FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD }, "The flexes to use, if the model has any" ) end

if !ConVarExists( "cl_playerhands" ) then CreateConVar( "cl_playerhands", "", { FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD }, "The hands to use, if the model has any" ) end
end )


Expand Down Expand Up @@ -633,7 +650,113 @@ function Menu.Setup()
end

Menu.ModelPopulate()

-------------------------------------------------------------
local handtab = Menu.Right:Add( "DPropertySheet" )
Menu.Right:AddSheet( "Hands", handtab, "icon16/attach.png" )

local t = handtab:Add( "DLabel" )
t:SetPos( 129, 1 )
--t:SetSize( 100, 20 )
t:SetText( "Search:" )

Menu.ModelFilter = handtab:Add( "DTextEntry" )
Menu.ModelFilter:SetPos( 168, 1 )
Menu.ModelFilter:SetSize( 246, 20 )
Menu.ModelFilter:SetUpdateOnType( true )
Menu.ModelFilter.OnValueChange = function() Menu.ModelPopulate() end

local ModelScroll = handtab:Add( "DScrollPanel" )
handtab:AddSheet( "Icons", ModelScroll, "icon16/application_view_tile.png" )
ModelScroll:DockMargin( 2, 0, 2, 2 )
ModelScroll:Dock( FILL )

local ModelIconLayout = ModelScroll:Add( "DIconLayout" )
ModelIconLayout:SetSpaceX( 2 )
ModelIconLayout:SetSpaceY( 2 )
ModelIconLayout:Dock( FILL )

local modelicons = { }


local ModelList = handtab:Add( "DListView" )
handtab:AddSheet( "Table", ModelList, "icon16/application_view_list.png" )
ModelList:DockMargin( 5, 0, 5, 5 )
ModelList:Dock( FILL )
ModelList:SetMultiSelect( false )
ModelList:AddColumn( "Model" )
ModelList:AddColumn( "Path" )
ModelList.OnRowSelected = function()
local sel = ModelList:GetSelected()
if !sel[1] then return end
local name = tostring( sel[1]:GetValue(1) )
RunConsoleCommand( "cl_playerhands", name )
timer.Simple( 0.1, function() Menu.UpdateFromConvars() end )
end

local AllModels = player_manager.AllValidModels()
--AllModels["AbsolutelyNone"] = ""
--PrintTable(AllModels)

function Menu.ModelPopulate()

ModelIconLayout:Clear()
ModelList:Clear()

local ModelFilter = Menu.ModelFilter:GetValue() or nil

local function IsInFilter( name )
if not ModelFilter or ModelFilter == "" then
return true
else
local tbl = string.Split( ModelFilter, " " )
for _, substr in pairs( tbl ) do
if not string.match( name:lower(), string.PatternSafe( substr:lower() ) ) then
return false
end
end
return true
end
end

local icon = ModelIconLayout:Add( "SpawnIcon" )
icon:SetSize( 64, 64 )
icon:SetSpawnIcon( "icon64/playermodel.png" )
--icon:SetModel( model )
icon:SetTooltip( "Use playermodel" )
table.insert( modelicons, icon )
icon.DoClick = function()
RunConsoleCommand( "cl_playerhands", "" )
timer.Simple( 0.1, function() Menu.UpdateFromConvars() end )
end

ModelList:AddLine( name, model )

for name, model in SortedPairs( AllModels ) do

if IsInFilter( name ) then

local icon = ModelIconLayout:Add( "SpawnIcon" )
icon:SetSize( 64, 64 )
--icon:InvalidateLayout( true )
icon:SetModel( model )
icon:SetTooltip( name )
table.insert( modelicons, icon )
icon.DoClick = function()
RunConsoleCommand( "cl_playerhands", name )
timer.Simple( 0.1, function() Menu.UpdateFromConvars() end )
end

ModelList:AddLine( name, model )

end

end

end

Menu.ModelPopulate()
--------------------------------------------------------

local favorites = Menu.Right:Add( "DPanel" )
Menu.Right:AddSheet( "Favorites", favorites, "icon16/star.png" )
Expand Down Expand Up @@ -1217,6 +1340,7 @@ function Menu.Setup()
t:AddFunction( "url", "copy", function( str ) SetClipboardText( str ) end )

local intro = [[Created by <a href="javascript:url.open( 'http://steamcommunity.com/id/libertyforce' )" oncontextmenu="url.copy( 'http://steamcommunity.com/id/libertyforce' )">LibertyForce</a>.<br>Thank you for installing this addon! Enjoying it?<br>
Modified by <a href="javascript:url.open( 'http://steamcommunity.com/id/Fesiug' )" oncontextmenu="url.copy( 'http://steamcommunity.com/id/Fesiug' )">Fesiug</a>. You can now customize your hands!<br>
<a href="javascript:url.open( 'http://steamcommunity.com/sharedfiles/filedetails/?id=504945881' )" oncontextmenu="url.copy( 'http://steamcommunity.com/sharedfiles/filedetails/?id=504945881' )">Please leave a LIKE on the workshop page.</a>]]
if !game.SinglePlayer() and !LocalPlayer():IsSuperAdmin() then
intro = [[This server is running Enhanced PlayerModel Selector by <a href="javascript:url.open( 'http://steamcommunity.com/id/libertyforce' )" oncontextmenu="url.copy( 'http://steamcommunity.com/id/libertyforce' )">LibertyForce</a>. Enjoying it?<br>
Expand Down
1 change: 1 addition & 0 deletions workshop_id.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set WorkshopId=2257795841

0 comments on commit 087e21e

Please sign in to comment.