mirror of
https://github.com/nzp-team/quakec.git
synced 2025-04-13 13:32:44 +00:00
MENU: Final bringup
This commit is contained in:
parent
dfc2cd9932
commit
70ea41fef8
7 changed files with 116 additions and 20 deletions
|
@ -630,6 +630,9 @@ void(string cmdname) registercommand = #352; /*
|
|||
Register the given console command, for easy console use.
|
||||
Console commands that are later used will invoke CSQC_ConsoleCommand. */
|
||||
|
||||
string(string key) serverkey = #354; /*
|
||||
Look up a key in the server's public serverinfo string. If the key contains binary data then it will be truncated at the first null. */
|
||||
|
||||
float(string s) findfont = #356; /* Part of DP_GFX_FONTS
|
||||
Looks up a named font slot. Matches the actual font name as a last resort. */
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ float running_platform;
|
|||
|
||||
float last_input_was_gamepad;
|
||||
|
||||
float loading_into_server;
|
||||
string map_name_override;
|
||||
|
||||
#ifdef MENU
|
||||
|
||||
float last_input_deviceid;
|
||||
|
|
|
@ -627,6 +627,7 @@ static string(string s) str2ascii =
|
|||
// Menu_ServerList(id, pos, size, scrollofs, num_servers)
|
||||
// Draw the master server list
|
||||
//
|
||||
void(float type) Menu_PlaySound;
|
||||
void(string id, vector pos, vector size, __inout vector scrollofs, float num_servers) Menu_ServerList =
|
||||
{
|
||||
vector rowsize = [size.x, 16];
|
||||
|
@ -650,9 +651,15 @@ void(string id, vector pos, vector size, __inout vector scrollofs, float num_ser
|
|||
if (sui_is_hovered(listitem_id))
|
||||
sui_fill(bpos, rowsize, [0.25, 0.1, 0.1], 0.5, 0);
|
||||
|
||||
#ifdef MENU
|
||||
// do it
|
||||
if (sui_is_clicked(listitem_id))
|
||||
if (sui_is_clicked(listitem_id)) {
|
||||
Menu_PlaySound(MENU_SND_ENTER);
|
||||
m_toggle(false);
|
||||
map_name_override = gethostcachestring(gethostcacheindexforkey("map"), index);
|
||||
localcmd("connect ", gethostcachestring(gethostcacheindexforkey("cname"), index), "\n");
|
||||
}
|
||||
#endif // MENU
|
||||
|
||||
// name
|
||||
sui_fill(bpos, bsize, [0.25, 0.1, 0.1], 0.5, 0);
|
||||
|
|
|
@ -221,6 +221,23 @@ void() m_init =
|
|||
|
||||
void(vector screensize) m_draw =
|
||||
{
|
||||
// In game or connecting.
|
||||
if (!menu_active) {
|
||||
menu_changetime = 0;
|
||||
music_duration_time = 0;
|
||||
|
||||
// Draw the loading screen if we're connecting to a lobby.
|
||||
tokenize(serverkey("loadstate"));
|
||||
float loadstate = stof(argv(0));
|
||||
|
||||
if (loadstate == 1) {
|
||||
loading_into_server = true;
|
||||
m_drawloading(screensize, false);
|
||||
loading_into_server = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Menu Music Playback
|
||||
if (time > music_duration_time) {
|
||||
localsound(sprintf("tracks/%s.ogg", cvar_string("menu_trackname")), 1, cvar("nzp_bgmvolume"));
|
||||
|
@ -235,8 +252,8 @@ void(vector screensize) m_draw =
|
|||
}
|
||||
|
||||
sui_begin(screensize_x, screensize_y);
|
||||
if (menu_active)
|
||||
root_menu(screensize);
|
||||
|
||||
root_menu(screensize);
|
||||
|
||||
sui_end();
|
||||
};
|
||||
|
@ -253,6 +270,19 @@ void() m_open =
|
|||
menu_active = TRUE;
|
||||
};
|
||||
|
||||
void(float wantmode) m_toggle =
|
||||
{
|
||||
if (menu_active) {
|
||||
map_name_override = "";
|
||||
m_close();
|
||||
setcursormode(FALSE);
|
||||
} else {
|
||||
m_open();
|
||||
setcursormode(TRUE);
|
||||
current_menu = MENU_MAIN;
|
||||
}
|
||||
};
|
||||
|
||||
float(float evtype, float scanx, float chary, float devid) Menu_InputEvent =
|
||||
{
|
||||
last_input_deviceid = devid;
|
||||
|
@ -296,12 +326,6 @@ float(string cmd) m_consolecommand =
|
|||
return FALSE;
|
||||
};
|
||||
|
||||
void(float wantmode) m_toggle =
|
||||
{
|
||||
if (menu_active) m_close();
|
||||
else m_open();
|
||||
};
|
||||
|
||||
void() m_shutdown =
|
||||
{
|
||||
};
|
|
@ -153,6 +153,14 @@ void() Menu_Coop_Browse =
|
|||
sui_pop_frame();
|
||||
};
|
||||
|
||||
void(string ip) Menu_Coop_Connect =
|
||||
{
|
||||
Menu_PlaySound(MENU_SND_ENTER);
|
||||
m_toggle(false);
|
||||
localcmd("connect ", ip, "\n");
|
||||
map_name_override = "OVERRIDE";
|
||||
};
|
||||
|
||||
void() Menu_Coop_Direct =
|
||||
{
|
||||
Menu_Coop_UpdatePassword();
|
||||
|
@ -168,7 +176,7 @@ void() Menu_Coop_Direct =
|
|||
Menu_PasswordInput("cdm_serverpassword", 2, server_password, server_password_cursor);
|
||||
|
||||
Menu_DrawDivider(3);
|
||||
Menu_Button(3.25, "cdm_connect", "CONNECT TO SERVER", "Attempt to connect to Game.") ? localcmd("connect ", server_ip, "\n") : 0;
|
||||
Menu_Button(3.25, "cdm_connect", "CONNECT TO SERVER", "Attempt to connect to Game.") ? Menu_Coop_Connect(server_ip) : 0;
|
||||
|
||||
Menu_Button(-1, "cdm_back", "BACK", "Return to Join Game Menu.") ? current_menu = MENU_COOPJOIN : 0;
|
||||
|
||||
|
@ -208,14 +216,24 @@ void() Menu_Coop_Create =
|
|||
Menu_Button(3, "ccm_password", "SERVER PASSWORD", "Enter an (optional) password to limit who can join.");
|
||||
Menu_PasswordInput("ccm_password", 3, server_password, server_password_cursor);
|
||||
|
||||
Menu_DrawDivider(4);
|
||||
Menu_Button(4.25, "ccm_choosemap", "CHOOSE MAP", "Select a Map to start the Game.") ? Menu_StartCoop() : 0;
|
||||
// Max players
|
||||
Menu_Button(4, "ccm_maxplayers", "MAX PLAYERS", "Change the maximum number of players who can join your server.") ? 0 : 0;
|
||||
Menu_CvarSlider(4, [1, 4, 3], "maxplayers", true, false);
|
||||
|
||||
Menu_DrawDivider(5);
|
||||
Menu_Button(5.25, "ccm_choosemap", "CHOOSE MAP", "Select a Map to start the Game.") ? Menu_StartCoop() : 0;
|
||||
|
||||
Menu_Button(-1, "ccm_back", "BACK", "Return to Co-Op Menu.") ? current_menu = MENU_COOP : 0;
|
||||
|
||||
sui_pop_frame();
|
||||
};
|
||||
|
||||
void() Menu_Coop_EnterCreate =
|
||||
{
|
||||
localcmd("maxplayers 4\n");
|
||||
current_menu = MENU_COOPCREATE;
|
||||
};
|
||||
|
||||
void() Menu_Coop =
|
||||
{
|
||||
Menu_Coop_UpdateName();
|
||||
|
@ -229,7 +247,7 @@ void() Menu_Coop =
|
|||
|
||||
Menu_DrawDivider(2);
|
||||
Menu_Button(2.25, "cm_join", "JOIN GAME", "Join an in-progress Match.") ? current_menu = MENU_COOPJOIN : 0;
|
||||
Menu_Button(3.25, "cm_create", "CREATE GAME", "Create a new Match for others to join.") ? current_menu = MENU_COOPCREATE : 0;
|
||||
Menu_Button(3.25, "cm_create", "CREATE GAME", "Create a new Match for others to join.") ? Menu_Coop_EnterCreate() : 0;
|
||||
|
||||
Menu_Button(-1, "cm_back", "BACK", "Return to Main Menu.") ? current_menu = MENU_MAIN : 0;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ string loading_tips[] =
|
|||
"'Where's the armor station?'",
|
||||
"https://docs.nzp.gay/",
|
||||
"Also try FreeCS by eukara!",
|
||||
"Also try FreeHL by eukara!",
|
||||
"FTE is a pretty awesome Quake sourceport",
|
||||
"\"your lg is nothink on the lan\" - Cooller",
|
||||
"\"¦]\" - Cooller",
|
||||
|
@ -38,7 +39,17 @@ string loading_tips[] =
|
|||
"\"it's not internet\" - Cooller",
|
||||
"\"relax\" - Cooller",
|
||||
"Also try LibreQuake.",
|
||||
"Support the Internet Archive!"
|
||||
"Support the Internet Archive!",
|
||||
"Now with a Server Browser!",
|
||||
"Don't write your menus in CSQC, trust me!",
|
||||
"Down with all that's good and clean...",
|
||||
"...And you can't fucking annihilate me!",
|
||||
"As seen on GamingOnLinux!",
|
||||
"Use the Zap-O-Matic if you need to revive in a pinch.",
|
||||
"Don't try to statically link OpenSSL in MinGW!",
|
||||
"As seen on YouTube!",
|
||||
"Now with less bugs!",
|
||||
"Free software!"
|
||||
};
|
||||
|
||||
float loading_tip_endtime;
|
||||
|
@ -58,7 +69,14 @@ void(vector screensize, float opaque) m_drawloading =
|
|||
// Black Background
|
||||
drawfill([0, 0], screensize, [0, 0, 0], 1);
|
||||
|
||||
string current_map_loading = cvar_string("mapname");
|
||||
string current_map_loading = "";
|
||||
|
||||
if (map_name_override != "")
|
||||
current_map_loading = map_name_override;
|
||||
else
|
||||
current_map_loading = cvar_string("mapname");
|
||||
|
||||
string map_loadscreen_path = sprintf("gfx/lscreen/%s", current_map_loading);
|
||||
|
||||
// If it's blank, just keep the screen black until FTE sends it to us.
|
||||
if (current_map_loading == "")
|
||||
|
@ -66,12 +84,28 @@ void(vector screensize, float opaque) m_drawloading =
|
|||
|
||||
// Pick a loading tip.
|
||||
string loading_tip = GetLoadingTip();
|
||||
string map_name_pretty = UserMapNameLookup(current_map_loading);
|
||||
|
||||
//float(vector position, string pic, vector size, vector rgb, float alpha, optional float flag) drawpic = #456;
|
||||
string map_name_pretty = "";
|
||||
|
||||
// We use the OVERRIDE key if we don't know (direct connect).
|
||||
if (map_name_override != "OVERRIDE") {
|
||||
// A little slow but whatever.
|
||||
// If the loading screen doesn't exist on disk, default to a generic one.
|
||||
float file_handle = fopen(sprintf("%s.png", map_loadscreen_path), FILE_READ);
|
||||
|
||||
if (file_handle == -1)
|
||||
map_loadscreen_path = "gfx/lscreen/lscreen";
|
||||
else
|
||||
fclose(file_handle);
|
||||
|
||||
map_name_pretty = UserMapNameLookup(current_map_loading);
|
||||
} else {
|
||||
map_name_pretty = "Direct Connect..";
|
||||
map_loadscreen_path = "gfx/lscreen/lscreen";
|
||||
}
|
||||
|
||||
// Loading screen
|
||||
drawpic([0, 0], sprintf("gfx/lscreen/%s", current_map_loading), screensize, [1, 1, 1], 1);
|
||||
drawpic([0, 0], map_loadscreen_path, screensize, [1, 1, 1], 1);
|
||||
|
||||
// Cinematic Lines
|
||||
drawfill([0, 0], [screensize_x, 36], [0, 0, 0], 175/255);
|
||||
|
@ -80,6 +114,13 @@ void(vector screensize, float opaque) m_drawloading =
|
|||
// Map Title
|
||||
Draw_String([10, 5], map_name_pretty, MENU_TEXT_LARGE, [1, 1, 0], 1, 0);
|
||||
|
||||
// Notice for how to end server connecting
|
||||
if (loading_into_server == true) {
|
||||
string abort_message = "Press ESC to abort connection and return to Menu..";
|
||||
drawfill([0, 111], [screensize_x, 36], [0, 0, 0], 175/255);
|
||||
Draw_String([screensize_x/2 - getTextWidth(abort_message, MENU_TEXT_MEDIUM_x)/2, 120], abort_message, MENU_TEXT_MEDIUM, [1, 1, 1], 1, 0);
|
||||
}
|
||||
|
||||
// Loading Tip
|
||||
Draw_String([screensize_x/2 - getTextWidth(loading_tip, MENU_TEXT_SMALL_x)/2, screensize_y - 25], loading_tip, MENU_TEXT_SMALL, [1, 1, 1], 1, 0);
|
||||
};
|
|
@ -87,9 +87,9 @@ void() Menu_Main =
|
|||
}
|
||||
|
||||
Menu_SocialBadge(1, "soc_youtube", "youtube.com/@nzpteam", 2);
|
||||
Menu_SocialBadge(2, "soc_mastadon", "twitter.com/nzpteam", 3); // FIXME: Move to Mastadon
|
||||
Menu_SocialBadge(2, "soc_bluesky", "@nzportable.bsky.social", 3);
|
||||
Menu_SocialBadge(3, "soc_patreon", "patreon.com/cypressimplex", 4);
|
||||
Menu_SocialBadge(4, "soc_matrix", "discord.nzp.gay", 1); // FIXME: Move to Matrix
|
||||
Menu_SocialBadge(4, "soc_docs", "docs.nzp.gay", 1);
|
||||
|
||||
sui_pop_frame();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue