2023-05-01 00:08:23 +02:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 2023 the OpenMoHAA team
|
|
|
|
|
|
|
|
This file is part of OpenMoHAA source code.
|
|
|
|
|
|
|
|
OpenMoHAA source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
OpenMoHAA source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenMoHAA source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
// DESCRIPTION:
|
|
|
|
// UI features
|
|
|
|
|
|
|
|
#include "cg_local.h"
|
2023-05-06 19:10:28 +02:00
|
|
|
#include "str.h"
|
2024-09-08 16:31:19 +02:00
|
|
|
#include "../client/keycodes.h"
|
2023-05-01 00:08:23 +02:00
|
|
|
|
2023-05-06 18:48:05 +02:00
|
|
|
void CG_MessageMode_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cgi.UI_ToggleDMMessageConsole(300);
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageMode_All_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cgi.UI_ToggleDMMessageConsole(100);
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageMode_Team_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cgi.UI_ToggleDMMessageConsole(200);
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageMode_Private_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
int clientNum;
|
|
|
|
|
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-09-18 22:11:20 +02:00
|
|
|
clientNum = atoi(cgi.Argv(1));
|
|
|
|
if (clientNum < 1 || clientNum >= MAX_CLIENTS) {
|
2023-05-06 19:10:28 +02:00
|
|
|
cgi.Printf(HUD_MESSAGE_CHAT_WHITE "Message Error: %s is a bad client number\n", cgi.Argv(1));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cgi.UI_ToggleDMMessageConsole(clientNum);
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageSingleAll_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cgi.Argc() > 1) {
|
|
|
|
cgi.SendClientCommand(va("dmmessage 0 %s\n", cgi.Args()));
|
2023-07-05 21:24:23 +02:00
|
|
|
} else {
|
2023-05-06 19:10:28 +02:00
|
|
|
cgi.UI_ToggleDMMessageConsole(-100);
|
|
|
|
}
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageSingleTeam_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cgi.Argc() > 1) {
|
|
|
|
cgi.SendClientCommand(va("dmmessage -1 %s\n", cgi.Args()));
|
2023-07-05 21:24:23 +02:00
|
|
|
} else {
|
2023-05-06 19:10:28 +02:00
|
|
|
cgi.UI_ToggleDMMessageConsole(-200);
|
|
|
|
}
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_MessageSingleClient_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
int clientNum;
|
|
|
|
|
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clientNum = atoi(cgi.Argv(1));
|
2023-07-05 21:24:23 +02:00
|
|
|
if (clientNum < 1 || clientNum > MAX_CLIENTS) {
|
2023-05-06 19:10:28 +02:00
|
|
|
cgi.Printf(HUD_MESSAGE_CHAT_WHITE "Message Error: %s is a bad client number\n", cgi.Argv(1));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-05 21:24:23 +02:00
|
|
|
if (cgi.Argc() > 2) {
|
2023-05-06 19:10:28 +02:00
|
|
|
int i;
|
|
|
|
str sString;
|
|
|
|
|
|
|
|
sString = "dmmessage ";
|
|
|
|
sString += va("%i", clientNum);
|
|
|
|
|
|
|
|
// copy the rest
|
|
|
|
for (i = 2; i < cgi.Argc(); i++) {
|
2024-12-29 15:43:41 +01:00
|
|
|
sString += va(" %s", cgi.Argv(i));
|
2023-05-06 19:10:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sString += "\n";
|
|
|
|
cgi.SendClientCommand(sString.c_str());
|
2023-07-05 21:24:23 +02:00
|
|
|
} else {
|
2023-05-06 19:10:28 +02:00
|
|
|
cgi.UI_ToggleDMMessageConsole(-clientNum);
|
|
|
|
}
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageMain_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!voiceChat->integer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = -1;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageGroupA_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = 1;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageGroupB_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = 2;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageGroupC_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = 3;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageGroupD_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = 4;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_InstaMessageGroupE_f(void)
|
|
|
|
{
|
2023-05-06 19:10:28 +02:00
|
|
|
if (!cgs.gametype) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cg.iInstaMessageMenu = 5;
|
2023-05-06 18:48:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CG_HudPrint_f(void)
|
2023-05-01 15:14:05 +02:00
|
|
|
{
|
2023-11-04 19:02:24 +01:00
|
|
|
cgi.Printf("\x1%s", cgi.Argv(1));
|
2023-05-01 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2024-09-08 16:31:19 +02:00
|
|
|
qboolean CG_CheckCaptureKey(int key, qboolean down, unsigned int time)
|
2023-05-01 00:08:23 +02:00
|
|
|
{
|
2024-10-02 21:49:20 +02:00
|
|
|
char minKey = '1', maxKey = '9';
|
|
|
|
|
2024-09-08 16:31:19 +02:00
|
|
|
if (!cg.iInstaMessageMenu || !down) {
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
2024-10-02 21:49:20 +02:00
|
|
|
if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) {
|
|
|
|
maxKey = '8';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key < minKey || key > maxKey) {
|
2024-09-08 16:31:19 +02:00
|
|
|
if (key == K_ESCAPE || key == '0') {
|
|
|
|
cg.iInstaMessageMenu = 0;
|
|
|
|
return qtrue;
|
|
|
|
}
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cg.iInstaMessageMenu == -1) {
|
|
|
|
if (key > '6') {
|
|
|
|
cg.iInstaMessageMenu = 0;
|
|
|
|
} else {
|
|
|
|
cg.iInstaMessageMenu = key - '0';
|
|
|
|
}
|
|
|
|
} else if (cg.iInstaMessageMenu > 0) {
|
|
|
|
cgi.SendClientCommand(va("dmmessage 0 *%i%i\n", cg.iInstaMessageMenu, key - '0'));
|
|
|
|
cg.iInstaMessageMenu = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return qtrue;
|
2023-05-01 00:08:23 +02:00
|
|
|
}
|