Game Development Community

dev|Pro Game Development Curriculum

Show ControlsHelpDlg on first-run only

by Michael Hall · 06/27/2011 (1:07 pm) · 2 comments

When I originally created the ControlsHelpDlg it was intended to use a preference variable to have it display itself when the game is first run and allow the user to disable it for subsequent runs. Unfortunately this never got done, and I left it toggled off. With the 1.1 Final release this HUD is now automatically shown every time the player is dropped into a game -- even on mission restarts!

I've seen the comments about people not even knowing this HUD was even there - just like my Hide-Hud or Hudless screenshot features -- so I understand the reasoning why it was toggled on, it just annoys me.

As a quick one minute exercise we'll find the initial toggle-on, and if a certain preference variable is not already defined (Torque 3D has the nifty isDefined() method) we'll make the call for the toggle method and then set the preference so that the next time the game is run the HUD won't automatically show itself. It will still be toggle-able as normal by pressing the H key.

Inside of "scripts/client/serverConnection.cs" find the line inside of GameConnection::initialControlSet() that turns the ControlsHelpDlg on:
ControlsHelpDlg.toggle();
Replace that line with this:
if(!isDefined("$pref::HelpFirstRunDone"))
{
   ControlsHelpDlg.toggle();
   $pref::HelpFirstRunDone = true;  
}

And you're all done. Now when you run the game for the first time the ControlsHelpDlg will show itself, and a preference will be set disallowing the automatic toggle-on for subsequent runs -- much better :)

--------------------------------

One final annoying undesired bit of behavior will be that if you let the mission timer expire and/or a new mission is started the ControlsHelpDlg will show itself at the MissionEnd screen and once again be toggled on when the player is spawned for the new mission -- ugh!!

Inside of "scripts/client/game.cs" find the line inside of clientCmdGameStart() that turns the ControlsHelpDlg on:
ControlsHelpDlg.toggle();
Remove that line, it's not needed.

About the author

Been dabbling with game-programming since the age of 10 when I got my first computer, a Commodore. Got serious about game-development after modding Tribes for several years. Doesn't sleep much. Drinks rum. Teaches guitar. Plays cello.


#1
07/03/2011 (12:43 pm)
Quote:I've seen the comments about people not even knowing this HUD was even there - just like my Hide-Hud or Hudless screenshot features -- so I understand the reasoning why it was toggled on, it just annoys me.

Hehe, that's exactly why Mich decided to enable it. It can be annoying for veteran users though, good resource.
#2
05/04/2012 (2:33 pm)
You know, after all of this time I wish I had never created that ControlsHelpDlg!!! Well mostly it just annoys me that it's always there! ;)