• make your own custom vgui element
    6 replies, posted
hello, i was wondering what would creating my own vgui element like DFrame, would help me?
This should help [URL="http://wiki.garrysmod.com/page/Panel_Customization"]http://wiki.garrysmod.com/page/Panel_Customization[/URL] You can also take a look at the source for all of the panels [URL="https://github.com/garrynewman/garrysmod/tree/master/garrysmod/lua/vgui"]https://github.com/garrynewman/garrysmod/tree/master/garrysmod/lua/vgui[/URL], should help clear some stuff up
[url]http://wiki.garrysmod.com/page/vgui/Register[/url]
Ok so I'll not give you my own implementation of DFrame (RRP_DFrame), so basicaly you want to remake DFrame paint stuff : [code] local PANEL = {} function PANEL:Init() //Correct GMod DFrame attempt to call a nil value self.SizeW = 0 self.SizeH = 0 end function PANEL:Paint() surface.SetDrawColor(255, 0, 0, 64) surface.DrawRect(0, 0, self.SizeW, self.SizeH) end vgui.Register("MyOwnDFrameClass", PANEL, "DFrame") [/code] There you go.
[QUOTE=Yuri6037;47683534]Ok so I'll not give you my own implementation of DFrame (RRP_DFrame), so basicaly you want to remake DFrame paint stuff : [code] local PANEL = {} function PANEL:Init() //Correct GMod DFrame attempt to call a nil value self.SizeW = 0 self.SizeH = 0 end function PANEL:Paint() surface.SetDrawColor(255, 0, 0, 64) surface.DrawRect(0, 0, self.SizeW, self.SizeH) end vgui.Register("MyOwnDFrameClass", PANEL, "DFrame") [/code] There you go.[/QUOTE] 1- You aren't seeint self.SizeW or self.SizeH to anything other than 0. 2- Why even bother with that if you can just use the paint hook correctly? [lua] function PANEL:Paint(w,h) surface.SetDrawColor(255, 0, 0, 64) surface.DrawRect(0, 0, w, h) end [/lua]
[QUOTE=James xX;47684409]1- You aren't seeint self.SizeW or self.SizeH to anything other than 0. 2- Why even bother with that if you can just use the paint hook correctly? [lua] function PANEL:Paint(w,h) surface.SetDrawColor(255, 0, 0, 64) surface.DrawRect(0, 0, w, h) end [/lua][/QUOTE] Well on my side self.SizeW/SizeH are equal to window size, otherwise I don't know how My frame can display... If you need a screen of the Game tell me, I can even make a video for you showing that SizeW and SizeH are indead equal to the size of the window !! [editline]9th May 2015[/editline] About the w, h in Paint, well to be honnest, I just saw on GMod dframe.lua, because anyway, the wiki is terribly uninformed about VGui creation, so I remade many VGui elements of GMod because fo 3 reasons : 1- Very bad looking (rendering is horrible not even any transparency effect...). 2- Some people had attemp to index nil values when using default GMod vgui, so I decided to make my own. 3- Many people found that GMod VGui is horrible because there are not even any animation, so I made my own VGui to add animations when opening frames (this is hacky I know, but not found other ways).
[QUOTE=Yuri6037;47689749]Well on my side self.SizeW/SizeH are equal to window size, otherwise I don't know how My frame can display... If you need a screen of the Game tell me, I can even make a video for you showing that SizeW and SizeH are indead equal to the size of the window !! [editline]9th May 2015[/editline] About the w, h in Paint, well to be honnest, I just saw on GMod dframe.lua, because anyway, the wiki is terribly uninformed about VGui creation, so I remade many VGui elements of GMod because fo 3 reasons : 1- Very bad looking (rendering is horrible not even any transparency effect...). 2- Some people had attemp to index nil values when using default GMod vgui, so I decided to make my own. 3- Many people found that GMod VGui is horrible because there are not even any animation, so I made my own VGui to add animations when opening frames (this is hacky I know, but not found other ways).[/QUOTE] I think he meant that self.SizeW and self.SizeH are equal to your screen width and height, so there's no point setting them to 0 if they already have correct values. Not even any transparency effect? Why not just do [URL="http://wiki.garrysmod.com/page/draw/RoundedBox"]draw.RoundedBox[/URL] and set the Color()'s last digit to be the alpha amount you want? [URL="http://wiki.garrysmod.com/page/Global/Derma_Anim"]Really? There aren't any animations?[/URL]
Sorry, you need to Log In to post a reply to this thread.