ULX

Author Topic: Derma Question  (Read 5242 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Derma Question
« on: December 06, 2013, 03:42:48 PM »
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: [Select]
function MyMenu( ply )
    umsg.Start( "MyMenu", ply )
    umsg.End()
end --End the function
hook.Add("ShowTeam", "MyHook", MyMenu)

Dumb Client Side:
Code: [Select]

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 )


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})
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Derma Question
« Reply #1 on: December 06, 2013, 04:18:43 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})

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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Derma Question
« Reply #2 on: December 06, 2013, 04:27:06 PM »
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.
« Last Edit: December 06, 2013, 04:38:24 PM by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Derma Question
« Reply #3 on: December 06, 2013, 04:41:56 PM »
You have tried what, exactly, in the past?
Experiencing God's grace one day at a time.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Derma Question
« Reply #4 on: December 06, 2013, 04:49:40 PM »
You have tried what, exactly, in the past?

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: [Select]
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 )
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Derma Question
« Reply #5 on: December 06, 2013, 06:30:17 PM »
And what piece doesn't work?
Experiencing God's grace one day at a time.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Derma Question
« Reply #6 on: December 06, 2013, 11:05:26 PM »
And what piece doesn't work?

The menu doesn't go away if it is already opened when I press F2 .
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Derma Question
« Reply #7 on: December 07, 2013, 10:18:50 AM »
Try basing it off your main frame instead of the panel frame.
Experiencing God's grace one day at a time.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given