307 lines
9.4 KiB
C
Executable file
307 lines
9.4 KiB
C
Executable file
/*
|
|
FreeCS 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"
|
|
|
|
vguiweaponobject_t vguiWeaponTable[ CS_WEAPON_COUNT ] = {
|
|
{ _("None"), "" },
|
|
{ _("Knife"), "" },
|
|
{ _("H&K USP .45 Tactical"), "gfx/vgui/640_usp" },
|
|
{ _("Glock18 Select Fire"), "gfx/vgui/640_glock18" },
|
|
{ _("Desert Eagle .50AE"), "gfx/vgui/640_deagle" },
|
|
{ _("SIG P228"), "gfx/vgui/640_p228" },
|
|
{ _("Dual Beretta 96G Elite"), "gfx/vgui/640_elite" },
|
|
{ _("FN Five-Seven"), "gfx/vgui/640_fiveseven" },
|
|
{ _("Benelli M3 Super90"), "gfx/vgui/640_m3" },
|
|
{ _("Benelli XM1014"), "gfx/vgui/640_xm1014" },
|
|
{ _("H&K MP5-Navy"), "gfx/vgui/640_mp5" },
|
|
{ _("FN P90"), "gfx/vgui/640_p90" },
|
|
{ _("H&K UMP45"), "gfx/vgui/640_ump45" },
|
|
{ _("Ingram MAC-10"), "gfx/vgui/640_mac10" },
|
|
{ _("Steyr Tactical Machine Pistol"), "gfx/vgui/640_tmp" },
|
|
{ _("AK-47"), "gfx/vgui/640_ak47" },
|
|
{ _("Sig SG-552 Commando"), "gfx/vgui/640_sg552" },
|
|
{ _("Colt M4A1 Carbine"), "gfx/vgui/640_m4a1" },
|
|
{ _("Steyr Aug"), "gfx/vgui/640_aug" },
|
|
{ _("Steyr Scout"), "gfx/vgui/640_scout" },
|
|
{ _("AI Arctic Warfare/Magnum"), "gfx/vgui/640_awp" },
|
|
{ _("H&K G3/SG-1 Sniper Rifle"), "gfx/vgui/640_g3sg1" },
|
|
{ _("Sig SG-550 Sniper"), "gfx/vgui/640_sg550" },
|
|
{ _("FN M249 Para"), "gfx/vgui/640_m249" }
|
|
};
|
|
|
|
vguiequipobject_t vguiEquipmentTable[ 7 ] = {
|
|
{ EQUIPMENT_KEVLAR, _("Kevlar"), "gfx/vgui/640_kevlar" },
|
|
{ EQUIPMENT_HELMET, _("Kevlar & Helmet"), "gfx/vgui/640_kevlar_helmet" },
|
|
{ WEAPON_FLASHBANG, _("Flashbang"), "gfx/vgui/640_flashbang" },
|
|
{ WEAPON_HEGRENADE, _("HE Grenade"), "gfx/vgui/640_hegrenade" },
|
|
{ WEAPON_SMOKEGRENADE, _("Smoke Grenade"), "gfx/vgui/640_smokegrenade" },
|
|
{ EQUIPMENT_DEFUSALKIT, _("Defusal Kit"), "gfx/vgui/640_defuser" },
|
|
{ EQUIPMENT_NIGHTVISION, _("NightVision"), "gfx/vgui/640_nightvision" },
|
|
};
|
|
|
|
// TODO: Clean this up
|
|
void VGUI_BuyMenu_Main( vector vPos ) {
|
|
static void BuyMenu_Main_1( void ) {
|
|
fVGUI_Display = VGUI_BM_HANDGUNS;
|
|
}
|
|
static void BuyMenu_Main_2( void ) {
|
|
fVGUI_Display = VGUI_BM_SHOTGUNS;
|
|
}
|
|
static void BuyMenu_Main_3( void ) {
|
|
fVGUI_Display = VGUI_BM_SMG;
|
|
}
|
|
static void BuyMenu_Main_4( void ) {
|
|
fVGUI_Display = VGUI_BM_RIFLES;
|
|
}
|
|
static void BuyMenu_Main_5( void ) {
|
|
fVGUI_Display = VGUI_BM_MGS;
|
|
}
|
|
static void BuyMenu_Main_6( void ) {
|
|
sendevent( "GamePlayerBuyAmmo", "f", 0 );
|
|
fVGUI_Display = VGUI_NONE;
|
|
}
|
|
static void BuyMenu_Main_7( void ) {
|
|
sendevent( "GamePlayerBuyAmmo", "f", 1 );
|
|
fVGUI_Display = VGUI_NONE;
|
|
}
|
|
static void BuyMenu_Main_8( void ) {
|
|
fVGUI_Display = VGUI_BM_EQUIPMENT;
|
|
}
|
|
static void BuyMenu_Main_9( void ) {
|
|
fVGUI_Display = VGUI_NONE;
|
|
}
|
|
|
|
VGUI_Button( _("Handguns"), BuyMenu_Main_1, vPos + '16 116 0', '180 24 0' );
|
|
VGUI_Button( _("Shotguns"), BuyMenu_Main_2, vPos + '16 148 0', '180 24 0' );
|
|
VGUI_Button( _("SMGs"), BuyMenu_Main_3, vPos + '16 180 0', '180 24 0' );
|
|
VGUI_Button( _("Rifles"), BuyMenu_Main_4, vPos + '16 212 0', '180 24 0' );
|
|
VGUI_Button( _("Machine Gun"), BuyMenu_Main_5, vPos + '16 244 0', '180 24 0' );
|
|
|
|
VGUI_Button( _("Primary Ammo"), BuyMenu_Main_6, vPos + '16 308 0', '180 24 0' );
|
|
VGUI_Button( _("Secondary Ammo"), BuyMenu_Main_7, vPos + '16 340 0', '180 24 0' );
|
|
VGUI_Button( _("Equipment"), BuyMenu_Main_8, vPos + '16 372 0', '180 24 0' );
|
|
|
|
VGUI_Button( _("Exit"), BuyMenu_Main_9, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
void VGUI_BuyMenu_Back( void ) {
|
|
fVGUI_Display = VGUI_BM_MAIN;
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_BuyWeapon
|
|
|
|
This is kinda ugly, but it will work for now
|
|
====================
|
|
*/
|
|
float iLastSelected;
|
|
void VGUI_BuyMenu_BuyWeapon( void ) {
|
|
if( iLastSelected ) {
|
|
sendevent( "PlayerBuyWeapon", "f", iLastSelected );
|
|
fVGUI_Display = VGUI_NONE;
|
|
}
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_BuyEquipment
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_BuyEquipment( void ) {
|
|
sendevent( "PlayerBuyEquipment", "f", iLastSelected );
|
|
fVGUI_Display = VGUI_NONE;
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_WeaponButton
|
|
|
|
Draws a button that displays whether or not you can purchase said weapon etc.
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_WeaponButton( float fWeapon ) {
|
|
iLastSelected = fWeapon;
|
|
|
|
if ( wptTable[ fWeapon ].iPrice <= getstatf( STAT_MONEY ) ) {
|
|
if ( VGUI_Button( vguiWeaponTable[ fWeapon ].sName, VGUI_BuyMenu_BuyWeapon, vVGUIButtonPos, '264 24 0' ) == TRUE ) {
|
|
drawpic( vVGUIWindowPos + '328 116', vguiWeaponTable[ fWeapon ].sImage, '256 64', '1 1 1', 1 );
|
|
VGUI_Text( sprintf( _("Price: %i"), wptTable[ fWeapon ].iPrice ), vVGUIWindowPos + '328 250', '8 8 0' );
|
|
VGUI_Text( sprintf( _("Caliber: %i"), wptTable[ fWeapon ].iCaliber ), vVGUIWindowPos + '328 260', '8 8 0' );
|
|
VGUI_Text( sprintf( _("Rounds Per Minute: %d"), ( wptTable[ fWeapon ].fAttackFinished) * 3600 ), vVGUIWindowPos + '328 270', '8 8 0' );
|
|
}
|
|
} else {
|
|
VGUI_FakeButton( vguiWeaponTable[ fWeapon ].sName, vVGUIButtonPos, '264 24 0' );
|
|
}
|
|
|
|
vVGUIButtonPos_y += 32;
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_EquipmentButton
|
|
|
|
Draws a button that displays whether or not you can purchase said equipment
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_EquipmentButton( float fID ) {
|
|
iLastSelected = fID;
|
|
|
|
if ( eqptTable[ fID ].iPrice <= getstatf( STAT_MONEY ) ) {
|
|
if ( VGUI_Button( vguiEquipmentTable[ fID ].sName, VGUI_BuyMenu_BuyEquipment, vVGUIButtonPos, '180 24 0' ) == TRUE ) {
|
|
drawpic( vVGUIWindowPos + '290 116', vguiEquipmentTable[ fID ].sImage, '256 64', '1 1 1', 1 );
|
|
VGUI_Text( sprintf( _("Price: %i"), eqptTable[ fID ].iPrice ) , vVGUIWindowPos + '256 250', '8 8 0' );
|
|
}
|
|
} else {
|
|
VGUI_FakeButton( vguiEquipmentTable[ fID ].sName, vVGUIButtonPos, '180 24 0' );
|
|
}
|
|
|
|
vVGUIButtonPos_y += 32;
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_Handguns
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_Handguns( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_USP45 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_GLOCK18 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_DEAGLE );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_P228 );
|
|
|
|
vVGUIButtonPos_y += 32;
|
|
|
|
if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_T ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_ELITES );
|
|
} else if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_CT ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_FIVESEVEN );
|
|
}
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_Shotguns
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_Shotguns( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_M3 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_XM1014 );
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_SMGs
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_SMGs( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_MP5 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_P90 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_UMP45 );
|
|
|
|
vVGUIButtonPos_y += 32;
|
|
|
|
if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_T ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_MAC10 );
|
|
} else if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_CT ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_TMP );
|
|
}
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_Rifles
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_Rifles( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_T ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_AK47 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_SG552 );
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_SCOUT );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_AWP );
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_G3SG1 );
|
|
}
|
|
|
|
if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_CT ) {
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_M4A1 );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_AUG );
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_SCOUT );
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_AWP );
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_SG550 );
|
|
}
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_Machineguns
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_Machineguns( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
VGUI_BuyMenu_WeaponButton( WEAPON_PARA );
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|
|
|
|
/*
|
|
====================
|
|
VGUI_BuyMenu_Equipment
|
|
====================
|
|
*/
|
|
void VGUI_BuyMenu_Equipment( vector vPos ) {
|
|
vVGUIButtonPos = vPos + '16 116 0';
|
|
|
|
VGUI_BuyMenu_EquipmentButton( 0 );
|
|
VGUI_BuyMenu_EquipmentButton( 1 );
|
|
VGUI_BuyMenu_EquipmentButton( 2 );
|
|
VGUI_BuyMenu_EquipmentButton( 3 );
|
|
VGUI_BuyMenu_EquipmentButton( 4 );
|
|
|
|
if ( stof( getplayerkeyvalue( player_localnum, "*team" ) ) == TEAM_CT ) {
|
|
VGUI_BuyMenu_EquipmentButton( 5 );
|
|
}
|
|
|
|
VGUI_BuyMenu_EquipmentButton( 6 );
|
|
|
|
VGUI_Button( _("Back"), VGUI_BuyMenu_Back, vPos + '16 440 0', '180 24 0' );
|
|
}
|