CLIENT: Allow specifying hostname in Menu

This commit is contained in:
cypress 2023-12-02 13:21:20 -05:00
parent 3472c06043
commit a3de55e071
2 changed files with 42 additions and 8 deletions

View file

@ -1081,7 +1081,7 @@ noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent
if (in_menu == MENU_MULTI) {
// GO AWAY!
if (scanx == K_ENTER || scanx == K_ESCAPE) {
editing_player_name = editing_server_id = editing_password = false;
editing_player_name = editing_server_id = editing_password = editing_hostname = false;
return FALSE;
}
@ -1122,6 +1122,18 @@ noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent
// No, I don't want to read binds. Thanks.
return TRUE;
}
// Hostname
if (editing_hostname == true) {
// Update the temp string.
temp_hostname = GetUserInput(temp_hostname, scanx, chary, 18);
// Always append.
cvar_set("hostname", temp_hostname);
// No, I don't want to read binds. Thanks.
return TRUE;
}
}
// Controller Menu Navigation

View file

@ -39,6 +39,9 @@ float editing_server_id;
string temp_password;
float editing_password;
string temp_hostname;
float editing_hostname;
void() menu_single =
{
in_menu = MENU_SINGLE;
@ -129,7 +132,7 @@ void() menu_back =
} else
in_menu = MENU_MAIN;
editing_player_name = editing_server_id = editing_password = false;
editing_player_name = editing_server_id = editing_password = editing_hostname = false;
};
void() menu_loadndu =
@ -795,19 +798,25 @@ void() setting_mastervol2 =
void() setting_playername =
{
editing_player_name = !editing_player_name;
editing_server_id = editing_password = false;
editing_server_id = editing_password = editing_hostname = false;
}
void() setting_serverid =
{
editing_server_id = !editing_server_id;
editing_player_name = editing_password = false;
editing_player_name = editing_password = editing_hostname = false;
}
void() setting_password =
{
editing_password = !editing_password;
editing_player_name = editing_server_id = false;
editing_player_name = editing_server_id = editing_hostname = false;
}
void() setting_servername =
{
editing_hostname = !editing_hostname;
editing_player_name = editing_server_id = editing_password = false;
}
void() setting_connect =
@ -945,11 +954,12 @@ var struct
// Create Game
{[6, 75], "Server Password", -1, setting_password, null, MENU_CREATE, 0, OPTION_WEB_AND_EXE}, // 63
{[6, 95], "Choose Map", -1, menu_matchmake, null, MENU_CREATE, 0, OPTION_WEB_AND_EXE} // 64
{[6, 95], "Server Name", -1, setting_servername, null, MENU_CREATE, 0, OPTION_WEB_AND_EXE}, // 64
{[6, 115], "Choose Map", -1, menu_matchmake, null, MENU_CREATE, 0, OPTION_WEB_AND_EXE} // 65
};
//REMEMBER TO UPDATE THIS CONST IF YOU ADD BUTTONS
float BUTTONS_COUNT = 65;
float BUTTONS_COUNT = 66;
float lastActive;
@ -1220,7 +1230,16 @@ void() Draw_Extra_Create =
// Draw a cute little guy for password
if (editing_password) {
drawstring([320 + (strlen(temp_password)*14), 75], "_", [14, 14], [1, 1, 0], 1, 0);
drawstring([320 + (strlen(temp_hostname)*14), 75], "_", [14, 14], [1, 1, 0], 1, 0);
}
// hostname
drawfill ([318, 93], [14 * 19, 18], [0.07, 0.07, 0.07], 0.5, 0);
drawstring([320, 95], temp_hostname, [14, 14], [1, 1, 1], 1, 0);
// Draw a cute little guy for hostname
if (editing_hostname) {
drawstring([320 + (strlen(temp_hostname)*14), 95], "_", [14, 14], [1, 1, 0], 1, 0);
}
// Descriptions
@ -1229,6 +1248,9 @@ void() Draw_Extra_Create =
crea_desc = "Enter a password to limit who can join.";
break;
case 64:
crea_desc = "Enter a name that will appear in the Server List.";
break;
case 65:
crea_desc = "Select a Map to start the Game.";
break;
default: