openmohaa/code/cgame/cg_ui.cpp

223 lines
4.4 KiB
C++
Raw Normal View History

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;
}
clientNum = atoi(cgi.Argv(1)) - 1;
2023-07-05 21:24:23 +02:00
if (clientNum < 0 || 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++) {
sString += va("%s", cgi.Argv(i));
}
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
{
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-09-08 16:31:19 +02:00
if (!cg.iInstaMessageMenu || !down) {
return qfalse;
}
if (key < '1' || key > '8') {
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
}