@@ -250,6 +250,9 @@ local function DefineMoreOptionsLeftClick(self, callFuncLeft, callFuncRight)
250250 return btn
251251end
252252
253+ local function populate_bookmarks (menu , mode , self )
254+ end
255+
253256function pace .CreateSearchList (property , key , name , add_columns , get_list , get_current , add_line , select_value , select_value_search )
254257 select_value = select_value or function (val , key ) return val end
255258 select_value_search = select_value_search or select_value
@@ -742,6 +745,44 @@ do -- list
742745 end
743746 end
744747 pace .current_part .hide_property_pnl = var
748+ elseif key == " Model" then
749+ local btn2 = vgui .Create (" DImageButton" , pnl )
750+ btn2 :SetSize (self :GetItemHeight (), self :GetItemHeight ())
751+ btn2 :Dock (RIGHT ) pnl :DockPadding (0 ,0 ,self :GetItemHeight (),0 )
752+ btn2 :SetTooltip (" bookmarks" )
753+ btn2 :SetImage (" icon16/cart_go.png" )
754+ btn2 .DoClick = function ()
755+ local menu = DermaMenu ()
756+ menu :SetPos (input .GetCursorPos ())
757+ menu :MakePopup ()
758+ populate_bookmarks (menu , " models" , pace .current_part )
759+ end
760+ elseif key == " Material" or key == " SpritePath" then
761+ local btn2 = vgui .Create (" DImageButton" , pnl )
762+ btn2 :SetSize (self :GetItemHeight (), self :GetItemHeight ())
763+ btn2 :Dock (RIGHT ) pnl :DockPadding (0 ,0 ,self :GetItemHeight (),0 )
764+ btn2 :SetTooltip (" bookmarks" )
765+ btn2 :SetImage (" icon16/cart_go.png" )
766+ btn2 .DoClick = function ()
767+ local menu = DermaMenu ()
768+ menu :SetPos (input .GetCursorPos ())
769+ menu :MakePopup ()
770+ populate_bookmarks (menu , " materials" , pace .current_part )
771+ end
772+ elseif string.find (pace .current_part .ClassName , " sound" ) then
773+ if key == " Sound" or key == " Path" then
774+ local btn2 = vgui .Create (" DImageButton" , pnl )
775+ btn2 :SetSize (self :GetItemHeight (), self :GetItemHeight ())
776+ btn2 :Dock (RIGHT ) pnl :DockPadding (0 ,0 ,self :GetItemHeight (),0 )
777+ btn2 :SetTooltip (" bookmarks" )
778+ btn2 :SetImage (" icon16/cart_go.png" )
779+ btn2 .DoClick = function ()
780+ local menu = DermaMenu ()
781+ menu :SetPos (input .GetCursorPos ())
782+ menu :MakePopup ()
783+ populate_bookmarks (menu , " sound" , pace .current_part )
784+ end
785+ end
745786 end
746787 end
747788
@@ -1624,320 +1665,16 @@ do -- base editable
16241665 end
16251666
16261667 if self .CurrentKey == " Model" then
1627- pace .bookmarked_ressources = pace .bookmarked_ressources or {}
1628- if not pace .bookmarked_ressources [" models" ] then
1629- pace .bookmarked_ressources [" models" ] = {
1630- " models/pac/default.mdl" ,
1631- " models/pac/plane.mdl" ,
1632- " models/pac/circle.mdl" ,
1633- " models/hunter/blocks/cube025x025x025.mdl" ,
1634- " models/editor/axis_helper.mdl" ,
1635- " models/editor/axis_helper_thick.mdl"
1636- }
1637- end
1638-
1639- local menu2 , pnl = menu :AddSubMenu (L " Load favourite models" , function ()
1640- end )
1641- pnl :SetImage (" icon16/cart_go.png" )
1642-
1643- local pm = pace .current_part :GetPlayerOwner ():GetModel ()
1644- local pm_selected = player_manager .TranslatePlayerModel (GetConVar (" cl_playermodel" ):GetString ())
1645-
1646- if pm_selected ~= pm then
1647- menu2 :AddOption (" Selected playermodel - " .. string.gsub (string .GetFileFromFilename (pm_selected ), " .mdl" , " " ), function ()
1648- pace .current_part :SetModel (pm_selected )
1649- pace .current_part .pace_properties [" Model" ]:SetValue (pm_selected )
1650- pace .PopulateProperties (pace .current_part )
1651-
1652- end ):SetImage (" materials/spawnicons/" .. string.gsub (pm_selected , " .mdl" , " " ).. " .png" )
1653- end
1654-
1655- if IsValid (pace .current_part :GetRootPart ():GetOwner ()) then
1656- local root_model = pace .current_part :GetRootPart ():GetOwner ():GetModel ()
1657- if root_model ~= pm then
1658- if not file .Exists (" materials/spawnicons/" .. string.gsub (root_model , " .mdl" , " " ).. " .png" , " GAME" ) then
1659- pace .FlashNotification (" missing spawn icon" )
1660- local spawnicon = vgui .Create (" SpawnIcon" )
1661- spawnicon :SetPos (0 ,0 )
1662- spawnicon :SetModel (root_model )
1663- spawnicon :RebuildSpawnIcon ()
1664- timer .Simple (2 , function ()
1665- spawnicon :Remove ()
1666- end )
1667- end
1668- local pnl = menu2 :AddOption (" root owner model - " .. string.gsub (string .GetFileFromFilename (root_model ), " .mdl" , " " ), function ()
1669- pace .current_part :SetModel (root_model )
1670- pace .current_part .pace_properties [" Model" ]:SetValue (root_model )
1671- pace .PopulateProperties (pace .current_part )
1672-
1673- end )
1674- pnl :SetImage (" materials/spawnicons/" .. string.gsub (root_model , " .mdl" , " " ).. " .png" )
1675- timer .Simple (0 , function ()
1676- pnl :SetImage (" materials/spawnicons/" .. string.gsub (root_model , " .mdl" , " " ).. " .png" )
1677- end )
1678- end
1679- end
1680-
1681- menu2 :AddOption (" Active playermodel - " .. string.gsub (string .GetFileFromFilename (pm ), " .mdl" , " " ), function ()
1682- pace .current_part :SetModel (pm )
1683- pace .current_part .pace_properties [" Model" ]:SetValue (pm )
1684- pace .PopulateProperties (pace .current_part )
1685- end ):SetImage (" materials/spawnicons/" .. string.gsub (pm , " .mdl" , " " ).. " .png" )
1686-
1687- if IsValid (pac .LocalPlayer :GetActiveWeapon ()) then
1688- local wep = pac .LocalPlayer :GetActiveWeapon ()
1689- local wep_mdl = wep :GetModel ()
1690- menu2 :AddOption (" Active weapon - " .. wep :GetClass () .. " - model - " .. string.gsub (string .GetFileFromFilename (wep_mdl ), " .mdl" , " " ), function ()
1691- pace .current_part :SetModel (wep_mdl )
1692- pace .current_part .pace_properties [" Model" ]:SetValue (wep_mdl )
1693- pace .PopulateProperties (pace .current_part )
1694- end ):SetImage (" materials/spawnicons/" .. string.gsub (wep_mdl , " .mdl" , " " ).. " .png" )
1695- end
1696-
1697- for id ,mdl in ipairs (pace .bookmarked_ressources [" models" ]) do
1698- if string.sub (mdl , 1 , 7 ) == " folder:" then
1699- mdl = string.sub (mdl , 8 , # mdl )
1700- local menu3 , pnl2 = menu2 :AddSubMenu (string .GetFileFromFilename (mdl ), function ()
1701- end )
1702- pnl2 :SetImage (" icon16/folder.png" )
1703-
1704- local files = get_files_recursively (nil , mdl , " mdl" )
1705-
1706- for i ,file in ipairs (files ) do
1707- menu3 :AddOption (string .GetFileFromFilename (file ), function ()
1708- self :SetValue (file )
1709- pace .current_part :SetModel (file )
1710- timer .Simple (0.2 , function ()
1711- pace .current_part .pace_properties [" Model" ]:SetValue (file )
1712- pace .PopulateProperties (pace .current_part )
1713- end )
1714- end ):SetImage (" materials/spawnicons/" .. string.gsub (file , " .mdl" , " " ).. " .png" )
1715- end
1716- else
1717- menu2 :AddOption (string .GetFileFromFilename (mdl ), function ()
1718- self :SetValue (mdl )
1719- pace .current_part :SetModel (mdl )
1720- timer .Simple (0.2 , function ()
1721- pace .current_part .pace_properties [" Model" ]:SetValue (mdl )
1722- pace .PopulateProperties (pace .current_part )
1723- end )
1724- end ):SetImage (" materials/spawnicons/" .. string.gsub (mdl , " .mdl" , " " ).. " .png" )
1725- end
1726- end
1668+ populate_bookmarks (menu , " models" , self )
17271669 end
17281670
17291671 if self .CurrentKey == " Material" or self .CurrentKey == " SpritePath" then
1730- pace .bookmarked_ressources = pace .bookmarked_ressources or {}
1731- if not pace .bookmarked_ressources [" materials" ] then
1732- pace .bookmarked_ressources [" materials" ] = {
1733- " models/debug/debugwhite.vmt" ,
1734- " vgui/null.vmt" ,
1735- " debug/env_cubemap_model.vmt" ,
1736- " models/wireframe.vmt" ,
1737- " cable/physbeam.vmt" ,
1738- " cable/cable2.vmt" ,
1739- " effects/tool_tracer.vmt" ,
1740- " effects/flashlight/logo.vmt" ,
1741- " particles/flamelet[1,5]" ,
1742- " sprites/key_[0,9]" ,
1743- " vgui/spawnmenu/generating.vmt" ,
1744- " vgui/spawnmenu/hover.vmt" ,
1745- " metal"
1746- }
1747- end
1748-
1749- local menu2 , pnl = menu :AddSubMenu (L " Load favourite materials" , function ()
1750- end )
1751- pnl :SetImage (" icon16/cart_go.png" )
1752-
1753- for id ,mat in ipairs (pace .bookmarked_ressources [" materials" ]) do
1754- mat = string.gsub (mat , " ^materials/" , " " )
1755- local mat_no_ext = string .StripExtension (mat )
1756-
1757- if string.sub (mat , 1 , 7 ) == " folder:" then
1758- local path = string.sub (mat , 8 , # mat )
1759- local menu3 , pnl2 = menu2 :AddSubMenu (string .GetFileFromFilename (path ), function ()
1760- end )
1761- pnl2 :SetImage (" icon16/folder.png" ) pnl2 :SetTooltip (mat )
1762-
1763- local files = get_files_recursively (nil , path , {" vmt" })
1764-
1765- for i ,file in ipairs (files ) do
1766- local mat_no_ext = string .StripExtension (string.sub (file ,11 ,# file )) -- "materials/"
1767- menu3 :AddOption (mat_no_ext , function ()
1768- self :SetValue (mat_no_ext )
1769- if self .CurrentKey == " Material" then
1770- pace .current_part :SetMaterial (mat_no_ext )
1771- elseif self .CurrentKey == " SpritePath" then
1772- pace .current_part :SetSpritePath (mat_no_ext )
1773- end
1774- end ):SetMaterial (mat_no_ext )
1775- end
1776- elseif string.find (mat , " %[%d+,%d+%]" ) then -- find the bracket notation
1777- mat_no_ext = string.gsub (mat_no_ext , " %[%d+,%d+%]" , " " )
1778- pace .AddSubmenuWithBracketExpansion (menu2 , function (str )
1779- str = str or " "
1780- str = string .StripExtension (string.gsub (str , " ^materials/" , " " ))
1781- self :SetValue (str )
1782- if self .CurrentKey == " Material" then
1783- pace .current_part :SetMaterial (str )
1784- elseif self .CurrentKey == " SpritePath" then
1785- pace .current_part :SetSpritePath (str )
1786- end
1787- end , mat_no_ext , " vmt" , " materials" )
1788-
1789- else
1790- menu2 :AddOption (string .StripExtension (mat ), function ()
1791- self :SetValue (mat_no_ext )
1792- if self .CurrentKey == " Material" then
1793- pace .current_part :SetMaterial (mat_no_ext )
1794- elseif self .CurrentKey == " SpritePath" then
1795- pace .current_part :SetSpritePath (mat_no_ext )
1796- end
1797- end ):SetMaterial (mat )
1798- end
1799-
1800- end
1801-
1802- local pac_materials = {}
1803- local has_pac_materials = false
1804-
1805- local class_shaders = {
1806- [" material" ] = " VertexLitGeneric" ,
1807- [" material_3d" ] = " VertexLitGeneric" ,
1808- [" material_2d" ] = " UnlitGeneric" ,
1809- [" material_eye refract" ] = " EyeRefract" ,
1810- [" material_refract" ] = " Refract" ,
1811- }
1812-
1813- for _ ,part in pairs (pac .GetLocalParts ()) do
1814- if part .Name ~= " " and string.find (part .ClassName , " material" ) then
1815- if pac_materials [class_shaders [part .ClassName ]] == nil then pac_materials [class_shaders [part .ClassName ]] = {} end
1816- has_pac_materials = true
1817- pac_materials [class_shaders [part .ClassName ]][part :GetName ()] = {part = part , shader = class_shaders [part .ClassName ]}
1818- end
1819- end
1820- if has_pac_materials then
1821- menu2 :AddSpacer ()
1822- for shader ,mats in pairs (pac_materials ) do
1823- local shader_submenu = menu2 :AddSubMenu (" pac3 materials - " .. shader )
1824- for mat ,tbl in pairs (mats ) do
1825- local part = tbl .part
1826- local pnl2 = shader_submenu :AddOption (mat , function ()
1827- self :SetValue (mat )
1828- if self .CurrentKey == " Material" then
1829- pace .current_part :SetMaterial (mat )
1830- elseif self .CurrentKey == " SpritePath" then
1831- pace .current_part :SetSpritePath (mat )
1832- end
1833- end )
1834- pnl2 :SetMaterial (pac .Material (mat , part ))
1835- pnl2 :SetTooltip (tbl .shader )
1836- end
1837- end
1838- end
1839-
1840- if self .CurrentKey == " Material" and pace .current_part .ClassName == " particles" then
1841- pnl :SetTooltip (" Appropriate shaders for particles are UnlitGeneric materials.\n OOtherwise, they should usually be additive or use VertexAlpha" )
1842- elseif self .CurrentKey == " SpritePath" then
1843- pnl :SetTooltip (" Appropriate shaders for sprites are UnlitGeneric materials.\n OOtherwise, they should usually be additive or use VertexAlpha" )
1844- end
1672+ populate_bookmarks (menu , " materials" , self )
18451673 end
18461674
18471675 if string.find (pace .current_part .ClassName , " sound" ) then
18481676 if self .CurrentKey == " Sound" or self .CurrentKey == " Path" then
1849- pace .bookmarked_ressources = pace .bookmarked_ressources or {}
1850- if not pace .bookmarked_ressources [" sound" ] then
1851- pace .bookmarked_ressources [" sound" ] = {
1852- " music/hl1_song11.mp3" ,
1853- " music/hl2_song23_suitsong3.mp3" ,
1854- " music/hl2_song1.mp3" ,
1855- " npc/combine_gunship/dropship_engine_near_loop1.wav" ,
1856- " ambient/alarms/warningbell1.wav" ,
1857- " phx/epicmetal_hard7.wav" ,
1858- " phx/explode02.wav"
1859- }
1860- end
1861-
1862- local menu2 , pnl = menu :AddSubMenu (L " Load favourite sounds" , function ()
1863- end )
1864- pnl :SetImage (" icon16/cart_go.png" )
1865-
1866- for id ,snd in ipairs (pace .bookmarked_ressources [" sound" ]) do
1867- local extension = string .GetExtensionFromFilename (snd )
1868- local snd_no_ext = string .StripExtension (snd )
1869- local single_menu = not favorites_menu_expansion :GetBool ()
1870-
1871- if string.sub (snd , 1 , 7 ) == " folder:" then
1872- snd = string.sub (snd , 8 , # snd )
1873- local menu3 , pnl2 = menu2 :AddSubMenu (string .GetFileFromFilename (snd ), function ()
1874- end )
1875- pnl2 :SetImage (" icon16/folder.png" ) pnl2 :SetTooltip (snd )
1876-
1877- local files = get_files_recursively (nil , snd , {" wav" , " mp3" , " ogg" })
1878-
1879- for i ,file in ipairs (files ) do
1880- file = string.sub (file ,7 ,# file ) -- "sound/"
1881- local icon = " icon16/sound.png"
1882- if string.find (file , " music" ) or string.find (file , " theme" ) then
1883- icon = " icon16/music.png"
1884- elseif string.find (file , " loop" ) then
1885- icon = " icon16/arrow_rotate_clockwise.png"
1886- end
1887- local pnl3 = menu3 :AddOption (string .GetFileFromFilename (file ), function ()
1888- self :SetValue (file )
1889- if self .CurrentKey == " Sound" then
1890- pace .current_part :SetSound (file )
1891- elseif self .CurrentKey == " Path" then
1892- pace .current_part :SetPath (file )
1893- end
1894- end )
1895- pnl3 :SetImage (icon ) pnl3 :SetTooltip (file )
1896- end
1897- elseif string.find (snd_no_ext , " %[%d+,%d+%]" ) then -- find the bracket notation
1898- pace .AddSubmenuWithBracketExpansion (menu2 , function (str )
1899- self :SetValue (str )
1900- if self .CurrentKey == " Sound" then
1901- pace .current_part :SetSound (str )
1902- elseif self .CurrentKey == " Path" then
1903- pace .current_part :SetPath (str )
1904- end
1905- end , snd_no_ext , extension , " sound" )
1906-
1907- elseif not single_menu and string.find (snd_no_ext , " %d+" ) then -- find a file ending in a number
1908- -- expand only if we want it with the cvar
1909- pace .AddSubmenuWithBracketExpansion (menu2 , function (str )
1910- self :SetValue (str )
1911- if self .CurrentKey == " Sound" then
1912- pace .current_part :SetSound (str )
1913- elseif self .CurrentKey == " Path" then
1914- pace .current_part :SetPath (str )
1915- end
1916- end , snd_no_ext , extension , " sound" )
1917-
1918- else
1919-
1920- local icon = " icon16/sound.png"
1921-
1922- if string.find (snd , " music" ) or string.find (snd , " theme" ) then
1923- icon = " icon16/music.png"
1924- elseif string.find (snd , " loop" ) then
1925- icon = " icon16/arrow_rotate_clockwise.png"
1926- end
1927-
1928- menu2 :AddOption (snd , function ()
1929- self :SetValue (snd )
1930- if self .CurrentKey == " Sound" then
1931- pace .current_part :SetSound (snd )
1932- elseif self .CurrentKey == " Path" then
1933- pace .current_part :SetPath (snd )
1934- end
1935-
1936- end ):SetIcon (icon )
1937- end
1938-
1939-
1940- end
1677+ populate_bookmarks (menu , " sound" , self )
19411678 end
19421679 end
19431680
@@ -2106,7 +1843,7 @@ do -- base editable
21061843 local inset_x = self :GetTextInset ()
21071844
21081845 pac .AddHook (' Think' , hookID , function (code )
2109- if not IsValid (self ) or not IsValid (textEntry ) then return pac .RemoveHook (' Think' , hookID ) end
1846+ if not IsValid (self ) or not IsValid (textEntry ) or self . CurrentKey == nil then return pac .RemoveHook (' Think' , hookID ) end
21101847 if textEntry :IsHovered () or self :IsHovered () then return end
21111848 if delay > os.clock () then return end
21121849 if not input .IsMouseDown (MOUSE_LEFT ) and not input .IsKeyDown (KEY_ESCAPE ) then return end
@@ -2163,7 +1900,7 @@ do -- base editable
21631900
21641901 -- draw a rectangle with property key's name and arrows to show where the line is scrolling out of bounds
21651902 pac .AddHook (' PostRenderVGUI' , hookID .. " 2" , function (code )
2166- if not IsValid (self ) or not IsValid (pnl ) then pac .RemoveHook (' Think' , hookID .. " 2" ) return end
1903+ if not IsValid (self ) or not IsValid (pnl ) or self . CurrentKey == nil then pac .RemoveHook (' Think' , hookID .. " 2" ) return end
21671904 local _ ,prop_y = pace .properties :LocalToScreen (0 ,0 )
21681905 local x , y = self :LocalToScreen ()
21691906 local overflow = y < prop_y or y > ScrH () - self :GetTall ()
0 commit comments