diff --git a/addons/README.md b/addons/README.md index d205eee..49df45a 100644 --- a/addons/README.md +++ b/addons/README.md @@ -18,5 +18,6 @@ Listed below is all of the addons you can find in this repo. - `ror2_hud`: A Risk of Rain 2-inspired replacement to the default HUD. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=2210715789) - `screenshot_editor`: Lets you customize & save your Garry's Mod screenshots by applying effects and filters. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=2910871996) - `simple_bunnyhop`: A gamemode designed for bunnyhopping. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1767781900) +- `spraymesh_extended`: An improvement to the original SprayMesh with various new features, bug fixes and optimizations. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=3072351693) - `vector_loc`: A developer tool that allows you to visualize the locations of vector coordinates on a map. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1782161573) - `vm_velocity`: Makes viewmodels move up and down depending on how fast you moving vertically. [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=2294290206) diff --git a/addons/spraymesh_extended/addon.json b/addons/spraymesh_extended/addon.json new file mode 100644 index 0000000..5eecfec --- /dev/null +++ b/addons/spraymesh_extended/addon.json @@ -0,0 +1,6 @@ +{ + "title": "SprayMesh Extended", + "type": "effects", + "tags": ["fun", "build"], + "ignore": [] +} diff --git a/addons/spraymesh_extended/lua/autorun/client/cl_spraymesh.lua b/addons/spraymesh_extended/lua/autorun/client/cl_spraymesh.lua new file mode 100644 index 0000000..4e3c49c --- /dev/null +++ b/addons/spraymesh_extended/lua/autorun/client/cl_spraymesh.lua @@ -0,0 +1,2 @@ +-- Initialize SprayMesh Extended on the client +include("spraymesh/client/cl_init.lua") diff --git a/addons/spraymesh_extended/lua/autorun/server/sv_spraymesh.lua b/addons/spraymesh_extended/lua/autorun/server/sv_spraymesh.lua new file mode 100644 index 0000000..0928939 --- /dev/null +++ b/addons/spraymesh_extended/lua/autorun/server/sv_spraymesh.lua @@ -0,0 +1,11 @@ +-- Initialize SprayMesh Extended on the server +include("spraymesh/server/sv_init.lua") + +-- Send Lua files to the client +AddCSLuaFile("spraymesh/sh_init.lua") +AddCSLuaFile("spraymesh/sh_config.lua") + +AddCSLuaFile("spraymesh/client/cl_init.lua") +AddCSLuaFile("spraymesh/client/cl_spray_list_db.lua") +AddCSLuaFile("spraymesh/client/cl_derma_utils.lua") +AddCSLuaFile("spraymesh/client/cl_sandbox_context_menu.lua") diff --git a/addons/spraymesh_extended/lua/spraymesh/client/cl_derma_utils.lua b/addons/spraymesh_extended/lua/spraymesh/client/cl_derma_utils.lua new file mode 100644 index 0000000..d28d474 --- /dev/null +++ b/addons/spraymesh_extended/lua/spraymesh/client/cl_derma_utils.lua @@ -0,0 +1,107 @@ +spraymesh_derma_utils = spraymesh_derma_utils or {} + +-- Enables the maximize button on DFrame panels, used by SprayMesh Extended panels +function spraymesh_derma_utils.EnableMaximizeButton(dframe) + dframe.btnMaxim.Maximized = false + dframe.btnMaxim.OriginalSize = {panelWidth, panelHeight} + dframe.btnMaxim.OriginalPos = {dframe:GetX(), dframe:GetY()} + dframe.btnMaxim:SetDisabled(false) + dframe.btnMaxim.DoClick = function(pnl) + local targetSize = {512, 512} + local targetPos = {0, 0} + + -- If we're maximized, unmaximize + if pnl.Maximized then + targetSize = pnl.OriginalSize + targetPos = pnl.OriginalPos + -- If we're unmaximized, maximize + else + -- Store current position and size if the user decides to unmaximize later + pnl.OriginalSize = {dframe:GetSize()} + pnl.OriginalPos = {dframe:GetPos()} + + targetSize = {ScrW(), ScrH()} + targetPos = {0, 0} + end + + pnl.Maximized = not pnl.Maximized + + -- Don't allow the button to be clicked while the transition animation plays + pnl:SetEnabled(false) + local animData = dframe:NewAnimation(0.4, 0, 0.3, function(animTable, tgtPanel) + if IsValid(pnl) then + pnl:SetEnabled(true) + end + end) + animData.StartSize = {dframe:GetSize()} + animData.EndSize = targetSize + animData.StartPos = {dframe:GetPos()} + animData.EndPos = targetPos + + animData.Think = function(animTable, tgtPanel, fraction) + local easedFraction = math.ease.OutSine(fraction) + + local easedPosX = Lerp(easedFraction, animTable.StartPos[1], animTable.EndPos[1]) + local easedPosY = Lerp(easedFraction, animTable.StartPos[2], animTable.EndPos[2]) + local easedSizeW = Lerp(easedFraction, animTable.StartSize[1], animTable.EndSize[1]) + local easedSizeH = Lerp(easedFraction, animTable.StartSize[2], animTable.EndSize[2]) + + tgtPanel:SetPos(math.Round(easedPosX, 0), math.Round(easedPosY, 0)) + tgtPanel:SetSize(math.Round(easedSizeW, 0), math.Round(easedSizeH, 0)) + end + end +end + +-- Get preview HTML to preview sprays using DHTML +local PREVIEW_HTML_BASE = [=[ + + +
+ + + + + %s + + +]=] + +local PREVIEW_HTML_IMAGE = [=[