From 70ea41fef825fb89be7c6750b43115896aceeb6b Mon Sep 17 00:00:00 2001 From: MotoLegacy Date: Mon, 25 Nov 2024 21:17:55 -0800 Subject: [PATCH] MENU: Final bringup --- source/menu/defs/fte.qc | 3 +++ source/menu/defs/menu_defs.qc | 3 +++ source/menu/m_menu.qc | 9 ++++++- source/menu/main.qc | 40 +++++++++++++++++++++------ source/menu/menu_coop.qc | 26 +++++++++++++++--- source/menu/menu_load.qc | 51 +++++++++++++++++++++++++++++++---- source/menu/menu_main.qc | 4 +-- 7 files changed, 116 insertions(+), 20 deletions(-) diff --git a/source/menu/defs/fte.qc b/source/menu/defs/fte.qc index 9031b60..a08d3ee 100644 --- a/source/menu/defs/fte.qc +++ b/source/menu/defs/fte.qc @@ -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. */ diff --git a/source/menu/defs/menu_defs.qc b/source/menu/defs/menu_defs.qc index 1863b08..5c7dec8 100644 --- a/source/menu/defs/menu_defs.qc +++ b/source/menu/defs/menu_defs.qc @@ -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; diff --git a/source/menu/m_menu.qc b/source/menu/m_menu.qc index 4c013cd..7495fdb 100644 --- a/source/menu/m_menu.qc +++ b/source/menu/m_menu.qc @@ -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); diff --git a/source/menu/main.qc b/source/menu/main.qc index 501ef91..85c72e5 100644 --- a/source/menu/main.qc +++ b/source/menu/main.qc @@ -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 = { }; \ No newline at end of file diff --git a/source/menu/menu_coop.qc b/source/menu/menu_coop.qc index 18f1fd0..c341905 100644 --- a/source/menu/menu_coop.qc +++ b/source/menu/menu_coop.qc @@ -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; diff --git a/source/menu/menu_load.qc b/source/menu/menu_load.qc index 77adf7d..0dbdd67 100644 --- a/source/menu/menu_load.qc +++ b/source/menu/menu_load.qc @@ -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); }; \ No newline at end of file diff --git a/source/menu/menu_main.qc b/source/menu/menu_main.qc index aeb684c..09b1228 100644 --- a/source/menu/menu_main.qc +++ b/source/menu/menu_main.qc @@ -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(); };