Garry's Mod menu state surface based UI
Using render.SetViewPort and render.SetScissorRect
- Download the repository here
- Extract the ZIP file into
garrysmod/addons/port-ui
- Add the following line at the bottom of your
garrysmod/lua/menu/menu.lua
file to load the script:
RunString(file.Read("addons/port-ui/lua/port-ui/init.lua", "GAME"), "addons/port-ui/lua/port-ui/init.lua")
- Now you can access the
portui
global table and create elements like so:
local ExampleWindow = portui.Elements.Create("Window")
ExampleWindow:SetPos(10, 10)
ExampleWindow:SetSize(200, 150)
ExampleWindow:SetTitle("I am a Beautiful Window")
Result:
Tip
You can view documentation for everything in the docs folder.
Important
-
Due to this being made with View Ports, Elements rendered with a screen X or Y position off the screen bounds will be clipped due to DirectX clipping. This is NOT able to be fixed with
DisableClipping
. -
Due to how the current Rendering and Input systems work, there is no
:IsHovered
function for elements. Since there are no Render Targets in menu state, fixing this would require looping all elements multiple times per frame, which is very detrimental to performance. -
Text rendering is weird inside Elements because of the View Ports due to how the View Ports mess with aspect ratio. This is allegedly due to a lack of
cam.Start
availability in menu state. This has been partially remedied by the implementation of theportui.Elements.Renderer.SwapPortRect()
andportui.Elements.> Renderer.UnSwapPortRect()
functions. -
The ColorPicker's sub Elements don't have their handles in the correct location on instantiation