menu: Add Char_Event support for the textfields in the menu.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1030 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2014-09-13 16:13:16 +00:00
parent d690b1e38a
commit a21d18a4ec
3 changed files with 80 additions and 50 deletions

View file

@ -1054,6 +1054,9 @@ void Char_Event (int key)
case key_message:
Char_Message (key);
break;
case key_menu:
M_Textinput (key);
break;
case key_console:
Char_Console (key);
break;

View file

@ -726,8 +726,6 @@ void M_Setup_Draw (void)
void M_Setup_Key (int k)
{
int l;
switch (k)
{
case K_ESCAPE:
@ -799,28 +797,6 @@ forward:
setup_myname[strlen(setup_myname)-1] = 0;
}
break;
default:
if (k < 32 || k > 127)
break;
if (setup_cursor == 0)
{
l = strlen(setup_hostname);
if (l < 15)
{
setup_hostname[l+1] = 0;
setup_hostname[l] = k;
}
}
if (setup_cursor == 1)
{
l = strlen(setup_myname);
if (l < 15)
{
setup_myname[l+1] = 0;
setup_myname[l] = k;
}
}
}
if (setup_top > 13)
@ -833,6 +809,35 @@ forward:
setup_bottom = 13;
}
void M_Setup_Textinput (int k)
{
int l;
if (k < 32 || k > 126)
return;
switch (setup_cursor)
{
case 0:
l = strlen(setup_hostname);
if (l < 15)
{
setup_hostname[l+1] = 0;
setup_hostname[l] = k;
}
break;
case 1:
l = strlen(setup_myname);
if (l < 15)
{
setup_myname[l+1] = 0;
setup_myname[l] = k;
}
break;
}
}
//=============================================================================
/* NET MENU */
@ -1779,32 +1784,6 @@ void M_LanConfig_Key (int key)
lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
}
break;
default:
if (key < 32 || key > 127)
break;
if (lanConfig_cursor == 2)
{
l = strlen(lanConfig_joinname);
if (l < 21)
{
lanConfig_joinname[l+1] = 0;
lanConfig_joinname[l] = key;
}
}
if (key < '0' || key > '9')
break;
if (lanConfig_cursor == 0)
{
l = strlen(lanConfig_portname);
if (l < 5)
{
lanConfig_portname[l+1] = 0;
lanConfig_portname[l] = key;
}
}
}
if (StartingGame && lanConfig_cursor == 2)
@ -1823,6 +1802,37 @@ void M_LanConfig_Key (int key)
sprintf(lanConfig_portname, "%u", lanConfig_port);
}
void M_LanConfig_Textinput (int key)
{
int l;
if (key < 32 || key > 126)
return;
switch (lanConfig_cursor)
{
case 0:
if (key < '0' || key > '9')
return;
l = strlen(lanConfig_portname);
if (l < 5)
{
lanConfig_portname[l+1] = 0;
lanConfig_portname[l] = key;
}
break;
case 2:
l = strlen(lanConfig_joinname);
if (l < 21)
{
lanConfig_joinname[l+1] = 0;
lanConfig_joinname[l] = key;
}
break;
}
}
//=============================================================================
/* GAME OPTIONS MENU */
@ -2625,6 +2635,22 @@ void M_Keydown (int key)
}
void M_Textinput (int key)
{
switch (m_state)
{
case m_setup:
M_Setup_Textinput (key);
return;
case m_lanconfig:
M_LanConfig_Textinput (key);
return;
default:
return;
}
}
void M_ConfigureNetSubsystem(void)
{
// enable/disable net systems to match desired config

View file

@ -54,6 +54,7 @@ extern qboolean m_keys_bind_grab;
//
void M_Init (void);
void M_Keydown (int key);
void M_Textinput (int key);
void M_ToggleMenu_f (void);
void M_Menu_Main_f (void);