// // C_DoNetDemoKey // // [SL] 2012-03-29 - Handles the hard-coded key bindings used during // NetDemo playback. Returns false if the key pressed is not // bound to any netdemo command. // bool C_DoNetDemoKey (event_t *ev) { if (!netdemo.isPlaying() && !netdemo.isPaused()) return false; static bool initialized = false; if (!initialized) { NetDemoBindings[GetKeyFromName("leftarrow")] = "netrew"; NetDemoBindings[GetKeyFromName("rightarrow")] = "netff"; NetDemoBindings[GetKeyFromName("uparrow")] = "netprevmap"; NetDemoBindings[GetKeyFromName("downarrow")] = "netnextmap"; NetDemoBindings[GetKeyFromName("space")] = "netpause"; initialized = true; } if (ev->type != ev_keydown && ev->type != ev_keyup) return false; std::string *binding = &NetDemoBindings[ev->data1]; // nothing bound to this key specific to netdemos? if (binding->empty()) return false; if (ev->type == ev_keydown) AddCommandString(binding->c_str()); return true; }
// // C_DoSpectatorKey // // [SL] 2012-09-14 - Handles the hard-coded key bindings used while spectating // or during NetDemo playback. Returns false if the key pressed is not // bound to any spectating command such as spynext. // bool C_DoSpectatorKey (event_t *ev) { if (!consoleplayer().spectator && !netdemo.isPlaying() && !netdemo.isPaused()) return false; if (ev->type == ev_keydown && ev->data1 == KEY_MWHEELUP) { AddCommandString("spyprev"); return true; } if (ev->type == ev_keydown && ev->data1 == KEY_MWHEELDOWN) { AddCommandString("spynext"); return true; } return false; }
// Return the amount of time elapsed in a netdemo. std::string NetdemoElapsed() { if (!(netdemo.isPlaying() || netdemo.isPaused())) { return ""; } int timeelapsed = netdemo.calculateTimeElapsed(); int hours = timeelapsed / 3600; timeelapsed -= hours * 3600; int minutes = timeelapsed / 60; timeelapsed -= minutes * 60; int seconds = timeelapsed; char str[9]; if (hours) { sprintf(str, "%02d:%02d:%02d", hours, minutes, seconds); } else { sprintf(str, "%02d:%02d", minutes, seconds); } return str; }