I'm still working on some stuff but I found that using [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/InvalidateParent"]Panel:InvalidateParent[/URL] (with [B]true[/B] as arguement if you need to update immediately) updates the panel's bounds after using Dock on it.
Here what I mean:
[lua]
local panel = vgui.Create( "DPanel", MyFrame ) -- MyFrame is a 480x500 DFrame
panel:Dock( FILL )
print( panel:GetBounds() ) -- prints its original bounds: 0, 0, 64, 20
panel:InvalidateParent( true ) -- update now as we need its bounds on the same frame
print( panel:GetBounds() ) -- prints its correct bounds: 5, 29, 470, 466
[/lua]
I have updated [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/Dock"]Panel:Dock[/URL] to include this note.
Made a crafting thing
[media]https://www.youtube.com/watch?v=FJnt1eDwTeI[/media]
[QUOTE=Chessnut;48401352]Made a crafting thing
[media]https://www.youtube.com/watch?v=FJnt1eDwTeI[/media][/QUOTE]
I suggest giving the dragged item the same size as the crafting slots. :)
[editline]7th August 2015[/editline]
[QUOTE=Shadow45;48399913]I'm still working on some stuff but I found that using [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/InvalidateParent"]Panel:InvalidateParent[/URL] (with [B]true[/B] as arguement if you need to update immediately) updates the panel's bounds after using Dock on it.
Here what I mean:
[lua]
local panel = vgui.Create( "DPanel", MyFrame ) -- MyFrame is a 480x500 DFrame
panel:Dock( FILL )
print( panel:GetBounds() ) -- prints its original bounds: 0, 0, 64, 20
panel:InvalidateParent( true ) -- update now as we need its bounds on the same frame
print( panel:GetBounds() ) -- prints its correct bounds: 5, 29, 470, 466
[/lua]
I have updated [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/Dock"]Panel:Dock[/URL] to include this note.[/QUOTE]
I think I love you.
Proof of concept for text truncation for custom rendering of DLabels. Doesn't support text wrapping.
I the text alignment portion is ugly and bloaty, but it gets the job done.
The main attraction lies in GLabel:UpdateTruncation, if anyone wants to take it and improve upon it, feel free to.
[code]
local GLabel = {}
local TOP_LEFT = 7
local TOP_CENTER = 8
local TOP_RIGHT = 9
local CENTER_LEFT = 4
local CENTER_CENTER = 5
local CENTER_RIGHT = 6
local BOTTOM_LEFT = 1
local BOTTOM_CENTER = 2
local BOTTOM_RIGHT = 3
function GLabel:Init()
self.TextData = {
text = "",
origtext = "",
font = "DermaDefault",
color = Color(240, 240, 240),
pos = {0, 0},
xalign = TEXT_ALIGN_LEFT,
yalign = TEXT_ALIGN_CENTER,
}
self:SetContentAlignment(CENTER_LEFT)
end
function GLabel:SetText(str)
self.TextData.origtext = str
self:UpdateTruncation()
end
function GLabel:GetText(str)
return self.TextData.text
end
function GLabel:SetTextColor(col)
self.TextData.color = col
end
function GLabel:SetFont(font)
self.TextData.font = font
self:SetFontInternal(font)
self:UpdateTruncation()
end
function GLabel:GetFont()
return self.TextData.font
end
function GLabel:SizeToContents()
surface.SetFont(self.TextData.font)
self:SetSize(surface.GetTextSize(self.TextData.origtext))
end
function GLabel:Paint(w, h)
DisableClipping(true)
draw.Text(self.TextData)
DisableClipping(false)
return true
end
function GLabel:UpdateTruncation()
local w = self:GetWide()
local str = self.TextData.origtext
surface.SetFont(self.TextData.font)
local dw = surface.GetTextSize(".") * 3
local tw = surface.GetTextSize(str)
local wanted = w - dw
local numchars = 0
local cur = 0
if tw > w then
repeat
numchars = numchars + 1
tw = surface.GetTextSize(str:sub(1, numchars))
if tw > wanted then
break
end
until numchars == str:len()
str = str:sub(1, numchars) .. "..."
end
self.TextData.text = str
end
function GLabel:SetContentAlignment(align)
self.Alignment = align
self:UpdateAlignment()
self:UpdateTruncation()
return true
end
function GLabel:UpdateAlignment()
local w, h = self:GetSize()
local a = self.Alignment
local t = self.TextData
if a == TOP_LEFT then
t.pos = {0, 0}
t.xalign = TEXT_ALIGN_LEFT
t.yalign = TEXT_ALIGN_TOP
elseif a == TOP_CENTER then
t.pos = {w/2, 0}
t.xalign = TEXT_ALIGN_CENTER
t.yalign = TEXT_ALIGN_TOP
elseif a == TOP_RIGHT then
t.pos = {w, 0}
t.xalign = TEXT_ALIGN_RIGHT
t.yalign = TEXT_ALIGN_TOP
elseif a == CENTER_CENTER then
t.pos = {w/2, h/2}
t.xalign = TEXT_ALIGN_CENTER
t.yalign = TEXT_ALIGN_CENTER
elseif a == CENTER_RIGHT then
t.pos = {w, h/2}
t.xalign = TEXT_ALIGN_RIGHT
t.yalign = TEXT_ALIGN_CENTER
elseif a == BOTTOM_LEFT then
t.pos = {0, h}
t.xalign = TEXT_ALIGN_LEFT
t.yalign = TEXT_ALIGN_BOTTOM
elseif a == BOTTOM_CENTER then
t.pos = {w/2, h}
t.xalign = TEXT_ALIGN_CENTER
t.yalign = TEXT_ALIGN_BOTTOM
elseif a == BOTTOM_RIGHT then
t.pos = {w, h}
t.xalign = TEXT_ALIGN_RIGHT
t.yalign = TEXT_ALIGN_BOTTOM
else -- if a == CENTER_LEFT then
t.pos = {0, h/2}
t.xalign = TEXT_ALIGN_LEFT
t.yalign = TEXT_ALIGN_CENTER
end
end
function GLabel:PerformLayout(w, h)
self:UpdateAlignment()
self:UpdateTruncation()
end
derma.DefineControl("GLabel", "Glowing Label", GLabel, "DLabel")
[/code]
Someone on my TTT server requested passive chickens, so I took it a step further
[video=youtube;uaaqOXw9CbQ]http://www.youtube.com/watch?v=uaaqOXw9CbQ&feature=youtu.be[/video]
[t]http://rp.braxnet.org/scr/1438995351474.jpg[/t]
and away from html panels we go! now it's only the tv that requires them
using rendertargets for the first time properly
only drawback is that i can't draw emojis and filters with it
those filters were pretty useless anyways
My first not so good gamemode (WIP)
[CODE]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
include("player.lua")
// Serverside only stuff goes here
/*---------------------------------------------------------
Name: gamemode:PlayerLoadout( )
Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/
function GM:PlayerLoadout( pl )
pl:GiveAmmo( 255, "pistol", true )
if pl:Team() == 0 then
pl:Give( "explosive_fists" )
pl:StripWeapon( "weapon_pistol" )
else
pl:Give( "weapon_pistol" )
pl:StripWeapon( "explosive_fists" )
end
end
function GM:PlayerInitialSpawn( ply )
for k, ply in pairs( player.GetAll() ) do
PrintMessage( HUD_PRINTTALK, ply:Nick().. " has joined the server!" )
end
ply:SetGamemodeTeam( math.random( 0, 1 ) )
end
function GM:PlayerSetModel( ply )
if ply:Team() == 0 then
ply:SetModel("models/player/demon_violinist/demon_violinist.mdl")
else
ply:SetModel("models/player/group01/male_07.mdl")
end
end
local weapon = { "weapon_357", "weapon_gravgun", "weapon_ar2"}
hook.Add( "PlayerDeath", "Death", function(ply, attacker, dmg)
for k, weapon in pairs(weapon) do
attacker:Give( weapon )
end
end )
hook.Add( "PlayerDeath", "Death", function(ply, attacker, dmg)
for k, weapon in pairs(weapon) do
ply:Give( weapon )
end
end )
function GM:PlayerDeath( victim, inflictor, attacker )
PrintMessage( HUD_PRINTTALK, victim:Name() .. " was killed by " .. attacker:Name() .. "." )
end
function GM:GetFallDamage( ply, speed )
return ( speed / 8 )
end
// You can make a simple function using arguements to make this less messier but this would be the simplest way to explain what it does.
function TEAM_1( ply )
ply:UnSpectate()
ply:SetTeam( 0 )
ply:Spawn()
end -- End the function
concommand.Add("TEAM_1", TEAM_1)
function TEAM_2( ply )
ply:UnSpectate()
ply:SetTeam( 1 )
ply:Spawn()
end
concommand.Add("TEAM_2", TEAM_2)
[/CODE]
[QUOTE=CGHippo;48405107]My first not so good gamemode (WIP)
[code]snip[/code][/quote]
I know it's your first gamemode, but may I ask why you use PrintMessage on every player? PrintMessage already prints to every player's screen, so the end result would be:
[lua]--If 10 players were on the server, and another one just joined
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
...
[/lua]
[QUOTE=Mooda Looda;48405338]I know it's your first gamemode, but may I ask why you use PrintMessage on every player? PrintMessage already prints to every player's screen, so the end result would be:
[lua]--If 10 players were on the server, and another one just joined
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
Examplenick has joined the server!
...
[/lua][/QUOTE]
It doesn't do that though. Weird.
Been working on a Vehicle system lately. Wanted to show you some of the UI that's already done.
The vehicle system is something I'd like to call unique. There are preset locations that we provide around the map, which have a certain slot count for the garage, and the price.
Each location stores the player's garages, in which you can give friends access to, so you can share your cars.
The vehicles themselves are owned by the garage, and are local to the location the garage is owned by.
Each vehicle has colour customization and skin choosing. I also plan on adding bodygroup changing.
Garage:
[t]https://dl.dropboxusercontent.com/u/79424230/ShareX/2015/August/1439000209.png[/t]
Vehicle modification:
[t]https://dl.dropboxusercontent.com/u/79424230/ShareX/2015/August/1439000239.png[/t]
Vehicle purchase:
[t]https://dl.dropboxusercontent.com/u/79424230/ShareX/2015/August/1439000265.jpg[/t]
Some suggestions would be great! :)
Edit: I just noticed there is inconsistency with style throughout the menus. I will work on that.
I'm super happy—
finally, after screwing with them for so long and absolutely destroying the rendering engine a few times, I figured out stencils.
I've always wanted to cut holes in the map, and now I can, yay.
[vid]http://puu.sh/jtEjc.webm[/vid]
most of you probably already know how to do this anyway but stencils were exceptionally difficult for me, so I'm happy. I got fog to hide how deep the objects go, too.
Next I'll need to combine it with RenderScene or something and make it render world geometry behind it, too, or something to that effect.
[QUOTE=Z0mb1n3;48406640]I'm super happy—
finally, after screwing with them for so long and absolutely destroying the rendering engine a few times, I figured out stencils.
I've always wanted to cut holes in the map, and now I can, yay.
[vid]http://puu.sh/jtEjc.webm[/vid]
most of you probably already know how to do this anyway but stencils were exceptionally difficult for me, so I'm happy. I got fog to hide how deep the objects go, too.
Next I'll need to combine it with RenderScene or something and make it render world geometry behind it, too, or something to that effect.[/QUOTE]
I still find stencils extremely confusing, I've pretty much only been able to make anything with them by checking the wiki every two seconds and fiddling with different ENUMs
-snip-
Working on new SWEP pack :v:
[video=youtube;bKO86WjSUOE]http://www.youtube.com/watch?v=bKO86WjSUOE[/video]
[QUOTE=Melted Bu11et;48406999]I still find stencils extremely confusing, I've pretty much only been able to make anything with them by checking the wiki every two seconds and fiddling with different ENUMs[/QUOTE]
Don't think of stencils as some magical drawing thing.
Think of them as an image mask.
The pixels you draw with stencils can have a "stencil value" of 0-255 (think of it like a greyscale image).
You draw whatever with a pixel value to tell the engine which pixels on screen have whatever value.
Then, you set the stencil reference value so you can draw a new thing into those stencil values. Whatever comparison function you use determines which pixels keep the new drawn thing and what doesn't (STENCIL_EQUAL makes only exact pixel values be drawn over, etc).
Simple concept, but you can do some crazy stuff if you mix this and other things (like a hole right through a wall).
[QUOTE=vexx21322;48407384]Don't think of stencils as some magical drawing thing.
Think of them as an image mask.
The pixels you draw with stencils can have a "stencil value" of 0-255 (think of it like a greyscale image).
You draw whatever with a pixel value to tell the engine which pixels on screen have whatever value.
Then, you set the stencil reference value so you can draw a new thing into those stencil values. Whatever comparison function you use determines which pixels keep the new drawn thing and what doesn't (STENCIL_EQUAL makes only exact pixel values be drawn over, etc).
Simple concept, but you can do some crazy stuff if you mix this and other things (like a hole right through a wall).[/QUOTE]
Ah, yes, I know some of those words.
[QUOTE=vexx21322;48407384]Don't think of stencils as some magical drawing thing.
Think of them as an image mask.
The pixels you draw with stencils can have a "stencil value" of 0-255 (think of it like a greyscale image).
You draw whatever with a pixel value to tell the engine which pixels on screen have whatever value.
Then, you set the stencil reference value so you can draw a new thing into those stencil values. Whatever comparison function you use determines which pixels keep the new drawn thing and what doesn't (STENCIL_EQUAL makes only exact pixel values be drawn over, etc).
Simple concept, but you can do some crazy stuff if you mix this and other things (like a hole right through a wall).[/QUOTE]
And I thought I found stencils confusing BEFORE this post :nope:
[QUOTE=vexx21322;48407384]Don't think of stencils as some magical drawing thing.
Think of them as an image mask.
The pixels you draw with stencils can have a "stencil value" of 0-255 (think of it like a greyscale image).
You draw whatever with a pixel value to tell the engine which pixels on screen have whatever value.
Then, you set the stencil reference value so you can draw a new thing into those stencil values. Whatever comparison function you use determines which pixels keep the new drawn thing and what doesn't (STENCIL_EQUAL makes only exact pixel values be drawn over, etc).
Simple concept, but you can do some crazy stuff if you mix this and other things (like a hole right through a wall).[/QUOTE]
Every time I think I finally get the concept of stencils down, something new always pops its head up. Such as the last time I did anything with them, shooting the entity they were being used on would cause the stencil to completely bug out.
[QUOTE=jaooe;48407695]And I thought I found stencils confusing BEFORE this post :nope:[/QUOTE]
Sorry, I tried to find a simple way to explain the basic use of them. :v:
[B]Edit:[/B]
You inspired me to create an illustration to visually demonstrate what I said.
Comments on the same line explain what the line is/does
Comments below the line further explain or give details.
[lua]
render.ClearStencil();
render.SetStencilEnable(true);
render.SetStencilTestMask(1); -- These have to do with bitwise masking, not image masking
render.SetStencilWriteMask(1); -- they do bitwise masking on the reference values, best to leave them at 1 unless you know what you're doing
render.SetStencilReferenceValue(1); -- set the reference value to '1'
-- all current pixels (before drawing anything using stencils) is 0
render.SetStencilCompareFunction(STENCIL_ALWAYS); -- all drawn pixels are written regardless (to draw the entire mask)
-- this is needed as newly drawn pixels have the reference value while other pixels are 0
render.SetStencilPassOperation(STENCIL_REPLACE); -- the operation when the Compare Function passes, replace all drawn pixel values to current reference value (1)
-- replace any drawn pixels with the reference value
render.SetStencilFailOperation(STENCIL_KEEP);
render.SetStencilZFailOperation(STENCIL_KEEP);
-- if the comparison function fails, or the drawn pixels fail the Z-Buffer test (the object drawn is behind something, so the pixels are unseen), keep the pixel value to the value they are current at (ignores reference value)
drawMask(); -- Draw something to act as a mask
-- can be physical object (prop/3D2D/etc), or 2D elements
render.SetStencilCompareFunction(STENCIL_EQUAL); -- now set the comparison function to equal
-- we now compare all pixel values against the reference (currently set to 1 from above)
render.ClearBuffersObeyStencil(0, 0, 0, 0, true);
-- clear the inside of our mask so we have a clean slate to draw in.
drawObject(); -- draw new objects to be masked by the previous drawn mask
-- if any of the pixels of this drawn object are within pixels from the mask pixels that match the reference value (1 = 1), then draw these pixels to the screen
render.SetStencilEnable(false);
[/lua]
Grey = world/pre stencil drawings
Red = mask object
Blue = drawn object
This is the start, before any stencil operations or drawings have taken place.
[t]http://i.imgur.com/1BlMS6y.png[/t]
This is the mask drawn behind some geometry, so parts of it are hidden (Failed Z-Buffer test)
[t]http://i.imgur.com/YJfZiq0.png[/t]
This is the drawn object
[t]http://i.imgur.com/858zLZz.png[/t]
This is the pixel values of the mask before stencils have done their job
Green = 1 (or any number 0-255 really, but 1 for the example)
Black = 0
[t]http://i.imgur.com/PvwmcTn.png[/t]
Here is what it would look like if you drew the objects without stencils. You can see the drawn object overlaps the mask object.
[t]http://i.imgur.com/tR49EHD.png[/t]
And the final result of all the stencil operations
[t]http://i.imgur.com/AMdPKZH.png[/t]
This is only the very basic that can be done with stencils.
There are lots of crazy stuff you can do with the stencils that involve stuff like multiple pixel values and the Z Buffer.
Finally got around to adding Luadev support to Atom.
[url]https://github.com/Lixquid/atom-gmod-luadev[/url]
I still need to work on thing such as sending to specific clients, bulk sending multiple files, etc.
[video=youtube;FW5dCE5yZ0g]https://www.youtube.com/watch?v=FW5dCE5yZ0g[/video]
Forgive the lack of sound and the 800x600 resolution, it's running on my server box.
I am in the process of making an admin mod for myself and this is my favorite addition so far.
[QUOTE=Lixquid;48408729]Finally got around to adding Luadev support to Atom.
[url]https://github.com/Lixquid/atom-gmod-luadev[/url]
I still need to work on thing such as sending to specific clients, bulk sending multiple files, etc.[/QUOTE]
Sorry, but what's this
I really want glua syntax on atom
[QUOTE=gonzalolog;48408814]Sorry, but what's this
I really want glua syntax on atom[/QUOTE]
I also do that. [url]https://github.com/Lixquid/atom-language-gmod-lua[/url]
[QUOTE=TylerB;48408773][video=youtube;FW5dCE5yZ0g]https://www.youtube.com/watch?v=FW5dCE5yZ0g[/video]
Forgive the lack of sound and the 800x600 resolution, it's running on my server box.
I am in the process of making an admin mod for myself and this is my favorite addition so far.[/QUOTE]
Its a player ran on your box and it acts like a camera but is a person, I'm assuming that's what this is ?
[QUOTE=BigBadWilly;48408838]Its a player ran on your box and it acts like a camera but is a person, I'm assuming that's what this is ?[/QUOTE]
was going to toy with it being an admin bot / surveillance system for my site
[QUOTE=TylerB;48408848]was going to toy with it being an admin bot / surveillance system for my site[/QUOTE]
You could always display a monitor of every player in the server on the admins screen then record it so if you ever get reports of admin abuse/ban appeals you could ask for the date/time and you can check the bot system
[QUOTE=BigBadWilly;48408877]You could always display a monitor of every player in the server on the admins screen then record it so if you ever get reports of admin abuse/ban appeals you could ask for the date/time and you can check the bot system[/QUOTE]
but this wouldn't cause framerate drops for clients, or increase web-server latency?
I could envision (albeit laggy as fuck, but i'd only need 1-2 fps) rendering the views on my bot's screen and just record all of them to files
My local server has a 4tb HDD in it so i'm all for big brother level recording.
You can fit a lot more half-size 16bit/256 color images in a small space than you think.
Sorry, you need to Log In to post a reply to this thread.