User-friendly tilde typing in the console

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
mankrip
Posts: 924
Joined: Fri Jul 04, 2008 3:02 am

User-friendly tilde typing in the console

Post by mankrip »

This tutorial will allow the user to type the tilde character in the console, without affecting the default behavior of the tilde key.

If the prompt is empty, the tilde key will behave as usual, but if it isn't, the desired character will be typed.

Open keys.c

In the function Key_Init, change these values to true:

Code: Select all

	consolekeys['`'] = true;
	consolekeys['~'] = true;
In the function Key_Event, add this line:

Code: Select all

//
// if not a consolekey, send to the interpreter no matter what mode is
//
	if ( (key_dest == key_menu && menubound[key])
	|| (key_dest == key_console && !consolekeys[key])
	|| (key_dest == key_console && (key == '`' || key == '~') && !key_lines[edit_line][1]) // mankrip - tilde typing when the prompt is empty
	|| (key_dest == key_game && ( !con_forcedup || !consolekeys[key] ) ) )
	{
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Post Reply