All Projects → TomDotBat → ui3d2d

TomDotBat / ui3d2d

Licence: other
A clean and simple 3D2D UI library for Garry's Mod. Built to be easy to use and optimised.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to ui3d2d

3d2d-vgui
👀 Render and control 2D VGUI in 3D world space for Garry's Mod
Stars: ✭ 69 (+283.33%)
Mutual labels:  gmod, 3d2d
sourcesdk-minimal
A compact and Garry's Mod compatible SourceSDK (don't use in other Source engine games).
Stars: ✭ 34 (+88.89%)
Mutual labels:  gmod
garrysmod common
A repository of common bits for compilation projects based on Garry's Mod.
Stars: ✭ 76 (+322.22%)
Mutual labels:  gmod
EasyChat
A modular Garry's Mod chat addon for both users and developers.
Stars: ✭ 74 (+311.11%)
Mutual labels:  gmod
3D2D-Textscreens
3D2D Textscreens Garry's Mod Workshop Addon
Stars: ✭ 26 (+44.44%)
Mutual labels:  gmod
leysourceengineclient
A source engine network client implementation based on some of my reversing work with basic functionality ( joining servers, talking, receiving/sending voicedata etc. ). Made this & reversed netchan to learn about Sources networking.
Stars: ✭ 122 (+577.78%)
Mutual labels:  gmod
VJ-Base
An addon for Garry's mod that contains bunch of bases to make many different types of addons.
Stars: ✭ 57 (+216.67%)
Mutual labels:  gmod
XPGUI
A modern VGUI framework.
Stars: ✭ 15 (-16.67%)
Mutual labels:  gmod
gm luaerror
A module for Garry's Mod that adds hooks for obtaining errors that happen on the client and server (if activated on server, it also pushes errors from clients).
Stars: ✭ 35 (+94.44%)
Mutual labels:  gmod
glua-docs
🔍 Quick documentation lookup for Garry's Mod Lua
Stars: ✭ 14 (-22.22%)
Mutual labels:  gmod
Half-Life-Resurgence
Recreation & expansion of NPCs, entities, and weapons from the Half-Life series into Garry's Mod!
Stars: ✭ 52 (+188.89%)
Mutual labels:  gmod
gmod luasocket
Modules for Garry's Mod that add bindings for OS sockets through luasocket.
Stars: ✭ 21 (+16.67%)
Mutual labels:  gmod
BadCoderz
Find unoptimized gmod addons and KILL the devs who made them
Stars: ✭ 66 (+266.67%)
Mutual labels:  gmod
Lua-Obfuscator
Obfuscate your lua code because it's so easy to steal!
Stars: ✭ 69 (+283.33%)
Mutual labels:  gmod
zombie-escape
🏃 Gamemode for Garry's Mod based on the popular Counter-Strike: Source server mod
Stars: ✭ 17 (-5.56%)
Mutual labels:  gmod
helix-plugins
github.com/Bilwin/helix-plugins
Stars: ✭ 24 (+33.33%)
Mutual labels:  gmod
machado
This repository provides users with a framework to store, search and visualize biological data.
Stars: ✭ 18 (+0%)
Mutual labels:  gmod
Fun
Small fun scripts
Stars: ✭ 22 (+22.22%)
Mutual labels:  gmod
map-compiling-toolkit
Tools for map compiling in Source Engine, tailored for Garry's Mod (and metastruct, sorry)
Stars: ✭ 17 (-5.56%)
Mutual labels:  gmod
Pointshop2
Next-Gen Garrysmod shop system https://discord.gg/N9DmwwX
Stars: ✭ 37 (+105.56%)
Mutual labels:  gmod

ui3d2d

A simple and optimised library for drawing 3D2D UIs in Garry's Mod. Supports both immediate mode drawing and VGUI (found in the extras file).

Example Usage

Adding UI to an entity:

ENT.RenderGroup = RENDERGROUP_TRANSLUCENT

local pos = Vector(0, 0, 0)
local angles = Angle(0, 0, 0)

local color_red = Color(255, 0, 0)

function ENT:DrawTranslucent()
    if not ui3d2d.startDraw(self:WorldToLocal(pos), self:WorldToLocalAngles(angles), .1, self) then return end --Skip drawing if the player can't see the UI

    --Draw your UI here
    surface.SetFont("DermaLarge")
    local w, h = surface.GetTextSize("Hover me!")

    draw.RoundedBox(0, 0, 0, w, h, color_white)

    if ui3d2d.isPressed() then --Flash red if input was pressed this frame
        draw.RoundedBox(0, 0, 0, w, h, color_red)
    end

    if ui3d2d.isHovering(0, 0, w, h) then --Check if the box is being hovered
        if ui3d2d.isPressing() then --Check if input is being held
            draw.SimpleText("Wow!", nil, 0, 0, color_black)
        else
            draw.SimpleText("Click me!", nil, 0, 0, color_black)
        end
    else
        draw.SimpleText("Hover me!", nil, 0, 0, color_black)
    end

    ui3d2d.endDraw() --Finish the UI render
end

Adding UI to the world:

local pos = Vector(0, 0, 0)
local angles = Angle(0, 0, 0)

hook.Add("PostDrawTranslucentRenderables", "DrawMyUI", function(_, depthDrawing)
    if depthDrawing then return end

    if ui3d2d.startDraw(pos, angles, .1) then
        --Draw your UI here
        ui3d2d.endDraw()
    end
end)

Global Functions

ui3d2d.startDraw

ui3d2d.startDraw(pos :: Vector, angles :: Angle, scale :: number, ignoredEntity :: Entity) :: boolean

This starts a UI3D2D rendering context in immediate mode, calling this will calculate your mouse position and input status for the same frame.

  • The ignoredEntity paramater is optional, this is used for disabling eyetrace collisions with the entity you're attaching your UI to.

ui3d2d.endDraw

ui3d2d.endDraw()

This ends a UI3D2D rendering context, only call this if you have called startDraw already and it has returned true.

ui3d2d.isPressing

ui3d2d.isPressing() :: boolean

This returns true if the user is holding down the UI input key.

ui3d2d.isPressed

ui3d2d.isPressed() :: boolean

This returns true if the user started pressing the UI input key on this frame.

ui3d2d.getCursorPos

ui3d2d.getCursorPos() :: number, number

This returns two numbers, the x and y values of the cursor position on the current UI.

  • This will return nil if the player isn't looking at the UI.

ui3d2d.isHovering

ui3d2d.isHovering(x :: number, y :: number, w :: number, h :: number) :: boolean

This will return true if the cursor is currently within the bounds of the box specified in the parameters.

ui3d2d.drawVgui (Extra only)

ui3d2d.drawVgui(panel :: Panel, pos :: Vector, angles :: Angle, scale :: number, ignoredEntity :: Entity)

This will draw a VGUI panel in 3D space and allow the user to interact with it. This may not work always work as intended.

  • The ignoredEntity paramater is optional, this is used for disabling eyetrace collisions with the entity you're attaching your UI to.

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].