General > Developers Corner

Derma Question

(1/3) > >>

Bite That Apple:
I'm not too familiar with Derma and whatever xgui uses (draw boxes?). I'm trying to make a derma frrame that I can make up and close with the F2 key. I got it to open up with the key, but I want to be able to press it again and it closes.. anyone thing they can assist me on this?

Server Side:

--- Code: ---function MyMenu( ply )
    umsg.Start( "MyMenu", ply )
    umsg.End()
end --End the function
hook.Add("ShowTeam", "MyHook", MyMenu)
--- End code ---

Dumb Client Side:

--- Code: ---
function menu(ply)


// Start of Main Frame
local MainMenuFrame = vgui.Create( "DFrame" )
MainMenuFrame:SetSize( 600, 250 )
MainMenuFrame:SetTitle("Menu" )
MainMenuFrame:Center()
MainMenuFrame:SetVisible( true )
MainMenuFrame:SetDraggable( false )
MainMenuFrame:MakePopup()
// End of Main Frame

end

usermessage.Hook( "MyMenu", menu )

--- End code ---


If anyone can assist me here, or direct me to where I can get help that would be really great, thanks.
(Also if anyone knows what xgui is coded in that would also be helpful. {Ex. Derma(vgui.Create) or this draw(draw.RoundedBox) stuff})

JamminR:

--- Quote from: chaos13125 on December 06, 2013, 03:42:48 PM ---If anyone can assist me here, or direct me to where I can get help that would be really great, thanks.
(Also if anyone knows what xgui is coded in that would also be helpful. {Ex. Derma(vgui.Create) or this draw(draw.RoundedBox) stuff})

--- End quote ---

Have a toggle function, and a show and a hide function.
F2 runs toggle.
The toggle function checks a variable and or IsVisible to see if the panel is visible, and runs hide if showing.
If not visible, the toggle function runs show.
Sorry, don't know command for closing, SetVisible or Close or something.
In a much more robust way, that's how XGUI does it.

Xgui is mostly written in the derma vgui. model, but has one or two drawroundedboxes too, which I thought was derma.

Sorry, I don't know Derma, etc.
The above is just my basic knowledge of lua/xgui and the little I picked up while looking through XGUI for what you were asking to do.

Bite That Apple:
I'll see what I can do. Hopefully that will work, and I'm glad we're somewhat on the same boat here. I'll edit this post if it ended up not working.

Edit:
As I have just remembered, I tried this before in the past, but for whatever reason it did not work. It never gave an error, it just didn't work.. Not sure what I want to do now.

Megiddo:
You have tried what, exactly, in the past?

Bite That Apple:

--- Quote from: Megiddo on December 06, 2013, 04:41:56 PM ---You have tried what, exactly, in the past?

--- End quote ---

Basically what Jam said. I did try it again though, and it still didn't work.

Client Side: (I have it commented because it's not working, and I testing a whole punch of things atm, so I need this menu to work no matter what.. I just wanted to be able to press the same button so it would go away :()

--- Code: ---function tdm_menu(ply)
--if TestingPanel != nil then
--if TestingPanel:IsVisible( ) then
--MsgN('IsVisible')
--else
--MsgN('IsNotVisible')
--end

--else
local GAMEMODE_VERSION = "0.9b"

// Start of Main Frame
local MainMenuFrame = vgui.Create( "DFrame" )
MainMenuFrame:SetSize( 600, 250 )
MainMenuFrame:SetTitle("Team Deathmatch Menu: Version "..GAMEMODE_VERSION )
MainMenuFrame:Center()
MainMenuFrame:SetVisible( true )
MainMenuFrame:SetDraggable( false )
MainMenuFrame:MakePopup()
function MainMenuFrame:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color(team.GetColor(LocalPlayer():Team()).r,team.GetColor(LocalPlayer():Team()).g,team.GetColor(LocalPlayer():Team()).b,50))
surface.SetDrawColor(0,0,0)
surface.DrawOutlinedRect(1,1,w-1,h-1)
end
local TestingPanel = vgui.Create( "DPanel", MainMenuFrame )
TestingPanel:SetPos( 25, 50 )
TestingPanel:SetSize( 250, 250 )
TestingPanel.Paint = function() -- Paint function
    --Set our rect color below us; we do this so you can see items added to this panel
    surface.SetDrawColor( 50, 50, 50, 255 )
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
end

end
--end

concommand.Add( "tdm_menu", tdm_menu )
usermessage.Hook( "MyMenu", tdm_menu )

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version