Game Development Community

dev|Pro Game Development Curriculum

Custom menu for exiting a server or mission

by 000 · 08/30/2012 (7:37 pm) · 4 comments

Tired of that little white box menu: "Want to disconnect from server?", "Want to exit the mission?" and want to add your own personal flare? This resource will bring up GUI prompts for custom menus when pressing Escape.

Under game\scripts\client\default.bind.cs you'll find:

function escapeFromGame()
{
   if ( $Server::ServerType $= "SinglePlayer" )
      MessageBoxYesNo( "Exit", "Exit from this Mission?", "disconnect();", "");
   else
      MessageBoxYesNo( "Disconnect", "Disconnect from the server?", "disconnect();", "");
}

Edit it to prompt your custom GUI instead:

function escapeFromGame()
{
   if ( $Server::ServerType $= "SinglePlayer" )
      Canvas.pushDialog(YOUR CUSTOM GUI FOR EXIT MISSION HERE);
   else
      Canvas.pushDialog(YOUR CUSTOM GUI FOR EXIT SERVER HERE);
}

Here's what mine looks like

function escapeFromGame()
{
   if ( $Server::ServerType $= "SinglePlayer" )
      Canvas.pushDialog(MissionQuitGui);
   else
      Canvas.pushDialog(ServerQuitGui);
}

Default directory it loads the GUIs from is game\art\gui, remember to init your new GUI elements under game\scripts\client\init.cs as well!

Hope this help and let me know if I'm out to lunch on somethings and I'll adjust the resource.

#1
08/31/2012 (6:20 am)
Nice. This should help people who were looking to find this one.

Personally, I went the Tribes 2 Route ;p and pushed a lobby when you press escape.
#2
09/12/2012 (5:15 am)
I love this stuff, Mack.

I'd figured this one out, at least, on my own, but this is the kind of thing everybody has to deal with and no one ever talks about, so it was good to read and check my own approach against--thanks for taking the time to post it.
#3
09/27/2012 (5:33 am)
Sweet, This is what I was planning also. Thanks!
#4
09/29/2012 (1:13 pm)
Nice resource.... I figured mine out dealing with the pushing and popping of my 3 sec intro screens!! Would of like this one sooner, but for the beginners this is awsome, its why i love this community.