Added radio1, radio2 and radio3 commands for VGUI radio message menus
This commit is contained in:
parent
712b2cebbc
commit
bbc798bccb
8 changed files with 188 additions and 1 deletions
|
@ -34,6 +34,10 @@ void CSQC_ConsoleCommand_Init( void ) {
|
|||
registercommand( "-showscores" );
|
||||
registercommand( "nightvision" );
|
||||
|
||||
registercommand( "radio1" );
|
||||
registercommand( "radio2" );
|
||||
registercommand( "radio3" );
|
||||
|
||||
registercommand( "glock" );
|
||||
registercommand( "usp" );
|
||||
registercommand( "p228" );
|
||||
|
@ -70,6 +74,7 @@ void CSQC_ConsoleCommand_Init( void ) {
|
|||
|
||||
registercommand( "coverme" );
|
||||
registercommand( "takepoint" );
|
||||
registercommand( "holdpos" );
|
||||
registercommand( "regroup" );
|
||||
registercommand( "followme" );
|
||||
registercommand( "takingfire" );
|
||||
|
@ -233,6 +238,10 @@ float CSQC_ConsoleCommand( string sCMD ) {
|
|||
sendevent( "RadioMessage", "f", RADIO_CT_POINT );
|
||||
return TRUE;
|
||||
break;
|
||||
case "takepoint":
|
||||
sendevent( "RadioMessage", "f", RADIO_POSITION );
|
||||
return TRUE;
|
||||
break;
|
||||
case "regroup":
|
||||
sendevent( "RadioMessage", "f", RADIO_REGROUP );
|
||||
return TRUE;
|
||||
|
@ -305,6 +314,18 @@ float CSQC_ConsoleCommand( string sCMD ) {
|
|||
sendevent( "RadioMessage", "f", RADIO_ENEMYDOWN );
|
||||
return TRUE;
|
||||
break;
|
||||
case "radio1":
|
||||
VGUI_Radio_Toggle( VGUI_RADIO1 );
|
||||
return TRUE;
|
||||
break;
|
||||
case "radio2":
|
||||
VGUI_Radio_Toggle( VGUI_RADIO2 );
|
||||
return TRUE;
|
||||
break;
|
||||
case "radio3":
|
||||
VGUI_Radio_Toggle( VGUI_RADIO3 );
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,11 @@ void CSQC_VGUI_Draw( void ) {
|
|||
|
||||
vVGUIColor = autocvar_vgui_color * ( 1 / 255 );
|
||||
|
||||
if ( fVGUI_Display >= 11 ) {
|
||||
VGUI_Radio_Draw();
|
||||
return;
|
||||
}
|
||||
|
||||
setcursormode( TRUE );
|
||||
|
||||
// Align the window to the center
|
||||
|
|
|
@ -35,7 +35,10 @@ enum {
|
|||
VGUI_BM_SMG,
|
||||
VGUI_BM_RIFLES,
|
||||
VGUI_BM_MGS,
|
||||
VGUI_BM_EQUIPMENT
|
||||
VGUI_BM_EQUIPMENT,
|
||||
VGUI_RADIO1,
|
||||
VGUI_RADIO2,
|
||||
VGUI_RADIO3
|
||||
};
|
||||
|
||||
vector vVGUIWindowPos;
|
||||
|
|
|
@ -29,6 +29,7 @@ void VGUI_MessageOfTheDay( vector vPos ) {
|
|||
VGUI_Text( serverkey( "hostname" ), vPos + '16 64 0', '16 16 0');
|
||||
|
||||
vector vTextPos = vPos + '16 116 0';
|
||||
|
||||
for ( int i = 0; i < 25; i++ ) {
|
||||
VGUI_Text( sMOTDString[ i ], vTextPos, '8 8 0' );
|
||||
vTextPos_y += 10;
|
||||
|
|
|
@ -76,6 +76,32 @@ void VGUI_Window( string sTitle, vector vPos, vector vSize ) {
|
|||
drawline( 1.0, vPos + '0 48 0', v1 + '0 48 0', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
}
|
||||
|
||||
// Draws window with outline, border and title
|
||||
void VGUI_WindowSmall( string sTitle, vector vPos, vector vSize ) {
|
||||
vector v1, v2, v3;
|
||||
|
||||
// Draw the background
|
||||
drawfill( vPos, vSize - '1 1 0', VGUI_WINDOW_BGCOLOR, VGUI_WINDOW_BGALPHA );
|
||||
|
||||
// Draw the outline START
|
||||
v1_x = vPos_x + vSize_x;
|
||||
v1_y = vPos_y;
|
||||
drawline( 1.0, vPos - '1 0 0', v1, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
|
||||
v2_x = vPos_x;
|
||||
v2_y = vPos_y + vSize_y;
|
||||
drawline( 1.0, vPos, v2, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
|
||||
v3 = vPos + vSize;
|
||||
drawline( 1.0, v1, v3, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
drawline( 1.0, v2, v3, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
// Draw the outline END
|
||||
|
||||
// Draw the window title
|
||||
drawstring( vPos + '8 8 0', sTitle, '8 8 0', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
drawline( 1.0, vPos + '0 24 0', v1 + '0 24 0', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE );
|
||||
}
|
||||
|
||||
// Draws a button, returns whether or not a mouse is hovering over it (for inheritance' sake)
|
||||
float VGUI_Button( string sLabel, void() vFunction, vector vPos, vector vSize ) {
|
||||
vector v1, v2, v3, v4;
|
||||
|
|
130
Source/Client/VGUIRadio.c
Normal file
130
Source/Client/VGUIRadio.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
OpenCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "VGUI.h"
|
||||
|
||||
// Radio Commands
|
||||
#define VGUIRADIO_COMMANDS 6
|
||||
float fRadioCommands[ VGUIRADIO_COMMANDS ] = {
|
||||
RADIO_CT_COVERME,
|
||||
RADIO_CT_POINT,
|
||||
RADIO_POSITION,
|
||||
RADIO_REGROUP,
|
||||
RADIO_FOLLOWME,
|
||||
RADIO_FIREASSIS
|
||||
};
|
||||
|
||||
// Group Radio Commands
|
||||
#define VGUIRADIO_GROUPCOMMANDS 6
|
||||
float fRadioGroupCommands[ VGUIRADIO_GROUPCOMMANDS ] = {
|
||||
RADIO_GO,
|
||||
RADIO_FALLBACK,
|
||||
RADIO_STICKTOG,
|
||||
RADIO_CT_INPOS,
|
||||
RADIO_STORMFRONT,
|
||||
RADIO_COM_REPORTIN
|
||||
};
|
||||
|
||||
// Radio Responses
|
||||
#define VGUIRADIO_RESPONSES 9
|
||||
float fRadioResponses[ VGUIRADIO_RESPONSES ] = {
|
||||
RADIO_CT_AFFIRM,
|
||||
RADIO_CT_ENEMYS,
|
||||
RADIO_CT_BACKUP,
|
||||
RADIO_CLEAR,
|
||||
RADIO_CT_INPOS,
|
||||
RADIO_CT_REPORTINGIN,
|
||||
RADIO_BLOW,
|
||||
RADIO_NEGATIVE,
|
||||
RADIO_ENEMYDOWN
|
||||
};
|
||||
|
||||
void VGUI_Radio_DrawCommand( float fIndex, float fMessage, vector vPos ) {
|
||||
VGUI_Text( sprintf( "%d) %s", fIndex + 1, sRadioChat[ fMessage ] ), vPos, '8 8 0' );
|
||||
|
||||
if ( fInputKeyCode == ( fIndex + 49 ) ) {
|
||||
sendevent( "RadioMessage", "f", fMessage );
|
||||
fVGUI_Display = VGUI_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void VGUI_Radio_Draw( void ) {
|
||||
vector vSize, vPos;
|
||||
|
||||
if ( fVGUI_Display == VGUI_RADIO1 ) {
|
||||
vSize_x = ( 33 * 8 ) + 16;
|
||||
vSize_y = ( 10 * VGUIRADIO_COMMANDS ) + 64;
|
||||
vPos = [ 16, vVideoResolution_y - 148 - vSize_y ];
|
||||
|
||||
VGUI_WindowSmall( "Radio Commands", vPos, vSize );
|
||||
|
||||
vPos_y += 24;
|
||||
vPos_x += 8;
|
||||
for ( float i = 0; i < VGUIRADIO_COMMANDS; i++ ) {
|
||||
vPos_y += 10;
|
||||
VGUI_Radio_DrawCommand( i, fRadioCommands[ i ], vPos );
|
||||
}
|
||||
} else if ( fVGUI_Display == VGUI_RADIO2 ) {
|
||||
vSize_x = ( 24 * 8 ) + 16;
|
||||
vSize_y = ( 10 * VGUIRADIO_GROUPCOMMANDS ) + 64;
|
||||
vPos = [ 16, vVideoResolution_y - 148 - vSize_y ];
|
||||
|
||||
VGUI_WindowSmall( "Group Radio Commands", vPos, vSize );
|
||||
|
||||
vPos_y += 24;
|
||||
vPos_x += 8;
|
||||
for ( float i = 0; i < VGUIRADIO_GROUPCOMMANDS; i++ ) {
|
||||
vPos_y += 10;
|
||||
VGUI_Radio_DrawCommand( i, fRadioGroupCommands[ i ], vPos );
|
||||
}
|
||||
} else {
|
||||
vSize_x = ( 37 * 8 ) + 16;
|
||||
vSize_y = ( 10 * VGUIRADIO_RESPONSES ) + 64;
|
||||
vPos = [ 16, vVideoResolution_y - 148 - vSize_y ];
|
||||
|
||||
VGUI_WindowSmall( "Radio Responses", vPos, vSize );
|
||||
|
||||
vPos_y += 24;
|
||||
vPos_x += 8;
|
||||
for ( float i = 0; i < VGUIRADIO_RESPONSES; i++ ) {
|
||||
vPos_y += 10;
|
||||
VGUI_Radio_DrawCommand( i, fRadioResponses[ i ], vPos );
|
||||
}
|
||||
}
|
||||
|
||||
vPos_y += 20;
|
||||
VGUI_Text( "0) Back", vPos, '8 8 0' );
|
||||
|
||||
if ( fInputKeyCode == 48 ) {
|
||||
fVGUI_Display = VGUI_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void VGUI_Radio_Toggle( float fMenu ) {
|
||||
if ( getstatf( STAT_HEALTH ) <= 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fVGUI_Display == fMenu ) {
|
||||
fVGUI_Display = VGUI_NONE;
|
||||
} else {
|
||||
fVGUI_Display = fMenu;
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@ VGUIScoreboard.c
|
|||
VGUIMOTD.c
|
||||
VGUIBuyMenu.c
|
||||
VGUITeamSelect.c
|
||||
VGUIRadio.c
|
||||
VGUI.c
|
||||
Nightvision.c
|
||||
HUDCrosshair.c
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue