CLIENT: Add loading screens

This commit is contained in:
MotoLegacy 2023-11-06 09:45:36 -05:00
parent 02bb83d09e
commit e8dc7028e4
3 changed files with 329 additions and 16 deletions

View file

@ -37,6 +37,13 @@ float walk;
float in_menu; //what menu are we in
float time_in_menu;
// Loading screen definitions
float in_loadscreen;
float loadscreen_timetrigger;
string loadscreen_mapname;
string loadscreen_maptitle;
string loadscreen_tip;
entity player;
entity vmodel;
entity v2model;

View file

@ -70,6 +70,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
registercommand("showscores");
cvar_set("sv_cheats", ftos(1));
cvar_set("r_fb_models", ftos(0));
autocvar(r_viewmodel_default_fov, 70);
// Runtime check if we're running this in WebASM/WebGL.
@ -545,6 +546,270 @@ void() DropRecoilKick =
gun_kick[2] *= len;
}
string() LoadScreen_GiveTip =
{
float index = rint((random() * (80 - 1))) + 1;
switch(index)
{
case 1:
return "Released in 1996, Quake is over 25 years old!";
break;
case 2:
return "Use the Kar98k to be the hero we need!";
break;
case 3:
return "Lots of modern engines are based on Quake!";
break;
case 4:
return "NZ:P began development on September 27 2009!";
break;
case 5:
return "NZ:P was first released on December 25, 2010!";
break;
case 6:
return "NZ:P Beta 1.1 has over 300,000 downloads!";
break;
case 7:
return "NZ:P has been downloaded over 500,000 times!";
break;
case 8:
return "A lot of people have worked on NZ:P!";
break;
case 9:
return "Blubswillrule, or \"blubs\", is from the US.";
break;
case 10:
return "Jukki is from Finland.";
break;
case 11:
return "Ju[s]tice, or \"tom\" is from Lithuania.";
break;
case 12:
return "This game has given us bad sleeping habits!";
break;
case 13:
return "We had a lot of fun making this game!";
break;
case 14:
return "Pro Tip: you can make your own custom map!";
break;
case 15:
return "Try Retro Mode, it's in the Graphics Settings!";
break;
case 16:
return "Tired of our maps? Go make your own!";
break;
case 17:
return "Slay zombies & be grateful.";
break;
case 18:
return "Custom maps, CUSTOM MAPS!";
break;
case 19:
return "Go outside & build a snowman!";
break;
case 20:
return "Please surround yourself with zombies!";
break;
case 21:
return "Don't play for too long.. zombies may eat you.";
break;
case 22:
return "That was epic... EPIC FOR THE WIIIN!"; //why
break;
case 23:
return "FTEQW is an awesome Quake Engine!";
break;
case 24:
return "You dead yet?";
break;
case 25:
return "Now 21% cooler!";
break;
case 26:
return "your lg is nothink on the lan!"; //what
break;
case 27:
return "I'm not your chaotic on dm6!";
break;
case 28:
return "Shoot or knife zombies to kill them, up to you!";
break;
case 29:
return "How many people forgot to Compile today?";
break;
case 30:
return "ggnore";
break;
case 31:
return "NZ:P is also on PC, Switch, Vita, and PSP!";
break;
case 32:
return "Submerge your device in water for godmode!";
break;
case 33:
return "10/10/10 was a good day.";
break;
case 34:
return "Also check out \"Halo Revamped\" for 3DS!";
break;
case 35:
return "CypressImplex, or \"Ivy\", is from the USA.";
break;
case 36:
return "Zombies don't like bullets.";
break;
case 37:
return "Thanks for being an awesome fan!";
break;
case 38:
return "Removed Herobrine";
break;
case 39:
return "Pack-a-Punch the Kar98k to get to round 100000.";
break;
case 40:
return "I feel like I'm being gaslit.";
break;
case 41:
return "Heads up! You will die if you are killed!";
break;
case 42:
return "Zombies legally can't kill you if you say no!";
break;
case 43:
return "Please help me find the meaning of . Thanks.";
break;
case 44:
return "Discord is ONLY for Thomas the Tank Engine RP!";
break;
case 45:
return "\"Get rid of the 21% tip, it's an MLP reference.\"";
break;
case 46:
return "You're playing on a 3DS!";
break;
case 47:
return "Don't leak the beta!";
break;
case 48:
return "Jugger-Nog increases your health!";
break;
case 49:
return "greg was here";
break;
case 50:
return "Where the hell is the Mystery Box?!";
break;
case 51:
return "Zombies like getting shot.. I think.";
break;
case 52:
return "pro tip: aiming helps";
break;
case 53:
return "\"my mom gave me plunger money\"";
break;
case 54:
return "dolphin dive on top of your friend for god mode";
break;
case 55:
return "no free rides. ass, grass, or cash!";
break;
case 56:
return "nzp-team.github.io/latest/game.html";
break;
case 57:
return "im an mlg gamer girl so its pretty guaranteed";
break;
case 58:
return "this is a w because you cant have enough fnaf";
break;
case 59:
return "i hope santa drops bombs on the uk";
break;
case 60:
return "Hoyl shit, bro! You fucking ported fortnite!";
break;
case 61:
return "icarly feet futtishist.";
break;
case 62:
return "Well, it's impossible to play, I'm disgusted.";
break;
case 63:
return "I like my women to not be cartoons";
break;
case 64:
return "Plot twist: NZP was always broken";
break;
case 65:
return "testing some think.";
break;
case 66:
return "fnaf is older than gay marriage in the us";
break;
case 67:
return "i want that twink Obliterated";
break;
case 68:
return "i think he started the femboy transition process";
break;
case 69:
return "nice";
break;
case 70:
return "He's FUCKING annoying";
break;
case 71:
return "yeah pog female bikers";
break;
case 72:
return "Its either a stroke of genius or just a stroke";
break;
case 73:
return "Play some Custom Maps!";
break;
case 74:
return "Real OGs play on \"Old\" 3DS models!";
break;
case 75:
return "Adding this tip improved framerate by 39%!";
break;
case 76:
return "The NZ in NZP stands for New Zealand!";
break;
case 77:
return "The P in NZP stands for Professional!";
break;
case 78:
return "Remember to stay hydrated!";
break;
case 79:
return "cofe";
break;
}
return "wut wut";
};
noref void(float width, float height, float notmenu) CSQC_UpdateViewLoading =
{
if (loadscreen_mapname != "") {
drawpic([0, 0], strcat("gfx/lscreen/", loadscreen_mapname), [width, height], [1, 1, 1], 1);
}
drawfill ([0, 0], [width, 32, 1], [0, 0, 0], 0.68, 0);
drawfill ([0, height - 32], [width, 32, 1], [0, 0, 0], 0.68, 0);
drawstring([width/2 - (stringwidth(loadscreen_tip, 0, [12, 12])/2), height - 16, 0], loadscreen_tip, [12, 12], [1, 1, 1], 1, 0);
drawstring([6, 6], loadscreen_maptitle, [24, 24], TEXT_ORANGE, 1, 0);
drawfill ([width/2 - 160, height - 42], [320, 18, 1], [0.27, 0.27, 0.27], 1, 0);
drawfill ([width/2 - 164, height - 46], [328, 26, 1], [0, 0, 0], 0.77, 0);
drawstring([width/2 - (stringwidth("Loading...", 0, [14, 14])/2), height - 40, 0], "Loading...", [14, 14], [1, 1, 1], 1, 0);
};
#define SCALE_CONSTANT 8
// CALLED EVERY CLIENT RENDER FRAME
@ -707,6 +972,11 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
//does what you think it does
renderscene();
if (in_loadscreen)
{
in_loadscreen = false;
localcmd(strcat("map ", loadscreen_mapname, "\n"));
}
if(in_menu)
{
//in menu.qc
@ -716,11 +986,6 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
{
HUD_Draw(g_width, g_height);
}
if(serverkey("constate") != "active" && serverkey("disconnected"))
{
drawfill('0 0 0', [width, height, 0], '0.2 0.4 0.7', 1, 0);
drawstring([width/2 - 60, height/2, 0], "Loading...", [16,16,0],[1,1,1],1,0);
}
};
noref float(string cmd) CSQC_ConsoleCommand =

View file

@ -103,27 +103,33 @@ void() menu_back =
void() menu_loadndu =
{
localcmd("map ndu\n");
loadscreen_timetrigger = cltime + 0.1;
loadscreen_mapname = "ndu";
loadscreen_maptitle = "Nacht der Untoten";
};
void() menu_loadwh =
{
localcmd("map warehouse\n");
loadscreen_timetrigger = cltime + 0.1;
loadscreen_mapname = "warehouse";
loadscreen_maptitle = "Warehouse";
};
void() menu_loadch =
{
localcmd("map christmas_special\n");
loadscreen_timetrigger = cltime + 0.1;
loadscreen_mapname = "christmas_special";
loadscreen_maptitle = "Christmas Special";
};
void() menu_loadwn =
{
localcmd("map wahnsinn\n");
//localcmd("map wahnsinn\n");
};
void() menu_loadkn =
{
localcmd("map kino\n");
//localcmd("map kino\n");
};
void() menu_join =
@ -938,7 +944,7 @@ var struct
{[6, 95], "Kino der Toten", -1, menu_loadndu, null, MENU_SINGLE, 1, OPTION_WEB_AND_EXE}, // 7
{[6, 115], "Warehouse", -1, menu_loadwh, null, MENU_SINGLE, 0, OPTION_WEB_AND_EXE}, // 8
{[6, 135], "Wahnsinn", -1, menu_loadwh, null, MENU_SINGLE, 1, OPTION_WEB_AND_EXE}, // 9
{[6, 155], "Christmas Special", -1, menu_loadwh, null, MENU_SINGLE, 0, OPTION_WEB_AND_EXE}, // 10
{[6, 155], "Christmas Special", -1, menu_loadch, null, MENU_SINGLE, 0, OPTION_WEB_AND_EXE}, // 10
// ...
{[6, 185], "Custom Maps", -1, menu_customs, null, MENU_SINGLE, 0, OPTION_WEB_AND_EXE}, // 11
@ -994,7 +1000,7 @@ var struct
// Custom Maps
{[6, -2], "Next Page", -1, menu_custom_next, null, MENU_CUSTOMS + MENU_ACHIEVEMENTS, 0, OPTION_WEB_AND_EXE}, // 51
{[6, -1], "Previous Page", -1, menu_custom_back, null, MENU_CUSTOMS + MENU_ACHIEVEMENTS, 0, OPTION_WEB_AND_EXE}, // 52
{[6, -1], "Previous Page", -1, menu_custom_back, null, MENU_CUSTOMS + MENU_ACHIEVEMENTS, 1, OPTION_WEB_AND_EXE}, // 52
// Everything, pretty much
{[6, 0], "Back", -1, menu_back, null, MENU_SINGLE + MENU_MULTI + MENU_SETTINGS + MENU_ABOUT +
@ -1106,7 +1112,7 @@ void() Controller_UpdateButton =
drawstring([0.025*g_width, 0.375*g_height, 0], ftos(GPActive[2]), [g_height * 0.020, g_height * 0.020, 1], [0.8,0.8,0.8], 1, 0);
}
float button_timer;
void(float index, float type) Button_Click =
{
// don't click if not active
@ -1129,6 +1135,9 @@ void(float index, float type) Button_Click =
pos_y = g_height - 95;
if (cursor_pos_x > pos_x && cursor_pos_x < pos_x + 300 && cursor_pos_y > pos_y && cursor_pos_y < pos_y + 14) {
if (button_timer > cltime)
return;
if (type == 0) { //left click
buttons[index].action();
} else { //right click
@ -1137,6 +1146,7 @@ void(float index, float type) Button_Click =
lastActive = -1;
localsound_enhanced("sounds/menu/enter.wav", CHAN_SFX, 1);
button_timer = cltime + 0.25;
}
if (in_menu == MENU_CUSTOMS)
@ -1661,13 +1671,16 @@ void() Draw_Extra_Customs =
for (float i = 0; i < 10; i++) {
if (cursor_pos_x > 6 && cursor_pos_x < 320 &&
cursor_pos_y > 75 + (20 * i) && cursor_pos_y < 75 + (20 * i) + 14) {
cursor_pos_y > 75 + (20 * i) && cursor_pos_y < 75 + (20 * i) + 14 && button_timer <= cltime) {
if (i != last_active_custom_select)
localsound_enhanced("sounds/menu/navigate.wav", CHAN_SFX, 1);
if (customs_interact)
localcmd(strcat("map "), custom_map_names[i]);
if (customs_interact) {
loadscreen_timetrigger = cltime + 0.1;
loadscreen_mapname = custom_map_names[i];
loadscreen_maptitle = custom_maps[i + multiplier].map_name_pretty;
}
if (last_active_custom_select != -1)
custom_map_active[last_active_custom_select] = FALSE;
@ -1889,8 +1902,36 @@ void() Draw_Extra_ASettings =
float menu_sound_length;
float menu_sound_time;
string() LoadScreen_GiveTip;
void() Draw_Menu =
{
// CSQC likes to take us back and forth between UpdateView and UpdateViewLoading,
// meaning normally you'd see the menu pop in and out of scene. We add a delay
// before the loading sequence and make sure to draw the first load screen "frame",
// so when this back and forth shenanigan happens, the client will not notice
// this stupid hack.
if (loadscreen_timetrigger) {
if (!loadscreen_tip)
loadscreen_tip = LoadScreen_GiveTip();
drawpic([0, 0], strcat("gfx/lscreen/", loadscreen_mapname), [g_width, g_height], [1, 1, 1], 1);
drawfill ([0, 0], [g_width, 32, 1], [0, 0, 0], 0.68, 0);
drawfill ([0, g_height - 32], [g_width, 32, 1], [0, 0, 0], 0.68, 0);
drawstring([g_width/2 - (stringwidth(loadscreen_tip, 0, [12, 12])/2), g_height - 16, 0], loadscreen_tip, [12, 12], [1, 1, 1], 1, 0);
drawstring([6, 6], loadscreen_maptitle, [24, 24], TEXT_ORANGE, 1, 0);
drawfill ([g_width/2 - 160, g_height - 42], [320, 18, 1], [0.27, 0.27, 0.27], 1, 0);
drawfill ([g_width/2 - 164, g_height - 46], [328, 26, 1], [0, 0, 0], 0.77, 0);
drawstring([g_width/2 - (stringwidth("Loading...", 0, [14, 14])/2), g_height - 40, 0], "Loading...", [14, 14], [1, 1, 1], 1, 0);
if (loadscreen_timetrigger < cltime) {
in_loadscreen = true;
}
return;
}
// main menu theme iterating
if (menu_initialized == false && in_menu == MENU_MAIN) {
localsound_enhanced("tracks/tensioned_by_the_damned.ogg", CHAN_MUSIC, 1);