Remove sdk folder, add as submodule in include
This commit is contained in:
parent
4a7bfcf6dd
commit
923be5eb11
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "src/include/sdk"]
|
||||||
|
path = src/include/sdk
|
||||||
|
url = https://github.com/ValveSoftware/halflife.git
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit c7240b965743a53a29491dd49320c88eecf6257b
|
|
@ -1,7 +0,0 @@
|
||||||
# Force CRLF for Windows files:
|
|
||||||
*.bat text eol=crlf
|
|
||||||
*.dsp text eol=crlf
|
|
||||||
*.dsw text eol=crlf
|
|
||||||
*.sln text eol=crlf
|
|
||||||
*.vcxproj text eol=crlf
|
|
||||||
*.vcxproj.filters text eol=crlf
|
|
|
@ -1,39 +0,0 @@
|
||||||
Half Life 1 SDK LICENSE
|
|
||||||
======================
|
|
||||||
|
|
||||||
Half Life 1 SDK Copyright(c) Valve Corp.
|
|
||||||
|
|
||||||
THIS DOCUMENT DESCRIBES A CONTRACT BETWEEN YOU AND VALVE CORPORATION ("Valve").
|
|
||||||
PLEASE READ IT BEFORE DOWNLOADING OR USING THE HALF LIFE 1 SDK ("SDK"). BY
|
|
||||||
DOWNLOADING AND/OR USING THE HALF LIFE 1 SDK YOU ACCEPT THIS LICENSE. IF YOU DO
|
|
||||||
NOT AGREE TO THE TERMS OF THIS LICENSE PLEASE DON'T DOWNLOAD OR USE THE SDK.
|
|
||||||
|
|
||||||
You may, free of charge, download and use the SDK to develop a modified Valve
|
|
||||||
game running on the Half-Life 1 engine. You may distribute your modified Valve
|
|
||||||
game in source and object code form, but only for free. Terms of use for Valve
|
|
||||||
games are found in the Steam Subscriber Agreement located here:
|
|
||||||
http://store.steampowered.com/subscriber_agreement/
|
|
||||||
|
|
||||||
You may copy, modify, and distribute the SDK and any modifications you make to
|
|
||||||
the SDK in source and object code form, but only for free. Any distribution of
|
|
||||||
this SDK must include this LICENSE file.
|
|
||||||
|
|
||||||
Any distribution of the SDK or a substantial portion of the SDK must include
|
|
||||||
the above copyright notice and the following:
|
|
||||||
|
|
||||||
DISCLAIMER OF WARRANTIES. THE HALF LIFE 1 SDK AND ANY OTHER MATERIAL
|
|
||||||
DOWNLOADED BY LICENSEE IS PROVIDED "AS IS". VALVE AND ITS SUPPLIERS
|
|
||||||
DISCLAIM ALL WARRANTIES WITH RESPECT TO THE SDK, EITHER EXPRESS OR IMPLIED,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
||||||
NON-INFRINGEMENT, TITLE AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
LIMITATION OF LIABILITY. IN NO EVENT SHALL VALVE OR ITS SUPPLIERS BE LIABLE
|
|
||||||
FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
|
||||||
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
|
||||||
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
|
||||||
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE ENGINE AND/OR THE
|
|
||||||
SDK, EVEN IF VALVE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
|
|
||||||
If you would like to use the SDK for a commercial purpose, please contact Valve
|
|
||||||
at sourceengine@valvesoftware.com.
|
|
|
@ -1,57 +0,0 @@
|
||||||
Half Life 1 SDK LICENSE
|
|
||||||
======================
|
|
||||||
|
|
||||||
Half Life 1 SDK Copyright© Valve Corp.
|
|
||||||
|
|
||||||
THIS DOCUMENT DESCRIBES A CONTRACT BETWEEN YOU AND VALVE CORPORATION (“Valve”). PLEASE READ IT BEFORE DOWNLOADING OR USING THE HALF LIFE 1 SDK (“SDK”). BY DOWNLOADING AND/OR USING THE SOURCE ENGINE SDK YOU ACCEPT THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE PLEASE DON’T DOWNLOAD OR USE THE SDK.
|
|
||||||
|
|
||||||
You may, free of charge, download and use the SDK to develop a modified Valve game running on the Half-Life engine. You may distribute your modified Valve game in source and object code form, but only for free. Terms of use for Valve games are found in the Steam Subscriber Agreement located here: http://store.steampowered.com/subscriber_agreement/
|
|
||||||
|
|
||||||
You may copy, modify, and distribute the SDK and any modifications you make to the SDK in source and object code form, but only for free. Any distribution of this SDK must include this license.txt and third_party_licenses.txt.
|
|
||||||
|
|
||||||
Any distribution of the SDK or a substantial portion of the SDK must include the above copyright notice and the following:
|
|
||||||
|
|
||||||
DISCLAIMER OF WARRANTIES. THE SOURCE SDK AND ANY OTHER MATERIAL DOWNLOADED BY LICENSEE IS PROVIDED “AS IS”. VALVE AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES WITH RESPECT TO THE SDK, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, TITLE AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
LIMITATION OF LIABILITY. IN NO EVENT SHALL VALVE OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE ENGINE AND/OR THE SDK, EVEN IF VALVE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
|
|
||||||
If you would like to use the SDK for a commercial purpose, please contact Valve at sourceengine@valvesoftware.com.
|
|
||||||
|
|
||||||
|
|
||||||
Half-Life 1
|
|
||||||
======================
|
|
||||||
|
|
||||||
This is the README for the Half-Life 1 engine and its associated games.
|
|
||||||
|
|
||||||
Please use this repository to report bugs and feature requests for Half-Life 1 related products.
|
|
||||||
|
|
||||||
Reporting Issues
|
|
||||||
----------------
|
|
||||||
|
|
||||||
If you encounter an issue while using Half-Life 1 games, first search the [issue list](https://github.com/ValveSoftware/halflife/issues) to see if it has already been reported. Include closed issues in your search.
|
|
||||||
|
|
||||||
If it has not been reported, create a new issue with at least the following information:
|
|
||||||
|
|
||||||
- a short, descriptive title;
|
|
||||||
- a detailed description of the issue, including any output from the command line;
|
|
||||||
- steps for reproducing the issue;
|
|
||||||
- your system information.\*; and
|
|
||||||
- the `version` output from the in‐game console.
|
|
||||||
|
|
||||||
Please place logs either in a code block (press `M` in your browser for a GFM cheat sheet) or a [gist](https://gist.github.com).
|
|
||||||
|
|
||||||
\* The preferred and easiest way to get this information is from Steam's Hardware Information viewer from the menu (`Help -> System Information`). Once your information appears: right-click within the dialog, choose `Select All`, right-click again, and then choose `Copy`. Paste this information into your report, preferably in a code block.
|
|
||||||
|
|
||||||
Conduct
|
|
||||||
-------
|
|
||||||
|
|
||||||
|
|
||||||
There are basic rules of conduct that should be followed at all times by everyone participating in the discussions. While this is generally a relaxed environment, please remember the following:
|
|
||||||
|
|
||||||
- Do not insult, harass, or demean anyone.
|
|
||||||
- Do not intentionally multi-post an issue.
|
|
||||||
- Do not use ALL CAPS when creating an issue report.
|
|
||||||
- Do not repeatedly update an open issue remarking that the issue persists.
|
|
||||||
|
|
||||||
Remember: Just because the issue you reported was reported here does not mean that it is an issue with Half-Life. As well, should your issue not be resolved immediately, it does not mean that a resolution is not being researched or tested. Patience is always appreciated.
|
|
|
@ -1,117 +0,0 @@
|
||||||
// CL_DLLEXPORT is the client version of dllexport. It's turned off for secure clients.
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define CL_DLLEXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define CL_DLLEXPORT __attribute__ ((visibility("default")))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
// From hl_weapons
|
|
||||||
void CL_DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
|
|
||||||
|
|
||||||
// From cdll_int
|
|
||||||
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
|
|
||||||
int CL_DLLEXPORT HUD_VidInit( void );
|
|
||||||
void CL_DLLEXPORT HUD_Init( void );
|
|
||||||
int CL_DLLEXPORT HUD_Redraw( float flTime, int intermission );
|
|
||||||
int CL_DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
|
|
||||||
void CL_DLLEXPORT HUD_Reset ( void );
|
|
||||||
void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
|
|
||||||
void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
|
|
||||||
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name );
|
|
||||||
int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
|
|
||||||
int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
|
|
||||||
void CL_DLLEXPORT HUD_Frame( double time );
|
|
||||||
void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
|
|
||||||
void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
|
|
||||||
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y );
|
|
||||||
|
|
||||||
// From demo
|
|
||||||
void CL_DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
|
|
||||||
|
|
||||||
// From entity
|
|
||||||
int CL_DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
|
|
||||||
void CL_DLLEXPORT HUD_CreateEntities( void );
|
|
||||||
void CL_DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
|
|
||||||
void CL_DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
|
|
||||||
void CL_DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
|
|
||||||
void CL_DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
|
|
||||||
void CL_DLLEXPORT HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) );
|
|
||||||
struct cl_entity_s CL_DLLEXPORT *HUD_GetUserEntity( int index );
|
|
||||||
|
|
||||||
// From in_camera
|
|
||||||
void CL_DLLEXPORT CAM_Think( void );
|
|
||||||
int CL_DLLEXPORT CL_IsThirdPerson( void );
|
|
||||||
void CL_DLLEXPORT CL_CameraOffset( float *ofs );
|
|
||||||
|
|
||||||
// From input
|
|
||||||
struct kbutton_s CL_DLLEXPORT *KB_Find( const char *name );
|
|
||||||
void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
|
|
||||||
void CL_DLLEXPORT HUD_Shutdown( void );
|
|
||||||
int CL_DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );
|
|
||||||
|
|
||||||
// From inputw32
|
|
||||||
void CL_DLLEXPORT IN_ActivateMouse( void );
|
|
||||||
void CL_DLLEXPORT IN_DeactivateMouse( void );
|
|
||||||
void CL_DLLEXPORT IN_MouseEvent (int mstate);
|
|
||||||
void CL_DLLEXPORT IN_Accumulate (void);
|
|
||||||
void CL_DLLEXPORT IN_ClearStates (void);
|
|
||||||
|
|
||||||
// From tri
|
|
||||||
void CL_DLLEXPORT HUD_DrawNormalTriangles( void );
|
|
||||||
void CL_DLLEXPORT HUD_DrawTransparentTriangles( void );
|
|
||||||
|
|
||||||
// From view
|
|
||||||
void CL_DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );
|
|
||||||
|
|
||||||
// From GameStudioModelRenderer
|
|
||||||
int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
extern cldll_func_dst_t *g_pcldstAddrs;
|
|
||||||
|
|
||||||
// Macros for the client receiving calls from the engine
|
|
||||||
#define RecClInitialize(a, b) (g_pcldstAddrs->pInitFunc(&a, &b))
|
|
||||||
#define RecClHudInit() (g_pcldstAddrs->pHudInitFunc())
|
|
||||||
#define RecClHudVidInit() (g_pcldstAddrs->pHudVidInitFunc())
|
|
||||||
#define RecClHudRedraw(a, b) (g_pcldstAddrs->pHudRedrawFunc(&a, &b))
|
|
||||||
#define RecClHudUpdateClientData(a, b) (g_pcldstAddrs->pHudUpdateClientDataFunc(&a, &b))
|
|
||||||
#define RecClHudReset() (g_pcldstAddrs->pHudResetFunc())
|
|
||||||
#define RecClClientMove(a, b) (g_pcldstAddrs->pClientMove(&a, &b))
|
|
||||||
#define RecClClientMoveInit(a) (g_pcldstAddrs->pClientMoveInit(&a))
|
|
||||||
#define RecClClientTextureType(a) (g_pcldstAddrs->pClientTextureType(&a))
|
|
||||||
#define RecClIN_ActivateMouse() (g_pcldstAddrs->pIN_ActivateMouse())
|
|
||||||
#define RecClIN_DeactivateMouse() (g_pcldstAddrs->pIN_DeactivateMouse())
|
|
||||||
#define RecClIN_MouseEvent(a) (g_pcldstAddrs->pIN_MouseEvent(&a))
|
|
||||||
#define RecClIN_ClearStates() (g_pcldstAddrs->pIN_ClearStates())
|
|
||||||
#define RecClIN_Accumulate() (g_pcldstAddrs->pIN_Accumulate())
|
|
||||||
#define RecClCL_CreateMove(a, b, c) (g_pcldstAddrs->pCL_CreateMove(&a, &b, &c))
|
|
||||||
#define RecClCL_IsThirdPerson() (g_pcldstAddrs->pCL_IsThirdPerson())
|
|
||||||
#define RecClCL_GetCameraOffsets(a) (g_pcldstAddrs->pCL_GetCameraOffsets(&a))
|
|
||||||
#define RecClFindKey(a) (g_pcldstAddrs->pFindKey(&a))
|
|
||||||
#define RecClCamThink() (g_pcldstAddrs->pCamThink())
|
|
||||||
#define RecClCalcRefdef(a) (g_pcldstAddrs->pCalcRefdef(&a))
|
|
||||||
#define RecClAddEntity(a, b, c) (g_pcldstAddrs->pAddEntity(&a, &b, &c))
|
|
||||||
#define RecClCreateEntities() (g_pcldstAddrs->pCreateEntities())
|
|
||||||
#define RecClDrawNormalTriangles() (g_pcldstAddrs->pDrawNormalTriangles())
|
|
||||||
#define RecClDrawTransparentTriangles() (g_pcldstAddrs->pDrawTransparentTriangles())
|
|
||||||
#define RecClStudioEvent(a, b) (g_pcldstAddrs->pStudioEvent(&a, &b))
|
|
||||||
#define RecClPostRunCmd(a, b, c, d, e, f) (g_pcldstAddrs->pPostRunCmd(&a, &b, &c, &d, &e, &f))
|
|
||||||
#define RecClShutdown() (g_pcldstAddrs->pShutdown())
|
|
||||||
#define RecClTxferLocalOverrides(a, b) (g_pcldstAddrs->pTxferLocalOverrides(&a, &b))
|
|
||||||
#define RecClProcessPlayerState(a, b) (g_pcldstAddrs->pProcessPlayerState(&a, &b))
|
|
||||||
#define RecClTxferPredictionData(a, b, c, d, e, f) (g_pcldstAddrs->pTxferPredictionData(&a, &b, &c, &d, &e, &f))
|
|
||||||
#define RecClReadDemoBuffer(a, b) (g_pcldstAddrs->pReadDemoBuffer(&a, &b))
|
|
||||||
#define RecClConnectionlessPacket(a, b, c, d) (g_pcldstAddrs->pConnectionlessPacket(&a, &b, &c, &d))
|
|
||||||
#define RecClGetHullBounds(a, b, c) (g_pcldstAddrs->pGetHullBounds(&a, &b, &c))
|
|
||||||
#define RecClHudFrame(a) (g_pcldstAddrs->pHudFrame(&a))
|
|
||||||
#define RecClKeyEvent(a, b, c) (g_pcldstAddrs->pKeyEvent(&a, &b, &c))
|
|
||||||
#define RecClTempEntUpdate(a, b, c, d, e, f, g) (g_pcldstAddrs->pTempEntUpdate(&a, &b, &c, &d, &e, &f, &g))
|
|
||||||
#define RecClGetUserEntity(a) (g_pcldstAddrs->pGetUserEntity(&a))
|
|
||||||
#define RecClVoiceStatus(a, b) (g_pcldstAddrs->pVoiceStatus(&a, &b))
|
|
||||||
#define RecClDirectorMessage(a, b) (g_pcldstAddrs->pDirectorMessage(&a, &b))
|
|
||||||
#define RecClStudioInterface(a, b, c) (g_pcldstAddrs->pStudioInterface(&a, &b, &c))
|
|
||||||
#define RecClChatInputPosition(a, b) (g_pcldstAddrs->pChatInputPosition(&a, &b))
|
|
||||||
*/
|
|
|
@ -1,121 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "com_model.h"
|
|
||||||
#include "studio.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "dlight.h"
|
|
||||||
#include "triangleapi.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "studio_util.h"
|
|
||||||
#include "r_studioint.h"
|
|
||||||
|
|
||||||
#include "StudioModelRenderer.h"
|
|
||||||
#include "GameStudioModelRenderer.h"
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Override the StudioModelRender virtual member functions here to implement custom bone
|
|
||||||
// setup, blending, etc.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Global engine <-> studio model rendering code interface
|
|
||||||
extern engine_studio_api_t IEngineStudio;
|
|
||||||
|
|
||||||
// The renderer object, created on the stack.
|
|
||||||
CGameStudioModelRenderer g_StudioRenderer;
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CGameStudioModelRenderer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
CGameStudioModelRenderer::CGameStudioModelRenderer( void )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////
|
|
||||||
// Hooks to class implementation
|
|
||||||
////////////////////////////////////
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioDrawPlayer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioDrawModel
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int R_StudioDrawModel( int flags )
|
|
||||||
{
|
|
||||||
return g_StudioRenderer.StudioDrawModel( flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioInit
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void R_StudioInit( void )
|
|
||||||
{
|
|
||||||
g_StudioRenderer.Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The simple drawing interface we'll pass back to the engine
|
|
||||||
r_studio_interface_t studio =
|
|
||||||
{
|
|
||||||
STUDIO_INTERFACE_VERSION,
|
|
||||||
R_StudioDrawModel,
|
|
||||||
R_StudioDrawPlayer,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
HUD_GetStudioModelInterface
|
|
||||||
|
|
||||||
Export this function for the engine to use the studio renderer class to render objects.
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
|
|
||||||
{
|
|
||||||
// RecClStudioInterface(version, ppinterface, pstudio);
|
|
||||||
|
|
||||||
if ( version != STUDIO_INTERFACE_VERSION )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Point the engine to our callbacks
|
|
||||||
*ppinterface = &studio;
|
|
||||||
|
|
||||||
// Copy in engine helper functions
|
|
||||||
memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
|
|
||||||
|
|
||||||
// Initialize local variables, etc.
|
|
||||||
R_StudioInit();
|
|
||||||
|
|
||||||
// Success
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( GAMESTUDIOMODELRENDERER_H )
|
|
||||||
#define GAMESTUDIOMODELRENDERER_H
|
|
||||||
#if defined( _WIN32 )
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CGameStudioModelRenderer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
class CGameStudioModelRenderer : public CStudioModelRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CGameStudioModelRenderer( void );
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GAMESTUDIOMODELRENDERER_H
|
|
|
@ -1,992 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "com_model.h"
|
|
||||||
#include "studio.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "dlight.h"
|
|
||||||
#include "triangleapi.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "studio_util.h"
|
|
||||||
#include "r_studioint.h"
|
|
||||||
|
|
||||||
#include "StudioModelRenderer.h"
|
|
||||||
#include "GameStudioModelRenderer.h"
|
|
||||||
|
|
||||||
// Predicted values saved off in hl_weapons.cpp
|
|
||||||
void Game_GetSequence( int *seq, int *gaitseq );
|
|
||||||
void Game_GetOrientation( float *o, float *a );
|
|
||||||
|
|
||||||
float g_flStartScaleTime;
|
|
||||||
int iPrevRenderState;
|
|
||||||
int iRenderStateChanged;
|
|
||||||
|
|
||||||
// Global engine <-> studio model rendering code interface
|
|
||||||
extern engine_studio_api_t IEngineStudio;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vec3_t origin;
|
|
||||||
vec3_t angles;
|
|
||||||
|
|
||||||
vec3_t realangles;
|
|
||||||
|
|
||||||
float animtime;
|
|
||||||
float frame;
|
|
||||||
int sequence;
|
|
||||||
int gaitsequence;
|
|
||||||
float framerate;
|
|
||||||
|
|
||||||
int m_fSequenceLoops;
|
|
||||||
int m_fSequenceFinished;
|
|
||||||
|
|
||||||
byte controller[ 4 ];
|
|
||||||
byte blending[ 2 ];
|
|
||||||
|
|
||||||
latchedvars_t lv;
|
|
||||||
} client_anim_state_t;
|
|
||||||
|
|
||||||
static client_anim_state_t g_state;
|
|
||||||
static client_anim_state_t g_clientstate;
|
|
||||||
|
|
||||||
// The renderer object, created on the stack.
|
|
||||||
CGameStudioModelRenderer g_StudioRenderer;
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CGameStudioModelRenderer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
CGameStudioModelRenderer::CGameStudioModelRenderer( void )
|
|
||||||
{
|
|
||||||
// If you want to predict animations locally, set this to TRUE
|
|
||||||
// NOTE: The animation code is somewhat broken, but gives you a sense for how
|
|
||||||
// to do client side animation of the predicted player in a third person game.
|
|
||||||
m_bLocal = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
StudioSetupBones
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::StudioSetupBones ( void )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
double f;
|
|
||||||
|
|
||||||
mstudiobone_t *pbones;
|
|
||||||
mstudioseqdesc_t *pseqdesc;
|
|
||||||
mstudioanim_t *panim;
|
|
||||||
|
|
||||||
static float pos[MAXSTUDIOBONES][3];
|
|
||||||
static vec4_t q[MAXSTUDIOBONES];
|
|
||||||
float bonematrix[3][4];
|
|
||||||
|
|
||||||
static float pos2[MAXSTUDIOBONES][3];
|
|
||||||
static vec4_t q2[MAXSTUDIOBONES];
|
|
||||||
static float pos3[MAXSTUDIOBONES][3];
|
|
||||||
static vec4_t q3[MAXSTUDIOBONES];
|
|
||||||
static float pos4[MAXSTUDIOBONES][3];
|
|
||||||
static vec4_t q4[MAXSTUDIOBONES];
|
|
||||||
|
|
||||||
// Use default bone setup for nonplayers
|
|
||||||
if ( !m_pCurrentEntity->player )
|
|
||||||
{
|
|
||||||
CStudioModelRenderer::StudioSetupBones();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bound sequence number.
|
|
||||||
if ( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq )
|
|
||||||
{
|
|
||||||
m_pCurrentEntity->curstate.sequence = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
|
|
||||||
|
|
||||||
if ( m_pPlayerInfo && m_pPlayerInfo->gaitsequence != 0 )
|
|
||||||
{
|
|
||||||
f = m_pPlayerInfo->gaitframe;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f = StudioEstimateFrame( pseqdesc );
|
|
||||||
}
|
|
||||||
|
|
||||||
// This game knows how to do three way blending
|
|
||||||
if ( pseqdesc->numblends == 3 )
|
|
||||||
{
|
|
||||||
float s;
|
|
||||||
|
|
||||||
// Get left anim
|
|
||||||
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
|
|
||||||
|
|
||||||
// Blending is 0-127 == Left to Middle, 128 to 255 == Middle to right
|
|
||||||
if ( m_pCurrentEntity->curstate.blending[0] <= 127 )
|
|
||||||
{
|
|
||||||
StudioCalcRotations( pos, q, pseqdesc, panim, f );
|
|
||||||
|
|
||||||
// Scale 0-127 blending up to 0-255
|
|
||||||
s = m_pCurrentEntity->curstate.blending[0];
|
|
||||||
s = ( s * 2.0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
// Skip ahead to middle
|
|
||||||
panim += m_pStudioHeader->numbones;
|
|
||||||
|
|
||||||
StudioCalcRotations( pos, q, pseqdesc, panim, f );
|
|
||||||
|
|
||||||
// Scale 127-255 blending up to 0-255
|
|
||||||
s = m_pCurrentEntity->curstate.blending[0];
|
|
||||||
s = 2.0 * ( s - 127.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize interpolant
|
|
||||||
s /= 255.0;
|
|
||||||
|
|
||||||
// Go to middle or right
|
|
||||||
panim += m_pStudioHeader->numbones;
|
|
||||||
|
|
||||||
StudioCalcRotations( pos2, q2, pseqdesc, panim, f );
|
|
||||||
|
|
||||||
// Spherically interpolate the bones
|
|
||||||
StudioSlerpBones( q, pos, q2, pos2, s );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
|
|
||||||
StudioCalcRotations( pos, q, pseqdesc, panim, f );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are we in the process of transitioning from one sequence to another.
|
|
||||||
if ( m_fDoInterp &&
|
|
||||||
m_pCurrentEntity->latched.sequencetime &&
|
|
||||||
( m_pCurrentEntity->latched.sequencetime + 0.2 > m_clTime ) &&
|
|
||||||
( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq ))
|
|
||||||
{
|
|
||||||
// blend from last sequence
|
|
||||||
static float pos1b[MAXSTUDIOBONES][3];
|
|
||||||
static vec4_t q1b[MAXSTUDIOBONES];
|
|
||||||
float s;
|
|
||||||
|
|
||||||
// Blending value into last sequence
|
|
||||||
unsigned char prevseqblending = m_pCurrentEntity->latched.prevseqblending[ 0 ];
|
|
||||||
|
|
||||||
// Point at previous sequenece
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->latched.prevsequence;
|
|
||||||
|
|
||||||
// Know how to do three way blends
|
|
||||||
if ( pseqdesc->numblends == 3 )
|
|
||||||
{
|
|
||||||
float s;
|
|
||||||
|
|
||||||
// Get left animation
|
|
||||||
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
|
|
||||||
|
|
||||||
if ( prevseqblending <= 127 )
|
|
||||||
{
|
|
||||||
// Set up bones based on final frame of previous sequence
|
|
||||||
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
|
|
||||||
|
|
||||||
s = prevseqblending;
|
|
||||||
s = ( s * 2.0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Skip to middle blend
|
|
||||||
panim += m_pStudioHeader->numbones;
|
|
||||||
|
|
||||||
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
|
|
||||||
|
|
||||||
s = prevseqblending;
|
|
||||||
s = 2.0 * ( s - 127.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize
|
|
||||||
s /= 255.0;
|
|
||||||
|
|
||||||
panim += m_pStudioHeader->numbones;
|
|
||||||
StudioCalcRotations( pos2, q2, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
|
|
||||||
|
|
||||||
// Interpolate bones
|
|
||||||
StudioSlerpBones( q1b, pos1b, q2, pos2, s );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
|
|
||||||
// clip prevframe
|
|
||||||
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now blend last frame of previous sequence with current sequence.
|
|
||||||
s = 1.0 - (m_clTime - m_pCurrentEntity->latched.sequencetime) / 0.2;
|
|
||||||
StudioSlerpBones( q, pos, q1b, pos1b, s );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pCurrentEntity->latched.prevframe = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now convert quaternions and bone positions into matrices
|
|
||||||
pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex);
|
|
||||||
|
|
||||||
for (i = 0; i < m_pStudioHeader->numbones; i++)
|
|
||||||
{
|
|
||||||
QuaternionMatrix( q[i], bonematrix );
|
|
||||||
|
|
||||||
bonematrix[0][3] = pos[i][0];
|
|
||||||
bonematrix[1][3] = pos[i][1];
|
|
||||||
bonematrix[2][3] = pos[i][2];
|
|
||||||
|
|
||||||
if (pbones[i].parent == -1)
|
|
||||||
{
|
|
||||||
if ( IEngineStudio.IsHardware() )
|
|
||||||
{
|
|
||||||
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_pbonetransform)[i]);
|
|
||||||
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConcatTransforms ((*m_paliastransform), bonematrix, (*m_pbonetransform)[i]);
|
|
||||||
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply client-side effects to the transformation matrix
|
|
||||||
StudioFxTransform( m_pCurrentEntity, (*m_pbonetransform)[i] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConcatTransforms ((*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i]);
|
|
||||||
ConcatTransforms ((*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
StudioEstimateGait
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
float dt;
|
|
||||||
vec3_t est_velocity;
|
|
||||||
|
|
||||||
dt = (m_clTime - m_clOldTime);
|
|
||||||
dt = max( 0.0, dt );
|
|
||||||
dt = min( 1.0, dt );
|
|
||||||
|
|
||||||
if (dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount)
|
|
||||||
{
|
|
||||||
m_flGaitMovement = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// VectorAdd( pplayer->velocity, pplayer->prediction_error, est_velocity );
|
|
||||||
if ( m_fGaitEstimation )
|
|
||||||
{
|
|
||||||
VectorSubtract( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin, est_velocity );
|
|
||||||
VectorCopy( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin );
|
|
||||||
m_flGaitMovement = Length( est_velocity );
|
|
||||||
if (dt <= 0 || m_flGaitMovement / dt < 5)
|
|
||||||
{
|
|
||||||
m_flGaitMovement = 0;
|
|
||||||
est_velocity[0] = 0;
|
|
||||||
est_velocity[1] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VectorCopy( pplayer->velocity, est_velocity );
|
|
||||||
m_flGaitMovement = Length( est_velocity ) * dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (est_velocity[1] == 0 && est_velocity[0] == 0)
|
|
||||||
{
|
|
||||||
float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
|
|
||||||
flYawDiff = flYawDiff - (int)(flYawDiff / 360) * 360;
|
|
||||||
if (flYawDiff > 180)
|
|
||||||
flYawDiff -= 360;
|
|
||||||
if (flYawDiff < -180)
|
|
||||||
flYawDiff += 360;
|
|
||||||
|
|
||||||
if (dt < 0.25)
|
|
||||||
flYawDiff *= dt * 4;
|
|
||||||
else
|
|
||||||
flYawDiff *= dt;
|
|
||||||
|
|
||||||
m_pPlayerInfo->gaityaw += flYawDiff;
|
|
||||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)(m_pPlayerInfo->gaityaw / 360) * 360;
|
|
||||||
|
|
||||||
m_flGaitMovement = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI);
|
|
||||||
if (m_pPlayerInfo->gaityaw > 180)
|
|
||||||
m_pPlayerInfo->gaityaw = 180;
|
|
||||||
if (m_pPlayerInfo->gaityaw < -180)
|
|
||||||
m_pPlayerInfo->gaityaw = -180;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
StudioProcessGait
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
mstudioseqdesc_t *pseqdesc;
|
|
||||||
float dt;
|
|
||||||
float flYaw; // view direction relative to movement
|
|
||||||
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
|
|
||||||
|
|
||||||
m_pCurrentEntity->angles[PITCH] = 0;
|
|
||||||
m_pCurrentEntity->latched.prevangles[PITCH] = m_pCurrentEntity->angles[PITCH];
|
|
||||||
|
|
||||||
dt = (m_clTime - m_clOldTime);
|
|
||||||
dt = max( 0.0, dt );
|
|
||||||
dt = min( 1.0, dt );
|
|
||||||
|
|
||||||
StudioEstimateGait( pplayer );
|
|
||||||
|
|
||||||
// calc side to side turning
|
|
||||||
flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
|
|
||||||
|
|
||||||
flYaw = fmod( flYaw, 360.0 );
|
|
||||||
|
|
||||||
if (flYaw < -180)
|
|
||||||
{
|
|
||||||
flYaw = flYaw + 360;
|
|
||||||
}
|
|
||||||
else if (flYaw > 180)
|
|
||||||
{
|
|
||||||
flYaw = flYaw - 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
float maxyaw = 120.0;
|
|
||||||
|
|
||||||
if (flYaw > maxyaw)
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180;
|
|
||||||
m_flGaitMovement = -m_flGaitMovement;
|
|
||||||
flYaw = flYaw - 180;
|
|
||||||
}
|
|
||||||
else if (flYaw < -maxyaw)
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180;
|
|
||||||
m_flGaitMovement = -m_flGaitMovement;
|
|
||||||
flYaw = flYaw + 180;
|
|
||||||
}
|
|
||||||
|
|
||||||
float blend_yaw = ( flYaw / 90.0 ) * 128.0 + 127.0;
|
|
||||||
blend_yaw = min( 255.0, blend_yaw );
|
|
||||||
blend_yaw = max( 0.0, blend_yaw );
|
|
||||||
|
|
||||||
blend_yaw = 255.0 - blend_yaw;
|
|
||||||
|
|
||||||
m_pCurrentEntity->curstate.blending[0] = (int)(blend_yaw);
|
|
||||||
m_pCurrentEntity->latched.prevblending[0] = m_pCurrentEntity->curstate.blending[0];
|
|
||||||
m_pCurrentEntity->latched.prevseqblending[0] = m_pCurrentEntity->curstate.blending[0];
|
|
||||||
|
|
||||||
m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw;
|
|
||||||
if (m_pCurrentEntity->angles[YAW] < -0)
|
|
||||||
{
|
|
||||||
m_pCurrentEntity->angles[YAW] += 360;
|
|
||||||
}
|
|
||||||
m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW];
|
|
||||||
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence;
|
|
||||||
|
|
||||||
// Calc gait frame
|
|
||||||
if (pseqdesc->linearmovement[0] > 0)
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaitframe += (m_flGaitMovement / pseqdesc->linearmovement[0]) * pseqdesc->numframes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaitframe += pseqdesc->fps * dt * m_pCurrentEntity->curstate.framerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do modulo
|
|
||||||
m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)(m_pPlayerInfo->gaitframe / pseqdesc->numframes) * pseqdesc->numframes;
|
|
||||||
if (m_pPlayerInfo->gaitframe < 0)
|
|
||||||
{
|
|
||||||
m_pPlayerInfo->gaitframe += pseqdesc->numframes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============================
|
|
||||||
SavePlayerState
|
|
||||||
|
|
||||||
For local player, in third person, we need to store real render data and then
|
|
||||||
setup for with fake/client side animation data
|
|
||||||
==============================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::SavePlayerState( entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
client_anim_state_t *st;
|
|
||||||
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
|
|
||||||
assert( ent );
|
|
||||||
if ( !ent )
|
|
||||||
return;
|
|
||||||
|
|
||||||
st = &g_state;
|
|
||||||
|
|
||||||
st->angles = ent->curstate.angles;
|
|
||||||
st->origin = ent->curstate.origin;
|
|
||||||
|
|
||||||
st->realangles = ent->angles;
|
|
||||||
|
|
||||||
st->sequence = ent->curstate.sequence;
|
|
||||||
st->gaitsequence = pplayer->gaitsequence;
|
|
||||||
st->animtime = ent->curstate.animtime;
|
|
||||||
st->frame = ent->curstate.frame;
|
|
||||||
st->framerate = ent->curstate.framerate;
|
|
||||||
memcpy( st->blending, ent->curstate.blending, 2 );
|
|
||||||
memcpy( st->controller, ent->curstate.controller, 4 );
|
|
||||||
|
|
||||||
st->lv = ent->latched;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetSequenceInfo( void *pmodel, client_anim_state_t *pev, float *pflFrameRate, float *pflGroundSpeed )
|
|
||||||
{
|
|
||||||
studiohdr_t *pstudiohdr;
|
|
||||||
|
|
||||||
pstudiohdr = (studiohdr_t *)pmodel;
|
|
||||||
if (! pstudiohdr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mstudioseqdesc_t *pseqdesc;
|
|
||||||
|
|
||||||
if (pev->sequence >= pstudiohdr->numseq)
|
|
||||||
{
|
|
||||||
*pflFrameRate = 0.0;
|
|
||||||
*pflGroundSpeed = 0.0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
|
|
||||||
|
|
||||||
if (pseqdesc->numframes > 1)
|
|
||||||
{
|
|
||||||
*pflFrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1);
|
|
||||||
*pflGroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] );
|
|
||||||
*pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*pflFrameRate = 256.0;
|
|
||||||
*pflGroundSpeed = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetSequenceFlags( void *pmodel, client_anim_state_t *pev )
|
|
||||||
{
|
|
||||||
studiohdr_t *pstudiohdr;
|
|
||||||
|
|
||||||
pstudiohdr = (studiohdr_t *)pmodel;
|
|
||||||
if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
mstudioseqdesc_t *pseqdesc;
|
|
||||||
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
|
|
||||||
|
|
||||||
return pseqdesc->flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
float StudioFrameAdvance ( client_anim_state_t *st, float framerate, float flInterval )
|
|
||||||
{
|
|
||||||
if (flInterval == 0.0)
|
|
||||||
{
|
|
||||||
flInterval = (gEngfuncs.GetClientTime() - st->animtime);
|
|
||||||
if (flInterval <= 0.001)
|
|
||||||
{
|
|
||||||
st->animtime = gEngfuncs.GetClientTime();
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!st->animtime)
|
|
||||||
flInterval = 0.0;
|
|
||||||
|
|
||||||
st->frame += flInterval * framerate * st->framerate;
|
|
||||||
st->animtime = gEngfuncs.GetClientTime();
|
|
||||||
|
|
||||||
if (st->frame < 0.0 || st->frame >= 256.0)
|
|
||||||
{
|
|
||||||
if ( st->m_fSequenceLoops )
|
|
||||||
st->frame -= (int)(st->frame / 256.0) * 256.0;
|
|
||||||
else
|
|
||||||
st->frame = (st->frame < 0.0) ? 0 : 255;
|
|
||||||
st->m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
|
|
||||||
}
|
|
||||||
|
|
||||||
return flInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============================
|
|
||||||
SetupClientAnimation
|
|
||||||
|
|
||||||
Called to set up local player's animation values
|
|
||||||
==============================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::SetupClientAnimation( entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
static double oldtime;
|
|
||||||
double curtime, dt;
|
|
||||||
|
|
||||||
client_anim_state_t *st;
|
|
||||||
float fr, gs;
|
|
||||||
|
|
||||||
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
|
|
||||||
assert( ent );
|
|
||||||
if ( !ent )
|
|
||||||
return;
|
|
||||||
|
|
||||||
curtime = gEngfuncs.GetClientTime();
|
|
||||||
dt = curtime - oldtime;
|
|
||||||
dt = min( 1.0, max( 0.0, dt ) );
|
|
||||||
|
|
||||||
oldtime = curtime;
|
|
||||||
st = &g_clientstate;
|
|
||||||
|
|
||||||
st->framerate = 1.0;
|
|
||||||
|
|
||||||
int oldseq = st->sequence;
|
|
||||||
Game_GetSequence( &st->sequence, &st->gaitsequence ); //CVAR_GET_FLOAT( "sequence" );
|
|
||||||
Game_GetOrientation( (float *)&st->origin, (float *)&st->angles );
|
|
||||||
st->realangles = st->angles;
|
|
||||||
|
|
||||||
if ( st->sequence != oldseq )
|
|
||||||
{
|
|
||||||
st->frame = 0.0;
|
|
||||||
st->lv.prevsequence = oldseq;
|
|
||||||
st->lv.sequencetime = st->animtime;
|
|
||||||
|
|
||||||
memcpy( st->lv.prevseqblending, st->blending, 2 );
|
|
||||||
memcpy( st->lv.prevcontroller, st->controller, 4 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void *pmodel = (studiohdr_t *)IEngineStudio.Mod_Extradata( ent->model );
|
|
||||||
|
|
||||||
GetSequenceInfo( pmodel, st, &fr, &gs );
|
|
||||||
st->m_fSequenceLoops = ((GetSequenceFlags( pmodel, st ) & STUDIO_LOOPING) != 0);
|
|
||||||
StudioFrameAdvance( st, fr, dt );
|
|
||||||
|
|
||||||
// gEngfuncs.Con_Printf( "gs %i frame %f\n", st->gaitsequence, st->frame );
|
|
||||||
|
|
||||||
ent->angles = st->realangles;
|
|
||||||
ent->curstate.angles = st->angles;
|
|
||||||
ent->curstate.origin = st->origin;
|
|
||||||
|
|
||||||
ent->curstate.sequence = st->sequence;
|
|
||||||
pplayer->gaitsequence = st->gaitsequence;
|
|
||||||
ent->curstate.animtime = st->animtime;
|
|
||||||
ent->curstate.frame = st->frame;
|
|
||||||
ent->curstate.framerate = st->framerate;
|
|
||||||
memcpy( ent->curstate.blending, st->blending, 2 );
|
|
||||||
memcpy( ent->curstate.controller, st->controller, 4 );
|
|
||||||
|
|
||||||
ent->latched = st->lv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============================
|
|
||||||
RestorePlayerState
|
|
||||||
|
|
||||||
Called to restore original player state information
|
|
||||||
==============================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::RestorePlayerState( entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
client_anim_state_t *st;
|
|
||||||
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
|
|
||||||
assert( ent );
|
|
||||||
if ( !ent )
|
|
||||||
return;
|
|
||||||
|
|
||||||
st = &g_clientstate;
|
|
||||||
|
|
||||||
st->angles = ent->curstate.angles;
|
|
||||||
st->origin = ent->curstate.origin;
|
|
||||||
st->realangles = ent->angles;
|
|
||||||
|
|
||||||
st->sequence = ent->curstate.sequence;
|
|
||||||
st->gaitsequence = pplayer->gaitsequence;
|
|
||||||
st->animtime = ent->curstate.animtime;
|
|
||||||
st->frame = ent->curstate.frame;
|
|
||||||
st->framerate = ent->curstate.framerate;
|
|
||||||
memcpy( st->blending, ent->curstate.blending, 2 );
|
|
||||||
memcpy( st->controller, ent->curstate.controller, 4 );
|
|
||||||
|
|
||||||
st->lv = ent->latched;
|
|
||||||
|
|
||||||
st = &g_state;
|
|
||||||
|
|
||||||
ent->curstate.angles = st->angles;
|
|
||||||
ent->curstate.origin = st->origin;
|
|
||||||
ent->angles = st->realangles;
|
|
||||||
|
|
||||||
ent->curstate.sequence = st->sequence;
|
|
||||||
pplayer->gaitsequence = st->gaitsequence;
|
|
||||||
ent->curstate.animtime = st->animtime;
|
|
||||||
ent->curstate.frame = st->frame;
|
|
||||||
ent->curstate.framerate = st->framerate;
|
|
||||||
memcpy( ent->curstate.blending, st->blending, 2 );
|
|
||||||
memcpy( ent->curstate.controller, st->controller, 4 );
|
|
||||||
|
|
||||||
ent->latched = st->lv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============================
|
|
||||||
StudioDrawPlayer
|
|
||||||
|
|
||||||
==============================
|
|
||||||
*/
|
|
||||||
int CGameStudioModelRenderer::StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
int iret = 0;
|
|
||||||
|
|
||||||
bool isLocalPlayer = false;
|
|
||||||
|
|
||||||
// Set up for client?
|
|
||||||
if ( m_bLocal && IEngineStudio.GetCurrentEntity() == gEngfuncs.GetLocalPlayer() )
|
|
||||||
{
|
|
||||||
isLocalPlayer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isLocalPlayer )
|
|
||||||
{
|
|
||||||
// Store original data
|
|
||||||
SavePlayerState( pplayer );
|
|
||||||
|
|
||||||
// Copy in client side animation data
|
|
||||||
SetupClientAnimation( pplayer );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call real draw function
|
|
||||||
iret = _StudioDrawPlayer( flags, pplayer );
|
|
||||||
|
|
||||||
// Restore for client?
|
|
||||||
if ( isLocalPlayer )
|
|
||||||
{
|
|
||||||
// Restore the original data for the player
|
|
||||||
RestorePlayerState( pplayer );
|
|
||||||
}
|
|
||||||
|
|
||||||
return iret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
_StudioDrawPlayer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int CGameStudioModelRenderer::_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
alight_t lighting;
|
|
||||||
vec3_t dir;
|
|
||||||
|
|
||||||
m_pCurrentEntity = IEngineStudio.GetCurrentEntity();
|
|
||||||
IEngineStudio.GetTimes( &m_nFrameCount, &m_clTime, &m_clOldTime );
|
|
||||||
IEngineStudio.GetViewInfo( m_vRenderOrigin, m_vUp, m_vRight, m_vNormal );
|
|
||||||
IEngineStudio.GetAliasScale( &m_fSoftwareXScale, &m_fSoftwareYScale );
|
|
||||||
|
|
||||||
m_nPlayerIndex = pplayer->number - 1;
|
|
||||||
|
|
||||||
if (m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
m_pRenderModel = IEngineStudio.SetupPlayerModel( m_nPlayerIndex );
|
|
||||||
if (m_pRenderModel == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (m_pRenderModel);
|
|
||||||
IEngineStudio.StudioSetHeader( m_pStudioHeader );
|
|
||||||
IEngineStudio.SetRenderModel( m_pRenderModel );
|
|
||||||
|
|
||||||
if (pplayer->gaitsequence)
|
|
||||||
{
|
|
||||||
vec3_t orig_angles;
|
|
||||||
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
|
|
||||||
|
|
||||||
VectorCopy( m_pCurrentEntity->angles, orig_angles );
|
|
||||||
|
|
||||||
StudioProcessGait( pplayer );
|
|
||||||
|
|
||||||
m_pPlayerInfo->gaitsequence = pplayer->gaitsequence;
|
|
||||||
m_pPlayerInfo = NULL;
|
|
||||||
|
|
||||||
StudioSetUpTransform( 0 );
|
|
||||||
VectorCopy( orig_angles, m_pCurrentEntity->angles );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pCurrentEntity->curstate.controller[0] = 127;
|
|
||||||
m_pCurrentEntity->curstate.controller[1] = 127;
|
|
||||||
m_pCurrentEntity->curstate.controller[2] = 127;
|
|
||||||
m_pCurrentEntity->curstate.controller[3] = 127;
|
|
||||||
m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0];
|
|
||||||
m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1];
|
|
||||||
m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2];
|
|
||||||
m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3];
|
|
||||||
|
|
||||||
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
|
|
||||||
m_pPlayerInfo->gaitsequence = 0;
|
|
||||||
|
|
||||||
StudioSetUpTransform( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & STUDIO_RENDER)
|
|
||||||
{
|
|
||||||
// see if the bounding box lets us trivially reject, also sets
|
|
||||||
if (!IEngineStudio.StudioCheckBBox ())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
(*m_pModelsDrawn)++;
|
|
||||||
(*m_pStudioModelCount)++; // render data cache cookie
|
|
||||||
|
|
||||||
if (m_pStudioHeader->numbodyparts == 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
|
|
||||||
StudioSetupBones( );
|
|
||||||
StudioSaveBones( );
|
|
||||||
m_pPlayerInfo->renderframe = m_nFrameCount;
|
|
||||||
|
|
||||||
m_pPlayerInfo = NULL;
|
|
||||||
|
|
||||||
if (flags & STUDIO_EVENTS)
|
|
||||||
{
|
|
||||||
StudioCalcAttachments( );
|
|
||||||
IEngineStudio.StudioClientEvents( );
|
|
||||||
// copy attachments into global entity array
|
|
||||||
if ( m_pCurrentEntity->index > 0 )
|
|
||||||
{
|
|
||||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( m_pCurrentEntity->index );
|
|
||||||
|
|
||||||
memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * 4 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & STUDIO_RENDER)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if (m_pCvarHiModels->value && m_pRenderModel != m_pCurrentEntity->model )
|
|
||||||
{
|
|
||||||
// show highest resolution multiplayer model
|
|
||||||
m_pCurrentEntity->curstate.body = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(m_pCvarDeveloper->value == 0 && gEngfuncs.GetMaxClients() == 1 ) && ( m_pRenderModel == m_pCurrentEntity->model ) )
|
|
||||||
{
|
|
||||||
m_pCurrentEntity->curstate.body = 1; // force helmet
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
lighting.plightvec = dir;
|
|
||||||
IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting );
|
|
||||||
|
|
||||||
IEngineStudio.StudioEntityLight( &lighting );
|
|
||||||
|
|
||||||
// model and frame independant
|
|
||||||
IEngineStudio.StudioSetupLighting (&lighting);
|
|
||||||
|
|
||||||
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
|
|
||||||
|
|
||||||
// get remap colors
|
|
||||||
m_nTopColor = m_pPlayerInfo->topcolor;
|
|
||||||
if (m_nTopColor < 0)
|
|
||||||
m_nTopColor = 0;
|
|
||||||
if (m_nTopColor > 360)
|
|
||||||
m_nTopColor = 360;
|
|
||||||
m_nBottomColor = m_pPlayerInfo->bottomcolor;
|
|
||||||
if (m_nBottomColor < 0)
|
|
||||||
m_nBottomColor = 0;
|
|
||||||
if (m_nBottomColor > 360)
|
|
||||||
m_nBottomColor = 360;
|
|
||||||
|
|
||||||
IEngineStudio.StudioSetRemapColors( m_nTopColor, m_nBottomColor );
|
|
||||||
|
|
||||||
StudioRenderModel( );
|
|
||||||
m_pPlayerInfo = NULL;
|
|
||||||
|
|
||||||
if (pplayer->weaponmodel)
|
|
||||||
{
|
|
||||||
cl_entity_t saveent = *m_pCurrentEntity;
|
|
||||||
|
|
||||||
model_t *pweaponmodel = IEngineStudio.GetModelByIndex( pplayer->weaponmodel );
|
|
||||||
|
|
||||||
m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (pweaponmodel);
|
|
||||||
IEngineStudio.StudioSetHeader( m_pStudioHeader );
|
|
||||||
|
|
||||||
StudioMergeBones( pweaponmodel);
|
|
||||||
|
|
||||||
IEngineStudio.StudioSetupLighting (&lighting);
|
|
||||||
|
|
||||||
StudioRenderModel( );
|
|
||||||
|
|
||||||
StudioCalcAttachments( );
|
|
||||||
|
|
||||||
*m_pCurrentEntity = saveent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
Studio_FxTransform
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void CGameStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[3][4] )
|
|
||||||
{
|
|
||||||
switch( ent->curstate.renderfx )
|
|
||||||
{
|
|
||||||
case kRenderFxDistort:
|
|
||||||
case kRenderFxHologram:
|
|
||||||
if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
|
|
||||||
{
|
|
||||||
int axis = gEngfuncs.pfnRandomLong(0,1);
|
|
||||||
if ( axis == 1 ) // Choose between x & z
|
|
||||||
axis = 2;
|
|
||||||
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat(1,1.484), transform[axis] );
|
|
||||||
}
|
|
||||||
else if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
|
|
||||||
{
|
|
||||||
float offset;
|
|
||||||
int axis = gEngfuncs.pfnRandomLong(0,1);
|
|
||||||
if ( axis == 1 ) // Choose between x & z
|
|
||||||
axis = 2;
|
|
||||||
offset = gEngfuncs.pfnRandomFloat(-10,10);
|
|
||||||
transform[gEngfuncs.pfnRandomLong(0,2)][3] += offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kRenderFxExplode:
|
|
||||||
{
|
|
||||||
if ( iRenderStateChanged )
|
|
||||||
{
|
|
||||||
g_flStartScaleTime = m_clTime;
|
|
||||||
iRenderStateChanged = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the Model continue to shrink
|
|
||||||
float flTimeDelta = m_clTime - g_flStartScaleTime;
|
|
||||||
if ( flTimeDelta > 0 )
|
|
||||||
{
|
|
||||||
float flScale = 0.001;
|
|
||||||
// Goes almost all away
|
|
||||||
if ( flTimeDelta <= 2.0 )
|
|
||||||
flScale = 1.0 - (flTimeDelta / 2.0);
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
transform[i][j] *= flScale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////
|
|
||||||
// Hooks to class implementation
|
|
||||||
////////////////////////////////////
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioDrawPlayer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|
||||||
{
|
|
||||||
return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioDrawModel
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int R_StudioDrawModel( int flags )
|
|
||||||
{
|
|
||||||
return g_StudioRenderer.StudioDrawModel( flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
R_StudioInit
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void R_StudioInit( void )
|
|
||||||
{
|
|
||||||
g_StudioRenderer.Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The simple drawing interface we'll pass back to the engine
|
|
||||||
r_studio_interface_t studio =
|
|
||||||
{
|
|
||||||
STUDIO_INTERFACE_VERSION,
|
|
||||||
R_StudioDrawModel,
|
|
||||||
R_StudioDrawPlayer,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
HUD_GetStudioModelInterface
|
|
||||||
|
|
||||||
Export this function for the engine to use the studio renderer class to render objects.
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
#define DLLEXPORT __declspec( dllexport )
|
|
||||||
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
|
|
||||||
{
|
|
||||||
if ( version != STUDIO_INTERFACE_VERSION )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Point the engine to our callbacks
|
|
||||||
*ppinterface = &studio;
|
|
||||||
|
|
||||||
// Copy in engine helper functions
|
|
||||||
memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
|
|
||||||
|
|
||||||
// Initialize local variables, etc.
|
|
||||||
R_StudioInit();
|
|
||||||
|
|
||||||
// Success
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( GAMESTUDIOMODELRENDERER_H )
|
|
||||||
#define GAMESTUDIOMODELRENDERER_H
|
|
||||||
#if defined( _WIN32 )
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CGameStudioModelRenderer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
class CGameStudioModelRenderer : public CStudioModelRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CGameStudioModelRenderer( void );
|
|
||||||
|
|
||||||
// Set up model bone positions
|
|
||||||
virtual void StudioSetupBones ( void );
|
|
||||||
|
|
||||||
// Estimate gait frame for player
|
|
||||||
virtual void StudioEstimateGait ( entity_state_t *pplayer );
|
|
||||||
|
|
||||||
// Process movement of player
|
|
||||||
virtual void StudioProcessGait ( entity_state_t *pplayer );
|
|
||||||
|
|
||||||
// Player drawing code
|
|
||||||
virtual int StudioDrawPlayer( int flags, entity_state_t *pplayer );
|
|
||||||
virtual int _StudioDrawPlayer( int flags, entity_state_t *pplayer );
|
|
||||||
|
|
||||||
// Apply special effects to transform matrix
|
|
||||||
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// For local player, in third person, we need to store real render data and then
|
|
||||||
// setup for with fake/client side animation data
|
|
||||||
void SavePlayerState( entity_state_t *pplayer );
|
|
||||||
// Called to set up local player's animation values
|
|
||||||
void SetupClientAnimation( entity_state_t *pplayer );
|
|
||||||
// Called to restore original player state information
|
|
||||||
void RestorePlayerState( entity_state_t *pplayer );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Private data
|
|
||||||
bool m_bLocal;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GAMESTUDIOMODELRENDERER_H
|
|
|
@ -1,155 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// MOTD.cpp
|
|
||||||
//
|
|
||||||
// for displaying a server-sent message of the day
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
//DECLARE_MESSAGE( m_MOTD, MOTD );
|
|
||||||
|
|
||||||
int CHudMOTD::MOTD_DISPLAY_TIME;
|
|
||||||
|
|
||||||
int CHudMOTD :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
// HOOK_MESSAGE( MOTD );
|
|
||||||
|
|
||||||
CVAR_CREATE( "motd_display_time", "15", 0 );
|
|
||||||
|
|
||||||
m_iFlags &= ~HUD_ACTIVE; // start out inactive
|
|
||||||
m_szMOTD[0] = 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudMOTD :: VidInit( void )
|
|
||||||
{
|
|
||||||
// Load sprites here
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudMOTD :: Reset( void )
|
|
||||||
{
|
|
||||||
m_iFlags &= ~HUD_ACTIVE; // start out inactive
|
|
||||||
m_szMOTD[0] = 0;
|
|
||||||
m_iLines = 0;
|
|
||||||
m_flActiveRemaining = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LINE_HEIGHT 13
|
|
||||||
|
|
||||||
int CHudMOTD :: Draw( float fTime )
|
|
||||||
{
|
|
||||||
static float sfLastTime;
|
|
||||||
float fElapsed;
|
|
||||||
|
|
||||||
// Draw MOTD line-by-line
|
|
||||||
if ( m_flActiveRemaining <= 0.0 )
|
|
||||||
{
|
|
||||||
// finished with MOTD, disable it
|
|
||||||
m_szMOTD[0] = 0;
|
|
||||||
m_iLines = 0;
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
m_flActiveRemaining = 0.0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fElapsed = gHUD.m_flTime - sfLastTime;
|
|
||||||
|
|
||||||
// Don't let time go negative ( level transition? )
|
|
||||||
fElapsed = max( 0.0, fElapsed );
|
|
||||||
// Don't let time go hugely positive ( first connection to active server ? )
|
|
||||||
fElapsed = min( 1.0, fElapsed );
|
|
||||||
|
|
||||||
// Remember last timestamp
|
|
||||||
sfLastTime = gHUD.m_flTime;
|
|
||||||
|
|
||||||
// Remove a bit of time
|
|
||||||
m_flActiveRemaining -= fElapsed;
|
|
||||||
|
|
||||||
// find the top of where the MOTD should be drawn, so the whole thing is centered in the screen
|
|
||||||
int ypos = max(((ScreenHeight - (m_iLines * LINE_HEIGHT)) / 2) - 40, 30 ); // shift it up slightly
|
|
||||||
char *ch = m_szMOTD;
|
|
||||||
while ( *ch )
|
|
||||||
{
|
|
||||||
int line_length = 0; // count the length of the current line
|
|
||||||
for ( char *next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
|
|
||||||
line_length += gHUD.m_scrinfo.charWidths[ *next_line ];
|
|
||||||
char *top = next_line;
|
|
||||||
if ( *top == '\n' )
|
|
||||||
*top = 0;
|
|
||||||
else
|
|
||||||
top = NULL;
|
|
||||||
|
|
||||||
// find where to start drawing the line
|
|
||||||
int xpos = (ScreenWidth - line_length) / 2;
|
|
||||||
|
|
||||||
gHUD.DrawHudString( xpos, ypos, ScreenWidth, ch, 255, 180, 0 );
|
|
||||||
|
|
||||||
ypos += LINE_HEIGHT;
|
|
||||||
|
|
||||||
if ( top ) // restore
|
|
||||||
*top = '\n';
|
|
||||||
ch = next_line;
|
|
||||||
if ( *ch == '\n' )
|
|
||||||
ch++;
|
|
||||||
|
|
||||||
if ( ypos > (ScreenHeight - 20) )
|
|
||||||
break; // don't let it draw too low
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
if ( m_iFlags & HUD_ACTIVE )
|
|
||||||
{
|
|
||||||
Reset(); // clear the current MOTD in prep for this one
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int is_finished = READ_BYTE();
|
|
||||||
strcat( m_szMOTD, READ_STRING() );
|
|
||||||
|
|
||||||
if ( is_finished )
|
|
||||||
{
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
MOTD_DISPLAY_TIME = max( 10, CVAR_GET_FLOAT( "motd_display_time" ) );
|
|
||||||
|
|
||||||
m_flActiveRemaining = MOTD_DISPLAY_TIME;
|
|
||||||
|
|
||||||
for ( char *sz = m_szMOTD; *sz != 0; sz++ ) // count the number of lines in the MOTD
|
|
||||||
{
|
|
||||||
if ( *sz == '\n' )
|
|
||||||
m_iLines++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,189 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined ( STUDIOMODELRENDERER_H )
|
|
||||||
#define STUDIOMODELRENDERER_H
|
|
||||||
#if defined( _WIN32 )
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CStudioModelRenderer
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
class CStudioModelRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Construction/Destruction
|
|
||||||
CStudioModelRenderer( void );
|
|
||||||
virtual ~CStudioModelRenderer( void );
|
|
||||||
|
|
||||||
// Initialization
|
|
||||||
virtual void Init( void );
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Public Interfaces
|
|
||||||
virtual int StudioDrawModel ( int flags );
|
|
||||||
virtual int StudioDrawPlayer ( int flags, struct entity_state_s *pplayer );
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Local interfaces
|
|
||||||
//
|
|
||||||
|
|
||||||
// Look up animation data for sequence
|
|
||||||
virtual mstudioanim_t *StudioGetAnim ( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
|
|
||||||
|
|
||||||
// Interpolate model position and angles and set up matrices
|
|
||||||
virtual void StudioSetUpTransform (int trivial_accept);
|
|
||||||
|
|
||||||
// Set up model bone positions
|
|
||||||
virtual void StudioSetupBones ( void );
|
|
||||||
|
|
||||||
// Find final attachment points
|
|
||||||
virtual void StudioCalcAttachments ( void );
|
|
||||||
|
|
||||||
// Save bone matrices and names
|
|
||||||
virtual void StudioSaveBones( void );
|
|
||||||
|
|
||||||
// Merge cached bones with current bones for model
|
|
||||||
virtual void StudioMergeBones ( model_t *m_pSubModel );
|
|
||||||
|
|
||||||
// Determine interpolation fraction
|
|
||||||
virtual float StudioEstimateInterpolant( void );
|
|
||||||
|
|
||||||
// Determine current frame for rendering
|
|
||||||
virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc );
|
|
||||||
|
|
||||||
// Apply special effects to transform matrix
|
|
||||||
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
|
|
||||||
|
|
||||||
// Spherical interpolation of bones
|
|
||||||
virtual void StudioSlerpBones ( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
|
|
||||||
|
|
||||||
// Compute bone adjustments ( bone controllers )
|
|
||||||
virtual void StudioCalcBoneAdj ( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen );
|
|
||||||
|
|
||||||
// Get bone quaternions
|
|
||||||
virtual void StudioCalcBoneQuaterion ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q );
|
|
||||||
|
|
||||||
// Get bone positions
|
|
||||||
virtual void StudioCalcBonePosition ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos );
|
|
||||||
|
|
||||||
// Compute rotations
|
|
||||||
virtual void StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f );
|
|
||||||
|
|
||||||
// Send bones and verts to renderer
|
|
||||||
virtual void StudioRenderModel ( void );
|
|
||||||
|
|
||||||
// Finalize rendering
|
|
||||||
virtual void StudioRenderFinal (void);
|
|
||||||
|
|
||||||
// GL&D3D vs. Software renderer finishing functions
|
|
||||||
virtual void StudioRenderFinal_Software ( void );
|
|
||||||
virtual void StudioRenderFinal_Hardware ( void );
|
|
||||||
|
|
||||||
// Player specific data
|
|
||||||
// Determine pitch and blending amounts for players
|
|
||||||
virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
|
|
||||||
|
|
||||||
// Estimate gait frame for player
|
|
||||||
virtual void StudioEstimateGait ( entity_state_t *pplayer );
|
|
||||||
|
|
||||||
// Process movement of player
|
|
||||||
virtual void StudioProcessGait ( entity_state_t *pplayer );
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Client clock
|
|
||||||
double m_clTime;
|
|
||||||
// Old Client clock
|
|
||||||
double m_clOldTime;
|
|
||||||
|
|
||||||
// Do interpolation?
|
|
||||||
int m_fDoInterp;
|
|
||||||
// Do gait estimation?
|
|
||||||
int m_fGaitEstimation;
|
|
||||||
|
|
||||||
// Current render frame #
|
|
||||||
int m_nFrameCount;
|
|
||||||
|
|
||||||
// Cvars that studio model code needs to reference
|
|
||||||
//
|
|
||||||
// Use high quality models?
|
|
||||||
cvar_t *m_pCvarHiModels;
|
|
||||||
// Developer debug output desired?
|
|
||||||
cvar_t *m_pCvarDeveloper;
|
|
||||||
// Draw entities bone hit boxes, etc?
|
|
||||||
cvar_t *m_pCvarDrawEntities;
|
|
||||||
|
|
||||||
// The entity which we are currently rendering.
|
|
||||||
cl_entity_t *m_pCurrentEntity;
|
|
||||||
|
|
||||||
// The model for the entity being rendered
|
|
||||||
model_t *m_pRenderModel;
|
|
||||||
|
|
||||||
// Player info for current player, if drawing a player
|
|
||||||
player_info_t *m_pPlayerInfo;
|
|
||||||
|
|
||||||
// The index of the player being drawn
|
|
||||||
int m_nPlayerIndex;
|
|
||||||
|
|
||||||
// The player's gait movement
|
|
||||||
float m_flGaitMovement;
|
|
||||||
|
|
||||||
// Pointer to header block for studio model data
|
|
||||||
studiohdr_t *m_pStudioHeader;
|
|
||||||
|
|
||||||
// Pointers to current body part and submodel
|
|
||||||
mstudiobodyparts_t *m_pBodyPart;
|
|
||||||
mstudiomodel_t *m_pSubModel;
|
|
||||||
|
|
||||||
// Palette substition for top and bottom of model
|
|
||||||
int m_nTopColor;
|
|
||||||
int m_nBottomColor;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Sprite model used for drawing studio model chrome
|
|
||||||
model_t *m_pChromeSprite;
|
|
||||||
|
|
||||||
// Caching
|
|
||||||
// Number of bones in bone cache
|
|
||||||
int m_nCachedBones;
|
|
||||||
// Names of cached bones
|
|
||||||
char m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ];
|
|
||||||
// Cached bone & light transformation matrices
|
|
||||||
float m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ];
|
|
||||||
float m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ];
|
|
||||||
|
|
||||||
// Software renderer scale factors
|
|
||||||
float m_fSoftwareXScale, m_fSoftwareYScale;
|
|
||||||
|
|
||||||
// Current view vectors and render origin
|
|
||||||
float m_vUp[ 3 ];
|
|
||||||
float m_vRight[ 3 ];
|
|
||||||
float m_vNormal[ 3 ];
|
|
||||||
|
|
||||||
float m_vRenderOrigin[ 3 ];
|
|
||||||
|
|
||||||
// Model render counters ( from engine )
|
|
||||||
int *m_pStudioModelCount;
|
|
||||||
int *m_pModelsDrawn;
|
|
||||||
|
|
||||||
// Matrices
|
|
||||||
// Model to world transformation
|
|
||||||
float (*m_protationmatrix)[ 3 ][ 4 ];
|
|
||||||
// Model to view transformation
|
|
||||||
float (*m_paliastransform)[ 3 ][ 4 ];
|
|
||||||
|
|
||||||
// Concatenated bone and light transforms
|
|
||||||
float (*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ];
|
|
||||||
float (*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // STUDIOMODELRENDERER_H
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,62 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
#ifndef __AMMO_H__
|
|
||||||
#define __AMMO_H__
|
|
||||||
|
|
||||||
#define MAX_WEAPON_NAME 128
|
|
||||||
|
|
||||||
|
|
||||||
#define WEAPON_FLAGS_SELECTONEMPTY 1
|
|
||||||
|
|
||||||
#define WEAPON_IS_ONTARGET 0x40
|
|
||||||
|
|
||||||
struct WEAPON
|
|
||||||
{
|
|
||||||
char szName[MAX_WEAPON_NAME];
|
|
||||||
int iAmmoType;
|
|
||||||
int iAmmo2Type;
|
|
||||||
int iMax1;
|
|
||||||
int iMax2;
|
|
||||||
int iSlot;
|
|
||||||
int iSlotPos;
|
|
||||||
int iFlags;
|
|
||||||
int iId;
|
|
||||||
int iClip;
|
|
||||||
|
|
||||||
int iCount; // # of itesm in plist
|
|
||||||
|
|
||||||
HSPRITE hActive;
|
|
||||||
wrect_t rcActive;
|
|
||||||
HSPRITE hInactive;
|
|
||||||
wrect_t rcInactive;
|
|
||||||
HSPRITE hAmmo;
|
|
||||||
wrect_t rcAmmo;
|
|
||||||
HSPRITE hAmmo2;
|
|
||||||
wrect_t rcAmmo2;
|
|
||||||
HSPRITE hCrosshair;
|
|
||||||
wrect_t rcCrosshair;
|
|
||||||
HSPRITE hAutoaim;
|
|
||||||
wrect_t rcAutoaim;
|
|
||||||
HSPRITE hZoomedCrosshair;
|
|
||||||
wrect_t rcZoomedCrosshair;
|
|
||||||
HSPRITE hZoomedAutoaim;
|
|
||||||
wrect_t rcZoomedAutoaim;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef int AMMO;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,159 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// ammo_secondary.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudAmmoSecondary class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
|
|
||||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
|
|
||||||
|
|
||||||
int CHudAmmoSecondary :: Init( void )
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( SecAmmoVal );
|
|
||||||
HOOK_MESSAGE( SecAmmoIcon );
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
m_HUD_ammoicon = 0;
|
|
||||||
|
|
||||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
|
||||||
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudAmmoSecondary :: Reset( void )
|
|
||||||
{
|
|
||||||
m_fFade = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudAmmoSecondary :: VidInit( void )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudAmmoSecondary :: Draw(float flTime)
|
|
||||||
{
|
|
||||||
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// draw secondary ammo icons above normal ammo readout
|
|
||||||
int a, x, y, r, g, b, AmmoWidth;
|
|
||||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
|
||||||
a = (int) max( MIN_ALPHA, m_fFade );
|
|
||||||
if (m_fFade > 0)
|
|
||||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
|
||||||
ScaleColors( r, g, b, a );
|
|
||||||
|
|
||||||
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
|
||||||
|
|
||||||
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
|
|
||||||
x = ScreenWidth - AmmoWidth;
|
|
||||||
|
|
||||||
if ( m_HUD_ammoicon )
|
|
||||||
{
|
|
||||||
// Draw the ammo icon
|
|
||||||
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
|
|
||||||
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
|
|
||||||
|
|
||||||
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
|
|
||||||
x -= AmmoWidth;
|
|
||||||
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw the ammo counts, in reverse order, from right to left
|
|
||||||
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
|
|
||||||
{
|
|
||||||
if ( m_iAmmoAmounts[i] < 0 )
|
|
||||||
continue; // negative ammo amounts imply that they shouldn't be drawn
|
|
||||||
|
|
||||||
// half a char gap between the ammo number and the previous pic
|
|
||||||
x -= (AmmoWidth / 2);
|
|
||||||
|
|
||||||
// draw the number, right-aligned
|
|
||||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
|
||||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
|
||||||
|
|
||||||
if ( i != 0 )
|
|
||||||
{
|
|
||||||
// draw the divider bar
|
|
||||||
x -= (AmmoWidth / 2);
|
|
||||||
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for Secondary Ammo Value
|
|
||||||
// accepts one value:
|
|
||||||
// string: sprite name
|
|
||||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for Secondary Ammo Icon
|
|
||||||
// Sets an ammo value
|
|
||||||
// takes two values:
|
|
||||||
// byte: ammo index
|
|
||||||
// byte: ammo value
|
|
||||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int index = READ_BYTE();
|
|
||||||
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
m_iAmmoAmounts[index] = READ_BYTE();
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
// check to see if there is anything left to draw
|
|
||||||
int count = 0;
|
|
||||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
|
||||||
{
|
|
||||||
count += max( 0, m_iAmmoAmounts[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( count == 0 )
|
|
||||||
{ // the ammo fields are all empty, so turn off this hud area
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make the icons light up
|
|
||||||
m_fFade = 200.0f;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,190 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// ammohistory.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "ammohistory.h"
|
|
||||||
|
|
||||||
HistoryResource gHR;
|
|
||||||
|
|
||||||
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
|
|
||||||
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
|
|
||||||
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
|
|
||||||
|
|
||||||
#define MAX_ITEM_NAME 32
|
|
||||||
int HISTORY_DRAW_TIME = 5;
|
|
||||||
|
|
||||||
// keep a list of items
|
|
||||||
struct ITEM_INFO
|
|
||||||
{
|
|
||||||
char szName[MAX_ITEM_NAME];
|
|
||||||
HSPRITE spr;
|
|
||||||
wrect_t rect;
|
|
||||||
};
|
|
||||||
|
|
||||||
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
|
|
||||||
{
|
|
||||||
if ( iType == HISTSLOT_AMMO && !iCount )
|
|
||||||
return; // no amount, so don't add
|
|
||||||
|
|
||||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
|
||||||
{ // the pic would have to be drawn too high
|
|
||||||
// so start from the bottom
|
|
||||||
iCurrentHistorySlot = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
|
||||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
|
||||||
|
|
||||||
freeslot->type = iType;
|
|
||||||
freeslot->iId = iId;
|
|
||||||
freeslot->iCount = iCount;
|
|
||||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
|
|
||||||
{
|
|
||||||
if ( iType != HISTSLOT_ITEM )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
|
||||||
{ // the pic would have to be drawn too high
|
|
||||||
// so start from the bottom
|
|
||||||
iCurrentHistorySlot = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
|
||||||
|
|
||||||
// I am really unhappy with all the code in this file
|
|
||||||
|
|
||||||
int i = gHUD.GetSpriteIndex( szName );
|
|
||||||
if ( i == -1 )
|
|
||||||
return; // unknown sprite name, don't add it to history
|
|
||||||
|
|
||||||
freeslot->iId = i;
|
|
||||||
freeslot->type = iType;
|
|
||||||
freeslot->iCount = iCount;
|
|
||||||
|
|
||||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
|
||||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HistoryResource :: CheckClearHistory( void )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
|
||||||
{
|
|
||||||
if ( rgAmmoHistory[i].type )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
iCurrentHistorySlot = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw Ammo pickup history
|
|
||||||
//
|
|
||||||
int HistoryResource :: DrawAmmoHistory( float flTime )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
|
||||||
{
|
|
||||||
if ( rgAmmoHistory[i].type )
|
|
||||||
{
|
|
||||||
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
|
|
||||||
|
|
||||||
if ( rgAmmoHistory[i].DisplayTime <= flTime )
|
|
||||||
{ // pic drawing time has expired
|
|
||||||
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
|
|
||||||
CheckClearHistory();
|
|
||||||
}
|
|
||||||
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
|
|
||||||
{
|
|
||||||
wrect_t rcPic;
|
|
||||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
|
||||||
|
|
||||||
int r, g, b;
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
|
||||||
ScaleColors(r, g, b, min(scale, 255) );
|
|
||||||
|
|
||||||
// Draw the pic
|
|
||||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
|
||||||
int xpos = ScreenWidth - 24;
|
|
||||||
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
|
|
||||||
{ // the dll has to make sure it has sent info the weapons you need
|
|
||||||
SPR_Set( *spr, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the number
|
|
||||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
|
||||||
}
|
|
||||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
|
||||||
{
|
|
||||||
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
|
|
||||||
|
|
||||||
if ( !weap )
|
|
||||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
|
||||||
|
|
||||||
int r, g, b;
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
|
|
||||||
if ( !gWR.HasAmmo( weap ) )
|
|
||||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
|
||||||
|
|
||||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
|
||||||
ScaleColors(r, g, b, min(scale, 255) );
|
|
||||||
|
|
||||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
|
||||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
|
||||||
SPR_Set( weap->hInactive, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
|
|
||||||
}
|
|
||||||
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
|
|
||||||
{
|
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
if ( !rgAmmoHistory[i].iId )
|
|
||||||
continue; // sprite not loaded
|
|
||||||
|
|
||||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
|
||||||
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
|
||||||
ScaleColors(r, g, b, min(scale, 255) );
|
|
||||||
|
|
||||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
|
||||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
|
||||||
|
|
||||||
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, xpos, ypos, &rect );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// ammohistory.h
|
|
||||||
//
|
|
||||||
|
|
||||||
// this is the max number of items in each bucket
|
|
||||||
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
|
||||||
|
|
||||||
class WeaponsResource
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Information about weapons & ammo
|
|
||||||
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
|
||||||
|
|
||||||
// counts of weapons * ammo
|
|
||||||
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
|
|
||||||
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
|
|
||||||
|
|
||||||
public:
|
|
||||||
void Init( void )
|
|
||||||
{
|
|
||||||
memset( rgWeapons, 0, sizeof rgWeapons );
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Reset( void )
|
|
||||||
{
|
|
||||||
iOldWeaponBits = 0;
|
|
||||||
memset( rgSlots, 0, sizeof rgSlots );
|
|
||||||
memset( riAmmo, 0, sizeof riAmmo );
|
|
||||||
}
|
|
||||||
|
|
||||||
///// WEAPON /////
|
|
||||||
int iOldWeaponBits;
|
|
||||||
|
|
||||||
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
|
||||||
void AddWeapon( WEAPON *wp )
|
|
||||||
{
|
|
||||||
rgWeapons[ wp->iId ] = *wp;
|
|
||||||
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
void PickupWeapon( WEAPON *wp )
|
|
||||||
{
|
|
||||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DropWeapon( WEAPON *wp )
|
|
||||||
{
|
|
||||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DropAllWeapons( void )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
|
||||||
{
|
|
||||||
if ( rgWeapons[i].iId )
|
|
||||||
DropWeapon( &rgWeapons[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
|
||||||
|
|
||||||
void LoadWeaponSprites( WEAPON* wp );
|
|
||||||
void LoadAllWeaponSprites( void );
|
|
||||||
WEAPON* GetFirstPos( int iSlot );
|
|
||||||
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
|
||||||
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
|
||||||
|
|
||||||
int HasAmmo( WEAPON *p );
|
|
||||||
|
|
||||||
///// AMMO /////
|
|
||||||
AMMO GetAmmo( int iId ) { return iId; }
|
|
||||||
|
|
||||||
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
|
||||||
|
|
||||||
int CountAmmo( int iId );
|
|
||||||
|
|
||||||
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
|
||||||
};
|
|
||||||
|
|
||||||
extern WeaponsResource gWR;
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_HISTORY 12
|
|
||||||
enum {
|
|
||||||
HISTSLOT_EMPTY,
|
|
||||||
HISTSLOT_AMMO,
|
|
||||||
HISTSLOT_WEAP,
|
|
||||||
HISTSLOT_ITEM,
|
|
||||||
};
|
|
||||||
|
|
||||||
class HistoryResource
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
struct HIST_ITEM {
|
|
||||||
int type;
|
|
||||||
float DisplayTime; // the time at which this item should be removed from the history
|
|
||||||
int iCount;
|
|
||||||
int iId;
|
|
||||||
};
|
|
||||||
|
|
||||||
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void Init( void )
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Reset( void )
|
|
||||||
{
|
|
||||||
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
|
||||||
}
|
|
||||||
|
|
||||||
int iHistoryGap;
|
|
||||||
int iCurrentHistorySlot;
|
|
||||||
|
|
||||||
void AddToHistory( int iType, int iId, int iCount = 0 );
|
|
||||||
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
|
||||||
|
|
||||||
void CheckClearHistory( void );
|
|
||||||
int DrawAmmoHistory( float flTime );
|
|
||||||
};
|
|
||||||
|
|
||||||
extern HistoryResource gHR;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// battery.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudBattery class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(m_Battery, Battery)
|
|
||||||
|
|
||||||
int CHudBattery::Init(void)
|
|
||||||
{
|
|
||||||
m_iBat = 0;
|
|
||||||
m_fFade = 0;
|
|
||||||
m_iFlags = 0;
|
|
||||||
|
|
||||||
HOOK_MESSAGE(Battery);
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int CHudBattery::VidInit(void)
|
|
||||||
{
|
|
||||||
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
|
|
||||||
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
|
|
||||||
|
|
||||||
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
|
|
||||||
m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
|
|
||||||
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
|
|
||||||
m_iHeight = m_prc2->bottom - m_prc1->top;
|
|
||||||
m_fFade = 0;
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
int x = READ_SHORT();
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
int y = READ_SHORT();
|
|
||||||
|
|
||||||
if ( x != m_iBat || y != m_iBatMax )
|
|
||||||
{
|
|
||||||
m_fFade = FADE_TIME;
|
|
||||||
m_iBat = x;
|
|
||||||
m_iBatMax = y;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if ( x != m_iBat )
|
|
||||||
{
|
|
||||||
m_fFade = FADE_TIME;
|
|
||||||
m_iBat = x;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudBattery::Draw(float flTime)
|
|
||||||
{
|
|
||||||
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int r, g, b, x, y, a;
|
|
||||||
wrect_t rc;
|
|
||||||
|
|
||||||
rc = *m_prc2;
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
float fScale = 0.0;
|
|
||||||
|
|
||||||
if ( m_iBatMax > 0 )
|
|
||||||
fScale = 1.0 / (float)m_iBatMax;
|
|
||||||
|
|
||||||
rc.top += m_iHeight * ((float)(m_iBatMax-(min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
|
|
||||||
#else
|
|
||||||
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
|
|
||||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Has health changed? Flash the health #
|
|
||||||
if (m_fFade)
|
|
||||||
{
|
|
||||||
if (m_fFade > FADE_TIME)
|
|
||||||
m_fFade = FADE_TIME;
|
|
||||||
|
|
||||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
|
||||||
if (m_fFade <= 0)
|
|
||||||
{
|
|
||||||
a = 128;
|
|
||||||
m_fFade = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fade the health number back to dim
|
|
||||||
|
|
||||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
a = MIN_ALPHA;
|
|
||||||
|
|
||||||
ScaleColors(r, g, b, a );
|
|
||||||
|
|
||||||
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
|
|
||||||
|
|
||||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
|
||||||
x = ScreenWidth/5;
|
|
||||||
|
|
||||||
// make sure we have the right sprite handles
|
|
||||||
if ( !m_hSprite1 )
|
|
||||||
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
|
|
||||||
if ( !m_hSprite2 )
|
|
||||||
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
|
|
||||||
|
|
||||||
SPR_Set(m_hSprite1, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
|
|
||||||
|
|
||||||
if (rc.bottom > rc.top)
|
|
||||||
{
|
|
||||||
SPR_Set(m_hSprite2, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
x += (m_prc1->right - m_prc1->left);
|
|
||||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
#if !defined ( BENCHH )
|
|
||||||
#define BENCHH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define FIRST_STAGE 1
|
|
||||||
#define SECOND_STAGE 2
|
|
||||||
#define THIRD_STAGE 3
|
|
||||||
#define FOURTH_STAGE 4
|
|
||||||
#define LAST_STAGE ( FOURTH_STAGE )
|
|
||||||
|
|
||||||
void Bench_CheckStart( void );
|
|
||||||
|
|
||||||
int Bench_InStage( int stage );
|
|
||||||
int Bench_GetPowerPlay( void );
|
|
||||||
int Bench_GetStage( void );
|
|
||||||
void Bench_SetPowerPlay( int set );
|
|
||||||
int Bench_Active( void );
|
|
||||||
|
|
||||||
void Bench_SetDotAdded( int dot );
|
|
||||||
void Bench_SpotPosition( vec3_t dot, vec3_t target );
|
|
||||||
void Bench_CheckEntity( int type, struct cl_entity_s *ent, const char *modelname );
|
|
||||||
void Bench_AddObjects( void );
|
|
||||||
void Bench_SetViewAngles( int recalc_wander, float *viewangles, float frametime, struct usercmd_s *cmd );
|
|
||||||
void Bench_SetViewOrigin( float *vieworigin, float frametime );
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,24 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// Camera.h -- defines and such for a 3rd person camera
|
|
||||||
// NOTE: must include quakedef.h first
|
|
||||||
|
|
||||||
#ifndef _CAMERA_H_
|
|
||||||
#define _CAMEA_H_
|
|
||||||
|
|
||||||
// pitch, yaw, dist
|
|
||||||
extern vec3_t cam_ofs;
|
|
||||||
// Using third person camera
|
|
||||||
extern int cam_thirdperson;
|
|
||||||
|
|
||||||
void CAM_Init( void );
|
|
||||||
void CAM_ClearStates( void );
|
|
||||||
void CAM_StartMouseMove(void);
|
|
||||||
void CAM_EndMouseMove(void);
|
|
||||||
|
|
||||||
#endif // _CAMERA_H_
|
|
|
@ -1,447 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// cdll_int.c
|
|
||||||
//
|
|
||||||
// this implementation handles the linking of the engine to the DLL
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "netadr.h"
|
|
||||||
#undef INTERFACE_H
|
|
||||||
#include "../public/interface.h"
|
|
||||||
//#include "vgui_schememanager.h"
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include "pm_shared.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "hud_servers.h"
|
|
||||||
#include "vgui_int.h"
|
|
||||||
#include "interface.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "winsani_in.h"
|
|
||||||
#include <windows.h>
|
|
||||||
#include "winsani_out.h"
|
|
||||||
#endif
|
|
||||||
#include "Exports.h"
|
|
||||||
#
|
|
||||||
#include "tri.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "../public/interface.h"
|
|
||||||
|
|
||||||
cl_enginefunc_t gEngfuncs;
|
|
||||||
CHud gHUD;
|
|
||||||
TeamFortressViewport *gViewPort = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
#include "particleman.h"
|
|
||||||
CSysModule *g_hParticleManModule = NULL;
|
|
||||||
IParticleMan *g_pParticleMan = NULL;
|
|
||||||
|
|
||||||
void CL_LoadParticleMan( void );
|
|
||||||
void CL_UnloadParticleMan( void );
|
|
||||||
|
|
||||||
void InitInput (void);
|
|
||||||
void EV_HookEvents( void );
|
|
||||||
void IN_Commands( void );
|
|
||||||
|
|
||||||
/*
|
|
||||||
================================
|
|
||||||
HUD_GetHullBounds
|
|
||||||
|
|
||||||
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
|
|
||||||
================================
|
|
||||||
*/
|
|
||||||
int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
|
|
||||||
{
|
|
||||||
// RecClGetHullBounds(hullnumber, mins, maxs);
|
|
||||||
|
|
||||||
int iret = 0;
|
|
||||||
|
|
||||||
switch ( hullnumber )
|
|
||||||
{
|
|
||||||
case 0: // Normal player
|
|
||||||
mins = Vector(-16, -16, -36);
|
|
||||||
maxs = Vector(16, 16, 36);
|
|
||||||
iret = 1;
|
|
||||||
break;
|
|
||||||
case 1: // Crouched player
|
|
||||||
mins = Vector(-16, -16, -18 );
|
|
||||||
maxs = Vector(16, 16, 18 );
|
|
||||||
iret = 1;
|
|
||||||
break;
|
|
||||||
case 2: // Point based hull
|
|
||||||
mins = Vector( 0, 0, 0 );
|
|
||||||
maxs = Vector( 0, 0, 0 );
|
|
||||||
iret = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return iret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
================================
|
|
||||||
HUD_ConnectionlessPacket
|
|
||||||
|
|
||||||
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
|
|
||||||
size of the response_buffer, so you must zero it out if you choose not to respond.
|
|
||||||
================================
|
|
||||||
*/
|
|
||||||
int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
|
|
||||||
{
|
|
||||||
// RecClConnectionlessPacket(net_from, args, response_buffer, response_buffer_size);
|
|
||||||
|
|
||||||
// Parse stuff from args
|
|
||||||
int max_buffer_size = *response_buffer_size;
|
|
||||||
|
|
||||||
// Zero it out since we aren't going to respond.
|
|
||||||
// If we wanted to response, we'd write data into response_buffer
|
|
||||||
*response_buffer_size = 0;
|
|
||||||
|
|
||||||
// Since we don't listen for anything here, just respond that it's a bogus message
|
|
||||||
// If we didn't reject the message, we'd return 1 for success instead.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
|
|
||||||
{
|
|
||||||
// RecClClientMoveInit(ppmove);
|
|
||||||
|
|
||||||
PM_Init( ppmove );
|
|
||||||
}
|
|
||||||
|
|
||||||
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name )
|
|
||||||
{
|
|
||||||
// RecClClientTextureType(name);
|
|
||||||
|
|
||||||
return PM_FindTextureType( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
|
||||||
{
|
|
||||||
// RecClClientMove(ppmove, server);
|
|
||||||
|
|
||||||
PM_Move( ppmove, server );
|
|
||||||
}
|
|
||||||
|
|
||||||
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
|
||||||
{
|
|
||||||
gEngfuncs = *pEnginefuncs;
|
|
||||||
|
|
||||||
// RecClInitialize(pEnginefuncs, iVersion);
|
|
||||||
|
|
||||||
if (iVersion != CLDLL_INTERFACE_VERSION)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
|
|
||||||
|
|
||||||
EV_HookEvents();
|
|
||||||
CL_LoadParticleMan();
|
|
||||||
|
|
||||||
// get tracker interface, if any
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_VidInit
|
|
||||||
|
|
||||||
Called when the game initializes
|
|
||||||
and whenever the vid_mode is changed
|
|
||||||
so the HUD can reinitialize itself.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
int CL_DLLEXPORT HUD_VidInit( void )
|
|
||||||
{
|
|
||||||
// RecClHudVidInit();
|
|
||||||
gHUD.VidInit();
|
|
||||||
|
|
||||||
VGui_Startup();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_Init
|
|
||||||
|
|
||||||
Called whenever the client connects
|
|
||||||
to a server. Reinitializes all
|
|
||||||
the hud variables.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_Init( void )
|
|
||||||
{
|
|
||||||
// RecClHudInit();
|
|
||||||
InitInput();
|
|
||||||
gHUD.Init();
|
|
||||||
Scheme_Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_Redraw
|
|
||||||
|
|
||||||
called every screen frame to
|
|
||||||
redraw the HUD.
|
|
||||||
===========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
int CL_DLLEXPORT HUD_Redraw( float time, int intermission )
|
|
||||||
{
|
|
||||||
// RecClHudRedraw(time, intermission);
|
|
||||||
|
|
||||||
gHUD.Redraw( time, intermission );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_UpdateClientData
|
|
||||||
|
|
||||||
called every time shared client
|
|
||||||
dll/engine data gets changed,
|
|
||||||
and gives the cdll a chance
|
|
||||||
to modify the data.
|
|
||||||
|
|
||||||
returns 1 if anything has been changed, 0 otherwise.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
int CL_DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
|
|
||||||
{
|
|
||||||
// RecClHudUpdateClientData(pcldata, flTime);
|
|
||||||
|
|
||||||
IN_Commands();
|
|
||||||
|
|
||||||
return gHUD.UpdateClientData(pcldata, flTime );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_Reset
|
|
||||||
|
|
||||||
Called at start and end of demos to restore to "non"HUD state.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_Reset( void )
|
|
||||||
{
|
|
||||||
// RecClHudReset();
|
|
||||||
|
|
||||||
gHUD.VidInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_Frame
|
|
||||||
|
|
||||||
Called by engine every frame that client .dll is loaded
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_Frame( double time )
|
|
||||||
{
|
|
||||||
// RecClHudFrame(time);
|
|
||||||
|
|
||||||
ServersThink( time );
|
|
||||||
|
|
||||||
GetClientVoiceMgr()->Frame(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_VoiceStatus
|
|
||||||
|
|
||||||
Called when a player starts or stops talking.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
|
|
||||||
{
|
|
||||||
//// RecClVoiceStatus(entindex, bTalking);
|
|
||||||
|
|
||||||
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_DirectorMessage
|
|
||||||
|
|
||||||
Called when a director event message was received
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
// RecClDirectorMessage(iSize, pbuf);
|
|
||||||
|
|
||||||
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CL_UnloadParticleMan( void )
|
|
||||||
{
|
|
||||||
Sys_UnloadModule( g_hParticleManModule );
|
|
||||||
|
|
||||||
g_pParticleMan = NULL;
|
|
||||||
g_hParticleManModule = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CL_LoadParticleMan( void )
|
|
||||||
{
|
|
||||||
char szPDir[512];
|
|
||||||
|
|
||||||
if ( gEngfuncs.COM_ExpandFilename( PARTICLEMAN_DLLNAME, szPDir, sizeof( szPDir ) ) == FALSE )
|
|
||||||
{
|
|
||||||
g_pParticleMan = NULL;
|
|
||||||
g_hParticleManModule = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hParticleManModule = Sys_LoadModule( szPDir );
|
|
||||||
CreateInterfaceFn particleManFactory = Sys_GetFactory( g_hParticleManModule );
|
|
||||||
|
|
||||||
if ( particleManFactory == NULL )
|
|
||||||
{
|
|
||||||
g_pParticleMan = NULL;
|
|
||||||
g_hParticleManModule = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_pParticleMan = (IParticleMan *)particleManFactory( PARTICLEMAN_INTERFACE, NULL);
|
|
||||||
|
|
||||||
if ( g_pParticleMan )
|
|
||||||
{
|
|
||||||
g_pParticleMan->SetUp( &gEngfuncs );
|
|
||||||
|
|
||||||
// Add custom particle classes here BEFORE calling anything else or you will die.
|
|
||||||
g_pParticleMan->AddCustomParticleClassSize ( sizeof ( CBaseParticle ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cldll_func_dst_t *g_pcldstAddrs;
|
|
||||||
|
|
||||||
extern "C" void CL_DLLEXPORT F(void *pv)
|
|
||||||
{
|
|
||||||
cldll_func_t *pcldll_func = (cldll_func_t *)pv;
|
|
||||||
|
|
||||||
// Hack!
|
|
||||||
g_pcldstAddrs = ((cldll_func_dst_t *)pcldll_func->pHudVidInitFunc);
|
|
||||||
|
|
||||||
cldll_func_t cldll_func =
|
|
||||||
{
|
|
||||||
Initialize,
|
|
||||||
HUD_Init,
|
|
||||||
HUD_VidInit,
|
|
||||||
HUD_Redraw,
|
|
||||||
HUD_UpdateClientData,
|
|
||||||
HUD_Reset,
|
|
||||||
HUD_PlayerMove,
|
|
||||||
HUD_PlayerMoveInit,
|
|
||||||
HUD_PlayerMoveTexture,
|
|
||||||
IN_ActivateMouse,
|
|
||||||
IN_DeactivateMouse,
|
|
||||||
IN_MouseEvent,
|
|
||||||
IN_ClearStates,
|
|
||||||
IN_Accumulate,
|
|
||||||
CL_CreateMove,
|
|
||||||
CL_IsThirdPerson,
|
|
||||||
CL_CameraOffset,
|
|
||||||
KB_Find,
|
|
||||||
CAM_Think,
|
|
||||||
V_CalcRefdef,
|
|
||||||
HUD_AddEntity,
|
|
||||||
HUD_CreateEntities,
|
|
||||||
HUD_DrawNormalTriangles,
|
|
||||||
HUD_DrawTransparentTriangles,
|
|
||||||
HUD_StudioEvent,
|
|
||||||
HUD_PostRunCmd,
|
|
||||||
HUD_Shutdown,
|
|
||||||
HUD_TxferLocalOverrides,
|
|
||||||
HUD_ProcessPlayerState,
|
|
||||||
HUD_TxferPredictionData,
|
|
||||||
Demo_ReadBuffer,
|
|
||||||
HUD_ConnectionlessPacket,
|
|
||||||
HUD_GetHullBounds,
|
|
||||||
HUD_Frame,
|
|
||||||
HUD_Key_Event,
|
|
||||||
HUD_TempEntUpdate,
|
|
||||||
HUD_GetUserEntity,
|
|
||||||
HUD_VoiceStatus,
|
|
||||||
HUD_DirectorMessage,
|
|
||||||
HUD_GetStudioModelInterface,
|
|
||||||
HUD_ChatInputPosition,
|
|
||||||
};
|
|
||||||
|
|
||||||
*pcldll_func = cldll_func;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "cl_dll/IGameClientExports.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Exports functions that are used by the gameUI for UI dialogs
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CClientExports : public IGameClientExports
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// returns the name of the server the user is connected to, if any
|
|
||||||
virtual const char *GetServerHostName()
|
|
||||||
{
|
|
||||||
/*if (gViewPortInterface)
|
|
||||||
{
|
|
||||||
return gViewPortInterface->GetServerName();
|
|
||||||
}*/
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ingame voice manipulation
|
|
||||||
virtual bool IsPlayerGameVoiceMuted(int playerIndex)
|
|
||||||
{
|
|
||||||
if (GetClientVoiceMgr())
|
|
||||||
return GetClientVoiceMgr()->IsPlayerBlocked(playerIndex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void MutePlayerGameVoice(int playerIndex)
|
|
||||||
{
|
|
||||||
if (GetClientVoiceMgr())
|
|
||||||
{
|
|
||||||
GetClientVoiceMgr()->SetPlayerBlockedState(playerIndex, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void UnmutePlayerGameVoice(int playerIndex)
|
|
||||||
{
|
|
||||||
if (GetClientVoiceMgr())
|
|
||||||
{
|
|
||||||
GetClientVoiceMgr()->SetPlayerBlockedState(playerIndex, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
EXPOSE_SINGLE_INTERFACE(CClientExports, IGameClientExports, GAMECLIENTEXPORTS_INTERFACE_VERSION);
|
|
|
@ -1,648 +0,0 @@
|
||||||
# Microsoft Developer Studio Project File - Name="cl_dll" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
|
||||||
|
|
||||||
CFG=cl_dll - Win32 Release
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "cl_dll.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "cl_dll.mak" CFG="cl_dll - Win32 Release"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "cl_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE "cl_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "cl_dll - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir ".\Release"
|
|
||||||
# PROP BASE Intermediate_Dir ".\Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir ".\Release"
|
|
||||||
# PROP Intermediate_Dir ".\Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
|
||||||
# ADD CPP /nologo /W3 /GR /GX /Zi /O2 /I "..\dlls" /I "." /I "..\tfc" /I "..\public" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /I "..\external" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /D "HL_DLL" /FR /YX /FD /c
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ..\utils\vgui\lib\win32_vc6\vgui.lib wsock32.lib ..\lib\public\sdl2.lib /nologo /base:"0x01900000" /subsystem:windows /dll /map /debug /machine:I386 /nodefaultlib:"LIBCMTD" /nodefaultlib:"LIBCD" /out:".\Release\client.dll"
|
|
||||||
# SUBTRACT LINK32 /pdb:none
|
|
||||||
# Begin Custom Build
|
|
||||||
InputDir=.\Release
|
|
||||||
ProjDir=.
|
|
||||||
InputPath=.\Release\client.dll
|
|
||||||
InputName=client
|
|
||||||
SOURCE="$(InputPath)"
|
|
||||||
|
|
||||||
BuildCmds= \
|
|
||||||
call ..\filecopy.bat $(InputDir)\$(InputName).dll $(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).dll \
|
|
||||||
call ..\filecopy.bat $(InputDir)\$(InputName).pdb $(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).pdb \
|
|
||||||
|
|
||||||
|
|
||||||
"$(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
|
||||||
$(BuildCmds)
|
|
||||||
|
|
||||||
"$(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).pdb" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
|
||||||
$(BuildCmds)
|
|
||||||
# End Custom Build
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "cl_dll - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir ".\Debug"
|
|
||||||
# PROP BASE Intermediate_Dir ".\Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir ".\Debug"
|
|
||||||
# PROP Intermediate_Dir ".\Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
|
||||||
# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "." /I "..\tfc" /I "..\public" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /I "..\external" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /D "_WINDLL" /D "HL_DLL" /FR /YX /FD /c
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
|
||||||
# ADD LINK32 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ..\utils\vgui\lib\win32_vc6\vgui.lib wsock32.lib ..\lib\public\sdl2.lib /nologo /base:"0x01900000" /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\client.dll"
|
|
||||||
# SUBTRACT LINK32 /pdb:none
|
|
||||||
# Begin Custom Build
|
|
||||||
InputDir=.\Debug
|
|
||||||
ProjDir=.
|
|
||||||
InputPath=.\Debug\client.dll
|
|
||||||
InputName=client
|
|
||||||
SOURCE="$(InputPath)"
|
|
||||||
|
|
||||||
BuildCmds= \
|
|
||||||
call ..\filecopy.bat $(InputDir)\$(InputName).dll $(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).dll \
|
|
||||||
call ..\filecopy.bat $(InputDir)\$(InputName).pdb $(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).pdb \
|
|
||||||
|
|
||||||
|
|
||||||
"$(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
|
||||||
$(BuildCmds)
|
|
||||||
|
|
||||||
"$(ProjDir)\..\..\game\mod\cl_dlls\$(InputName).pdb" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
|
||||||
$(BuildCmds)
|
|
||||||
# End Custom Build
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "cl_dll - Win32 Release"
|
|
||||||
# Name "cl_dll - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
|
||||||
# Begin Group "hl"
|
|
||||||
|
|
||||||
# PROP Default_Filter "*.cpp"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\crossbow.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\crowbar.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\egon.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ev_hldm.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\gauss.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\handgrenade.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hl\hl_baseentity.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hl\hl_events.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hl\hl_objects.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hl\hl_weapons.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\wpn_shared\hl_wpn_glock.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\hornetgun.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\mp5.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\python.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\rpg.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\satchel.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\shotgun.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\squeakgrenade.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\dlls\tripmine.cpp
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ammo.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ammo_secondary.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ammohistory.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\battery.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\cdll_int.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\com_weapons.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\death.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\demo.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\entity.cpp
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "cl_dll - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "cl_dll - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /MT
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ev_common.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\events.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\flashlight.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\GameStudioModelRenderer.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\geiger.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\health.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_bench.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_benchtrace.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_msg.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_redraw.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_servers.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_spectator.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_update.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\in_camera.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\input.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\inputw32.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\public\interface.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\interpolation.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\menu.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\message.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\common\parsemsg.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_debug.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_math.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_shared.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\saytext.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\status_icons.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\statusbar.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\studio_util.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\StudioModelRenderer.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\text_message.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\train.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\tri.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\util.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_checkbutton2.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ClassMenu.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ControlConfigPanel.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_CustomObjects.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_grid.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_helpers.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_int.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_listbox.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_loadtga.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_MOTDWindow.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_SchemeManager.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ScorePanel.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_scrollbar2.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ServerBrowser.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_slider2.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_SpectatorPanel.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_TeamFortressViewport.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_TeamMenu.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\view.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\voice_banmgr.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\voice_status.cpp
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ammo.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ammohistory.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\camera.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\cl_dll.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\cl_util.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\com_weapons.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\demo.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ev_hldm.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\eventscripts.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\GameStudioModelRenderer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\health.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_servers.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_servers_priv.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\hud_spectator.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\in_defs.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\interpolation.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\kbutton.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\common\parsemsg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_debug.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_defs.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_info.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_materials.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_movevars.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\pm_shared\pm_shared.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\StudioModelRenderer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\tri.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\util_vector.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ControlConfigPanel.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_SchemeManager.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ScorePanel.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_scrollbar2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_ServerBrowser.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\vgui_slider2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\vgui_SpectatorPanel.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\view.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\voice_banmgr.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\game_shared\voice_status.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\wrect.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\lib\public\game_controls.lib
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
|
@ -1,43 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// cl_dll.h
|
|
||||||
//
|
|
||||||
|
|
||||||
// 4-23-98 JOHN
|
|
||||||
|
|
||||||
//
|
|
||||||
// This DLL is linked by the client when they first initialize.
|
|
||||||
// This DLL is responsible for the following tasks:
|
|
||||||
// - Loading the HUD graphics upon initialization
|
|
||||||
// - Drawing the HUD graphics every frame
|
|
||||||
// - Handling the custum HUD-update packets
|
|
||||||
//
|
|
||||||
typedef unsigned char byte;
|
|
||||||
typedef unsigned short word;
|
|
||||||
typedef float vec_t;
|
|
||||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
#include "util_vector.h"
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define EXPORT _declspec( dllexport )
|
|
||||||
#else
|
|
||||||
#define EXPORT __attribute__ ((visibility("default")))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../engine/cdll_int.h"
|
|
||||||
#include "../dlls/cdll_dll.h"
|
|
||||||
|
|
||||||
extern cl_enginefunc_t gEngfuncs;
|
|
|
@ -1,196 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// cl_util.h
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "cvardef.h"
|
|
||||||
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h> // for safe_sprintf()
|
|
||||||
#include <stdarg.h> // "
|
|
||||||
#include <string.h> // for strncpy()
|
|
||||||
|
|
||||||
// Macros to hook function calls into the HUD object
|
|
||||||
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
|
|
||||||
|
|
||||||
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
|
|
||||||
{ \
|
|
||||||
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
|
|
||||||
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
|
|
||||||
{ \
|
|
||||||
gHUD.y.UserCmd_##x( ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
|
|
||||||
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
|
|
||||||
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
|
|
||||||
|
|
||||||
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
|
|
||||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
|
||||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
|
||||||
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
|
|
||||||
|
|
||||||
// SPR_Draw draws a the current sprite as solid
|
|
||||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
|
||||||
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
|
|
||||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
|
||||||
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
|
|
||||||
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
|
|
||||||
|
|
||||||
// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen.
|
|
||||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
|
||||||
// SPR_DisableScissor disables the clipping rect
|
|
||||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
|
||||||
//
|
|
||||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
|
||||||
|
|
||||||
|
|
||||||
// ScreenHeight returns the height of the screen, in pixels
|
|
||||||
#define ScreenHeight (gHUD.m_scrinfo.iHeight)
|
|
||||||
// ScreenWidth returns the width of the screen, in pixels
|
|
||||||
#define ScreenWidth (gHUD.m_scrinfo.iWidth)
|
|
||||||
|
|
||||||
#define BASE_XRES 640.f
|
|
||||||
|
|
||||||
// use this to project world coordinates to screen coordinates
|
|
||||||
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
|
|
||||||
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
|
|
||||||
|
|
||||||
#define XRES(x) (x * ((float)ScreenWidth / 640))
|
|
||||||
#define YRES(y) (y * ((float)ScreenHeight / 480))
|
|
||||||
|
|
||||||
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
|
|
||||||
#define ServerCmd (*gEngfuncs.pfnServerCmd)
|
|
||||||
#define EngineClientCmd (*gEngfuncs.pfnClientCmd)
|
|
||||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
|
||||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
|
||||||
|
|
||||||
|
|
||||||
// Gets the height & width of a sprite, at the specified frame
|
|
||||||
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
|
|
||||||
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
|
|
||||||
|
|
||||||
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
|
|
||||||
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
|
||||||
{
|
|
||||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int DrawConsoleString( int x, int y, const char *string )
|
|
||||||
{
|
|
||||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int ConsoleStringLen( const char *string )
|
|
||||||
{
|
|
||||||
int _width, _height;
|
|
||||||
GetConsoleStringSize( string, &_width, &_height );
|
|
||||||
return _width;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ConsolePrint( const char *string )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnConsolePrint( string );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void CenterPrint( const char *string )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnCenterPrint( string );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline char *safe_strcpy( char *dst, const char *src, int len_dst)
|
|
||||||
{
|
|
||||||
if( len_dst <= 0 )
|
|
||||||
{
|
|
||||||
return NULL; // this is bad
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(dst,src,len_dst);
|
|
||||||
dst[ len_dst - 1 ] = '\0';
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int safe_sprintf( char *dst, int len_dst, const char *format, ...)
|
|
||||||
{
|
|
||||||
if( len_dst <= 0 )
|
|
||||||
{
|
|
||||||
return -1; // this is bad
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list v;
|
|
||||||
|
|
||||||
va_start(v, format);
|
|
||||||
|
|
||||||
_vsnprintf(dst,len_dst,format,v);
|
|
||||||
|
|
||||||
va_end(v);
|
|
||||||
|
|
||||||
dst[ len_dst - 1 ] = '\0';
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sound functions
|
|
||||||
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
|
|
||||||
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
|
|
||||||
|
|
||||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
|
||||||
|
|
||||||
void ScaleColors( int &r, int &g, int &b, int a );
|
|
||||||
|
|
||||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
|
||||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
|
||||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
|
||||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
|
||||||
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
|
|
||||||
float Length(const float *v);
|
|
||||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
|
|
||||||
void VectorScale (const float *in, float scale, float *out);
|
|
||||||
float VectorNormalize (float *v);
|
|
||||||
void VectorInverse ( float *v );
|
|
||||||
|
|
||||||
extern vec3_t vec3_origin;
|
|
||||||
|
|
||||||
// disable 'possible loss of data converting float to int' warning message
|
|
||||||
#pragma warning( disable: 4244 )
|
|
||||||
// disable 'truncation from 'const double' to 'float' warning message
|
|
||||||
#pragma warning( disable: 4305 )
|
|
||||||
|
|
||||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
|
||||||
{\
|
|
||||||
r = (ulRGB & 0xFF0000) >>16;\
|
|
||||||
g = (ulRGB & 0xFF00) >> 8;\
|
|
||||||
b = ulRGB & 0xFF;\
|
|
||||||
}
|
|
||||||
|
|
||||||
HSPRITE LoadSprite(const char *pszName);
|
|
|
@ -1,277 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
// Com_Weapons.cpp
|
|
||||||
// Shared weapons common/shared functions
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "com_weapons.h"
|
|
||||||
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "r_efx.h"
|
|
||||||
|
|
||||||
// g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing
|
|
||||||
// command. If it is 1, then we should play events/sounds etc., otherwise, we just will be
|
|
||||||
// updating state info, but not firing events
|
|
||||||
int g_runfuncs = 0;
|
|
||||||
|
|
||||||
// During our weapon prediction processing, we'll need to reference some data that is part of
|
|
||||||
// the final state passed into the postthink functionality. We'll set this pointer and then
|
|
||||||
// reset it to NULL as appropriate
|
|
||||||
struct local_state_s *g_finalstate = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
COM_Log
|
|
||||||
|
|
||||||
Log debug messages to file ( appends )
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void COM_Log( char *pszFile, char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
char string[1024];
|
|
||||||
FILE *fp;
|
|
||||||
char *pfilename;
|
|
||||||
|
|
||||||
if ( !pszFile )
|
|
||||||
{
|
|
||||||
pfilename = "c:\\hllog.txt";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pfilename = pszFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start (argptr,fmt);
|
|
||||||
vsprintf (string, fmt,argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
|
|
||||||
fp = fopen( pfilename, "a+t");
|
|
||||||
if (fp)
|
|
||||||
{
|
|
||||||
fprintf(fp, "%s", string);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remember the current animation for the view model, in case we get out of sync with
|
|
||||||
// server.
|
|
||||||
static int g_currentanim;
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_SendWeaponAnim
|
|
||||||
|
|
||||||
Change weapon model animation
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void HUD_SendWeaponAnim( int iAnim, int body, int force )
|
|
||||||
{
|
|
||||||
// Don't actually change it.
|
|
||||||
if ( !g_runfuncs && !force )
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_currentanim = iAnim;
|
|
||||||
|
|
||||||
// Tell animation system new info
|
|
||||||
gEngfuncs.pfnWeaponAnim( iAnim, body );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_GetWeaponAnim
|
|
||||||
|
|
||||||
Retrieve current predicted weapon animation
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
int HUD_GetWeaponAnim( void )
|
|
||||||
{
|
|
||||||
return g_currentanim;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_PlaySound
|
|
||||||
|
|
||||||
Play a sound, if we are seeing this command for the first time
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void HUD_PlaySound( char *sound, float volume )
|
|
||||||
{
|
|
||||||
if ( !g_runfuncs || !g_finalstate )
|
|
||||||
return;
|
|
||||||
|
|
||||||
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_PlaybackEvent
|
|
||||||
|
|
||||||
Directly queue up an event on the client
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay,
|
|
||||||
float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
|
|
||||||
{
|
|
||||||
vec3_t org;
|
|
||||||
vec3_t ang;
|
|
||||||
|
|
||||||
if ( !g_runfuncs || !g_finalstate )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Weapon prediction events are assumed to occur at the player's origin
|
|
||||||
org = g_finalstate->playerstate.origin;
|
|
||||||
ang = v_angles;
|
|
||||||
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_SetMaxSpeed
|
|
||||||
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void HUD_SetMaxSpeed( const edict_t *ed, float speed )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
UTIL_WeaponTimeBase
|
|
||||||
|
|
||||||
Always 0.0 on client, even if not predicting weapons ( won't get called
|
|
||||||
in that case )
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
float UTIL_WeaponTimeBase( void )
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int glSeed = 0;
|
|
||||||
|
|
||||||
unsigned int seed_table[ 256 ] =
|
|
||||||
{
|
|
||||||
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
|
|
||||||
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
|
|
||||||
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
|
|
||||||
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
|
|
||||||
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
|
|
||||||
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
|
|
||||||
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
|
|
||||||
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
|
|
||||||
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
|
|
||||||
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
|
|
||||||
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
|
|
||||||
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
|
|
||||||
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
|
|
||||||
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
|
|
||||||
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
|
|
||||||
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned int U_Random( void )
|
|
||||||
{
|
|
||||||
glSeed *= 69069;
|
|
||||||
glSeed += seed_table[ glSeed & 0xff ];
|
|
||||||
|
|
||||||
return ( ++glSeed & 0x0fffffff );
|
|
||||||
}
|
|
||||||
|
|
||||||
void U_Srand( unsigned int seed )
|
|
||||||
{
|
|
||||||
glSeed = seed_table[ seed & 0xff ];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
UTIL_SharedRandomLong
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
|
|
||||||
{
|
|
||||||
unsigned int range;
|
|
||||||
|
|
||||||
U_Srand( (int)seed + low + high );
|
|
||||||
|
|
||||||
range = high - low + 1;
|
|
||||||
if ( !(range - 1) )
|
|
||||||
{
|
|
||||||
return low;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int offset;
|
|
||||||
int rnum;
|
|
||||||
|
|
||||||
rnum = U_Random();
|
|
||||||
|
|
||||||
offset = rnum % range;
|
|
||||||
|
|
||||||
return (low + offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
UTIL_SharedRandomFloat
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
|
|
||||||
{
|
|
||||||
//
|
|
||||||
unsigned int range;
|
|
||||||
|
|
||||||
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
|
|
||||||
|
|
||||||
U_Random();
|
|
||||||
U_Random();
|
|
||||||
|
|
||||||
range = high - low;
|
|
||||||
if ( !range )
|
|
||||||
{
|
|
||||||
return low;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int tensixrand;
|
|
||||||
float offset;
|
|
||||||
|
|
||||||
tensixrand = U_Random() & 65535;
|
|
||||||
|
|
||||||
offset = (float)tensixrand / 65536.0;
|
|
||||||
|
|
||||||
return (low + offset * range );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
======================
|
|
||||||
stub_*
|
|
||||||
|
|
||||||
stub functions for such things as precaching. So we don't have to modify weapons code that
|
|
||||||
is compiled into both game and client .dlls.
|
|
||||||
======================
|
|
||||||
*/
|
|
||||||
int stub_PrecacheModel ( char* s ) { return 0; }
|
|
||||||
int stub_PrecacheSound ( char* s ) { return 0; }
|
|
||||||
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
|
|
||||||
const char *stub_NameForFunction ( uint32 function ) { return "func"; }
|
|
||||||
void stub_SetModel ( edict_t *e, const char *m ) {}
|
|
|
@ -1,44 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// com_weapons.h
|
|
||||||
// Shared weapons common function prototypes
|
|
||||||
#if !defined( COM_WEAPONSH )
|
|
||||||
#define COM_WEAPONSH
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "hud_iface.h"
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
void COM_Log( char *pszFile, char *fmt, ...);
|
|
||||||
int CL_IsDead( void );
|
|
||||||
|
|
||||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
|
|
||||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
|
|
||||||
|
|
||||||
int HUD_GetWeaponAnim( void );
|
|
||||||
void HUD_SendWeaponAnim( int iAnim, int body, int force );
|
|
||||||
void HUD_PlaySound( char *sound, float volume );
|
|
||||||
void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
|
||||||
void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
|
|
||||||
int stub_PrecacheModel( char* s );
|
|
||||||
int stub_PrecacheSound( char* s );
|
|
||||||
unsigned short stub_PrecacheEvent( int type, const char *s );
|
|
||||||
const char *stub_NameForFunction ( uint32 function );
|
|
||||||
void stub_SetModel ( struct edict_s *e, const char *m );
|
|
||||||
|
|
||||||
|
|
||||||
extern cvar_t *cl_lw;
|
|
||||||
|
|
||||||
extern int g_runfuncs;
|
|
||||||
extern vec3_t v_angles;
|
|
||||||
extern float g_lastFOV;
|
|
||||||
extern struct local_state_s *g_finalstate;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,304 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// death notice
|
|
||||||
//
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
|
|
||||||
|
|
||||||
struct DeathNoticeItem {
|
|
||||||
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
|
|
||||||
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
|
|
||||||
int iId; // the index number of the associated sprite
|
|
||||||
int iSuicide;
|
|
||||||
int iTeamKill;
|
|
||||||
int iNonPlayerKill;
|
|
||||||
float flDisplayTime;
|
|
||||||
float *KillerColor;
|
|
||||||
float *VictimColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAX_DEATHNOTICES 4
|
|
||||||
static int DEATHNOTICE_DISPLAY_TIME = 6;
|
|
||||||
|
|
||||||
#define DEATHNOTICE_TOP 32
|
|
||||||
|
|
||||||
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
|
|
||||||
|
|
||||||
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
|
|
||||||
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
|
|
||||||
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
|
||||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
|
||||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
|
||||||
|
|
||||||
float *GetClientColor( int clientIndex )
|
|
||||||
{
|
|
||||||
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
|
|
||||||
{
|
|
||||||
case 1: return g_ColorBlue;
|
|
||||||
case 2: return g_ColorRed;
|
|
||||||
case 3: return g_ColorYellow;
|
|
||||||
case 4: return g_ColorGreen;
|
|
||||||
case 0: return g_ColorYellow;
|
|
||||||
|
|
||||||
default : return g_ColorGrey;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudDeathNotice :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( DeathMsg );
|
|
||||||
|
|
||||||
CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudDeathNotice :: InitHUDData( void )
|
|
||||||
{
|
|
||||||
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudDeathNotice :: VidInit( void )
|
|
||||||
{
|
|
||||||
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudDeathNotice :: Draw( float flTime )
|
|
||||||
{
|
|
||||||
int x, y, r, g, b;
|
|
||||||
|
|
||||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
|
||||||
{
|
|
||||||
if ( rgDeathNoticeList[i].iId == 0 )
|
|
||||||
break; // we've gone through them all
|
|
||||||
|
|
||||||
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
|
|
||||||
{ // display time has expired
|
|
||||||
// remove the current item from the list
|
|
||||||
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
|
|
||||||
i--; // continue on the next item; stop the counter getting incremented
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
|
|
||||||
|
|
||||||
// Only draw if the viewport will let me
|
|
||||||
if ( gViewPort && gViewPort->AllowedToPrintText() )
|
|
||||||
{
|
|
||||||
// Draw the death notice
|
|
||||||
y = DEATHNOTICE_TOP + 2 + (20 * i); //!!!
|
|
||||||
|
|
||||||
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
|
|
||||||
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
|
||||||
|
|
||||||
if ( !rgDeathNoticeList[i].iSuicide )
|
|
||||||
{
|
|
||||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
|
||||||
|
|
||||||
// Draw killers name
|
|
||||||
if ( rgDeathNoticeList[i].KillerColor )
|
|
||||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
|
||||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
|
||||||
}
|
|
||||||
|
|
||||||
r = 255; g = 80; b = 0;
|
|
||||||
if ( rgDeathNoticeList[i].iTeamKill )
|
|
||||||
{
|
|
||||||
r = 10; g = 240; b = 10; // display it in sickly green
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw death weapon
|
|
||||||
SPR_Set( gHUD.GetSprite(id), r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
|
|
||||||
|
|
||||||
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
|
||||||
|
|
||||||
// Draw victims name (if it was a player that was killed)
|
|
||||||
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
|
|
||||||
{
|
|
||||||
if ( rgDeathNoticeList[i].VictimColor )
|
|
||||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
|
||||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This message handler may be better off elsewhere
|
|
||||||
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int killer = READ_BYTE();
|
|
||||||
int victim = READ_BYTE();
|
|
||||||
|
|
||||||
char killedwith[32];
|
|
||||||
strcpy( killedwith, "d_" );
|
|
||||||
strncat( killedwith, READ_STRING(), 32 );
|
|
||||||
|
|
||||||
if (gViewPort)
|
|
||||||
gViewPort->DeathMsg( killer, victim );
|
|
||||||
|
|
||||||
gHUD.m_Spectator.DeathMessage(victim);
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
|
|
||||||
{
|
|
||||||
if ( rgDeathNoticeList[i].iId == 0 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( i == MAX_DEATHNOTICES )
|
|
||||||
{ // move the rest of the list forward to make room for this item
|
|
||||||
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
|
|
||||||
i = MAX_DEATHNOTICES - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gViewPort)
|
|
||||||
gViewPort->GetAllPlayersInfo();
|
|
||||||
|
|
||||||
// Get the Killer's name
|
|
||||||
char *killer_name = g_PlayerInfoList[ killer ].name;
|
|
||||||
if ( !killer_name )
|
|
||||||
{
|
|
||||||
killer_name = "";
|
|
||||||
rgDeathNoticeList[i].szKiller[0] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
|
||||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
|
||||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the Victim's name
|
|
||||||
char *victim_name = NULL;
|
|
||||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
|
||||||
if ( ((char)victim) != -1 )
|
|
||||||
victim_name = g_PlayerInfoList[ victim ].name;
|
|
||||||
if ( !victim_name )
|
|
||||||
{
|
|
||||||
victim_name = "";
|
|
||||||
rgDeathNoticeList[i].szVictim[0] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
|
||||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
|
||||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is it a non-player object kill?
|
|
||||||
if ( ((char)victim) == -1 )
|
|
||||||
{
|
|
||||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
|
||||||
|
|
||||||
// Store the object's name in the Victim slot (skip the d_ bit)
|
|
||||||
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( killer == victim || killer == 0 )
|
|
||||||
rgDeathNoticeList[i].iSuicide = TRUE;
|
|
||||||
|
|
||||||
if ( !strcmp( killedwith, "d_teammate" ) )
|
|
||||||
rgDeathNoticeList[i].iTeamKill = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the sprite in the list
|
|
||||||
int spr = gHUD.GetSpriteIndex( killedwith );
|
|
||||||
|
|
||||||
rgDeathNoticeList[i].iId = spr;
|
|
||||||
|
|
||||||
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
|
|
||||||
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
|
|
||||||
|
|
||||||
if (rgDeathNoticeList[i].iNonPlayerKill)
|
|
||||||
{
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
|
||||||
ConsolePrint( " killed a " );
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
|
||||||
ConsolePrint( "\n" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// record the death notice in the console
|
|
||||||
if ( rgDeathNoticeList[i].iSuicide )
|
|
||||||
{
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
|
||||||
|
|
||||||
if ( !strcmp( killedwith, "d_world" ) )
|
|
||||||
{
|
|
||||||
ConsolePrint( " died" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConsolePrint( " killed self" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( rgDeathNoticeList[i].iTeamKill )
|
|
||||||
{
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
|
||||||
ConsolePrint( " killed his teammate " );
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
|
||||||
ConsolePrint( " killed " );
|
|
||||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
|
|
||||||
{
|
|
||||||
ConsolePrint( " with " );
|
|
||||||
|
|
||||||
// replace the code names with the 'real' names
|
|
||||||
if ( !strcmp( killedwith+2, "egon" ) )
|
|
||||||
strcpy( killedwith, "d_gluon gun" );
|
|
||||||
if ( !strcmp( killedwith+2, "gauss" ) )
|
|
||||||
strcpy( killedwith, "d_tau cannon" );
|
|
||||||
|
|
||||||
ConsolePrint( killedwith+2 ); // skip over the "d_" part
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsolePrint( "\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "demo.h"
|
|
||||||
#include "demo_api.h"
|
|
||||||
#include <memory.h>
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
int g_demosniper = 0;
|
|
||||||
int g_demosniperdamage = 0;
|
|
||||||
float g_demosniperorg[3];
|
|
||||||
float g_demosniperangles[3];
|
|
||||||
float g_demozoom;
|
|
||||||
|
|
||||||
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
Demo_WriteBuffer
|
|
||||||
|
|
||||||
Write some data to the demo stream
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
|
|
||||||
{
|
|
||||||
int pos = 0;
|
|
||||||
unsigned char buf[ 32 * 1024 ];
|
|
||||||
*( int * )&buf[pos] = type;
|
|
||||||
pos+=sizeof( int );
|
|
||||||
|
|
||||||
memcpy( &buf[pos], buffer, size );
|
|
||||||
|
|
||||||
// Write full buffer out
|
|
||||||
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
Demo_ReadBuffer
|
|
||||||
|
|
||||||
Engine wants us to parse some data from the demo stream
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
|
||||||
{
|
|
||||||
// RecClReadDemoBuffer(size, buffer);
|
|
||||||
|
|
||||||
int type;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
type = *( int * )buffer;
|
|
||||||
i += sizeof( int );
|
|
||||||
switch ( type )
|
|
||||||
{
|
|
||||||
case TYPE_SNIPERDOT:
|
|
||||||
g_demosniper = *(int * )&buffer[ i ];
|
|
||||||
i += sizeof( int );
|
|
||||||
|
|
||||||
if ( g_demosniper )
|
|
||||||
{
|
|
||||||
g_demosniperdamage = *( int * )&buffer[ i ];
|
|
||||||
i += sizeof( int );
|
|
||||||
|
|
||||||
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
|
|
||||||
i += sizeof( float );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TYPE_ZOOM:
|
|
||||||
g_demozoom = *(float * )&buffer[ i ];
|
|
||||||
i += sizeof( float );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( DEMOH )
|
|
||||||
#define DEMOH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Types of demo messages we can write/parse
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
TYPE_SNIPERDOT = 0,
|
|
||||||
TYPE_ZOOM
|
|
||||||
};
|
|
||||||
|
|
||||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
|
|
||||||
|
|
||||||
extern int g_demosniper;
|
|
||||||
extern int g_demosniperdamage;
|
|
||||||
extern float g_demosniperorg[3];
|
|
||||||
extern float g_demosniperangles[3];
|
|
||||||
extern float g_demozoom;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,785 +0,0 @@
|
||||||
// Client side entity management functions
|
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_types.h"
|
|
||||||
#include "studio_event.h" // def. of mstudioevent_t
|
|
||||||
#include "r_efx.h"
|
|
||||||
#include "event_api.h"
|
|
||||||
#include "pm_defs.h"
|
|
||||||
#include "pmtrace.h"
|
|
||||||
#include "pm_shared.h"
|
|
||||||
#include "bench.h"
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
#include "particleman.h"
|
|
||||||
extern IParticleMan *g_pParticleMan;
|
|
||||||
|
|
||||||
void Game_AddObjects( void );
|
|
||||||
|
|
||||||
extern vec3_t v_origin;
|
|
||||||
|
|
||||||
int g_iAlive = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
HUD_AddEntity
|
|
||||||
Return 0 to filter entity from visible list for rendering
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
int CL_DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname )
|
|
||||||
{
|
|
||||||
// RecClAddEntity(type, ent, modelname);
|
|
||||||
|
|
||||||
switch ( type )
|
|
||||||
{
|
|
||||||
case ET_NORMAL:
|
|
||||||
Bench_CheckEntity( type, ent, modelname );
|
|
||||||
break;
|
|
||||||
case ET_PLAYER:
|
|
||||||
case ET_BEAM:
|
|
||||||
case ET_TEMPENTITY:
|
|
||||||
case ET_FRAGMENTED:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// each frame every entity passes this function, so the overview hooks it to filter the overview entities
|
|
||||||
// in spectator mode:
|
|
||||||
// each frame every entity passes this function, so the overview hooks
|
|
||||||
// it to filter the overview entities
|
|
||||||
|
|
||||||
if ( g_iUser1 )
|
|
||||||
{
|
|
||||||
gHUD.m_Spectator.AddOverviewEntity( type, ent, modelname );
|
|
||||||
|
|
||||||
if ( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) &&
|
|
||||||
ent->index == g_iUser2 )
|
|
||||||
return 0; // don't draw the player we are following in eye
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=========================
|
|
||||||
HUD_TxferLocalOverrides
|
|
||||||
|
|
||||||
The server sends us our origin with extra precision as part of the clientdata structure, not during the normal
|
|
||||||
playerstate update in entity_state_t. In order for these overrides to eventually get to the appropriate playerstate
|
|
||||||
structure, we need to copy them into the state structure at this point.
|
|
||||||
=========================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client )
|
|
||||||
{
|
|
||||||
// RecClTxferLocalOverrides(state, client);
|
|
||||||
|
|
||||||
VectorCopy( client->origin, state->origin );
|
|
||||||
|
|
||||||
// Spectator
|
|
||||||
state->iuser1 = client->iuser1;
|
|
||||||
state->iuser2 = client->iuser2;
|
|
||||||
|
|
||||||
// Duck prevention
|
|
||||||
state->iuser3 = client->iuser3;
|
|
||||||
|
|
||||||
// Fire prevention
|
|
||||||
state->iuser4 = client->iuser4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=========================
|
|
||||||
HUD_ProcessPlayerState
|
|
||||||
|
|
||||||
We have received entity_state_t for this player over the network. We need to copy appropriate fields to the
|
|
||||||
playerstate structure
|
|
||||||
=========================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src )
|
|
||||||
{
|
|
||||||
// RecClProcessPlayerState(dst, src);
|
|
||||||
|
|
||||||
// Copy in network data
|
|
||||||
VectorCopy( src->origin, dst->origin );
|
|
||||||
VectorCopy( src->angles, dst->angles );
|
|
||||||
|
|
||||||
VectorCopy( src->velocity, dst->velocity );
|
|
||||||
|
|
||||||
dst->frame = src->frame;
|
|
||||||
dst->modelindex = src->modelindex;
|
|
||||||
dst->skin = src->skin;
|
|
||||||
dst->effects = src->effects;
|
|
||||||
dst->weaponmodel = src->weaponmodel;
|
|
||||||
dst->movetype = src->movetype;
|
|
||||||
dst->sequence = src->sequence;
|
|
||||||
dst->animtime = src->animtime;
|
|
||||||
|
|
||||||
dst->solid = src->solid;
|
|
||||||
|
|
||||||
dst->rendermode = src->rendermode;
|
|
||||||
dst->renderamt = src->renderamt;
|
|
||||||
dst->rendercolor.r = src->rendercolor.r;
|
|
||||||
dst->rendercolor.g = src->rendercolor.g;
|
|
||||||
dst->rendercolor.b = src->rendercolor.b;
|
|
||||||
dst->renderfx = src->renderfx;
|
|
||||||
|
|
||||||
dst->framerate = src->framerate;
|
|
||||||
dst->body = src->body;
|
|
||||||
|
|
||||||
memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof( byte ) );
|
|
||||||
memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof( byte ) );
|
|
||||||
|
|
||||||
VectorCopy( src->basevelocity, dst->basevelocity );
|
|
||||||
|
|
||||||
dst->friction = src->friction;
|
|
||||||
dst->gravity = src->gravity;
|
|
||||||
dst->gaitsequence = src->gaitsequence;
|
|
||||||
dst->spectator = src->spectator;
|
|
||||||
dst->usehull = src->usehull;
|
|
||||||
dst->playerclass = src->playerclass;
|
|
||||||
dst->team = src->team;
|
|
||||||
dst->colormap = src->colormap;
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
dst->fuser1 = src->fuser1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Save off some data so other areas of the Client DLL can get to it
|
|
||||||
cl_entity_t *player = gEngfuncs.GetLocalPlayer(); // Get the local player's index
|
|
||||||
if ( dst->number == player->index )
|
|
||||||
{
|
|
||||||
g_iPlayerClass = dst->playerclass;
|
|
||||||
g_iTeamNumber = dst->team;
|
|
||||||
|
|
||||||
g_iUser1 = src->iuser1;
|
|
||||||
g_iUser2 = src->iuser2;
|
|
||||||
g_iUser3 = src->iuser3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=========================
|
|
||||||
HUD_TxferPredictionData
|
|
||||||
|
|
||||||
Because we can predict an arbitrary number of frames before the server responds with an update, we need to be able to copy client side prediction data in
|
|
||||||
from the state that the server ack'd receiving, which can be anywhere along the predicted frame path ( i.e., we could predict 20 frames into the future and the server ack's
|
|
||||||
up through 10 of those frames, so we need to copy persistent client-side only state from the 10th predicted frame to the slot the server
|
|
||||||
update is occupying.
|
|
||||||
=========================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd )
|
|
||||||
{
|
|
||||||
// RecClTxferPredictionData(ps, pps, pcd, ppcd, wd, pwd);
|
|
||||||
|
|
||||||
ps->oldbuttons = pps->oldbuttons;
|
|
||||||
ps->flFallVelocity = pps->flFallVelocity;
|
|
||||||
ps->iStepLeft = pps->iStepLeft;
|
|
||||||
ps->playerclass = pps->playerclass;
|
|
||||||
|
|
||||||
pcd->viewmodel = ppcd->viewmodel;
|
|
||||||
pcd->m_iId = ppcd->m_iId;
|
|
||||||
pcd->ammo_shells = ppcd->ammo_shells;
|
|
||||||
pcd->ammo_nails = ppcd->ammo_nails;
|
|
||||||
pcd->ammo_cells = ppcd->ammo_cells;
|
|
||||||
pcd->ammo_rockets = ppcd->ammo_rockets;
|
|
||||||
pcd->m_flNextAttack = ppcd->m_flNextAttack;
|
|
||||||
pcd->fov = ppcd->fov;
|
|
||||||
pcd->weaponanim = ppcd->weaponanim;
|
|
||||||
pcd->tfstate = ppcd->tfstate;
|
|
||||||
pcd->maxspeed = ppcd->maxspeed;
|
|
||||||
|
|
||||||
pcd->deadflag = ppcd->deadflag;
|
|
||||||
|
|
||||||
// Spectating or not dead == get control over view angles.
|
|
||||||
g_iAlive = ( ppcd->iuser1 || ( pcd->deadflag == DEAD_NO ) ) ? 1 : 0;
|
|
||||||
|
|
||||||
// Spectator
|
|
||||||
pcd->iuser1 = ppcd->iuser1;
|
|
||||||
pcd->iuser2 = ppcd->iuser2;
|
|
||||||
|
|
||||||
// Duck prevention
|
|
||||||
pcd->iuser3 = ppcd->iuser3;
|
|
||||||
|
|
||||||
if ( gEngfuncs.IsSpectateOnly() )
|
|
||||||
{
|
|
||||||
// in specator mode we tell the engine who we want to spectate and how
|
|
||||||
// iuser3 is not used for duck prevention (since the spectator can't duck at all)
|
|
||||||
pcd->iuser1 = g_iUser1; // observer mode
|
|
||||||
pcd->iuser2 = g_iUser2; // first target
|
|
||||||
pcd->iuser3 = g_iUser3; // second target
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire prevention
|
|
||||||
pcd->iuser4 = ppcd->iuser4;
|
|
||||||
|
|
||||||
pcd->fuser2 = ppcd->fuser2;
|
|
||||||
pcd->fuser3 = ppcd->fuser3;
|
|
||||||
|
|
||||||
VectorCopy( ppcd->vuser1, pcd->vuser1 );
|
|
||||||
VectorCopy( ppcd->vuser2, pcd->vuser2 );
|
|
||||||
VectorCopy( ppcd->vuser3, pcd->vuser3 );
|
|
||||||
VectorCopy( ppcd->vuser4, pcd->vuser4 );
|
|
||||||
|
|
||||||
memcpy( wd, pwd, 32 * sizeof( weapon_data_t ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined( BEAM_TEST )
|
|
||||||
// Note can't index beam[ 0 ] in Beam callback, so don't use that index
|
|
||||||
// Room for 1 beam ( 0 can't be used )
|
|
||||||
static cl_entity_t beams[ 2 ];
|
|
||||||
|
|
||||||
void BeamEndModel( void )
|
|
||||||
{
|
|
||||||
cl_entity_t *player, *model;
|
|
||||||
int modelindex;
|
|
||||||
struct model_s *mod;
|
|
||||||
|
|
||||||
// Load it up with some bogus data
|
|
||||||
player = gEngfuncs.GetLocalPlayer();
|
|
||||||
if ( !player )
|
|
||||||
return;
|
|
||||||
|
|
||||||
mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex );
|
|
||||||
if ( !mod )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Slot 1
|
|
||||||
model = &beams[ 1 ];
|
|
||||||
|
|
||||||
*model = *player;
|
|
||||||
model->player = 0;
|
|
||||||
model->model = mod;
|
|
||||||
model->curstate.modelindex = modelindex;
|
|
||||||
|
|
||||||
// Move it out a bit
|
|
||||||
model->origin[0] = player->origin[0] - 100;
|
|
||||||
model->origin[1] = player->origin[1];
|
|
||||||
|
|
||||||
model->attachment[0] = model->origin;
|
|
||||||
model->attachment[1] = model->origin;
|
|
||||||
model->attachment[2] = model->origin;
|
|
||||||
model->attachment[3] = model->origin;
|
|
||||||
|
|
||||||
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, model );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Beams( void )
|
|
||||||
{
|
|
||||||
static float lasttime;
|
|
||||||
float curtime;
|
|
||||||
struct model_s *mod;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
BeamEndModel();
|
|
||||||
|
|
||||||
curtime = gEngfuncs.GetClientTime();
|
|
||||||
float end[ 3 ];
|
|
||||||
|
|
||||||
if ( ( curtime - lasttime ) < 10.0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
mod = gEngfuncs.CL_LoadModel( "sprites/laserbeam.spr", &index );
|
|
||||||
if ( !mod )
|
|
||||||
return;
|
|
||||||
|
|
||||||
lasttime = curtime;
|
|
||||||
|
|
||||||
end [ 0 ] = v_origin.x + 100;
|
|
||||||
end [ 1 ] = v_origin.y + 100;
|
|
||||||
end [ 2 ] = v_origin.z;
|
|
||||||
|
|
||||||
BEAM *p1;
|
|
||||||
p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint( -1, end, index,
|
|
||||||
10.0, 2.0, 0.3, 1.0, 5.0, 0.0, 1.0, 1.0, 1.0, 1.0 );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
=========================
|
|
||||||
HUD_CreateEntities
|
|
||||||
|
|
||||||
Gives us a chance to add additional entities to the render this frame
|
|
||||||
=========================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_CreateEntities( void )
|
|
||||||
{
|
|
||||||
// RecClCreateEntities();
|
|
||||||
|
|
||||||
#if defined( BEAM_TEST )
|
|
||||||
Beams();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Bench_AddObjects();
|
|
||||||
|
|
||||||
// Add in any game specific objects
|
|
||||||
Game_AddObjects();
|
|
||||||
|
|
||||||
GetClientVoiceMgr()->CreateEntities();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
extern int g_bACSpinning[33];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
=========================
|
|
||||||
HUD_StudioEvent
|
|
||||||
|
|
||||||
The entity's studio model description indicated an event was
|
|
||||||
fired during this frame, handle the event by it's tag ( e.g., muzzleflash, sound )
|
|
||||||
=========================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity )
|
|
||||||
{
|
|
||||||
// RecClStudioEvent(event, entity);
|
|
||||||
|
|
||||||
int iMuzzleFlash = 1;
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
|
|
||||||
if ( g_bACSpinning[ entity->index - 1 ] )
|
|
||||||
iMuzzleFlash = 0;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch( event->event )
|
|
||||||
{
|
|
||||||
case 5001:
|
|
||||||
if ( iMuzzleFlash )
|
|
||||||
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options) );
|
|
||||||
break;
|
|
||||||
case 5011:
|
|
||||||
if ( iMuzzleFlash )
|
|
||||||
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options) );
|
|
||||||
break;
|
|
||||||
case 5021:
|
|
||||||
if ( iMuzzleFlash )
|
|
||||||
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options) );
|
|
||||||
break;
|
|
||||||
case 5031:
|
|
||||||
if ( iMuzzleFlash )
|
|
||||||
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options) );
|
|
||||||
break;
|
|
||||||
case 5002:
|
|
||||||
gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options), -100, 100 );
|
|
||||||
break;
|
|
||||||
// Client side sound
|
|
||||||
case 5004:
|
|
||||||
gEngfuncs.pfnPlaySoundByNameAtLocation( (char *)event->options, 1.0, (float *)&entity->attachment[0] );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
CL_UpdateTEnts
|
|
||||||
|
|
||||||
Simulation and cleanup of temporary entities
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_TempEntUpdate (
|
|
||||||
double frametime, // Simulation time
|
|
||||||
double client_time, // Absolute time on client
|
|
||||||
double cl_gravity, // True gravity on client
|
|
||||||
TEMPENTITY **ppTempEntFree, // List of freed temporary ents
|
|
||||||
TEMPENTITY **ppTempEntActive, // List
|
|
||||||
int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ),
|
|
||||||
void ( *Callback_TempEntPlaySound )( TEMPENTITY *pTemp, float damp ) )
|
|
||||||
{
|
|
||||||
// RecClTempEntUpdate(frametime, client_time, cl_gravity, ppTempEntFree, ppTempEntActive, Callback_AddVisibleEntity, Callback_TempEntPlaySound);
|
|
||||||
|
|
||||||
static int gTempEntFrame = 0;
|
|
||||||
int i;
|
|
||||||
TEMPENTITY *pTemp, *pnext, *pprev;
|
|
||||||
float freq, gravity, gravitySlow, life, fastFreq;
|
|
||||||
|
|
||||||
Vector vAngles;
|
|
||||||
|
|
||||||
gEngfuncs.GetViewAngles( (float*)vAngles );
|
|
||||||
|
|
||||||
if ( g_pParticleMan )
|
|
||||||
g_pParticleMan->SetVariables( cl_gravity, vAngles );
|
|
||||||
|
|
||||||
// Nothing to simulate
|
|
||||||
if ( !*ppTempEntActive )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// in order to have tents collide with players, we have to run the player prediction code so
|
|
||||||
// that the client has the player list. We run this code once when we detect any COLLIDEALL
|
|
||||||
// tent, then set this BOOL to true so the code doesn't get run again if there's more than
|
|
||||||
// one COLLIDEALL ent for this update. (often are).
|
|
||||||
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
|
|
||||||
|
|
||||||
// Store off the old count
|
|
||||||
gEngfuncs.pEventAPI->EV_PushPMStates();
|
|
||||||
|
|
||||||
// Now add in all of the players.
|
|
||||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( -1 );
|
|
||||||
|
|
||||||
// !!!BUGBUG -- This needs to be time based
|
|
||||||
gTempEntFrame = (gTempEntFrame+1) & 31;
|
|
||||||
|
|
||||||
pTemp = *ppTempEntActive;
|
|
||||||
|
|
||||||
// !!! Don't simulate while paused.... This is sort of a hack, revisit.
|
|
||||||
if ( frametime <= 0 )
|
|
||||||
{
|
|
||||||
while ( pTemp )
|
|
||||||
{
|
|
||||||
if ( !(pTemp->flags & FTENT_NOMODEL ) )
|
|
||||||
{
|
|
||||||
Callback_AddVisibleEntity( &pTemp->entity );
|
|
||||||
}
|
|
||||||
pTemp = pTemp->next;
|
|
||||||
}
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
pprev = NULL;
|
|
||||||
freq = client_time * 0.01;
|
|
||||||
fastFreq = client_time * 5.5;
|
|
||||||
gravity = -frametime * cl_gravity;
|
|
||||||
gravitySlow = gravity * 0.5;
|
|
||||||
|
|
||||||
while ( pTemp )
|
|
||||||
{
|
|
||||||
int active;
|
|
||||||
|
|
||||||
active = 1;
|
|
||||||
|
|
||||||
life = pTemp->die - client_time;
|
|
||||||
pnext = pTemp->next;
|
|
||||||
if ( life < 0 )
|
|
||||||
{
|
|
||||||
if ( pTemp->flags & FTENT_FADEOUT )
|
|
||||||
{
|
|
||||||
if (pTemp->entity.curstate.rendermode == kRenderNormal)
|
|
||||||
pTemp->entity.curstate.rendermode = kRenderTransTexture;
|
|
||||||
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed );
|
|
||||||
if ( pTemp->entity.curstate.renderamt <= 0 )
|
|
||||||
active = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
active = 0;
|
|
||||||
}
|
|
||||||
if ( !active ) // Kill it
|
|
||||||
{
|
|
||||||
pTemp->next = *ppTempEntFree;
|
|
||||||
*ppTempEntFree = pTemp;
|
|
||||||
if ( !pprev ) // Deleting at head of list
|
|
||||||
*ppTempEntActive = pnext;
|
|
||||||
else
|
|
||||||
pprev->next = pnext;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pprev = pTemp;
|
|
||||||
|
|
||||||
VectorCopy( pTemp->entity.origin, pTemp->entity.prevstate.origin );
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_SPARKSHOWER )
|
|
||||||
{
|
|
||||||
// Adjust speed if it's time
|
|
||||||
// Scale is next think time
|
|
||||||
if ( client_time > pTemp->entity.baseline.scale )
|
|
||||||
{
|
|
||||||
// Show Sparks
|
|
||||||
gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 );
|
|
||||||
|
|
||||||
// Reduce life
|
|
||||||
pTemp->entity.baseline.framerate -= 0.1;
|
|
||||||
|
|
||||||
if ( pTemp->entity.baseline.framerate <= 0.0 )
|
|
||||||
{
|
|
||||||
pTemp->die = client_time;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// So it will die no matter what
|
|
||||||
pTemp->die = client_time + 0.5;
|
|
||||||
|
|
||||||
// Next think
|
|
||||||
pTemp->entity.baseline.scale = client_time + 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( pTemp->flags & FTENT_PLYRATTACHMENT )
|
|
||||||
{
|
|
||||||
cl_entity_t *pClient;
|
|
||||||
|
|
||||||
pClient = gEngfuncs.GetEntityByIndex( pTemp->clientIndex );
|
|
||||||
|
|
||||||
VectorAdd( pClient->origin, pTemp->tentOffset, pTemp->entity.origin );
|
|
||||||
}
|
|
||||||
else if ( pTemp->flags & FTENT_SINEWAVE )
|
|
||||||
{
|
|
||||||
pTemp->x += pTemp->entity.baseline.origin[0] * frametime;
|
|
||||||
pTemp->y += pTemp->entity.baseline.origin[1] * frametime;
|
|
||||||
|
|
||||||
pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * (10*pTemp->entity.curstate.framerate);
|
|
||||||
pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * (8*pTemp->entity.curstate.framerate);
|
|
||||||
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
|
|
||||||
}
|
|
||||||
else if ( pTemp->flags & FTENT_SPIRAL )
|
|
||||||
{
|
|
||||||
float s, c;
|
|
||||||
s = sin( pTemp->entity.baseline.origin[2] + fastFreq );
|
|
||||||
c = cos( pTemp->entity.baseline.origin[2] + fastFreq );
|
|
||||||
|
|
||||||
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)pTemp );
|
|
||||||
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)pTemp );
|
|
||||||
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for ( i = 0; i < 3; i++ )
|
|
||||||
pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_SPRANIMATE )
|
|
||||||
{
|
|
||||||
pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate;
|
|
||||||
if ( pTemp->entity.curstate.frame >= pTemp->frameMax )
|
|
||||||
{
|
|
||||||
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame);
|
|
||||||
|
|
||||||
if ( !(pTemp->flags & FTENT_SPRANIMATELOOP) )
|
|
||||||
{
|
|
||||||
// this animating sprite isn't set to loop, so destroy it.
|
|
||||||
pTemp->die = client_time;
|
|
||||||
pTemp = pnext;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( pTemp->flags & FTENT_SPRCYCLE )
|
|
||||||
{
|
|
||||||
pTemp->entity.curstate.frame += frametime * 10;
|
|
||||||
if ( pTemp->entity.curstate.frame >= pTemp->frameMax )
|
|
||||||
{
|
|
||||||
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Experiment
|
|
||||||
#if 0
|
|
||||||
if ( pTemp->flags & FTENT_SCALE )
|
|
||||||
pTemp->entity.curstate.framerate += 20.0 * (frametime / pTemp->entity.curstate.framerate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_ROTATE )
|
|
||||||
{
|
|
||||||
pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime;
|
|
||||||
pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime;
|
|
||||||
pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * frametime;
|
|
||||||
|
|
||||||
VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD) )
|
|
||||||
{
|
|
||||||
vec3_t traceNormal;
|
|
||||||
float traceFraction = 1;
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_COLLIDEALL )
|
|
||||||
{
|
|
||||||
pmtrace_t pmtrace;
|
|
||||||
physent_t *pe;
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace );
|
|
||||||
|
|
||||||
|
|
||||||
if ( pmtrace.fraction != 1 )
|
|
||||||
{
|
|
||||||
pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent );
|
|
||||||
|
|
||||||
if ( !pmtrace.ent || ( pe->info != pTemp->clientIndex ) )
|
|
||||||
{
|
|
||||||
traceFraction = pmtrace.fraction;
|
|
||||||
VectorCopy( pmtrace.plane.normal, traceNormal );
|
|
||||||
|
|
||||||
if ( pTemp->hitcallback )
|
|
||||||
{
|
|
||||||
(*pTemp->hitcallback)( pTemp, &pmtrace );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( pTemp->flags & FTENT_COLLIDEWORLD )
|
|
||||||
{
|
|
||||||
pmtrace_t pmtrace;
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace );
|
|
||||||
|
|
||||||
if ( pmtrace.fraction != 1 )
|
|
||||||
{
|
|
||||||
traceFraction = pmtrace.fraction;
|
|
||||||
VectorCopy( pmtrace.plane.normal, traceNormal );
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_SPARKSHOWER )
|
|
||||||
{
|
|
||||||
// Chop spark speeds a bit more
|
|
||||||
//
|
|
||||||
VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin );
|
|
||||||
|
|
||||||
if ( Length( pTemp->entity.baseline.origin ) < 10 )
|
|
||||||
{
|
|
||||||
pTemp->entity.baseline.framerate = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pTemp->hitcallback )
|
|
||||||
{
|
|
||||||
(*pTemp->hitcallback)( pTemp, &pmtrace );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( traceFraction != 1 ) // Decent collision now, and damping works
|
|
||||||
{
|
|
||||||
float proj, damp;
|
|
||||||
|
|
||||||
// Place at contact point
|
|
||||||
VectorMA( pTemp->entity.prevstate.origin, traceFraction*frametime, pTemp->entity.baseline.origin, pTemp->entity.origin );
|
|
||||||
// Damp velocity
|
|
||||||
damp = pTemp->bounceFactor;
|
|
||||||
if ( pTemp->flags & (FTENT_GRAVITY|FTENT_SLOWGRAVITY) )
|
|
||||||
{
|
|
||||||
damp *= 0.5;
|
|
||||||
if ( traceNormal[2] > 0.9 ) // Hit floor?
|
|
||||||
{
|
|
||||||
if ( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 )
|
|
||||||
{
|
|
||||||
damp = 0; // Stop
|
|
||||||
pTemp->flags &= ~(FTENT_ROTATE|FTENT_GRAVITY|FTENT_SLOWGRAVITY|FTENT_COLLIDEWORLD|FTENT_SMOKETRAIL);
|
|
||||||
pTemp->entity.angles[0] = 0;
|
|
||||||
pTemp->entity.angles[2] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pTemp->hitSound)
|
|
||||||
{
|
|
||||||
Callback_TempEntPlaySound(pTemp, damp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pTemp->flags & FTENT_COLLIDEKILL)
|
|
||||||
{
|
|
||||||
// die on impact
|
|
||||||
pTemp->flags &= ~FTENT_FADEOUT;
|
|
||||||
pTemp->die = client_time;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Reflect velocity
|
|
||||||
if ( damp != 0 )
|
|
||||||
{
|
|
||||||
proj = DotProduct( pTemp->entity.baseline.origin, traceNormal );
|
|
||||||
VectorMA( pTemp->entity.baseline.origin, -proj*2, traceNormal, pTemp->entity.baseline.origin );
|
|
||||||
// Reflect rotation (fake)
|
|
||||||
|
|
||||||
pTemp->entity.angles[1] = -pTemp->entity.angles[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( damp != 1 )
|
|
||||||
{
|
|
||||||
|
|
||||||
VectorScale( pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin );
|
|
||||||
VectorScale( pTemp->entity.angles, 0.9, pTemp->entity.angles );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ( (pTemp->flags & FTENT_FLICKER) && gTempEntFrame == pTemp->entity.curstate.effects )
|
|
||||||
{
|
|
||||||
dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0);
|
|
||||||
VectorCopy (pTemp->entity.origin, dl->origin);
|
|
||||||
dl->radius = 60;
|
|
||||||
dl->color.r = 255;
|
|
||||||
dl->color.g = 120;
|
|
||||||
dl->color.b = 0;
|
|
||||||
dl->die = client_time + 0.01;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_SMOKETRAIL )
|
|
||||||
{
|
|
||||||
gEngfuncs.pEfxAPI->R_RocketTrail (pTemp->entity.prevstate.origin, pTemp->entity.origin, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_GRAVITY )
|
|
||||||
pTemp->entity.baseline.origin[2] += gravity;
|
|
||||||
else if ( pTemp->flags & FTENT_SLOWGRAVITY )
|
|
||||||
pTemp->entity.baseline.origin[2] += gravitySlow;
|
|
||||||
|
|
||||||
if ( pTemp->flags & FTENT_CLIENTCUSTOM )
|
|
||||||
{
|
|
||||||
if ( pTemp->callback )
|
|
||||||
{
|
|
||||||
( *pTemp->callback )( pTemp, frametime, client_time );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cull to PVS (not frustum cull, just PVS)
|
|
||||||
if ( !(pTemp->flags & FTENT_NOMODEL ) )
|
|
||||||
{
|
|
||||||
if ( !Callback_AddVisibleEntity( &pTemp->entity ) )
|
|
||||||
{
|
|
||||||
if ( !(pTemp->flags & FTENT_PERSIST) )
|
|
||||||
{
|
|
||||||
pTemp->die = client_time; // If we can't draw it this frame, just dump it.
|
|
||||||
pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pTemp = pnext;
|
|
||||||
}
|
|
||||||
|
|
||||||
finish:
|
|
||||||
// Restore state info
|
|
||||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
HUD_GetUserEntity
|
|
||||||
|
|
||||||
If you specify negative numbers for beam start and end point entities, then
|
|
||||||
the engine will call back into this function requesting a pointer to a cl_entity_t
|
|
||||||
object that describes the entity to attach the beam onto.
|
|
||||||
|
|
||||||
Indices must start at 1, not zero.
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
cl_entity_t CL_DLLEXPORT *HUD_GetUserEntity( int index )
|
|
||||||
{
|
|
||||||
// RecClGetUserEntity(index);
|
|
||||||
|
|
||||||
#if defined( BEAM_TEST )
|
|
||||||
// None by default, you would return a valic pointer if you create a client side
|
|
||||||
// beam and attach it to a client side entity.
|
|
||||||
if ( index > 0 && index <= 1 )
|
|
||||||
{
|
|
||||||
return &beams[ index ];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,205 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
// shared event functions
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
|
|
||||||
#include "r_efx.h"
|
|
||||||
|
|
||||||
#include "eventscripts.h"
|
|
||||||
#include "event_api.h"
|
|
||||||
#include "pm_shared.h"
|
|
||||||
|
|
||||||
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) )
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
GetEntity
|
|
||||||
|
|
||||||
Return's the requested cl_entity_t
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
struct cl_entity_s *GetEntity( int idx )
|
|
||||||
{
|
|
||||||
return gEngfuncs.GetEntityByIndex( idx );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
GetViewEntity
|
|
||||||
|
|
||||||
Return's the current weapon/view model
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
struct cl_entity_s *GetViewEntity( void )
|
|
||||||
{
|
|
||||||
return gEngfuncs.GetViewModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_CreateTracer
|
|
||||||
|
|
||||||
Creates a tracer effect
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void EV_CreateTracer( float *start, float *end )
|
|
||||||
{
|
|
||||||
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_IsPlayer
|
|
||||||
|
|
||||||
Is the entity's index in the player range?
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
qboolean EV_IsPlayer( int idx )
|
|
||||||
{
|
|
||||||
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_IsLocal
|
|
||||||
|
|
||||||
Is the entity == the local player
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
qboolean EV_IsLocal( int idx )
|
|
||||||
{
|
|
||||||
// check if we are in some way in first person spec mode
|
|
||||||
if ( IS_FIRSTPERSON_SPEC )
|
|
||||||
return (g_iUser2 == idx);
|
|
||||||
else
|
|
||||||
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_GetGunPosition
|
|
||||||
|
|
||||||
Figure out the height of the gun
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
|
||||||
{
|
|
||||||
int idx;
|
|
||||||
vec3_t view_ofs;
|
|
||||||
|
|
||||||
idx = args->entindex;
|
|
||||||
|
|
||||||
VectorClear( view_ofs );
|
|
||||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
|
||||||
|
|
||||||
if ( EV_IsPlayer( idx ) )
|
|
||||||
{
|
|
||||||
// in spec mode use entity viewheigh, not own
|
|
||||||
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
|
|
||||||
{
|
|
||||||
// Grab predicted result for local player
|
|
||||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
|
||||||
}
|
|
||||||
else if ( args->ducking == 1 )
|
|
||||||
{
|
|
||||||
view_ofs[2] = VEC_DUCK_VIEW;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorAdd( origin, view_ofs, pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_EjectBrass
|
|
||||||
|
|
||||||
Bullet shell casings
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
|
||||||
{
|
|
||||||
vec3_t endpos;
|
|
||||||
VectorClear( endpos );
|
|
||||||
endpos[1] = rotation;
|
|
||||||
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, 2.5, model, soundtype );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_GetDefaultShellInfo
|
|
||||||
|
|
||||||
Determine where to eject shells from
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
vec3_t view_ofs;
|
|
||||||
float fR, fU;
|
|
||||||
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
idx = args->entindex;
|
|
||||||
|
|
||||||
VectorClear( view_ofs );
|
|
||||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
|
||||||
|
|
||||||
if ( EV_IsPlayer( idx ) )
|
|
||||||
{
|
|
||||||
if ( EV_IsLocal( idx ) )
|
|
||||||
{
|
|
||||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
|
||||||
}
|
|
||||||
else if ( args->ducking == 1 )
|
|
||||||
{
|
|
||||||
view_ofs[2] = VEC_DUCK_VIEW;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fR = gEngfuncs.pfnRandomFloat( 50, 70 );
|
|
||||||
fU = gEngfuncs.pfnRandomFloat( 100, 150 );
|
|
||||||
|
|
||||||
for ( i = 0; i < 3; i++ )
|
|
||||||
{
|
|
||||||
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
|
|
||||||
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
EV_MuzzleFlash
|
|
||||||
|
|
||||||
Flag weapon/view model for muzzle flash
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void EV_MuzzleFlash( void )
|
|
||||||
{
|
|
||||||
// Add muzzle flash to current weapon model
|
|
||||||
cl_entity_t *ent = GetViewEntity();
|
|
||||||
if ( !ent )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Or in the muzzle flash
|
|
||||||
ent->curstate.effects |= EF_MUZZLEFLASH;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,95 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined ( EV_HLDMH )
|
|
||||||
#define EV_HLDMH
|
|
||||||
|
|
||||||
// bullet types
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
BULLET_NONE = 0,
|
|
||||||
BULLET_PLAYER_9MM, // glock
|
|
||||||
BULLET_PLAYER_MP5, // mp5
|
|
||||||
BULLET_PLAYER_357, // python
|
|
||||||
BULLET_PLAYER_BUCKSHOT, // shotgun
|
|
||||||
BULLET_PLAYER_CROWBAR, // crowbar swipe
|
|
||||||
|
|
||||||
BULLET_MONSTER_9MM,
|
|
||||||
BULLET_MONSTER_MP5,
|
|
||||||
BULLET_MONSTER_12MM,
|
|
||||||
} Bullet;
|
|
||||||
|
|
||||||
enum glock_e {
|
|
||||||
GLOCK_IDLE1 = 0,
|
|
||||||
GLOCK_IDLE2,
|
|
||||||
GLOCK_IDLE3,
|
|
||||||
GLOCK_SHOOT,
|
|
||||||
GLOCK_SHOOT_EMPTY,
|
|
||||||
GLOCK_RELOAD,
|
|
||||||
GLOCK_RELOAD_NOT_EMPTY,
|
|
||||||
GLOCK_DRAW,
|
|
||||||
GLOCK_HOLSTER,
|
|
||||||
GLOCK_ADD_SILENCER
|
|
||||||
};
|
|
||||||
|
|
||||||
enum shotgun_e {
|
|
||||||
SHOTGUN_IDLE = 0,
|
|
||||||
SHOTGUN_FIRE,
|
|
||||||
SHOTGUN_FIRE2,
|
|
||||||
SHOTGUN_RELOAD,
|
|
||||||
SHOTGUN_PUMP,
|
|
||||||
SHOTGUN_START_RELOAD,
|
|
||||||
SHOTGUN_DRAW,
|
|
||||||
SHOTGUN_HOLSTER,
|
|
||||||
SHOTGUN_IDLE4,
|
|
||||||
SHOTGUN_IDLE_DEEP
|
|
||||||
};
|
|
||||||
|
|
||||||
enum mp5_e
|
|
||||||
{
|
|
||||||
MP5_LONGIDLE = 0,
|
|
||||||
MP5_IDLE1,
|
|
||||||
MP5_LAUNCH,
|
|
||||||
MP5_RELOAD,
|
|
||||||
MP5_DEPLOY,
|
|
||||||
MP5_FIRE1,
|
|
||||||
MP5_FIRE2,
|
|
||||||
MP5_FIRE3,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum python_e {
|
|
||||||
PYTHON_IDLE1 = 0,
|
|
||||||
PYTHON_FIDGET,
|
|
||||||
PYTHON_FIRE1,
|
|
||||||
PYTHON_RELOAD,
|
|
||||||
PYTHON_HOLSTER,
|
|
||||||
PYTHON_DRAW,
|
|
||||||
PYTHON_IDLE2,
|
|
||||||
PYTHON_IDLE3
|
|
||||||
};
|
|
||||||
|
|
||||||
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
|
|
||||||
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
|
|
||||||
|
|
||||||
enum gauss_e {
|
|
||||||
GAUSS_IDLE = 0,
|
|
||||||
GAUSS_IDLE2,
|
|
||||||
GAUSS_FIDGET,
|
|
||||||
GAUSS_SPINUP,
|
|
||||||
GAUSS_SPIN,
|
|
||||||
GAUSS_FIRE,
|
|
||||||
GAUSS_FIRE2,
|
|
||||||
GAUSS_HOLSTER,
|
|
||||||
GAUSS_DRAW
|
|
||||||
};
|
|
||||||
|
|
||||||
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
|
|
||||||
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
|
|
||||||
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
|
|
||||||
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
|
|
||||||
|
|
||||||
#endif // EV_HLDMH
|
|
|
@ -1,23 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
|
|
||||||
void Game_HookEvents( void );
|
|
||||||
|
|
||||||
/*
|
|
||||||
===================
|
|
||||||
EV_HookEvents
|
|
||||||
|
|
||||||
See if game specific code wants to hook any events.
|
|
||||||
===================
|
|
||||||
*/
|
|
||||||
void EV_HookEvents( void )
|
|
||||||
{
|
|
||||||
Game_HookEvents();
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// eventscripts.h
|
|
||||||
#if !defined ( EVENTSCRIPTSH )
|
|
||||||
#define EVENTSCRIPTSH
|
|
||||||
|
|
||||||
// defaults for clientinfo messages
|
|
||||||
#define DEFAULT_VIEWHEIGHT 28
|
|
||||||
#define VEC_DUCK_VIEW 12
|
|
||||||
|
|
||||||
#define FTENT_FADEOUT 0x00000080
|
|
||||||
|
|
||||||
#define DMG_GENERIC 0 // generic damage was done
|
|
||||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
|
||||||
#define DMG_BULLET (1 << 1) // shot
|
|
||||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
|
||||||
#define DMG_BURN (1 << 3) // heat burned
|
|
||||||
#define DMG_FREEZE (1 << 4) // frozen
|
|
||||||
#define DMG_FALL (1 << 5) // fell too far
|
|
||||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
|
||||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
|
||||||
#define DMG_SHOCK (1 << 8) // electric shock
|
|
||||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
|
||||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
|
||||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
|
||||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
|
||||||
|
|
||||||
// time-based damage
|
|
||||||
//mask off TF-specific stuff too
|
|
||||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
|
||||||
|
|
||||||
#define DMG_DROWN (1 << 14) // Drowning
|
|
||||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
|
||||||
|
|
||||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
|
||||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
|
||||||
#define DMG_POISON (1 << 17) // blood poisioning
|
|
||||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
|
||||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
|
||||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
|
||||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
|
||||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
|
||||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
|
||||||
|
|
||||||
//TF ADDITIONS
|
|
||||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
|
||||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
|
||||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
|
||||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
|
||||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
|
||||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
|
||||||
|
|
||||||
#define DMG_CALTROP (1<<30)
|
|
||||||
#define DMG_HALLUC (1<<31)
|
|
||||||
|
|
||||||
// Some of these are HL/TFC specific?
|
|
||||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
|
|
||||||
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
|
|
||||||
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
|
|
||||||
qboolean EV_IsLocal( int idx );
|
|
||||||
qboolean EV_IsPlayer( int idx );
|
|
||||||
void EV_CreateTracer( float *start, float *end );
|
|
||||||
|
|
||||||
struct cl_entity_s *GetEntity( int idx );
|
|
||||||
struct cl_entity_s *GetViewEntity( void );
|
|
||||||
void EV_MuzzleFlash( void );
|
|
||||||
|
|
||||||
#endif // EVENTSCRIPTSH
|
|
|
@ -1,149 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// flashlight.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudFlashlight class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(m_Flash, FlashBat)
|
|
||||||
DECLARE_MESSAGE(m_Flash, Flashlight)
|
|
||||||
|
|
||||||
#define BAT_NAME "sprites/%d_Flashlight.spr"
|
|
||||||
|
|
||||||
int CHudFlashlight::Init(void)
|
|
||||||
{
|
|
||||||
m_fFade = 0;
|
|
||||||
m_fOn = 0;
|
|
||||||
|
|
||||||
HOOK_MESSAGE(Flashlight);
|
|
||||||
HOOK_MESSAGE(FlashBat);
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CHudFlashlight::Reset(void)
|
|
||||||
{
|
|
||||||
m_fFade = 0;
|
|
||||||
m_fOn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudFlashlight::VidInit(void)
|
|
||||||
{
|
|
||||||
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
|
|
||||||
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
|
|
||||||
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
|
|
||||||
|
|
||||||
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
|
|
||||||
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
|
|
||||||
m_hBeam = gHUD.GetSprite(HUD_flash_beam);
|
|
||||||
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
|
|
||||||
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
|
|
||||||
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
|
|
||||||
m_iWidth = m_prc2->right - m_prc2->left;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
int x = READ_BYTE();
|
|
||||||
m_iBat = x;
|
|
||||||
m_flBat = ((float)x)/100.0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
m_fOn = READ_BYTE();
|
|
||||||
int x = READ_BYTE();
|
|
||||||
m_iBat = x;
|
|
||||||
m_flBat = ((float)x)/100.0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudFlashlight::Draw(float flTime)
|
|
||||||
{
|
|
||||||
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int r, g, b, x, y, a;
|
|
||||||
wrect_t rc;
|
|
||||||
|
|
||||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (m_fOn)
|
|
||||||
a = 225;
|
|
||||||
else
|
|
||||||
a = MIN_ALPHA;
|
|
||||||
|
|
||||||
if (m_flBat < 0.20)
|
|
||||||
UnpackRGB(r,g,b, RGB_REDISH);
|
|
||||||
else
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
|
|
||||||
ScaleColors(r, g, b, a);
|
|
||||||
|
|
||||||
y = (m_prc1->bottom - m_prc2->top)/2;
|
|
||||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
|
||||||
|
|
||||||
// Draw the flashlight casing
|
|
||||||
SPR_Set(m_hSprite1, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, m_prc1);
|
|
||||||
|
|
||||||
if ( m_fOn )
|
|
||||||
{ // draw the flashlight beam
|
|
||||||
x = ScreenWidth - m_iWidth/2;
|
|
||||||
|
|
||||||
SPR_Set( m_hBeam, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, m_prcBeam );
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw the flashlight energy level
|
|
||||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
|
||||||
int iOffset = m_iWidth * (1.0 - m_flBat);
|
|
||||||
if (iOffset < m_iWidth)
|
|
||||||
{
|
|
||||||
rc = *m_prc2;
|
|
||||||
rc.left += iOffset;
|
|
||||||
|
|
||||||
SPR_Set(m_hSprite2, r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// Geiger.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudAmmo class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(m_Geiger, Geiger )
|
|
||||||
|
|
||||||
int CHudGeiger::Init(void)
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( Geiger );
|
|
||||||
|
|
||||||
m_iGeigerRange = 0;
|
|
||||||
m_iFlags = 0;
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
srand( (unsigned)time( NULL ) );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudGeiger::VidInit(void)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
// update geiger data
|
|
||||||
m_iGeigerRange = READ_BYTE();
|
|
||||||
m_iGeigerRange = m_iGeigerRange << 2;
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudGeiger::Draw (float flTime)
|
|
||||||
{
|
|
||||||
int pct;
|
|
||||||
float flvol;
|
|
||||||
int rg[3];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (m_iGeigerRange <= 800 && m_iGeigerRange > 0)
|
|
||||||
{
|
|
||||||
// peicewise linear is better than continuous formula for this
|
|
||||||
if (m_iGeigerRange > 600)
|
|
||||||
{
|
|
||||||
pct = 2;
|
|
||||||
flvol = 0.4; //Con_Printf ( "range > 600\n");
|
|
||||||
rg[0] = 1;
|
|
||||||
rg[1] = 1;
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 500)
|
|
||||||
{
|
|
||||||
pct = 4;
|
|
||||||
flvol = 0.5; //Con_Printf ( "range > 500\n");
|
|
||||||
rg[0] = 1;
|
|
||||||
rg[1] = 2;
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 400)
|
|
||||||
{
|
|
||||||
pct = 8;
|
|
||||||
flvol = 0.6; //Con_Printf ( "range > 400\n");
|
|
||||||
rg[0] = 1;
|
|
||||||
rg[1] = 2;
|
|
||||||
rg[2] = 3;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 300)
|
|
||||||
{
|
|
||||||
pct = 8;
|
|
||||||
flvol = 0.7; //Con_Printf ( "range > 300\n");
|
|
||||||
rg[0] = 2;
|
|
||||||
rg[1] = 3;
|
|
||||||
rg[2] = 4;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 200)
|
|
||||||
{
|
|
||||||
pct = 28;
|
|
||||||
flvol = 0.78; //Con_Printf ( "range > 200\n");
|
|
||||||
rg[0] = 2;
|
|
||||||
rg[1] = 3;
|
|
||||||
rg[2] = 4;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 150)
|
|
||||||
{
|
|
||||||
pct = 40;
|
|
||||||
flvol = 0.80; //Con_Printf ( "range > 150\n");
|
|
||||||
rg[0] = 3;
|
|
||||||
rg[1] = 4;
|
|
||||||
rg[2] = 5;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 100)
|
|
||||||
{
|
|
||||||
pct = 60;
|
|
||||||
flvol = 0.85; //Con_Printf ( "range > 100\n");
|
|
||||||
rg[0] = 3;
|
|
||||||
rg[1] = 4;
|
|
||||||
rg[2] = 5;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 75)
|
|
||||||
{
|
|
||||||
pct = 80;
|
|
||||||
flvol = 0.9; //Con_Printf ( "range > 75\n");
|
|
||||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
|
||||||
rg[0] = 4;
|
|
||||||
rg[1] = 5;
|
|
||||||
rg[2] = 6;
|
|
||||||
i = 3;
|
|
||||||
}
|
|
||||||
else if (m_iGeigerRange > 50)
|
|
||||||
{
|
|
||||||
pct = 90;
|
|
||||||
flvol = 0.95; //Con_Printf ( "range > 50\n");
|
|
||||||
rg[0] = 5;
|
|
||||||
rg[1] = 6;
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pct = 95;
|
|
||||||
flvol = 1.0; //Con_Printf ( "range < 50\n");
|
|
||||||
rg[0] = 5;
|
|
||||||
rg[1] = 6;
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
|
|
||||||
|
|
||||||
if ((rand() & 127) < pct || (rand() & 127) < pct)
|
|
||||||
{
|
|
||||||
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
|
|
||||||
char sz[256];
|
|
||||||
|
|
||||||
int j = rand() & 1;
|
|
||||||
if (i > 2)
|
|
||||||
j += rand() & 1;
|
|
||||||
|
|
||||||
sprintf(sz, "player/geiger%d.wav", j + 1);
|
|
||||||
PlaySound(sz, flvol);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
#ifndef GLOBALCONSTS_H
|
|
||||||
#define GLOBALCONSTS_H
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MAX_PLAYERS = 64,
|
|
||||||
MAX_TEAMS = 64,
|
|
||||||
MAX_TEAM_NAME = 16,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAX_SCORES 10
|
|
||||||
#define MAX_SCOREBOARD_TEAMS 5
|
|
||||||
|
|
||||||
#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2))
|
|
||||||
|
|
||||||
#define MAX_SERVERNAME_LENGTH 64
|
|
||||||
#define MAX_TEAMNAME_SIZE 32
|
|
||||||
|
|
||||||
#endif // GLOBALCONSTS_H
|
|
|
@ -1,473 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// Health.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudHealth class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(m_Health, Health )
|
|
||||||
DECLARE_MESSAGE(m_Health, Damage )
|
|
||||||
|
|
||||||
#define PAIN_NAME "sprites/%d_pain.spr"
|
|
||||||
#define DAMAGE_NAME "sprites/%d_dmg.spr"
|
|
||||||
|
|
||||||
int giDmgHeight, giDmgWidth;
|
|
||||||
|
|
||||||
int giDmgFlags[NUM_DMG_TYPES] =
|
|
||||||
{
|
|
||||||
DMG_POISON,
|
|
||||||
DMG_ACID,
|
|
||||||
DMG_FREEZE|DMG_SLOWFREEZE,
|
|
||||||
DMG_DROWN,
|
|
||||||
DMG_BURN|DMG_SLOWBURN,
|
|
||||||
DMG_NERVEGAS,
|
|
||||||
DMG_RADIATION,
|
|
||||||
DMG_SHOCK,
|
|
||||||
DMG_CALTROP,
|
|
||||||
DMG_TRANQ,
|
|
||||||
DMG_CONCUSS,
|
|
||||||
DMG_HALLUC
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudHealth::Init(void)
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE(Health);
|
|
||||||
HOOK_MESSAGE(Damage);
|
|
||||||
m_iHealth = 100;
|
|
||||||
m_fFade = 0;
|
|
||||||
m_iFlags = 0;
|
|
||||||
m_bitsDamage = 0;
|
|
||||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
|
||||||
giDmgHeight = 0;
|
|
||||||
giDmgWidth = 0;
|
|
||||||
|
|
||||||
memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES);
|
|
||||||
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudHealth::Reset( void )
|
|
||||||
{
|
|
||||||
// make sure the pain compass is cleared when the player respawns
|
|
||||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// force all the flashing damage icons to expire
|
|
||||||
m_bitsDamage = 0;
|
|
||||||
for ( int i = 0; i < NUM_DMG_TYPES; i++ )
|
|
||||||
{
|
|
||||||
m_dmg[i].fExpire = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudHealth::VidInit(void)
|
|
||||||
{
|
|
||||||
m_hSprite = 0;
|
|
||||||
|
|
||||||
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
|
|
||||||
m_HUD_cross = gHUD.GetSpriteIndex( "cross" );
|
|
||||||
|
|
||||||
giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left;
|
|
||||||
giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
// TODO: update local health data
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
int x = READ_BYTE();
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
// Only update the fade if we've changed health
|
|
||||||
if (x != m_iHealth)
|
|
||||||
{
|
|
||||||
m_fFade = FADE_TIME;
|
|
||||||
m_iHealth = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int armor = READ_BYTE(); // armor
|
|
||||||
int damageTaken = READ_BYTE(); // health
|
|
||||||
long bitsDamage = READ_LONG(); // damage bits
|
|
||||||
|
|
||||||
vec3_t vecFrom;
|
|
||||||
|
|
||||||
for ( int i = 0 ; i < 3 ; i++)
|
|
||||||
vecFrom[i] = READ_COORD();
|
|
||||||
|
|
||||||
UpdateTiles(gHUD.m_flTime, bitsDamage);
|
|
||||||
|
|
||||||
// Actually took damage?
|
|
||||||
if ( damageTaken > 0 || armor > 0 )
|
|
||||||
CalcDamageDirection(vecFrom);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns back a color from the
|
|
||||||
// Green <-> Yellow <-> Red ramp
|
|
||||||
void CHudHealth::GetPainColor( int &r, int &g, int &b )
|
|
||||||
{
|
|
||||||
int iHealth = m_iHealth;
|
|
||||||
|
|
||||||
if (iHealth > 25)
|
|
||||||
iHealth -= 25;
|
|
||||||
else if ( iHealth < 0 )
|
|
||||||
iHealth = 0;
|
|
||||||
#if 0
|
|
||||||
g = iHealth * 255 / 100;
|
|
||||||
r = 255 - g;
|
|
||||||
b = 0;
|
|
||||||
#else
|
|
||||||
if (m_iHealth > 25)
|
|
||||||
{
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 250;
|
|
||||||
g = 0;
|
|
||||||
b = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudHealth::Draw(float flTime)
|
|
||||||
{
|
|
||||||
int r, g, b;
|
|
||||||
int a = 0, x, y;
|
|
||||||
int HealthWidth;
|
|
||||||
|
|
||||||
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ( !m_hSprite )
|
|
||||||
m_hSprite = LoadSprite(PAIN_NAME);
|
|
||||||
|
|
||||||
// Has health changed? Flash the health #
|
|
||||||
if (m_fFade)
|
|
||||||
{
|
|
||||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
|
||||||
if (m_fFade <= 0)
|
|
||||||
{
|
|
||||||
a = MIN_ALPHA;
|
|
||||||
m_fFade = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fade the health number back to dim
|
|
||||||
|
|
||||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
a = MIN_ALPHA;
|
|
||||||
|
|
||||||
// If health is getting low, make it bright red
|
|
||||||
if (m_iHealth <= 15)
|
|
||||||
a = 255;
|
|
||||||
|
|
||||||
GetPainColor( r, g, b );
|
|
||||||
ScaleColors(r, g, b, a );
|
|
||||||
|
|
||||||
// Only draw health if we have the suit.
|
|
||||||
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
|
|
||||||
{
|
|
||||||
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
|
||||||
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
|
|
||||||
|
|
||||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
|
||||||
x = CrossWidth /2;
|
|
||||||
|
|
||||||
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
|
|
||||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
|
|
||||||
|
|
||||||
x = CrossWidth + HealthWidth / 2;
|
|
||||||
|
|
||||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
|
|
||||||
|
|
||||||
x += HealthWidth/2;
|
|
||||||
|
|
||||||
int iHeight = gHUD.m_iFontHeight;
|
|
||||||
int iWidth = HealthWidth/10;
|
|
||||||
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawDamage(flTime);
|
|
||||||
return DrawPain(flTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
|
|
||||||
{
|
|
||||||
vec3_t forward, right, up;
|
|
||||||
float side, front;
|
|
||||||
vec3_t vecOrigin, vecAngles;
|
|
||||||
|
|
||||||
if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2])
|
|
||||||
{
|
|
||||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t));
|
|
||||||
memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t));
|
|
||||||
|
|
||||||
|
|
||||||
VectorSubtract (vecFrom, vecOrigin, vecFrom);
|
|
||||||
|
|
||||||
float flDistToTarget = vecFrom.Length();
|
|
||||||
|
|
||||||
vecFrom = vecFrom.Normalize();
|
|
||||||
AngleVectors (vecAngles, forward, right, up);
|
|
||||||
|
|
||||||
front = DotProduct (vecFrom, right);
|
|
||||||
side = DotProduct (vecFrom, forward);
|
|
||||||
|
|
||||||
if (flDistToTarget <= 50)
|
|
||||||
{
|
|
||||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (side > 0)
|
|
||||||
{
|
|
||||||
if (side > 0.3)
|
|
||||||
m_fAttackFront = max(m_fAttackFront, side);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f = fabs(side);
|
|
||||||
if (f > 0.3)
|
|
||||||
m_fAttackRear = max(m_fAttackRear, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (front > 0)
|
|
||||||
{
|
|
||||||
if (front > 0.3)
|
|
||||||
m_fAttackRight = max(m_fAttackRight, front);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f = fabs(front);
|
|
||||||
if (f > 0.3)
|
|
||||||
m_fAttackLeft = max(m_fAttackLeft, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudHealth::DrawPain(float flTime)
|
|
||||||
{
|
|
||||||
if (!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int r, g, b;
|
|
||||||
int x, y, a, shade;
|
|
||||||
|
|
||||||
// TODO: get the shift value of the health
|
|
||||||
a = 255; // max brightness until then
|
|
||||||
|
|
||||||
float fFade = gHUD.m_flTimeDelta * 2;
|
|
||||||
|
|
||||||
// SPR_Draw top
|
|
||||||
if (m_fAttackFront > 0.4)
|
|
||||||
{
|
|
||||||
GetPainColor(r,g,b);
|
|
||||||
shade = a * max( m_fAttackFront, 0.5 );
|
|
||||||
ScaleColors(r, g, b, shade);
|
|
||||||
SPR_Set(m_hSprite, r, g, b );
|
|
||||||
|
|
||||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
|
|
||||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3;
|
|
||||||
SPR_DrawAdditive(0, x, y, NULL);
|
|
||||||
m_fAttackFront = max( 0, m_fAttackFront - fFade );
|
|
||||||
} else
|
|
||||||
m_fAttackFront = 0;
|
|
||||||
|
|
||||||
if (m_fAttackRight > 0.4)
|
|
||||||
{
|
|
||||||
GetPainColor(r,g,b);
|
|
||||||
shade = a * max( m_fAttackRight, 0.5 );
|
|
||||||
ScaleColors(r, g, b, shade);
|
|
||||||
SPR_Set(m_hSprite, r, g, b );
|
|
||||||
|
|
||||||
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
|
|
||||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2;
|
|
||||||
SPR_DrawAdditive(1, x, y, NULL);
|
|
||||||
m_fAttackRight = max( 0, m_fAttackRight - fFade );
|
|
||||||
} else
|
|
||||||
m_fAttackRight = 0;
|
|
||||||
|
|
||||||
if (m_fAttackRear > 0.4)
|
|
||||||
{
|
|
||||||
GetPainColor(r,g,b);
|
|
||||||
shade = a * max( m_fAttackRear, 0.5 );
|
|
||||||
ScaleColors(r, g, b, shade);
|
|
||||||
SPR_Set(m_hSprite, r, g, b );
|
|
||||||
|
|
||||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
|
|
||||||
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2;
|
|
||||||
SPR_DrawAdditive(2, x, y, NULL);
|
|
||||||
m_fAttackRear = max( 0, m_fAttackRear - fFade );
|
|
||||||
} else
|
|
||||||
m_fAttackRear = 0;
|
|
||||||
|
|
||||||
if (m_fAttackLeft > 0.4)
|
|
||||||
{
|
|
||||||
GetPainColor(r,g,b);
|
|
||||||
shade = a * max( m_fAttackLeft, 0.5 );
|
|
||||||
ScaleColors(r, g, b, shade);
|
|
||||||
SPR_Set(m_hSprite, r, g, b );
|
|
||||||
|
|
||||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
|
|
||||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2;
|
|
||||||
SPR_DrawAdditive(3, x, y, NULL);
|
|
||||||
|
|
||||||
m_fAttackLeft = max( 0, m_fAttackLeft - fFade );
|
|
||||||
} else
|
|
||||||
m_fAttackLeft = 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudHealth::DrawDamage(float flTime)
|
|
||||||
{
|
|
||||||
int r, g, b, a;
|
|
||||||
DAMAGE_IMAGE *pdmg;
|
|
||||||
|
|
||||||
if (!m_bitsDamage)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
|
|
||||||
a = (int)( fabs(sin(flTime*2)) * 256.0);
|
|
||||||
|
|
||||||
ScaleColors(r, g, b, a);
|
|
||||||
|
|
||||||
// Draw all the items
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < NUM_DMG_TYPES; i++)
|
|
||||||
{
|
|
||||||
if (m_bitsDamage & giDmgFlags[i])
|
|
||||||
{
|
|
||||||
pdmg = &m_dmg[i];
|
|
||||||
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
|
|
||||||
SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// check for bits that should be expired
|
|
||||||
for ( i = 0; i < NUM_DMG_TYPES; i++ )
|
|
||||||
{
|
|
||||||
DAMAGE_IMAGE *pdmg = &m_dmg[i];
|
|
||||||
|
|
||||||
if ( m_bitsDamage & giDmgFlags[i] )
|
|
||||||
{
|
|
||||||
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
|
|
||||||
|
|
||||||
if ( pdmg->fExpire <= flTime // when the time has expired
|
|
||||||
&& a < 40 ) // and the flash is at the low point of the cycle
|
|
||||||
{
|
|
||||||
pdmg->fExpire = 0;
|
|
||||||
|
|
||||||
int y = pdmg->y;
|
|
||||||
pdmg->x = pdmg->y = 0;
|
|
||||||
|
|
||||||
// move everyone above down
|
|
||||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
|
||||||
{
|
|
||||||
pdmg = &m_dmg[j];
|
|
||||||
if ((pdmg->y) && (pdmg->y < y))
|
|
||||||
pdmg->y += giDmgHeight;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bitsDamage &= ~giDmgFlags[i]; // clear the bits
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
|
|
||||||
{
|
|
||||||
DAMAGE_IMAGE *pdmg;
|
|
||||||
|
|
||||||
// Which types are new?
|
|
||||||
long bitsOn = ~m_bitsDamage & bitsDamage;
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_DMG_TYPES; i++)
|
|
||||||
{
|
|
||||||
pdmg = &m_dmg[i];
|
|
||||||
|
|
||||||
// Is this one already on?
|
|
||||||
if (m_bitsDamage & giDmgFlags[i])
|
|
||||||
{
|
|
||||||
pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration
|
|
||||||
if (!pdmg->fBaseline)
|
|
||||||
pdmg->fBaseline = flTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are we just turning it on?
|
|
||||||
if (bitsOn & giDmgFlags[i])
|
|
||||||
{
|
|
||||||
// put this one at the bottom
|
|
||||||
pdmg->x = giDmgWidth/8;
|
|
||||||
pdmg->y = ScreenHeight - giDmgHeight * 2;
|
|
||||||
pdmg->fExpire=flTime + DMG_IMAGE_LIFE;
|
|
||||||
|
|
||||||
// move everyone else up
|
|
||||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
|
||||||
{
|
|
||||||
if (j == i)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
pdmg = &m_dmg[j];
|
|
||||||
if (pdmg->y)
|
|
||||||
pdmg->y -= giDmgHeight;
|
|
||||||
|
|
||||||
}
|
|
||||||
pdmg = &m_dmg[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// damage bits are only turned on here; they are turned off when the draw time has expired (in DrawDamage())
|
|
||||||
m_bitsDamage |= bitsDamage;
|
|
||||||
}
|
|
|
@ -1,127 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
|
||||||
|
|
||||||
#define DMG_IMAGE_POISON 0
|
|
||||||
#define DMG_IMAGE_ACID 1
|
|
||||||
#define DMG_IMAGE_COLD 2
|
|
||||||
#define DMG_IMAGE_DROWN 3
|
|
||||||
#define DMG_IMAGE_BURN 4
|
|
||||||
#define DMG_IMAGE_NERVE 5
|
|
||||||
#define DMG_IMAGE_RAD 6
|
|
||||||
#define DMG_IMAGE_SHOCK 7
|
|
||||||
//tf defines
|
|
||||||
#define DMG_IMAGE_CALTROP 8
|
|
||||||
#define DMG_IMAGE_TRANQ 9
|
|
||||||
#define DMG_IMAGE_CONCUSS 10
|
|
||||||
#define DMG_IMAGE_HALLUC 11
|
|
||||||
#define NUM_DMG_TYPES 12
|
|
||||||
// instant damage
|
|
||||||
|
|
||||||
#define DMG_GENERIC 0 // generic damage was done
|
|
||||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
|
||||||
#define DMG_BULLET (1 << 1) // shot
|
|
||||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
|
||||||
#define DMG_BURN (1 << 3) // heat burned
|
|
||||||
#define DMG_FREEZE (1 << 4) // frozen
|
|
||||||
#define DMG_FALL (1 << 5) // fell too far
|
|
||||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
|
||||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
|
||||||
#define DMG_SHOCK (1 << 8) // electric shock
|
|
||||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
|
||||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
|
||||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
|
||||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
|
||||||
|
|
||||||
|
|
||||||
// time-based damage
|
|
||||||
//mask off TF-specific stuff too
|
|
||||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
|
||||||
|
|
||||||
|
|
||||||
#define DMG_DROWN (1 << 14) // Drowning
|
|
||||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
|
||||||
|
|
||||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
|
||||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
|
||||||
#define DMG_POISON (1 << 17) // blood poisioning
|
|
||||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
|
||||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
|
||||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
|
||||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
|
||||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
|
||||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
|
||||||
|
|
||||||
//TF ADDITIONS
|
|
||||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
|
||||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
|
||||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
|
||||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
|
||||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
|
||||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
|
||||||
|
|
||||||
#define DMG_CALTROP (1<<30)
|
|
||||||
#define DMG_HALLUC (1<<31)
|
|
||||||
|
|
||||||
// TF Healing Additions for TakeHealth
|
|
||||||
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
|
|
||||||
// TF Redefines since we never use the originals
|
|
||||||
#define DMG_NAIL DMG_SLASH
|
|
||||||
#define DMG_NOT_SELF DMG_FREEZE
|
|
||||||
|
|
||||||
|
|
||||||
#define DMG_TRANQ DMG_MORTAR
|
|
||||||
#define DMG_CONCUSS DMG_SONIC
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
float fExpire;
|
|
||||||
float fBaseline;
|
|
||||||
int x, y;
|
|
||||||
} DAMAGE_IMAGE;
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudHealth: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int Init( void );
|
|
||||||
virtual int VidInit( void );
|
|
||||||
virtual int Draw(float fTime);
|
|
||||||
virtual void Reset( void );
|
|
||||||
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int m_iHealth;
|
|
||||||
int m_HUD_dmg_bio;
|
|
||||||
int m_HUD_cross;
|
|
||||||
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
|
|
||||||
void GetPainColor( int &r, int &g, int &b );
|
|
||||||
float m_fFade;
|
|
||||||
|
|
||||||
private:
|
|
||||||
HSPRITE m_hSprite;
|
|
||||||
HSPRITE m_hDamage;
|
|
||||||
|
|
||||||
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
|
|
||||||
int m_bitsDamage;
|
|
||||||
int DrawPain(float fTime);
|
|
||||||
int DrawDamage(float fTime);
|
|
||||||
void CalcDamageDirection(vec3_t vecFrom);
|
|
||||||
void UpdateTiles(float fTime, long bits);
|
|
||||||
};
|
|
|
@ -1,348 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
This file contains "stubs" of class member implementations so that we can predict certain
|
|
||||||
weapons client side. From time to time you might find that you need to implement part of the
|
|
||||||
these functions. If so, cut it from here, paste it in hl_weapons.cpp or somewhere else and
|
|
||||||
add in the functionality you need.
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
#include "extdll.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "cbase.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "weapons.h"
|
|
||||||
#include "nodes.h"
|
|
||||||
#include "soundent.h"
|
|
||||||
#include "skill.h"
|
|
||||||
|
|
||||||
// Globals used by game logic
|
|
||||||
const Vector g_vecZero = Vector( 0, 0, 0 );
|
|
||||||
int gmsgWeapPickup = 0;
|
|
||||||
enginefuncs_t g_engfuncs;
|
|
||||||
globalvars_t *gpGlobals;
|
|
||||||
|
|
||||||
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
|
|
||||||
|
|
||||||
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { }
|
|
||||||
|
|
||||||
// CBaseEntity Stubs
|
|
||||||
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; }
|
|
||||||
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { return 1; }
|
|
||||||
CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; }
|
|
||||||
int CBaseEntity::Save( CSave &save ) { return 1; }
|
|
||||||
int CBaseEntity::Restore( CRestore &restore ) { return 1; }
|
|
||||||
void CBaseEntity::SetObjectCollisionBox( void ) { }
|
|
||||||
int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; }
|
|
||||||
void CBaseEntity :: MakeDormant( void ) { }
|
|
||||||
int CBaseEntity :: IsDormant( void ) { return 0; }
|
|
||||||
BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; }
|
|
||||||
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; }
|
|
||||||
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; }
|
|
||||||
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
|
|
||||||
void CBaseEntity::SUB_Remove( void ) { }
|
|
||||||
|
|
||||||
// CBaseDelay Stubs
|
|
||||||
void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { }
|
|
||||||
int CBaseDelay::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBaseDelay::Save( class CSave & ) { return 1; }
|
|
||||||
|
|
||||||
// CBaseAnimating Stubs
|
|
||||||
int CBaseAnimating::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBaseAnimating::Save( class CSave & ) { return 1; }
|
|
||||||
|
|
||||||
// DEBUG Stubs
|
|
||||||
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; }
|
|
||||||
void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { }
|
|
||||||
|
|
||||||
// UTIL_* Stubs
|
|
||||||
void UTIL_PrecacheOther( const char *szClassname ) { }
|
|
||||||
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { }
|
|
||||||
void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
|
||||||
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
|
||||||
void UTIL_MakeVectors( const Vector &vecAngles ) { }
|
|
||||||
BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; }
|
|
||||||
void UTIL_SetOrigin( entvars_t *, const Vector &org ) { }
|
|
||||||
BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; }
|
|
||||||
void UTIL_LogPrintf(char *,...) { }
|
|
||||||
void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { }
|
|
||||||
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { }
|
|
||||||
|
|
||||||
// CBaseToggle Stubs
|
|
||||||
int CBaseToggle::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBaseToggle::Save( class CSave & ) { return 1; }
|
|
||||||
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
|
|
||||||
|
|
||||||
// CGrenade Stubs
|
|
||||||
void CGrenade::BounceSound( void ) { }
|
|
||||||
void CGrenade::Explode( Vector, Vector ) { }
|
|
||||||
void CGrenade::Explode( TraceResult *, int ) { }
|
|
||||||
void CGrenade::Killed( entvars_t *, int ) { }
|
|
||||||
void CGrenade::Spawn( void ) { }
|
|
||||||
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; }
|
|
||||||
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ){ return 0; }
|
|
||||||
void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ){ }
|
|
||||||
|
|
||||||
void UTIL_Remove( CBaseEntity *pEntity ){ }
|
|
||||||
struct skilldata_t gSkillData;
|
|
||||||
void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ){ }
|
|
||||||
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ){ return 0;}
|
|
||||||
|
|
||||||
Vector UTIL_VecToAngles( const Vector &vec ){ return 0; }
|
|
||||||
CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ) { return 0; }
|
|
||||||
void CBeam::PointEntInit( const Vector &start, int endIndex ) { }
|
|
||||||
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; }
|
|
||||||
void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { }
|
|
||||||
|
|
||||||
|
|
||||||
CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; }
|
|
||||||
void CBaseMonster :: Eat ( float flFullDuration ) { }
|
|
||||||
BOOL CBaseMonster :: FShouldEat ( void ) { return TRUE; }
|
|
||||||
void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
|
|
||||||
void CBaseMonster :: BarnacleVictimReleased ( void ) { }
|
|
||||||
void CBaseMonster :: Listen ( void ) { }
|
|
||||||
float CBaseMonster :: FLSoundVolume ( CSound *pSound ) { return 0.0; }
|
|
||||||
BOOL CBaseMonster :: FValidateHintType ( short sHint ) { return FALSE; }
|
|
||||||
void CBaseMonster :: Look ( int iDistance ) { }
|
|
||||||
int CBaseMonster :: ISoundMask ( void ) { return 0; }
|
|
||||||
CSound* CBaseMonster :: PBestSound ( void ) { return NULL; }
|
|
||||||
CSound* CBaseMonster :: PBestScent ( void ) { return NULL; }
|
|
||||||
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
|
|
||||||
void CBaseMonster :: MonsterThink ( void ) { }
|
|
||||||
void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { }
|
|
||||||
int CBaseMonster :: IgnoreConditions ( void ) { return 0; }
|
|
||||||
void CBaseMonster :: RouteClear ( void ) { }
|
|
||||||
void CBaseMonster :: RouteNew ( void ) { }
|
|
||||||
BOOL CBaseMonster :: FRouteClear ( void ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: FRefreshRoute ( void ) { return 0; }
|
|
||||||
BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; }
|
|
||||||
int ShouldSimplify( int routeType ) { return TRUE; }
|
|
||||||
void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) { }
|
|
||||||
BOOL CBaseMonster :: FBecomeProne ( void ) { return TRUE; }
|
|
||||||
BOOL CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) { return FALSE; }
|
|
||||||
void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) { }
|
|
||||||
BOOL CBaseMonster :: FCanCheckAttacks ( void ) { return FALSE; }
|
|
||||||
int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) { return 0; }
|
|
||||||
void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { }
|
|
||||||
BOOL CBaseMonster :: PopEnemy( ) { return FALSE; }
|
|
||||||
void CBaseMonster :: SetActivity ( Activity NewActivity ) { }
|
|
||||||
void CBaseMonster :: SetSequenceByName ( char *szSequence ) { }
|
|
||||||
int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; }
|
|
||||||
float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; }
|
|
||||||
void CBaseMonster :: AdvanceRoute ( float distance ) { }
|
|
||||||
int CBaseMonster :: RouteClassify( int iMoveFlag ) { return 0; }
|
|
||||||
BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return FALSE; }
|
|
||||||
void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) { }
|
|
||||||
BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return FALSE; }
|
|
||||||
void CBaseMonster :: Move ( float flInterval ) { }
|
|
||||||
BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) { return FALSE; }
|
|
||||||
void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { }
|
|
||||||
void CBaseMonster :: MonsterInit ( void ) { }
|
|
||||||
void CBaseMonster :: MonsterInitThink ( void ) { }
|
|
||||||
void CBaseMonster :: StartMonster ( void ) { }
|
|
||||||
void CBaseMonster :: MovementComplete( void ) { }
|
|
||||||
int CBaseMonster::TaskIsRunning( void ) { return 0; }
|
|
||||||
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; }
|
|
||||||
BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; }
|
|
||||||
CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) { return NULL; }
|
|
||||||
BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return FALSE; }
|
|
||||||
BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return FALSE; }
|
|
||||||
BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return FALSE; }
|
|
||||||
void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { }
|
|
||||||
float CBaseMonster::FlYawDiff ( void ) { return 0.0; }
|
|
||||||
float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; }
|
|
||||||
float CBaseMonster::VecToYaw ( Vector vecDir ) { return 0.0; }
|
|
||||||
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
|
|
||||||
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
|
|
||||||
void CBaseMonster :: SetEyePosition ( void ) { }
|
|
||||||
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
|
|
||||||
void CBaseAnimating :: ResetSequenceInfo ( ) { }
|
|
||||||
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
|
|
||||||
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
|
|
||||||
void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { }
|
|
||||||
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; }
|
|
||||||
void CBaseAnimating :: InitBoneControllers ( void ) { }
|
|
||||||
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; }
|
|
||||||
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { }
|
|
||||||
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { }
|
|
||||||
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
|
|
||||||
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
|
|
||||||
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { }
|
|
||||||
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; }
|
|
||||||
Vector CBaseMonster :: GetGunPosition( void ) { return g_vecZero; }
|
|
||||||
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
|
|
||||||
void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { }
|
|
||||||
void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { }
|
|
||||||
void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { }
|
|
||||||
BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) { return TRUE; }
|
|
||||||
int CBaseMonster :: FindHintNode ( void ) { return NO_NODE; }
|
|
||||||
void CBaseMonster::ReportAIState( void ) { }
|
|
||||||
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { }
|
|
||||||
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; }
|
|
||||||
int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ) { return FALSE; }
|
|
||||||
Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; }
|
|
||||||
BOOL CBaseMonster :: FacingIdeal( void ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: FCanActiveIdle ( void ) { return FALSE; }
|
|
||||||
void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { }
|
|
||||||
void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { }
|
|
||||||
void CBaseMonster::SentenceStop( void ) { }
|
|
||||||
void CBaseMonster::CorpseFallThink( void ) { }
|
|
||||||
void CBaseMonster :: MonsterInitDead( void ) { }
|
|
||||||
BOOL CBaseMonster :: BBoxFlat ( void ) { return TRUE; }
|
|
||||||
BOOL CBaseMonster :: GetEnemy ( void ) { return FALSE; }
|
|
||||||
void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
|
|
||||||
CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; }
|
|
||||||
BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; }
|
|
||||||
void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
|
|
||||||
void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
|
|
||||||
void CBaseMonster::FadeMonster( void ) { }
|
|
||||||
void CBaseMonster :: GibMonster( void ) { }
|
|
||||||
BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; }
|
|
||||||
BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; }
|
|
||||||
Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; }
|
|
||||||
MONSTERSTATE CBaseMonster :: GetIdealState ( void ) { return MONSTERSTATE_ALERT; }
|
|
||||||
Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) { return NULL; }
|
|
||||||
Schedule_t *CBaseMonster :: GetSchedule ( void ) { return NULL; }
|
|
||||||
void CBaseMonster :: RunTask ( Task_t *pTask ) { }
|
|
||||||
void CBaseMonster :: StartTask ( Task_t *pTask ) { }
|
|
||||||
Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { return NULL;}
|
|
||||||
void CBaseMonster::BecomeDead( void ) {}
|
|
||||||
void CBaseMonster :: RunAI ( void ) {}
|
|
||||||
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {}
|
|
||||||
int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; }
|
|
||||||
int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
|
|
||||||
int CBaseMonster::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBaseMonster::Save( class CSave & ) { return 1; }
|
|
||||||
|
|
||||||
int TrainSpeed(int iSpeed, int iMax) { return 0; }
|
|
||||||
void CBasePlayer :: DeathSound( void ) { }
|
|
||||||
int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; }
|
|
||||||
void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
|
|
||||||
int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
|
|
||||||
void CBasePlayer::PackDeadPlayerItems( void ) { }
|
|
||||||
void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { }
|
|
||||||
void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { }
|
|
||||||
void CBasePlayer::WaterMove() { }
|
|
||||||
BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; }
|
|
||||||
void CBasePlayer::PlayerDeathThink(void) { }
|
|
||||||
void CBasePlayer::StartDeathCam( void ) { }
|
|
||||||
void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { }
|
|
||||||
void CBasePlayer::PlayerUse ( void ) { }
|
|
||||||
void CBasePlayer::Jump() { }
|
|
||||||
void CBasePlayer::Duck( ) { }
|
|
||||||
int CBasePlayer::Classify ( void ) { return 0; }
|
|
||||||
void CBasePlayer::PreThink(void) { }
|
|
||||||
void CBasePlayer::CheckTimeBasedDamage() { }
|
|
||||||
void CBasePlayer :: UpdateGeigerCounter( void ) { }
|
|
||||||
void CBasePlayer::CheckSuitUpdate() { }
|
|
||||||
void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { }
|
|
||||||
void CBasePlayer :: UpdatePlayerSound ( void ) { }
|
|
||||||
void CBasePlayer::PostThink() { }
|
|
||||||
void CBasePlayer :: Precache( void ) { }
|
|
||||||
int CBasePlayer::Save( CSave &save ) { return 0; }
|
|
||||||
void CBasePlayer::RenewItems(void) { }
|
|
||||||
int CBasePlayer::Restore( CRestore &restore ) { return 0; }
|
|
||||||
void CBasePlayer::SelectNextItem( int iItem ) { }
|
|
||||||
BOOL CBasePlayer::HasWeapons( void ) { return FALSE; }
|
|
||||||
void CBasePlayer::SelectPrevItem( int iItem ) { }
|
|
||||||
CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; }
|
|
||||||
BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; }
|
|
||||||
void CBasePlayer :: FlashlightTurnOn( void ) { }
|
|
||||||
void CBasePlayer :: FlashlightTurnOff( void ) { }
|
|
||||||
void CBasePlayer :: ForceClientDllUpdate( void ) { }
|
|
||||||
void CBasePlayer::ImpulseCommands( ) { }
|
|
||||||
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
|
|
||||||
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
|
||||||
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
|
||||||
void CBasePlayer::ItemPreFrame() { }
|
|
||||||
void CBasePlayer::ItemPostFrame() { }
|
|
||||||
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
|
|
||||||
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; }
|
|
||||||
void CBasePlayer::SendAmmoUpdate(void) { }
|
|
||||||
void CBasePlayer :: UpdateClientData( void ) { }
|
|
||||||
BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; }
|
|
||||||
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
|
|
||||||
void CBasePlayer :: BarnacleVictimReleased ( void ) { }
|
|
||||||
int CBasePlayer :: Illumination( void ) { return 0; }
|
|
||||||
void CBasePlayer :: EnableControl(BOOL fControl) { }
|
|
||||||
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; }
|
|
||||||
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
|
|
||||||
void CBasePlayer :: ResetAutoaim( ) { }
|
|
||||||
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { }
|
|
||||||
int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; }
|
|
||||||
void CBasePlayer::DropPlayerItem ( char *pszItemName ) { }
|
|
||||||
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
|
|
||||||
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
|
|
||||||
Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; }
|
|
||||||
const char *CBasePlayer::TeamID( void ) { return ""; }
|
|
||||||
int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; }
|
|
||||||
void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { }
|
|
||||||
void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { }
|
|
||||||
|
|
||||||
void ClearMultiDamage(void) { }
|
|
||||||
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
|
|
||||||
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
|
|
||||||
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { }
|
|
||||||
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
|
|
||||||
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
|
|
||||||
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
|
|
||||||
void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { }
|
|
||||||
int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBasePlayerItem::Save( class CSave & ) { return 1; }
|
|
||||||
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
|
|
||||||
int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
|
|
||||||
float CBasePlayerWeapon::GetNextAttackDelay( float flTime ) { return flTime; }
|
|
||||||
void CBasePlayerItem :: SetObjectCollisionBox( void ) { }
|
|
||||||
void CBasePlayerItem :: FallInit( void ) { }
|
|
||||||
void CBasePlayerItem::FallThink ( void ) { }
|
|
||||||
void CBasePlayerItem::Materialize( void ) { }
|
|
||||||
void CBasePlayerItem::AttemptToMaterialize( void ) { }
|
|
||||||
void CBasePlayerItem :: CheckRespawn ( void ) { }
|
|
||||||
CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; }
|
|
||||||
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
|
|
||||||
void CBasePlayerItem::DestroyItem( void ) { }
|
|
||||||
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; }
|
|
||||||
void CBasePlayerItem::Drop( void ) { }
|
|
||||||
void CBasePlayerItem::Kill( void ) { }
|
|
||||||
void CBasePlayerItem::Holster( int skiplocal ) { }
|
|
||||||
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
|
|
||||||
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
|
|
||||||
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
|
|
||||||
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
|
|
||||||
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
|
|
||||||
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
|
|
||||||
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; }
|
|
||||||
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
|
|
||||||
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
|
|
||||||
void CBasePlayerAmmo::Spawn( void ) { }
|
|
||||||
CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; }
|
|
||||||
void CBasePlayerAmmo::Materialize( void ) { }
|
|
||||||
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { }
|
|
||||||
int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
|
|
||||||
int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
|
|
||||||
void CBasePlayerWeapon::RetireWeapon( void ) { }
|
|
||||||
void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
|
|
||||||
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){}
|
|
|
@ -1,80 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
#include "../hud.h"
|
|
||||||
#include "../cl_util.h"
|
|
||||||
#include "event_api.h"
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
// HLDM
|
|
||||||
void EV_FireGlock1( struct event_args_s *args );
|
|
||||||
void EV_FireGlock2( struct event_args_s *args );
|
|
||||||
void EV_FireShotGunSingle( struct event_args_s *args );
|
|
||||||
void EV_FireShotGunDouble( struct event_args_s *args );
|
|
||||||
void EV_FireMP5( struct event_args_s *args );
|
|
||||||
void EV_FireMP52( struct event_args_s *args );
|
|
||||||
void EV_FirePython( struct event_args_s *args );
|
|
||||||
void EV_FireGauss( struct event_args_s *args );
|
|
||||||
void EV_SpinGauss( struct event_args_s *args );
|
|
||||||
void EV_Crowbar( struct event_args_s *args );
|
|
||||||
void EV_FireCrossbow( struct event_args_s *args );
|
|
||||||
void EV_FireCrossbow2( struct event_args_s *args );
|
|
||||||
void EV_FireRpg( struct event_args_s *args );
|
|
||||||
void EV_EgonFire( struct event_args_s *args );
|
|
||||||
void EV_EgonStop( struct event_args_s *args );
|
|
||||||
void EV_HornetGunFire( struct event_args_s *args );
|
|
||||||
void EV_TripmineFire( struct event_args_s *args );
|
|
||||||
void EV_SnarkFire( struct event_args_s *args );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EV_TrainPitchAdjust( struct event_args_s *args );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
======================
|
|
||||||
Game_HookEvents
|
|
||||||
|
|
||||||
Associate script file name with callback functions. Callback's must be extern "C" so
|
|
||||||
the engine doesn't get confused about name mangling stuff. Note that the format is
|
|
||||||
always the same. Of course, a clever mod team could actually embed parameters, behavior
|
|
||||||
into the actual .sc files and create a .sc file parser and hook their functionality through
|
|
||||||
that.. i.e., a scripting system.
|
|
||||||
|
|
||||||
That was what we were going to do, but we ran out of time...oh well.
|
|
||||||
======================
|
|
||||||
*/
|
|
||||||
void Game_HookEvents( void )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
|
|
||||||
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
#include "../hud.h"
|
|
||||||
#include "../cl_util.h"
|
|
||||||
#include "../demo.h"
|
|
||||||
|
|
||||||
#include "demo_api.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
|
|
||||||
#include "pm_defs.h"
|
|
||||||
#include "event_api.h"
|
|
||||||
#include "entity_types.h"
|
|
||||||
#include "r_efx.h"
|
|
||||||
|
|
||||||
extern BEAM *pBeam;
|
|
||||||
extern BEAM *pBeam2;
|
|
||||||
void HUD_GetLastOrg( float *org );
|
|
||||||
|
|
||||||
void UpdateBeams ( void )
|
|
||||||
{
|
|
||||||
vec3_t forward, vecSrc, vecEnd, origin, angles, right, up;
|
|
||||||
vec3_t view_ofs;
|
|
||||||
pmtrace_t tr;
|
|
||||||
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
|
|
||||||
int idx = pthisplayer->index;
|
|
||||||
|
|
||||||
// Get our exact viewangles from engine
|
|
||||||
gEngfuncs.GetViewAngles( (float *)angles );
|
|
||||||
|
|
||||||
// Determine our last predicted origin
|
|
||||||
HUD_GetLastOrg( (float *)&origin );
|
|
||||||
|
|
||||||
AngleVectors( angles, forward, right, up );
|
|
||||||
|
|
||||||
VectorCopy( origin, vecSrc );
|
|
||||||
|
|
||||||
VectorMA( vecSrc, 2048, forward, vecEnd );
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
|
|
||||||
|
|
||||||
// Store off the old count
|
|
||||||
gEngfuncs.pEventAPI->EV_PushPMStates();
|
|
||||||
|
|
||||||
// Now add in all of the players.
|
|
||||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
|
||||||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
|
|
||||||
|
|
||||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
|
||||||
|
|
||||||
if ( pBeam )
|
|
||||||
{
|
|
||||||
pBeam->target = tr.endpos;
|
|
||||||
pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pBeam2 )
|
|
||||||
{
|
|
||||||
pBeam2->target = tr.endpos;
|
|
||||||
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
Game_AddObjects
|
|
||||||
|
|
||||||
Add game specific, client-side objects here
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
void Game_AddObjects( void )
|
|
||||||
{
|
|
||||||
if ( pBeam && pBeam2 )
|
|
||||||
UpdateBeams();
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,698 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// hud.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHud class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
#include "hud_servers.h"
|
|
||||||
#include "vgui_int.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
#include "demo.h"
|
|
||||||
#include "demo_api.h"
|
|
||||||
#include "vgui_ScorePanel.h"
|
|
||||||
|
|
||||||
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
|
|
||||||
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
|
|
||||||
|
|
||||||
class CHLVoiceStatusHelper : public IVoiceStatusHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void GetPlayerTextColor(int entindex, int color[3])
|
|
||||||
{
|
|
||||||
color[0] = color[1] = color[2] = 255;
|
|
||||||
|
|
||||||
if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) )
|
|
||||||
{
|
|
||||||
int iTeam = g_PlayerExtraInfo[entindex].teamnumber;
|
|
||||||
|
|
||||||
if ( iTeam < 0 )
|
|
||||||
{
|
|
||||||
iTeam = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
iTeam = iTeam % iNumberOfTeamColors;
|
|
||||||
|
|
||||||
color[0] = iTeamColors[iTeam][0];
|
|
||||||
color[1] = iTeamColors[iTeam][1];
|
|
||||||
color[2] = iTeamColors[iTeam][2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void UpdateCursorState()
|
|
||||||
{
|
|
||||||
gViewPort->UpdateCursorState();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int GetAckIconHeight()
|
|
||||||
{
|
|
||||||
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool CanShowSpeakerLabels()
|
|
||||||
{
|
|
||||||
if( gViewPort && gViewPort->m_pScoreBoard )
|
|
||||||
return !gViewPort->m_pScoreBoard->isVisible();
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static CHLVoiceStatusHelper g_VoiceStatusHelper;
|
|
||||||
|
|
||||||
|
|
||||||
extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount);
|
|
||||||
|
|
||||||
extern cvar_t *sensitivity;
|
|
||||||
cvar_t *cl_lw = NULL;
|
|
||||||
|
|
||||||
void ShutdownInput (void);
|
|
||||||
|
|
||||||
//DECLARE_MESSAGE(m_Logo, Logo)
|
|
||||||
int __MsgFunc_Logo(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
return gHUD.MsgFunc_Logo(pszName, iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
//DECLARE_MESSAGE(m_Logo, Logo)
|
|
||||||
int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
return gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_ViewMode(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
return gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_Concuss(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
return gHUD.MsgFunc_Concuss( pszName, iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TFFree Command Menu
|
|
||||||
void __CmdFunc_OpenCommandMenu(void)
|
|
||||||
{
|
|
||||||
if ( gViewPort )
|
|
||||||
{
|
|
||||||
gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TFC "special" command
|
|
||||||
void __CmdFunc_InputPlayerSpecial(void)
|
|
||||||
{
|
|
||||||
if ( gViewPort )
|
|
||||||
{
|
|
||||||
gViewPort->InputPlayerSpecial();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __CmdFunc_CloseCommandMenu(void)
|
|
||||||
{
|
|
||||||
if ( gViewPort )
|
|
||||||
{
|
|
||||||
gViewPort->InputSignalHideCommandMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __CmdFunc_ForceCloseCommandMenu( void )
|
|
||||||
{
|
|
||||||
if ( gViewPort )
|
|
||||||
{
|
|
||||||
gViewPort->HideCommandMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __CmdFunc_ToggleServerBrowser( void )
|
|
||||||
{
|
|
||||||
if ( gViewPort )
|
|
||||||
{
|
|
||||||
gViewPort->ToggleServerBrowser();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TFFree Command Menu Message Handlers
|
|
||||||
int __MsgFunc_ValClass(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_ValClass( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_TeamNames(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_TeamNames( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_Feign(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_Feign( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_Detpack(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_Detpack( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_VGUIMenu(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_VGUIMenu( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_MOTD(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_MOTD( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_BuildSt(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_BuildSt( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_RandomPC(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_ServerName(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_ServerName( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_ScoreInfo( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_TeamScore(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_TeamScore( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_TeamInfo(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_TeamInfo( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_Spectator(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_Spectator( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_SpecFade(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_SpecFade( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_ResetFade(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_ResetFade( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
if (gViewPort)
|
|
||||||
return gViewPort->MsgFunc_AllowSpec( pszName, iSize, pbuf );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is called every time the DLL is loaded
|
|
||||||
void CHud :: Init( void )
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( Logo );
|
|
||||||
HOOK_MESSAGE( ResetHUD );
|
|
||||||
HOOK_MESSAGE( GameMode );
|
|
||||||
HOOK_MESSAGE( InitHUD );
|
|
||||||
HOOK_MESSAGE( ViewMode );
|
|
||||||
HOOK_MESSAGE( SetFOV );
|
|
||||||
HOOK_MESSAGE( Concuss );
|
|
||||||
|
|
||||||
// TFFree CommandMenu
|
|
||||||
HOOK_COMMAND( "+commandmenu", OpenCommandMenu );
|
|
||||||
HOOK_COMMAND( "-commandmenu", CloseCommandMenu );
|
|
||||||
HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu );
|
|
||||||
HOOK_COMMAND( "special", InputPlayerSpecial );
|
|
||||||
HOOK_COMMAND( "togglebrowser", ToggleServerBrowser );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( ValClass );
|
|
||||||
HOOK_MESSAGE( TeamNames );
|
|
||||||
HOOK_MESSAGE( Feign );
|
|
||||||
HOOK_MESSAGE( Detpack );
|
|
||||||
HOOK_MESSAGE( MOTD );
|
|
||||||
HOOK_MESSAGE( BuildSt );
|
|
||||||
HOOK_MESSAGE( RandomPC );
|
|
||||||
HOOK_MESSAGE( ServerName );
|
|
||||||
HOOK_MESSAGE( ScoreInfo );
|
|
||||||
HOOK_MESSAGE( TeamScore );
|
|
||||||
HOOK_MESSAGE( TeamInfo );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( Spectator );
|
|
||||||
HOOK_MESSAGE( AllowSpec );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( SpecFade );
|
|
||||||
HOOK_MESSAGE( ResetFade );
|
|
||||||
|
|
||||||
// VGUI Menus
|
|
||||||
HOOK_MESSAGE( VGUIMenu );
|
|
||||||
|
|
||||||
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
|
|
||||||
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round
|
|
||||||
|
|
||||||
|
|
||||||
m_iLogo = 0;
|
|
||||||
m_iFOV = 0;
|
|
||||||
|
|
||||||
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
|
|
||||||
default_fov = CVAR_CREATE( "default_fov", "90", 0 );
|
|
||||||
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
|
|
||||||
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
|
|
||||||
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
|
|
||||||
|
|
||||||
m_pSpriteList = NULL;
|
|
||||||
|
|
||||||
// Clear any old HUD list
|
|
||||||
if ( m_pHudList )
|
|
||||||
{
|
|
||||||
HUDLIST *pList;
|
|
||||||
while ( m_pHudList )
|
|
||||||
{
|
|
||||||
pList = m_pHudList;
|
|
||||||
m_pHudList = m_pHudList->pNext;
|
|
||||||
free( pList );
|
|
||||||
}
|
|
||||||
m_pHudList = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case we get messages before the first update -- time will be valid
|
|
||||||
m_flTime = 1.0;
|
|
||||||
|
|
||||||
m_Ammo.Init();
|
|
||||||
m_Health.Init();
|
|
||||||
m_SayText.Init();
|
|
||||||
m_Spectator.Init();
|
|
||||||
m_Geiger.Init();
|
|
||||||
m_Train.Init();
|
|
||||||
m_Battery.Init();
|
|
||||||
m_Flash.Init();
|
|
||||||
m_Message.Init();
|
|
||||||
m_StatusBar.Init();
|
|
||||||
m_DeathNotice.Init();
|
|
||||||
m_AmmoSecondary.Init();
|
|
||||||
m_TextMessage.Init();
|
|
||||||
m_StatusIcons.Init();
|
|
||||||
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
|
|
||||||
|
|
||||||
m_Menu.Init();
|
|
||||||
|
|
||||||
ServersInit();
|
|
||||||
|
|
||||||
MsgFunc_ResetHUD(0, 0, NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHud destructor
|
|
||||||
// cleans up memory allocated for m_rg* arrays
|
|
||||||
CHud :: ~CHud()
|
|
||||||
{
|
|
||||||
delete [] m_rghSprites;
|
|
||||||
delete [] m_rgrcRects;
|
|
||||||
delete [] m_rgszSpriteNames;
|
|
||||||
|
|
||||||
if ( m_pHudList )
|
|
||||||
{
|
|
||||||
HUDLIST *pList;
|
|
||||||
while ( m_pHudList )
|
|
||||||
{
|
|
||||||
pList = m_pHudList;
|
|
||||||
m_pHudList = m_pHudList->pNext;
|
|
||||||
free( pList );
|
|
||||||
}
|
|
||||||
m_pHudList = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServersShutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSpriteIndex()
|
|
||||||
// searches through the sprite list loaded from hud.txt for a name matching SpriteName
|
|
||||||
// returns an index into the gHUD.m_rghSprites[] array
|
|
||||||
// returns 0 if sprite not found
|
|
||||||
int CHud :: GetSpriteIndex( const char *SpriteName )
|
|
||||||
{
|
|
||||||
// look through the loaded sprite name list for SpriteName
|
|
||||||
for ( int i = 0; i < m_iSpriteCount; i++ )
|
|
||||||
{
|
|
||||||
if ( strncmp( SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 )
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1; // invalid sprite
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHud :: VidInit( void )
|
|
||||||
{
|
|
||||||
m_scrinfo.iSize = sizeof(m_scrinfo);
|
|
||||||
GetScreenInfo(&m_scrinfo);
|
|
||||||
|
|
||||||
// ----------
|
|
||||||
// Load Sprites
|
|
||||||
// ---------
|
|
||||||
// m_hsprFont = LoadSprite("sprites/%d_font.spr");
|
|
||||||
|
|
||||||
m_hsprLogo = 0;
|
|
||||||
m_hsprCursor = 0;
|
|
||||||
|
|
||||||
if (ScreenWidth < 640)
|
|
||||||
m_iRes = 320;
|
|
||||||
else
|
|
||||||
m_iRes = 640;
|
|
||||||
|
|
||||||
// Only load this once
|
|
||||||
if ( !m_pSpriteList )
|
|
||||||
{
|
|
||||||
// we need to load the hud.txt, and all sprites within
|
|
||||||
m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes);
|
|
||||||
|
|
||||||
if (m_pSpriteList)
|
|
||||||
{
|
|
||||||
// count the number of sprites of the appropriate res
|
|
||||||
m_iSpriteCount = 0;
|
|
||||||
client_sprite_t *p = m_pSpriteList;
|
|
||||||
int j;
|
|
||||||
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
|
|
||||||
{
|
|
||||||
if ( p->iRes == m_iRes )
|
|
||||||
m_iSpriteCount++;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// allocated memory for sprite handle arrays
|
|
||||||
m_rghSprites = new HSPRITE[m_iSpriteCount];
|
|
||||||
m_rgrcRects = new wrect_t[m_iSpriteCount];
|
|
||||||
m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH];
|
|
||||||
|
|
||||||
p = m_pSpriteList;
|
|
||||||
int index = 0;
|
|
||||||
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
|
|
||||||
{
|
|
||||||
if ( p->iRes == m_iRes )
|
|
||||||
{
|
|
||||||
char sz[256];
|
|
||||||
sprintf(sz, "sprites/%s.spr", p->szSprite);
|
|
||||||
m_rghSprites[index] = SPR_Load(sz);
|
|
||||||
m_rgrcRects[index] = p->rc;
|
|
||||||
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we have already have loaded the sprite reference from hud.txt, but
|
|
||||||
// we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game)
|
|
||||||
client_sprite_t *p = m_pSpriteList;
|
|
||||||
int index = 0;
|
|
||||||
for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
|
|
||||||
{
|
|
||||||
if ( p->iRes == m_iRes )
|
|
||||||
{
|
|
||||||
char sz[256];
|
|
||||||
sprintf( sz, "sprites/%s.spr", p->szSprite );
|
|
||||||
m_rghSprites[index] = SPR_Load(sz);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// assumption: number_1, number_2, etc, are all listed and loaded sequentially
|
|
||||||
m_HUD_number_0 = GetSpriteIndex( "number_0" );
|
|
||||||
|
|
||||||
m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top;
|
|
||||||
|
|
||||||
m_Ammo.VidInit();
|
|
||||||
m_Health.VidInit();
|
|
||||||
m_Spectator.VidInit();
|
|
||||||
m_Geiger.VidInit();
|
|
||||||
m_Train.VidInit();
|
|
||||||
m_Battery.VidInit();
|
|
||||||
m_Flash.VidInit();
|
|
||||||
m_Message.VidInit();
|
|
||||||
m_StatusBar.VidInit();
|
|
||||||
m_DeathNotice.VidInit();
|
|
||||||
m_SayText.VidInit();
|
|
||||||
m_Menu.VidInit();
|
|
||||||
m_AmmoSecondary.VidInit();
|
|
||||||
m_TextMessage.VidInit();
|
|
||||||
m_StatusIcons.VidInit();
|
|
||||||
GetClientVoiceMgr()->VidInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
// update Train data
|
|
||||||
m_iLogo = READ_BYTE();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
float g_lastFOV = 0.0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
============
|
|
||||||
COM_FileBase
|
|
||||||
============
|
|
||||||
*/
|
|
||||||
// Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
|
|
||||||
void COM_FileBase ( const char *in, char *out)
|
|
||||||
{
|
|
||||||
int len, start, end;
|
|
||||||
|
|
||||||
len = strlen( in );
|
|
||||||
|
|
||||||
// scan backward for '.'
|
|
||||||
end = len - 1;
|
|
||||||
while ( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
|
|
||||||
end--;
|
|
||||||
|
|
||||||
if ( in[end] != '.' ) // no '.', copy to end
|
|
||||||
end = len-1;
|
|
||||||
else
|
|
||||||
end--; // Found ',', copy to left of '.'
|
|
||||||
|
|
||||||
|
|
||||||
// Scan backward for '/'
|
|
||||||
start = len-1;
|
|
||||||
while ( start >= 0 && in[start] != '/' && in[start] != '\\' )
|
|
||||||
start--;
|
|
||||||
|
|
||||||
if ( in[start] != '/' && in[start] != '\\' )
|
|
||||||
start = 0;
|
|
||||||
else
|
|
||||||
start++;
|
|
||||||
|
|
||||||
// Length of new sting
|
|
||||||
len = end - start + 1;
|
|
||||||
|
|
||||||
// Copy partial string
|
|
||||||
strncpy( out, &in[start], len );
|
|
||||||
// Terminate it
|
|
||||||
out[len] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
HUD_IsGame
|
|
||||||
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
int HUD_IsGame( const char *game )
|
|
||||||
{
|
|
||||||
const char *gamedir;
|
|
||||||
char gd[ 1024 ];
|
|
||||||
|
|
||||||
gamedir = gEngfuncs.pfnGetGameDirectory();
|
|
||||||
if ( gamedir && gamedir[0] )
|
|
||||||
{
|
|
||||||
COM_FileBase( gamedir, gd );
|
|
||||||
if ( !stricmp( gd, game ) )
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
HUD_GetFOV
|
|
||||||
|
|
||||||
Returns last FOV
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
float HUD_GetFOV( void )
|
|
||||||
{
|
|
||||||
if ( gEngfuncs.pDemoAPI->IsRecording() )
|
|
||||||
{
|
|
||||||
// Write it
|
|
||||||
int i = 0;
|
|
||||||
unsigned char buf[ 100 ];
|
|
||||||
|
|
||||||
// Active
|
|
||||||
*( float * )&buf[ i ] = g_lastFOV;
|
|
||||||
i += sizeof( float );
|
|
||||||
|
|
||||||
Demo_WriteBuffer( TYPE_ZOOM, i, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( gEngfuncs.pDemoAPI->IsPlayingback() )
|
|
||||||
{
|
|
||||||
g_lastFOV = g_demozoom;
|
|
||||||
}
|
|
||||||
return g_lastFOV;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int newfov = READ_BYTE();
|
|
||||||
int def_fov = CVAR_GET_FLOAT( "default_fov" );
|
|
||||||
|
|
||||||
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
|
|
||||||
if ( cl_lw && cl_lw->value )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
g_lastFOV = newfov;
|
|
||||||
|
|
||||||
if ( newfov == 0 )
|
|
||||||
{
|
|
||||||
m_iFOV = def_fov;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_iFOV = newfov;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the clients fov is actually set in the client data update section of the hud
|
|
||||||
|
|
||||||
// Set a new sensitivity
|
|
||||||
if ( m_iFOV == def_fov )
|
|
||||||
{
|
|
||||||
// reset to saved sensitivity
|
|
||||||
m_flMouseSensitivity = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// set a new sensitivity that is proportional to the change from the FOV default
|
|
||||||
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)def_fov) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHud::AddHudElem(CHudBase *phudelem)
|
|
||||||
{
|
|
||||||
HUDLIST *pdl, *ptemp;
|
|
||||||
|
|
||||||
//phudelem->Think();
|
|
||||||
|
|
||||||
if (!phudelem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pdl = (HUDLIST *)malloc(sizeof(HUDLIST));
|
|
||||||
if (!pdl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset(pdl, 0, sizeof(HUDLIST));
|
|
||||||
pdl->p = phudelem;
|
|
||||||
|
|
||||||
if (!m_pHudList)
|
|
||||||
{
|
|
||||||
m_pHudList = pdl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptemp = m_pHudList;
|
|
||||||
|
|
||||||
while (ptemp->pNext)
|
|
||||||
ptemp = ptemp->pNext;
|
|
||||||
|
|
||||||
ptemp->pNext = pdl;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CHud::GetSensitivity( void )
|
|
||||||
{
|
|
||||||
return m_flMouseSensitivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,658 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// hud.h
|
|
||||||
//
|
|
||||||
// class CHud declaration
|
|
||||||
//
|
|
||||||
// CHud handles the message, calculation, and drawing the HUD
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#define RGB_YELLOWISH 0x00FFA000 //255,160,0
|
|
||||||
#define RGB_REDISH 0x00FF1010 //255,160,0
|
|
||||||
#define RGB_GREENISH 0x0000A000 //0,160,0
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#define _cdecl
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wrect.h"
|
|
||||||
#include "cl_dll.h"
|
|
||||||
#include "ammo.h"
|
|
||||||
|
|
||||||
#define DHN_DRAWZERO 1
|
|
||||||
#define DHN_2DIGITS 2
|
|
||||||
#define DHN_3DIGITS 4
|
|
||||||
#define MIN_ALPHA 100
|
|
||||||
|
|
||||||
#define HUDELEM_ACTIVE 1
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x, y;
|
|
||||||
} POSITION;
|
|
||||||
|
|
||||||
#include "global_consts.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned char r,g,b,a;
|
|
||||||
} RGBA;
|
|
||||||
|
|
||||||
typedef struct cvar_s cvar_t;
|
|
||||||
|
|
||||||
|
|
||||||
#define HUD_ACTIVE 1
|
|
||||||
#define HUD_INTERMISSION 2
|
|
||||||
|
|
||||||
#define MAX_PLAYER_NAME_LENGTH 32
|
|
||||||
|
|
||||||
#define MAX_MOTD_LENGTH 1536
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
POSITION m_pos;
|
|
||||||
int m_type;
|
|
||||||
int m_iFlags; // active, moving,
|
|
||||||
virtual ~CHudBase() {}
|
|
||||||
virtual int Init( void ) {return 0;}
|
|
||||||
virtual int VidInit( void ) {return 0;}
|
|
||||||
virtual int Draw(float flTime) {return 0;}
|
|
||||||
virtual void Think(void) {return;}
|
|
||||||
virtual void Reset(void) {return;}
|
|
||||||
virtual void InitHUDData( void ) {} // called every time a server is connected to
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HUDLIST {
|
|
||||||
CHudBase *p;
|
|
||||||
HUDLIST *pNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
#include "voice_status.h" // base voice handling class
|
|
||||||
#include "hud_spectator.h"
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudAmmo: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
void Think(void);
|
|
||||||
void Reset(void);
|
|
||||||
int DrawWList(float flTime);
|
|
||||||
int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
void SlotInput( int iSlot );
|
|
||||||
void _cdecl UserCmd_Slot1( void );
|
|
||||||
void _cdecl UserCmd_Slot2( void );
|
|
||||||
void _cdecl UserCmd_Slot3( void );
|
|
||||||
void _cdecl UserCmd_Slot4( void );
|
|
||||||
void _cdecl UserCmd_Slot5( void );
|
|
||||||
void _cdecl UserCmd_Slot6( void );
|
|
||||||
void _cdecl UserCmd_Slot7( void );
|
|
||||||
void _cdecl UserCmd_Slot8( void );
|
|
||||||
void _cdecl UserCmd_Slot9( void );
|
|
||||||
void _cdecl UserCmd_Slot10( void );
|
|
||||||
void _cdecl UserCmd_Close( void );
|
|
||||||
void _cdecl UserCmd_NextWeapon( void );
|
|
||||||
void _cdecl UserCmd_PrevWeapon( void );
|
|
||||||
|
|
||||||
private:
|
|
||||||
float m_fFade;
|
|
||||||
RGBA m_rgba;
|
|
||||||
WEAPON *m_pWeapon;
|
|
||||||
int m_HUD_bucket0;
|
|
||||||
int m_HUD_selection;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
|
|
||||||
class CHudAmmoSecondary: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
void Reset( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
|
|
||||||
int MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum {
|
|
||||||
MAX_SEC_AMMO_VALUES = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
int m_HUD_ammoicon; // sprite indices
|
|
||||||
int m_iAmmoAmounts[MAX_SEC_AMMO_VALUES];
|
|
||||||
float m_fFade;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#include "health.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define FADE_TIME 100
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudGeiger: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
int MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_iGeigerRange;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudTrain: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
int MsgFunc_Train(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
private:
|
|
||||||
HSPRITE m_hSprite;
|
|
||||||
int m_iPos;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudStatusBar : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw( float flTime );
|
|
||||||
void Reset( void );
|
|
||||||
void ParseStatusString( int line_num );
|
|
||||||
|
|
||||||
int MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
enum {
|
|
||||||
MAX_STATUSTEXT_LENGTH = 128,
|
|
||||||
MAX_STATUSBAR_VALUES = 8,
|
|
||||||
MAX_STATUSBAR_LINES = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
|
|
||||||
char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // the constructed bar that is drawn
|
|
||||||
int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar
|
|
||||||
|
|
||||||
int m_bReparseString; // set to TRUE whenever the m_szStatusBar needs to be recalculated
|
|
||||||
|
|
||||||
// an array of colors...one color for each line
|
|
||||||
float *m_pflNameColors[MAX_STATUSBAR_LINES];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct extra_player_info_t
|
|
||||||
{
|
|
||||||
short frags;
|
|
||||||
short deaths;
|
|
||||||
short playerclass;
|
|
||||||
short health; // UNUSED currently, spectator UI would like this
|
|
||||||
bool dead; // UNUSED currently, spectator UI would like this
|
|
||||||
short teamnumber;
|
|
||||||
char teamname[MAX_TEAM_NAME];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct team_info_t
|
|
||||||
{
|
|
||||||
char name[MAX_TEAM_NAME];
|
|
||||||
short frags;
|
|
||||||
short deaths;
|
|
||||||
short ping;
|
|
||||||
short packetloss;
|
|
||||||
short ownteam;
|
|
||||||
short players;
|
|
||||||
int already_drawn;
|
|
||||||
int scores_overriden;
|
|
||||||
int teamnumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "player_info.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudDeathNotice : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
void InitHUDData( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw( float flTime );
|
|
||||||
int MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_HUD_d_skull; // sprite index of skull icon
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudMenu : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
void InitHUDData( void );
|
|
||||||
int VidInit( void );
|
|
||||||
void Reset( void );
|
|
||||||
int Draw( float flTime );
|
|
||||||
int MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
void SelectMenuItem( int menu_item );
|
|
||||||
|
|
||||||
int m_fMenuDisplayed;
|
|
||||||
int m_bitsValidSlots;
|
|
||||||
float m_flShutoffTime;
|
|
||||||
int m_fWaitingForMore;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudSayText : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
void InitHUDData( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw( float flTime );
|
|
||||||
int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf );
|
|
||||||
void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 );
|
|
||||||
void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line );
|
|
||||||
friend class CHudSpectator;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
struct cvar_s * m_HUD_saytext;
|
|
||||||
struct cvar_s * m_HUD_saytext_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudBattery: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
private:
|
|
||||||
HSPRITE m_hSprite1;
|
|
||||||
HSPRITE m_hSprite2;
|
|
||||||
wrect_t *m_prc1;
|
|
||||||
wrect_t *m_prc2;
|
|
||||||
int m_iBat;
|
|
||||||
int m_iBatMax;
|
|
||||||
float m_fFade;
|
|
||||||
int m_iHeight; // width of the battery innards
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudFlashlight: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
void Reset( void );
|
|
||||||
int MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf );
|
|
||||||
int MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
private:
|
|
||||||
HSPRITE m_hSprite1;
|
|
||||||
HSPRITE m_hSprite2;
|
|
||||||
HSPRITE m_hBeam;
|
|
||||||
wrect_t *m_prc1;
|
|
||||||
wrect_t *m_prc2;
|
|
||||||
wrect_t *m_prcBeam;
|
|
||||||
float m_flBat;
|
|
||||||
int m_iBat;
|
|
||||||
int m_fOn;
|
|
||||||
float m_fFade;
|
|
||||||
int m_iWidth; // width of the battery innards
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
const int maxHUDMessages = 16;
|
|
||||||
struct message_parms_t
|
|
||||||
{
|
|
||||||
client_textmessage_t *pMessage;
|
|
||||||
float time;
|
|
||||||
int x, y;
|
|
||||||
int totalWidth, totalHeight;
|
|
||||||
int width;
|
|
||||||
int lines;
|
|
||||||
int lineLength;
|
|
||||||
int length;
|
|
||||||
int r, g, b;
|
|
||||||
int text;
|
|
||||||
int fadeBlend;
|
|
||||||
float charTime;
|
|
||||||
float fadeTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
|
|
||||||
class CHudTextMessage: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size );
|
|
||||||
static char *BufferedLocaliseTextString( const char *msg );
|
|
||||||
char *LookupString( const char *msg_name, int *msg_dest = NULL );
|
|
||||||
int MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf);
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
|
|
||||||
class CHudMessage: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
int MsgFunc_HudText(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_HudTextPro(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
float FadeBlend( float fadein, float fadeout, float hold, float localTime );
|
|
||||||
int XPosition( float x, int width, int lineWidth );
|
|
||||||
int YPosition( float y, int height );
|
|
||||||
|
|
||||||
void MessageAdd( const char *pName, float time );
|
|
||||||
void MessageAdd(client_textmessage_t * newMessage );
|
|
||||||
void MessageDrawScan( client_textmessage_t *pMessage, float time );
|
|
||||||
void MessageScanStart( void );
|
|
||||||
void MessageScanNextChar( void );
|
|
||||||
void Reset( void );
|
|
||||||
|
|
||||||
private:
|
|
||||||
client_textmessage_t *m_pMessages[maxHUDMessages];
|
|
||||||
float m_startTime[maxHUDMessages];
|
|
||||||
message_parms_t m_parms;
|
|
||||||
float m_gameTitleTime;
|
|
||||||
client_textmessage_t *m_pGameTitle;
|
|
||||||
|
|
||||||
int m_HUD_title_life;
|
|
||||||
int m_HUD_title_half;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
#define MAX_SPRITE_NAME_LENGTH 24
|
|
||||||
|
|
||||||
class CHudStatusIcons: public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
void Reset( void );
|
|
||||||
int Draw(float flTime);
|
|
||||||
int MsgFunc_StatusIcon(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
|
|
||||||
MAX_ICONSPRITES = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//had to make these public so CHud could access them (to enable concussion icon)
|
|
||||||
//could use a friend declaration instead...
|
|
||||||
void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue );
|
|
||||||
void DisableIcon( char *pszIconName );
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
|
|
||||||
HSPRITE spr;
|
|
||||||
wrect_t rc;
|
|
||||||
unsigned char r, g, b;
|
|
||||||
} icon_sprite_t;
|
|
||||||
|
|
||||||
icon_sprite_t m_IconList[MAX_ICONSPRITES];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
class CHudBenchmark : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init( void );
|
|
||||||
int VidInit( void );
|
|
||||||
int Draw( float flTime );
|
|
||||||
|
|
||||||
void SetScore( float score );
|
|
||||||
|
|
||||||
void Think( void );
|
|
||||||
|
|
||||||
void StartNextSection( int section );
|
|
||||||
|
|
||||||
int MsgFunc_Bench(const char *pszName, int iSize, void *pbuf);
|
|
||||||
|
|
||||||
void CountFrame( float dt );
|
|
||||||
|
|
||||||
int GetObjects( void ) { return m_nObjects; };
|
|
||||||
|
|
||||||
void SetCompositeScore( void );
|
|
||||||
|
|
||||||
void Restart( void );
|
|
||||||
|
|
||||||
int Bench_ScoreForValue( int stage, float raw );
|
|
||||||
|
|
||||||
private:
|
|
||||||
float m_fDrawTime;
|
|
||||||
float m_fDrawScore;
|
|
||||||
float m_fAvgScore;
|
|
||||||
|
|
||||||
float m_fSendTime;
|
|
||||||
float m_fReceiveTime;
|
|
||||||
|
|
||||||
int m_nFPSCount;
|
|
||||||
float m_fAverageFT;
|
|
||||||
float m_fAvgFrameRate;
|
|
||||||
|
|
||||||
int m_nSentFinish;
|
|
||||||
float m_fStageStarted;
|
|
||||||
|
|
||||||
float m_StoredLatency;
|
|
||||||
float m_StoredPacketLoss;
|
|
||||||
int m_nStoredHopCount;
|
|
||||||
int m_nTraceDone;
|
|
||||||
|
|
||||||
int m_nObjects;
|
|
||||||
|
|
||||||
int m_nScoreComputed;
|
|
||||||
int m_nCompositeScore;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
class CHud
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
HUDLIST *m_pHudList;
|
|
||||||
HSPRITE m_hsprLogo;
|
|
||||||
int m_iLogo;
|
|
||||||
client_sprite_t *m_pSpriteList;
|
|
||||||
int m_iSpriteCount;
|
|
||||||
int m_iSpriteCountAllRes;
|
|
||||||
float m_flMouseSensitivity;
|
|
||||||
int m_iConcussionEffect;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
HSPRITE m_hsprCursor;
|
|
||||||
float m_flTime; // the current client time
|
|
||||||
float m_fOldTime; // the time at which the HUD was last redrawn
|
|
||||||
double m_flTimeDelta; // the difference between flTime and fOldTime
|
|
||||||
Vector m_vecOrigin;
|
|
||||||
Vector m_vecAngles;
|
|
||||||
int m_iKeyBits;
|
|
||||||
int m_iHideHUDDisplay;
|
|
||||||
int m_iFOV;
|
|
||||||
int m_Teamplay;
|
|
||||||
int m_iRes;
|
|
||||||
cvar_t *m_pCvarStealMouse;
|
|
||||||
cvar_t *m_pCvarDraw;
|
|
||||||
|
|
||||||
int m_iFontHeight;
|
|
||||||
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
|
|
||||||
int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b );
|
|
||||||
int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b );
|
|
||||||
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
|
|
||||||
int GetNumWidth(int iNumber, int iFlags);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
|
|
||||||
// freed in ~CHud()
|
|
||||||
HSPRITE *m_rghSprites; /*[HUD_SPRITE_COUNT]*/ // the sprites loaded from hud.txt
|
|
||||||
wrect_t *m_rgrcRects; /*[HUD_SPRITE_COUNT]*/
|
|
||||||
char *m_rgszSpriteNames; /*[HUD_SPRITE_COUNT][MAX_SPRITE_NAME_LENGTH]*/
|
|
||||||
|
|
||||||
struct cvar_s *default_fov;
|
|
||||||
public:
|
|
||||||
HSPRITE GetSprite( int index )
|
|
||||||
{
|
|
||||||
return (index < 0) ? 0 : m_rghSprites[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
wrect_t& GetSpriteRect( int index )
|
|
||||||
{
|
|
||||||
return m_rgrcRects[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
|
|
||||||
|
|
||||||
CHudAmmo m_Ammo;
|
|
||||||
CHudHealth m_Health;
|
|
||||||
CHudSpectator m_Spectator;
|
|
||||||
CHudGeiger m_Geiger;
|
|
||||||
CHudBattery m_Battery;
|
|
||||||
CHudTrain m_Train;
|
|
||||||
CHudFlashlight m_Flash;
|
|
||||||
CHudMessage m_Message;
|
|
||||||
CHudStatusBar m_StatusBar;
|
|
||||||
CHudDeathNotice m_DeathNotice;
|
|
||||||
CHudSayText m_SayText;
|
|
||||||
CHudMenu m_Menu;
|
|
||||||
CHudAmmoSecondary m_AmmoSecondary;
|
|
||||||
CHudTextMessage m_TextMessage;
|
|
||||||
CHudStatusIcons m_StatusIcons;
|
|
||||||
CHudBenchmark m_Benchmark;
|
|
||||||
|
|
||||||
void Init( void );
|
|
||||||
void VidInit( void );
|
|
||||||
void Think(void);
|
|
||||||
int Redraw( float flTime, int intermission );
|
|
||||||
int UpdateClientData( client_data_t *cdata, float time );
|
|
||||||
|
|
||||||
CHud() : m_iSpriteCount(0), m_pHudList(NULL) {}
|
|
||||||
~CHud(); // destructor, frees allocated memory
|
|
||||||
|
|
||||||
// user messages
|
|
||||||
int _cdecl MsgFunc_Damage(const char *pszName, int iSize, void *pbuf );
|
|
||||||
int _cdecl MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf );
|
|
||||||
int _cdecl MsgFunc_Logo(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int _cdecl MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf);
|
|
||||||
void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf );
|
|
||||||
void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf );
|
|
||||||
int _cdecl MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf);
|
|
||||||
int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );
|
|
||||||
|
|
||||||
// Screen information
|
|
||||||
SCREENINFO m_scrinfo;
|
|
||||||
|
|
||||||
int m_iWeaponBits;
|
|
||||||
int m_fPlayerDead;
|
|
||||||
int m_iIntermission;
|
|
||||||
|
|
||||||
// sprite indexes
|
|
||||||
int m_HUD_number_0;
|
|
||||||
|
|
||||||
|
|
||||||
void AddHudElem(CHudBase *p);
|
|
||||||
|
|
||||||
float GetSensitivity();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CHud gHUD;
|
|
||||||
|
|
||||||
extern int g_iPlayerClass;
|
|
||||||
extern int g_iTeamNumber;
|
|
||||||
extern int g_iUser1;
|
|
||||||
extern int g_iUser2;
|
|
||||||
extern int g_iUser3;
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,236 +0,0 @@
|
||||||
// hud_benchtrace.cpp
|
|
||||||
// Functions for spawning a thread to get a hopcount to a particular ip address and returning the result in a specified
|
|
||||||
// variable
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "winsani_in.h"
|
|
||||||
#include <windows.h>
|
|
||||||
#include "winsani_out.h"
|
|
||||||
#else
|
|
||||||
#include "port.h"
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For tracking the trace threads
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
// Inputs
|
|
||||||
char server[ 256 ];
|
|
||||||
|
|
||||||
// Outputs
|
|
||||||
int *p_nresults;
|
|
||||||
int *p_ndone;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
DWORD hThreadId;
|
|
||||||
HANDLE hThread;
|
|
||||||
HANDLE hEventDone;
|
|
||||||
} trace_params_t;
|
|
||||||
|
|
||||||
// Static forces it to be zeroed out
|
|
||||||
static trace_params_t tp;
|
|
||||||
|
|
||||||
// For doing the actual traceroute
|
|
||||||
struct trace_options_s
|
|
||||||
{
|
|
||||||
unsigned char ucTTL;
|
|
||||||
unsigned char a[7];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
DWORD dwAddress;
|
|
||||||
unsigned long ulStatus, ulRoundTripTime;
|
|
||||||
unsigned char a[8];
|
|
||||||
struct trace_options_s Options;
|
|
||||||
} traceReturn;
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Trace_GetHopCount
|
|
||||||
|
|
||||||
Performs a synchronous hopcount on the specified server
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
int Trace_GetHopCount( char *pServer, int nMaxHops )
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
HMODULE hICMP; // Handle to ICMP .dll
|
|
||||||
HANDLE hIP; // Handle to icmp session
|
|
||||||
DWORD *dwIPAddr; // remote IP Address as a DWORD
|
|
||||||
struct hostent *pHostEnt; // Name of remote host
|
|
||||||
struct trace_options_s traceOptions; // Input options
|
|
||||||
int c; // Hop counter
|
|
||||||
|
|
||||||
// Prototypes
|
|
||||||
HANDLE ( WINAPI *pfnICMPCreateFile ) ( VOID );
|
|
||||||
BOOL ( WINAPI *pfnICMPCloseFile ) ( HANDLE );
|
|
||||||
DWORD (WINAPI *pfnICMPSendEcho) ( HANDLE, DWORD, LPVOID, WORD, LPVOID, LPVOID, DWORD, DWORD );
|
|
||||||
|
|
||||||
hICMP = ::LoadLibrary( "ICMP.DLL" );
|
|
||||||
|
|
||||||
pfnICMPCreateFile = ( HANDLE ( WINAPI *)(VOID ) )::GetProcAddress( hICMP,"IcmpCreateFile");
|
|
||||||
pfnICMPCloseFile = ( BOOL ( WINAPI *) ( HANDLE ) )::GetProcAddress( hICMP,"IcmpCloseHandle");
|
|
||||||
pfnICMPSendEcho = ( DWORD ( WINAPI * ) ( HANDLE, DWORD, LPVOID, WORD, LPVOID, LPVOID, DWORD,DWORD ) )::GetProcAddress( hICMP,"IcmpSendEcho" );
|
|
||||||
|
|
||||||
if ( !pfnICMPCreateFile ||
|
|
||||||
!pfnICMPCloseFile ||
|
|
||||||
!pfnICMPSendEcho )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
hIP = pfnICMPCreateFile();
|
|
||||||
if ( !hIP )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DNS lookup on remote host
|
|
||||||
pHostEnt = gethostbyname( pServer );
|
|
||||||
if ( !pHostEnt )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Take first IP address returned
|
|
||||||
dwIPAddr = ( DWORD * )( *pHostEnt->h_addr_list );
|
|
||||||
|
|
||||||
// Fixme: If not tracing, can use a "binary search" method to do the trace route
|
|
||||||
for ( c = 1; c <= nMaxHops ; c++)
|
|
||||||
{
|
|
||||||
// Set TTL correctly
|
|
||||||
traceOptions.ucTTL = (unsigned char)c;
|
|
||||||
|
|
||||||
// Clear out return structure
|
|
||||||
memset( &traceReturn, 0, sizeof( traceReturn ) );
|
|
||||||
|
|
||||||
// Send echo request, 2000 milliseconds maximum waiting time
|
|
||||||
pfnICMPSendEcho ( hIP, *dwIPAddr, 0, 0, &traceOptions, &traceReturn, sizeof(traceReturn), 2000 );
|
|
||||||
|
|
||||||
// Found requrested remote address, c contains the correct hopcount
|
|
||||||
if ( traceReturn.dwAddress == *dwIPAddr )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// This is how you do a raw ping
|
|
||||||
npings = 1;
|
|
||||||
pfnICMPSendEcho( hIP, *dwIPAddr, 0, 0, NULL, &E, sizeof( E ), 2000 );
|
|
||||||
*ping = (double)E.RoundTripTime / 1000.0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Clean up file and dll handles
|
|
||||||
pfnICMPCloseFile( hIP );
|
|
||||||
|
|
||||||
::FreeLibrary( hICMP );
|
|
||||||
|
|
||||||
// Failure?
|
|
||||||
if ( c > nMaxHops )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Trace_Cleanup
|
|
||||||
|
|
||||||
Destroys thread and event handle when trace is done, or when restarting a new trace
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
void Trace_Cleanup( void )
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if ( tp.hThread )
|
|
||||||
{
|
|
||||||
TerminateThread( tp.hThread, 0 );
|
|
||||||
CloseHandle( tp.hThread );
|
|
||||||
tp.hThread = (HANDLE)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( tp.hEventDone )
|
|
||||||
{
|
|
||||||
CloseHandle( tp.hEventDone );
|
|
||||||
tp.hEventDone = (HANDLE)0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Trace_ThreadFunction
|
|
||||||
|
|
||||||
Performs a trace, sets finish event and exits
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
DWORD WINAPI Trace_ThreadFunction( LPVOID p )
|
|
||||||
{
|
|
||||||
int *results;
|
|
||||||
|
|
||||||
results = ( int * )p;
|
|
||||||
|
|
||||||
*results = Trace_GetHopCount( tp.server, 30 );
|
|
||||||
SetEvent( tp.hEventDone );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Trace_StartTrace
|
|
||||||
|
|
||||||
Create finish event, sets up data, and starts thread to do a traceroute.
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
void Trace_StartTrace( int *results, int *finished, const char *server )
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
tp.p_nresults = results;
|
|
||||||
strcpy( tp.server, server );
|
|
||||||
|
|
||||||
*results = -1;
|
|
||||||
|
|
||||||
Trace_Cleanup();
|
|
||||||
|
|
||||||
tp.hEventDone = CreateEvent( NULL, TRUE, FALSE, NULL );
|
|
||||||
if ( !tp.hEventDone )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tp.p_ndone = finished;
|
|
||||||
*tp.p_ndone = 0;
|
|
||||||
|
|
||||||
tp.hThread = CreateThread( NULL, 0, Trace_ThreadFunction, results, 0, &tp.hThreadId );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
Trace_Think
|
|
||||||
|
|
||||||
Invoked by general frame loop on client to periodically check if the traceroute thread has completed.
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
void Trace_Think( void )
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if ( !tp.hEventDone )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( WaitForSingleObject( tp.hEventDone, 0 ) == WAIT_OBJECT_0 )
|
|
||||||
{
|
|
||||||
Trace_Cleanup();
|
|
||||||
*tp.p_ndone = 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
#if !defined( HUD_BENCHTRACEH )
|
|
||||||
#define HUD_BENCHTRACEH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
void Trace_StartTrace( int *results, int *finished, const char *pszServer );
|
|
||||||
void Trace_Think( void );
|
|
||||||
|
|
||||||
#endif // !HUD_BENCHTRACEH
|
|
|
@ -1,17 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( HUD_IFACEH )
|
|
||||||
#define HUD_IFACEH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
|
||||||
#include "wrect.h"
|
|
||||||
#include "../engine/cdll_int.h"
|
|
||||||
extern cl_enginefunc_t gEngfuncs;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,141 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// hud_msg.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
#include "r_efx.h"
|
|
||||||
|
|
||||||
#include "particleman.h"
|
|
||||||
extern IParticleMan *g_pParticleMan;
|
|
||||||
|
|
||||||
#define MAX_CLIENTS 32
|
|
||||||
|
|
||||||
#if !defined( _TFC )
|
|
||||||
extern BEAM *pBeam;
|
|
||||||
extern BEAM *pBeam2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
void ClearEventList( void );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// USER-DEFINED SERVER MESSAGE HANDLERS
|
|
||||||
|
|
||||||
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
ASSERT( iSize == 0 );
|
|
||||||
|
|
||||||
// clear all hud data
|
|
||||||
HUDLIST *pList = m_pHudList;
|
|
||||||
|
|
||||||
while ( pList )
|
|
||||||
{
|
|
||||||
if ( pList->p )
|
|
||||||
pList->p->Reset();
|
|
||||||
pList = pList->pNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset sensitivity
|
|
||||||
m_flMouseSensitivity = 0;
|
|
||||||
|
|
||||||
// reset concussion effect
|
|
||||||
m_iConcussionEffect = 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_ToFirstPerson(void);
|
|
||||||
|
|
||||||
void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
CAM_ToFirstPerson();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
// prepare all hud data
|
|
||||||
HUDLIST *pList = m_pHudList;
|
|
||||||
|
|
||||||
while (pList)
|
|
||||||
{
|
|
||||||
if ( pList->p )
|
|
||||||
pList->p->InitHUDData();
|
|
||||||
pList = pList->pNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
ClearEventList();
|
|
||||||
|
|
||||||
// catch up on any building events that are going on
|
|
||||||
gEngfuncs.pfnServerCmd("sendevents");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( g_pParticleMan )
|
|
||||||
g_pParticleMan->ResetParticles();
|
|
||||||
|
|
||||||
#if !defined( _TFC )
|
|
||||||
//Probably not a good place to put this.
|
|
||||||
pBeam = pBeam2 = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
m_Teamplay = READ_BYTE();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
int armor, blood;
|
|
||||||
Vector from;
|
|
||||||
int i;
|
|
||||||
float count;
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
armor = READ_BYTE();
|
|
||||||
blood = READ_BYTE();
|
|
||||||
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
from[i] = READ_COORD();
|
|
||||||
|
|
||||||
count = (blood * 0.5) + (armor * 0.5);
|
|
||||||
|
|
||||||
if (count < 10)
|
|
||||||
count = 10;
|
|
||||||
|
|
||||||
// TODO: kick viewangles, show damage visually
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
m_iConcussionEffect = READ_BYTE();
|
|
||||||
if (m_iConcussionEffect)
|
|
||||||
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
|
|
||||||
else
|
|
||||||
this->m_StatusIcons.DisableIcon("dmg_concuss");
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,346 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// hud_redraw.cpp
|
|
||||||
//
|
|
||||||
#include <math.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "bench.h"
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
#define MAX_LOGO_FRAMES 56
|
|
||||||
|
|
||||||
int grgLogoFrame[MAX_LOGO_FRAMES] =
|
|
||||||
{
|
|
||||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
|
|
||||||
16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
|
||||||
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern int g_iVisibleMouse;
|
|
||||||
|
|
||||||
float HUD_GetFOV( void );
|
|
||||||
|
|
||||||
extern cvar_t *sensitivity;
|
|
||||||
|
|
||||||
// Think
|
|
||||||
void CHud::Think(void)
|
|
||||||
{
|
|
||||||
m_scrinfo.iSize = sizeof(m_scrinfo);
|
|
||||||
GetScreenInfo(&m_scrinfo);
|
|
||||||
|
|
||||||
int newfov;
|
|
||||||
HUDLIST *pList = m_pHudList;
|
|
||||||
|
|
||||||
while (pList)
|
|
||||||
{
|
|
||||||
if (pList->p->m_iFlags & HUD_ACTIVE)
|
|
||||||
pList->p->Think();
|
|
||||||
pList = pList->pNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
newfov = HUD_GetFOV();
|
|
||||||
if ( newfov == 0 )
|
|
||||||
{
|
|
||||||
m_iFOV = default_fov->value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_iFOV = newfov;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the clients fov is actually set in the client data update section of the hud
|
|
||||||
|
|
||||||
// Set a new sensitivity
|
|
||||||
if ( m_iFOV == default_fov->value )
|
|
||||||
{
|
|
||||||
// reset to saved sensitivity
|
|
||||||
m_flMouseSensitivity = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// set a new sensitivity that is proportional to the change from the FOV default
|
|
||||||
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
|
|
||||||
}
|
|
||||||
|
|
||||||
// think about default fov
|
|
||||||
if ( m_iFOV == 0 )
|
|
||||||
{ // only let players adjust up in fov, and only if they are not overriden by something else
|
|
||||||
m_iFOV = max( default_fov->value, 90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( gEngfuncs.IsSpectateOnly() )
|
|
||||||
{
|
|
||||||
m_iFOV = gHUD.m_Spectator.GetFOV(); // default_fov->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bench_CheckStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redraw
|
|
||||||
// step through the local data, placing the appropriate graphics & text as appropriate
|
|
||||||
// returns 1 if they've changed, 0 otherwise
|
|
||||||
int CHud :: Redraw( float flTime, int intermission )
|
|
||||||
{
|
|
||||||
m_fOldTime = m_flTime; // save time of previous redraw
|
|
||||||
m_flTime = flTime;
|
|
||||||
m_flTimeDelta = (double)m_flTime - m_fOldTime;
|
|
||||||
static float m_flShotTime = 0;
|
|
||||||
|
|
||||||
// Clock was reset, reset delta
|
|
||||||
if ( m_flTimeDelta < 0 )
|
|
||||||
m_flTimeDelta = 0;
|
|
||||||
|
|
||||||
// Bring up the scoreboard during intermission
|
|
||||||
if (gViewPort)
|
|
||||||
{
|
|
||||||
if ( m_iIntermission && !intermission )
|
|
||||||
{
|
|
||||||
// Have to do this here so the scoreboard goes away
|
|
||||||
m_iIntermission = intermission;
|
|
||||||
gViewPort->HideCommandMenu();
|
|
||||||
gViewPort->HideScoreBoard();
|
|
||||||
gViewPort->UpdateSpectatorPanel();
|
|
||||||
}
|
|
||||||
else if ( !m_iIntermission && intermission )
|
|
||||||
{
|
|
||||||
m_iIntermission = intermission;
|
|
||||||
gViewPort->HideCommandMenu();
|
|
||||||
gViewPort->HideVGUIMenu();
|
|
||||||
gViewPort->ShowScoreBoard();
|
|
||||||
gViewPort->UpdateSpectatorPanel();
|
|
||||||
|
|
||||||
// Take a screenshot if the client's got the cvar set
|
|
||||||
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
|
|
||||||
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_flShotTime && m_flShotTime < flTime)
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnClientCmd("snapshot\n");
|
|
||||||
m_flShotTime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_iIntermission = intermission;
|
|
||||||
|
|
||||||
// if no redrawing is necessary
|
|
||||||
// return 0;
|
|
||||||
|
|
||||||
// draw all registered HUD elements
|
|
||||||
if ( m_pCvarDraw->value )
|
|
||||||
{
|
|
||||||
HUDLIST *pList = m_pHudList;
|
|
||||||
|
|
||||||
while (pList)
|
|
||||||
{
|
|
||||||
if ( !Bench_Active() )
|
|
||||||
{
|
|
||||||
if ( !intermission )
|
|
||||||
{
|
|
||||||
if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
|
|
||||||
pList->p->Draw(flTime);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions
|
|
||||||
if ( pList->p->m_iFlags & HUD_INTERMISSION )
|
|
||||||
pList->p->Draw( flTime );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( ( pList->p == &m_Benchmark ) &&
|
|
||||||
( pList->p->m_iFlags & HUD_ACTIVE ) &&
|
|
||||||
!( m_iHideHUDDisplay & HIDEHUD_ALL ) )
|
|
||||||
{
|
|
||||||
pList->p->Draw(flTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pList = pList->pNext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// are we in demo mode? do we need to draw the logo in the top corner?
|
|
||||||
if (m_iLogo)
|
|
||||||
{
|
|
||||||
int x, y, i;
|
|
||||||
|
|
||||||
if (m_hsprLogo == 0)
|
|
||||||
m_hsprLogo = LoadSprite("sprites/%d_logo.spr");
|
|
||||||
|
|
||||||
SPR_Set(m_hsprLogo, 250, 250, 250 );
|
|
||||||
|
|
||||||
x = SPR_Width(m_hsprLogo, 0);
|
|
||||||
x = ScreenWidth - x;
|
|
||||||
y = SPR_Height(m_hsprLogo, 0)/2;
|
|
||||||
|
|
||||||
// Draw the logo at 20 fps
|
|
||||||
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
|
|
||||||
i = grgLogoFrame[iFrame] - 1;
|
|
||||||
|
|
||||||
SPR_DrawAdditive(i, x, y, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ( g_iVisibleMouse )
|
|
||||||
{
|
|
||||||
void IN_GetMousePos( int *mx, int *my );
|
|
||||||
int mx, my;
|
|
||||||
|
|
||||||
IN_GetMousePos( &mx, &my );
|
|
||||||
|
|
||||||
if (m_hsprCursor == 0)
|
|
||||||
{
|
|
||||||
char sz[256];
|
|
||||||
sprintf( sz, "sprites/cursor.spr" );
|
|
||||||
m_hsprCursor = SPR_Load( sz );
|
|
||||||
}
|
|
||||||
|
|
||||||
SPR_Set(m_hsprCursor, 250, 250, 250 );
|
|
||||||
|
|
||||||
// Draw the logo at 20 fps
|
|
||||||
SPR_DrawAdditive( 0, mx, my, NULL );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleColors( int &r, int &g, int &b, int a )
|
|
||||||
{
|
|
||||||
float x = (float)a / 255;
|
|
||||||
r = (int)(r * x);
|
|
||||||
g = (int)(g * x);
|
|
||||||
b = (int)(b * x);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
|
|
||||||
{
|
|
||||||
return xpos + gEngfuncs.pfnDrawString( xpos, ypos, szIt, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
|
|
||||||
{
|
|
||||||
char szString[32];
|
|
||||||
sprintf( szString, "%d", iNumber );
|
|
||||||
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// draws a string from right to left (right-aligned)
|
|
||||||
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
|
|
||||||
{
|
|
||||||
return xpos - gEngfuncs.pfnDrawStringReverse( xpos, ypos, szString, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
|
|
||||||
{
|
|
||||||
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
|
|
||||||
int k;
|
|
||||||
|
|
||||||
if (iNumber > 0)
|
|
||||||
{
|
|
||||||
// SPR_Draw 100's
|
|
||||||
if (iNumber >= 100)
|
|
||||||
{
|
|
||||||
k = iNumber/100;
|
|
||||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
else if (iFlags & (DHN_3DIGITS))
|
|
||||||
{
|
|
||||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SPR_Draw 10's
|
|
||||||
if (iNumber >= 10)
|
|
||||||
{
|
|
||||||
k = (iNumber % 100)/10;
|
|
||||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
|
||||||
{
|
|
||||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SPR_Draw ones
|
|
||||||
k = iNumber % 10;
|
|
||||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
|
||||||
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
else if (iFlags & DHN_DRAWZERO)
|
|
||||||
{
|
|
||||||
SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
|
|
||||||
|
|
||||||
// SPR_Draw 100's
|
|
||||||
if (iFlags & (DHN_3DIGITS))
|
|
||||||
{
|
|
||||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
|
||||||
{
|
|
||||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SPR_Draw ones
|
|
||||||
|
|
||||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
|
|
||||||
x += iWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHud::GetNumWidth( int iNumber, int iFlags )
|
|
||||||
{
|
|
||||||
if (iFlags & (DHN_3DIGITS))
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
if (iFlags & (DHN_2DIGITS))
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
if (iNumber <= 0)
|
|
||||||
{
|
|
||||||
if (iFlags & (DHN_DRAWZERO))
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iNumber < 10)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (iNumber < 100)
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,41 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( HUD_SERVERSH )
|
|
||||||
#define HUD_SERVERSH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define NET_CALLBACK /* */
|
|
||||||
|
|
||||||
// Dispatchers
|
|
||||||
void NET_CALLBACK ListResponse( struct net_response_s *response );
|
|
||||||
void NET_CALLBACK ServerResponse( struct net_response_s *response );
|
|
||||||
void NET_CALLBACK PingResponse( struct net_response_s *response );
|
|
||||||
void NET_CALLBACK RulesResponse( struct net_response_s *response );
|
|
||||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
|
||||||
|
|
||||||
void ServersInit( void );
|
|
||||||
void ServersShutdown( void );
|
|
||||||
void ServersThink( double time );
|
|
||||||
void ServersCancel( void );
|
|
||||||
|
|
||||||
// Get list and get server info from each
|
|
||||||
void ServersList( void );
|
|
||||||
|
|
||||||
// Query for IP / IPX LAN servers
|
|
||||||
void BroadcastServersList( int clearpending );
|
|
||||||
|
|
||||||
void ServerPing( int server );
|
|
||||||
void ServerRules( int server );
|
|
||||||
void ServerPlayers( int server );
|
|
||||||
|
|
||||||
int ServersGetCount( void );
|
|
||||||
const char *ServersGetInfo( int server );
|
|
||||||
int ServersIsQuerying( void );
|
|
||||||
void SortServers( const char *fieldname );
|
|
||||||
|
|
||||||
#endif // HUD_SERVERSH
|
|
|
@ -1,98 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( HUD_SERVERS_PRIVH )
|
|
||||||
#define HUD_SERVERS_PRIVH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "netadr.h"
|
|
||||||
|
|
||||||
class CHudServers
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef struct request_s
|
|
||||||
{
|
|
||||||
struct request_s *next;
|
|
||||||
netadr_t remote_address;
|
|
||||||
int context;
|
|
||||||
} request_t;
|
|
||||||
|
|
||||||
typedef struct server_s
|
|
||||||
{
|
|
||||||
struct server_s *next;
|
|
||||||
netadr_t remote_address;
|
|
||||||
char *info;
|
|
||||||
int ping;
|
|
||||||
} server_t;
|
|
||||||
|
|
||||||
CHudServers();
|
|
||||||
~CHudServers();
|
|
||||||
|
|
||||||
void Think( double time );
|
|
||||||
void QueryThink( void );
|
|
||||||
int isQuerying( void );
|
|
||||||
|
|
||||||
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
|
|
||||||
|
|
||||||
void RequestList( void );
|
|
||||||
void RequestBroadcastList( int clearpending );
|
|
||||||
|
|
||||||
void ServerPing( int server );
|
|
||||||
void ServerRules( int server );
|
|
||||||
void ServerPlayers( int server );
|
|
||||||
|
|
||||||
void CancelRequest( void );
|
|
||||||
|
|
||||||
int CompareServers( server_t *p1, server_t *p2 );
|
|
||||||
|
|
||||||
void ClearServerList( server_t **ppList );
|
|
||||||
void ClearRequestList( request_t **ppList );
|
|
||||||
|
|
||||||
void AddServer( server_t **ppList, server_t *p );
|
|
||||||
|
|
||||||
void RemoveServerFromList( request_t **ppList, request_t *item );
|
|
||||||
|
|
||||||
request_t *FindRequest( int context, request_t *pList );
|
|
||||||
|
|
||||||
int ServerListSize( void );
|
|
||||||
char *GetServerInfo( int server );
|
|
||||||
int GetServerCount( void );
|
|
||||||
void SortServers( const char *fieldname );
|
|
||||||
|
|
||||||
void ListResponse( struct net_response_s *response );
|
|
||||||
void ServerResponse( struct net_response_s *response );
|
|
||||||
void PingResponse( struct net_response_s *response );
|
|
||||||
void RulesResponse( struct net_response_s *response );
|
|
||||||
void PlayersResponse( struct net_response_s *response );
|
|
||||||
private:
|
|
||||||
|
|
||||||
server_t *GetServer( int server );
|
|
||||||
|
|
||||||
//
|
|
||||||
char m_szToken[ 1024 ];
|
|
||||||
int m_nRequesting;
|
|
||||||
int m_nDone;
|
|
||||||
|
|
||||||
double m_dStarted;
|
|
||||||
|
|
||||||
request_t *m_pServerList;
|
|
||||||
request_t *m_pActiveList;
|
|
||||||
|
|
||||||
server_t *m_pServers;
|
|
||||||
|
|
||||||
int m_nServerCount;
|
|
||||||
|
|
||||||
int m_nActiveQueries;
|
|
||||||
int m_nQuerying;
|
|
||||||
double m_fElapsed;
|
|
||||||
|
|
||||||
request_t *m_pPingRequest;
|
|
||||||
request_t *m_pRulesRequest;
|
|
||||||
request_t *m_pPlayersRequest;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HUD_SERVERS_PRIVH
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,156 +0,0 @@
|
||||||
//========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef SPECTATOR_H
|
|
||||||
#define SPECTATOR_H
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "interpolation.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define INSET_OFF 0
|
|
||||||
#define INSET_CHASE_FREE 1
|
|
||||||
#define INSET_IN_EYE 2
|
|
||||||
#define INSET_MAP_FREE 3
|
|
||||||
#define INSET_MAP_CHASE 4
|
|
||||||
|
|
||||||
#define MAX_SPEC_HUD_MESSAGES 8
|
|
||||||
|
|
||||||
#define OVERVIEW_TILE_SIZE 128 // don't change this
|
|
||||||
#define OVERVIEW_MAX_LAYERS 1
|
|
||||||
|
|
||||||
extern void VectorAngles( const float *forward, float *angles );
|
|
||||||
extern "C" void NormalizeAngles( float *angles );
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
typedef struct overviewInfo_s {
|
|
||||||
char map[64]; // cl.levelname or empty
|
|
||||||
vec3_t origin; // center of map
|
|
||||||
float zoom; // zoom of map images
|
|
||||||
int layers; // how may layers do we have
|
|
||||||
float layersHeights[OVERVIEW_MAX_LAYERS];
|
|
||||||
char layersImages[OVERVIEW_MAX_LAYERS][255];
|
|
||||||
qboolean rotated; // are map images rotated (90 degrees) ?
|
|
||||||
|
|
||||||
int insetWindowX;
|
|
||||||
int insetWindowY;
|
|
||||||
int insetWindowHeight;
|
|
||||||
int insetWindowWidth;
|
|
||||||
} overviewInfo_t;
|
|
||||||
|
|
||||||
typedef struct overviewEntity_s {
|
|
||||||
|
|
||||||
HSPRITE hSprite;
|
|
||||||
struct cl_entity_s * entity;
|
|
||||||
double killTime;
|
|
||||||
} overviewEntity_t;
|
|
||||||
|
|
||||||
typedef struct cameraWayPoint_s
|
|
||||||
{
|
|
||||||
float time;
|
|
||||||
vec3_t position;
|
|
||||||
vec3_t angle;
|
|
||||||
float fov;
|
|
||||||
int flags;
|
|
||||||
} cameraWayPoint_t;
|
|
||||||
|
|
||||||
#define MAX_OVERVIEW_ENTITIES 128
|
|
||||||
#define MAX_CAM_WAYPOINTS 32
|
|
||||||
|
|
||||||
class CHudSpectator : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void Reset();
|
|
||||||
int ToggleInset(bool allowOff);
|
|
||||||
void CheckSettings();
|
|
||||||
void InitHUDData( void );
|
|
||||||
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
|
|
||||||
void DeathMessage(int victim);
|
|
||||||
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
|
|
||||||
void CheckOverviewEntities();
|
|
||||||
void DrawOverview();
|
|
||||||
void DrawOverviewEntities();
|
|
||||||
void GetMapPosition( float * returnvec );
|
|
||||||
void DrawOverviewLayer();
|
|
||||||
void LoadMapSprites();
|
|
||||||
bool ParseOverviewFile();
|
|
||||||
bool IsActivePlayer(cl_entity_t * ent);
|
|
||||||
void SetModes(int iMainMode, int iInsetMode);
|
|
||||||
void HandleButtonsDown(int ButtonPressed);
|
|
||||||
void HandleButtonsUp(int ButtonPressed);
|
|
||||||
void FindNextPlayer( bool bReverse );
|
|
||||||
void FindPlayer(const char *name);
|
|
||||||
void DirectorMessage( int iSize, void *pbuf );
|
|
||||||
void SetSpectatorStartPosition();
|
|
||||||
int Init();
|
|
||||||
int VidInit();
|
|
||||||
|
|
||||||
int Draw(float flTime);
|
|
||||||
|
|
||||||
void AddWaypoint( float time, vec3_t pos, vec3_t angle, float fov, int flags );
|
|
||||||
void SetCameraView( vec3_t pos, vec3_t angle, float fov);
|
|
||||||
float GetFOV();
|
|
||||||
bool GetDirectorCamera(vec3_t &position, vec3_t &angle);
|
|
||||||
void SetWayInterpolation(cameraWayPoint_t * prev, cameraWayPoint_t * start, cameraWayPoint_t * end, cameraWayPoint_t * next);
|
|
||||||
|
|
||||||
|
|
||||||
int m_iDrawCycle;
|
|
||||||
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
|
|
||||||
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
|
|
||||||
int m_lastHudMessage;
|
|
||||||
overviewInfo_t m_OverviewData;
|
|
||||||
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
|
|
||||||
int m_iObserverFlags;
|
|
||||||
int m_iSpectatorNumber;
|
|
||||||
|
|
||||||
float m_mapZoom; // zoom the user currently uses
|
|
||||||
vec3_t m_mapOrigin; // origin where user rotates around
|
|
||||||
cvar_t * m_drawnames;
|
|
||||||
cvar_t * m_drawcone;
|
|
||||||
cvar_t * m_drawstatus;
|
|
||||||
cvar_t * m_autoDirector;
|
|
||||||
cvar_t * m_pip;
|
|
||||||
qboolean m_chatEnabled;
|
|
||||||
|
|
||||||
qboolean m_IsInterpolating;
|
|
||||||
int m_ChaseEntity; // if != 0, follow this entity with viewangles
|
|
||||||
int m_WayPoint; // current waypoint 1
|
|
||||||
int m_NumWayPoints; // current number of waypoints
|
|
||||||
vec3_t m_cameraOrigin; // a help camera
|
|
||||||
vec3_t m_cameraAngles; // and it's angles
|
|
||||||
CInterpolation m_WayInterpolation;
|
|
||||||
|
|
||||||
private:
|
|
||||||
vec3_t m_vPlayerPos[MAX_PLAYERS];
|
|
||||||
HSPRITE m_hsprPlayerBlue;
|
|
||||||
HSPRITE m_hsprPlayerRed;
|
|
||||||
HSPRITE m_hsprPlayer;
|
|
||||||
HSPRITE m_hsprCamera;
|
|
||||||
HSPRITE m_hsprPlayerDead;
|
|
||||||
HSPRITE m_hsprViewcone;
|
|
||||||
HSPRITE m_hsprUnkownMap;
|
|
||||||
HSPRITE m_hsprBeam;
|
|
||||||
HSPRITE m_hCrosshair;
|
|
||||||
|
|
||||||
wrect_t m_crosshairRect;
|
|
||||||
|
|
||||||
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
|
|
||||||
float m_flNextObserverInput;
|
|
||||||
float m_FOV;
|
|
||||||
float m_zoomDelta;
|
|
||||||
float m_moveDelta;
|
|
||||||
int m_lastPrimaryObject;
|
|
||||||
int m_lastSecondaryObject;
|
|
||||||
|
|
||||||
cameraWayPoint_t m_CamPath[MAX_CAM_WAYPOINTS];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SPECTATOR_H
|
|
|
@ -1,54 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// hud_update.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
int CL_ButtonBits( int );
|
|
||||||
void CL_ResetButtonBits( int bits );
|
|
||||||
|
|
||||||
extern float v_idlescale;
|
|
||||||
float in_fov;
|
|
||||||
extern void HUD_SetCmdBits( int bits );
|
|
||||||
|
|
||||||
int CHud::UpdateClientData(client_data_t *cdata, float time)
|
|
||||||
{
|
|
||||||
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
|
|
||||||
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
|
|
||||||
|
|
||||||
m_iKeyBits = CL_ButtonBits( 0 );
|
|
||||||
m_iWeaponBits = cdata->iWeaponBits;
|
|
||||||
|
|
||||||
in_fov = cdata->fov;
|
|
||||||
|
|
||||||
Think();
|
|
||||||
|
|
||||||
cdata->fov = m_iFOV;
|
|
||||||
|
|
||||||
v_idlescale = m_iConcussionEffect;
|
|
||||||
|
|
||||||
CL_ResetButtonBits( m_iKeyBits );
|
|
||||||
|
|
||||||
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,631 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "kbutton.h"
|
|
||||||
#include "cvardef.h"
|
|
||||||
#include "usercmd.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "in_defs.h"
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
#include "SDL2/SDL_mouse.h"
|
|
||||||
#include "port.h"
|
|
||||||
|
|
||||||
float CL_KeyState (kbutton_t *key);
|
|
||||||
|
|
||||||
extern cl_enginefunc_t gEngfuncs;
|
|
||||||
|
|
||||||
//-------------------------------------------------- Constants
|
|
||||||
|
|
||||||
#define CAM_DIST_DELTA 1.0
|
|
||||||
#define CAM_ANGLE_DELTA 2.5
|
|
||||||
#define CAM_ANGLE_SPEED 2.5
|
|
||||||
#define CAM_MIN_DIST 30.0
|
|
||||||
#define CAM_ANGLE_MOVE .5
|
|
||||||
#define MAX_ANGLE_DIFF 10.0
|
|
||||||
#define PITCH_MAX 90.0
|
|
||||||
#define PITCH_MIN 0
|
|
||||||
#define YAW_MAX 135.0
|
|
||||||
#define YAW_MIN -135.0
|
|
||||||
|
|
||||||
enum ECAM_Command
|
|
||||||
{
|
|
||||||
CAM_COMMAND_NONE = 0,
|
|
||||||
CAM_COMMAND_TOTHIRDPERSON = 1,
|
|
||||||
CAM_COMMAND_TOFIRSTPERSON = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------- Global Variables
|
|
||||||
|
|
||||||
cvar_t *cam_command;
|
|
||||||
cvar_t *cam_snapto;
|
|
||||||
cvar_t *cam_idealyaw;
|
|
||||||
cvar_t *cam_idealpitch;
|
|
||||||
cvar_t *cam_idealdist;
|
|
||||||
cvar_t *cam_contain;
|
|
||||||
|
|
||||||
cvar_t *c_maxpitch;
|
|
||||||
cvar_t *c_minpitch;
|
|
||||||
cvar_t *c_maxyaw;
|
|
||||||
cvar_t *c_minyaw;
|
|
||||||
cvar_t *c_maxdistance;
|
|
||||||
cvar_t *c_mindistance;
|
|
||||||
|
|
||||||
// pitch, yaw, dist
|
|
||||||
vec3_t cam_ofs;
|
|
||||||
|
|
||||||
|
|
||||||
// In third person
|
|
||||||
int cam_thirdperson;
|
|
||||||
int cam_mousemove; //true if we are moving the cam with the mouse, False if not
|
|
||||||
int iMouseInUse=0;
|
|
||||||
int cam_distancemove;
|
|
||||||
extern int mouse_x, mouse_y; //used to determine what the current x and y values are
|
|
||||||
int cam_old_mouse_x, cam_old_mouse_y; //holds the last ticks mouse movement
|
|
||||||
POINT cam_mouse;
|
|
||||||
//-------------------------------------------------- Local Variables
|
|
||||||
|
|
||||||
static kbutton_t cam_pitchup, cam_pitchdown, cam_yawleft, cam_yawright;
|
|
||||||
static kbutton_t cam_in, cam_out, cam_move;
|
|
||||||
|
|
||||||
//-------------------------------------------------- Prototypes
|
|
||||||
|
|
||||||
void CAM_ToThirdPerson(void);
|
|
||||||
void CAM_ToFirstPerson(void);
|
|
||||||
void CAM_StartDistance(void);
|
|
||||||
void CAM_EndDistance(void);
|
|
||||||
|
|
||||||
void SDL_GetCursorPos( POINT *p )
|
|
||||||
{
|
|
||||||
gEngfuncs.GetMousePosition( (int *)&p->x, (int *)&p->y );
|
|
||||||
// SDL_GetMouseState( (int *)&p->x, (int *)&p->y );
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDL_SetCursorPos( const int x, const int y )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------- Local Functions
|
|
||||||
|
|
||||||
float MoveToward( float cur, float goal, float maxspeed )
|
|
||||||
{
|
|
||||||
if( cur != goal )
|
|
||||||
{
|
|
||||||
if( abs( cur - goal ) > 180.0 )
|
|
||||||
{
|
|
||||||
if( cur < goal )
|
|
||||||
cur += 360.0;
|
|
||||||
else
|
|
||||||
cur -= 360.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cur < goal )
|
|
||||||
{
|
|
||||||
if( cur < goal - 1.0 )
|
|
||||||
cur += ( goal - cur ) / 4.0;
|
|
||||||
else
|
|
||||||
cur = goal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( cur > goal + 1.0 )
|
|
||||||
cur -= ( cur - goal ) / 4.0;
|
|
||||||
else
|
|
||||||
cur = goal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// bring cur back into range
|
|
||||||
if( cur < 0 )
|
|
||||||
cur += 360.0;
|
|
||||||
else if( cur >= 360 )
|
|
||||||
cur -= 360;
|
|
||||||
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------- Gobal Functions
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
vec3_t boxmins, boxmaxs;// enclose the test object along entire move
|
|
||||||
float *mins, *maxs; // size of the moving object
|
|
||||||
vec3_t mins2, maxs2; // size when clipping against mosnters
|
|
||||||
float *start, *end;
|
|
||||||
trace_t trace;
|
|
||||||
int type;
|
|
||||||
edict_t *passedict;
|
|
||||||
qboolean monsterclip;
|
|
||||||
} moveclip_t;
|
|
||||||
|
|
||||||
extern trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
|
|
||||||
|
|
||||||
void CL_DLLEXPORT CAM_Think( void )
|
|
||||||
{
|
|
||||||
// RecClCamThink();
|
|
||||||
|
|
||||||
vec3_t origin;
|
|
||||||
vec3_t ext, pnt, camForward, camRight, camUp;
|
|
||||||
moveclip_t clip;
|
|
||||||
float dist;
|
|
||||||
vec3_t camAngles;
|
|
||||||
float flSensitivity;
|
|
||||||
#ifdef LATER
|
|
||||||
int i;
|
|
||||||
#endif
|
|
||||||
vec3_t viewangles;
|
|
||||||
|
|
||||||
switch( (int) cam_command->value )
|
|
||||||
{
|
|
||||||
case CAM_COMMAND_TOTHIRDPERSON:
|
|
||||||
CAM_ToThirdPerson();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CAM_COMMAND_TOFIRSTPERSON:
|
|
||||||
CAM_ToFirstPerson();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CAM_COMMAND_NONE:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !cam_thirdperson )
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef LATER
|
|
||||||
if ( cam_contain->value )
|
|
||||||
{
|
|
||||||
gEngfuncs.GetClientOrigin( origin );
|
|
||||||
ext[0] = ext[1] = ext[2] = 0.0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
camAngles[ PITCH ] = cam_idealpitch->value;
|
|
||||||
camAngles[ YAW ] = cam_idealyaw->value;
|
|
||||||
dist = cam_idealdist->value;
|
|
||||||
//
|
|
||||||
//movement of the camera with the mouse
|
|
||||||
//
|
|
||||||
if (cam_mousemove)
|
|
||||||
{
|
|
||||||
//get windows cursor position
|
|
||||||
SDL_GetCursorPos (&cam_mouse);
|
|
||||||
//check for X delta values and adjust accordingly
|
|
||||||
//eventually adjust YAW based on amount of movement
|
|
||||||
//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera
|
|
||||||
if (!cam_distancemove)
|
|
||||||
{
|
|
||||||
|
|
||||||
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
|
|
||||||
if (cam_mouse.x>gEngfuncs.GetWindowCenterX())
|
|
||||||
{
|
|
||||||
//if ((camAngles[YAW]>=225.0)||(camAngles[YAW]<135.0))
|
|
||||||
if (camAngles[YAW]<c_maxyaw->value)
|
|
||||||
{
|
|
||||||
camAngles[ YAW ] += (CAM_ANGLE_MOVE)*((cam_mouse.x-gEngfuncs.GetWindowCenterX())/2);
|
|
||||||
}
|
|
||||||
if (camAngles[YAW]>c_maxyaw->value)
|
|
||||||
{
|
|
||||||
|
|
||||||
camAngles[YAW]=c_maxyaw->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cam_mouse.x<gEngfuncs.GetWindowCenterX())
|
|
||||||
{
|
|
||||||
//if ((camAngles[YAW]<=135.0)||(camAngles[YAW]>225.0))
|
|
||||||
if (camAngles[YAW]>c_minyaw->value)
|
|
||||||
{
|
|
||||||
camAngles[ YAW ] -= (CAM_ANGLE_MOVE)* ((gEngfuncs.GetWindowCenterX()-cam_mouse.x)/2);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (camAngles[YAW]<c_minyaw->value)
|
|
||||||
{
|
|
||||||
camAngles[YAW]=c_minyaw->value;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//check for y delta values and adjust accordingly
|
|
||||||
//eventually adjust PITCH based on amount of movement
|
|
||||||
//also make sure camera is within bounds
|
|
||||||
if (cam_mouse.y>gEngfuncs.GetWindowCenterY())
|
|
||||||
{
|
|
||||||
if(camAngles[PITCH]<c_maxpitch->value)
|
|
||||||
{
|
|
||||||
camAngles[PITCH] +=(CAM_ANGLE_MOVE)* ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2);
|
|
||||||
}
|
|
||||||
if (camAngles[PITCH]>c_maxpitch->value)
|
|
||||||
{
|
|
||||||
camAngles[PITCH]=c_maxpitch->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY())
|
|
||||||
{
|
|
||||||
if (camAngles[PITCH]>c_minpitch->value)
|
|
||||||
{
|
|
||||||
camAngles[PITCH] -= (CAM_ANGLE_MOVE)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
|
|
||||||
}
|
|
||||||
if (camAngles[PITCH]<c_minpitch->value)
|
|
||||||
{
|
|
||||||
camAngles[PITCH]=c_minpitch->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//set old mouse coordinates to current mouse coordinates
|
|
||||||
//since we are done with the mouse
|
|
||||||
|
|
||||||
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
|
|
||||||
{
|
|
||||||
cam_old_mouse_x=cam_mouse.x*flSensitivity;
|
|
||||||
cam_old_mouse_y=cam_mouse.y*flSensitivity;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cam_old_mouse_x=cam_mouse.x;
|
|
||||||
cam_old_mouse_y=cam_mouse.y;
|
|
||||||
}
|
|
||||||
SDL_SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Nathan code here
|
|
||||||
if( CL_KeyState( &cam_pitchup ) )
|
|
||||||
camAngles[ PITCH ] += CAM_ANGLE_DELTA;
|
|
||||||
else if( CL_KeyState( &cam_pitchdown ) )
|
|
||||||
camAngles[ PITCH ] -= CAM_ANGLE_DELTA;
|
|
||||||
|
|
||||||
if( CL_KeyState( &cam_yawleft ) )
|
|
||||||
camAngles[ YAW ] -= CAM_ANGLE_DELTA;
|
|
||||||
else if( CL_KeyState( &cam_yawright ) )
|
|
||||||
camAngles[ YAW ] += CAM_ANGLE_DELTA;
|
|
||||||
|
|
||||||
if( CL_KeyState( &cam_in ) )
|
|
||||||
{
|
|
||||||
dist -= CAM_DIST_DELTA;
|
|
||||||
if( dist < CAM_MIN_DIST )
|
|
||||||
{
|
|
||||||
// If we go back into first person, reset the angle
|
|
||||||
camAngles[ PITCH ] = 0;
|
|
||||||
camAngles[ YAW ] = 0;
|
|
||||||
dist = CAM_MIN_DIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if( CL_KeyState( &cam_out ) )
|
|
||||||
dist += CAM_DIST_DELTA;
|
|
||||||
|
|
||||||
if (cam_distancemove)
|
|
||||||
{
|
|
||||||
if (cam_mouse.y>gEngfuncs.GetWindowCenterY())
|
|
||||||
{
|
|
||||||
if(dist<c_maxdistance->value)
|
|
||||||
{
|
|
||||||
dist +=CAM_DIST_DELTA * ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2);
|
|
||||||
}
|
|
||||||
if (dist>c_maxdistance->value)
|
|
||||||
{
|
|
||||||
dist=c_maxdistance->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY())
|
|
||||||
{
|
|
||||||
if (dist>c_mindistance->value)
|
|
||||||
{
|
|
||||||
dist -= (CAM_DIST_DELTA)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
|
|
||||||
}
|
|
||||||
if (dist<c_mindistance->value)
|
|
||||||
{
|
|
||||||
dist=c_mindistance->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//set old mouse coordinates to current mouse coordinates
|
|
||||||
//since we are done with the mouse
|
|
||||||
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity();
|
|
||||||
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity();
|
|
||||||
SDL_SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
|
||||||
}
|
|
||||||
#ifdef LATER
|
|
||||||
if( cam_contain->value )
|
|
||||||
{
|
|
||||||
// check new ideal
|
|
||||||
VectorCopy( origin, pnt );
|
|
||||||
AngleVectors( camAngles, camForward, camRight, camUp );
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
pnt[i] += -dist*camForward[i];
|
|
||||||
|
|
||||||
// check line from r_refdef.vieworg to pnt
|
|
||||||
memset ( &clip, 0, sizeof ( moveclip_t ) );
|
|
||||||
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
|
|
||||||
if( clip.trace.fraction == 1.0 )
|
|
||||||
{
|
|
||||||
// update ideal
|
|
||||||
cam_idealpitch->value = camAngles[ PITCH ];
|
|
||||||
cam_idealyaw->value = camAngles[ YAW ];
|
|
||||||
cam_idealdist->value = dist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// update ideal
|
|
||||||
cam_idealpitch->value = camAngles[ PITCH ];
|
|
||||||
cam_idealyaw->value = camAngles[ YAW ];
|
|
||||||
cam_idealdist->value = dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move towards ideal
|
|
||||||
VectorCopy( cam_ofs, camAngles );
|
|
||||||
|
|
||||||
gEngfuncs.GetViewAngles( (float *)viewangles );
|
|
||||||
|
|
||||||
if( cam_snapto->value )
|
|
||||||
{
|
|
||||||
camAngles[ YAW ] = cam_idealyaw->value + viewangles[ YAW ];
|
|
||||||
camAngles[ PITCH ] = cam_idealpitch->value + viewangles[ PITCH ];
|
|
||||||
camAngles[ 2 ] = cam_idealdist->value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( camAngles[ YAW ] - viewangles[ YAW ] != cam_idealyaw->value )
|
|
||||||
camAngles[ YAW ] = MoveToward( camAngles[ YAW ], cam_idealyaw->value + viewangles[ YAW ], CAM_ANGLE_SPEED );
|
|
||||||
|
|
||||||
if( camAngles[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch->value )
|
|
||||||
camAngles[ PITCH ] = MoveToward( camAngles[ PITCH ], cam_idealpitch->value + viewangles[ PITCH ], CAM_ANGLE_SPEED );
|
|
||||||
|
|
||||||
if( abs( camAngles[ 2 ] - cam_idealdist->value ) < 2.0 )
|
|
||||||
camAngles[ 2 ] = cam_idealdist->value;
|
|
||||||
else
|
|
||||||
camAngles[ 2 ] += ( cam_idealdist->value - camAngles[ 2 ] ) / 4.0;
|
|
||||||
}
|
|
||||||
#ifdef LATER
|
|
||||||
if( cam_contain->value )
|
|
||||||
{
|
|
||||||
// Test new position
|
|
||||||
dist = camAngles[ ROLL ];
|
|
||||||
camAngles[ ROLL ] = 0;
|
|
||||||
|
|
||||||
VectorCopy( origin, pnt );
|
|
||||||
AngleVectors( camAngles, camForward, camRight, camUp );
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
pnt[i] += -dist*camForward[i];
|
|
||||||
|
|
||||||
// check line from r_refdef.vieworg to pnt
|
|
||||||
memset ( &clip, 0, sizeof ( moveclip_t ) );
|
|
||||||
ext[0] = ext[1] = ext[2] = 0.0;
|
|
||||||
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
|
|
||||||
if( clip.trace.fraction != 1.0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
cam_ofs[ 0 ] = camAngles[ 0 ];
|
|
||||||
cam_ofs[ 1 ] = camAngles[ 1 ];
|
|
||||||
cam_ofs[ 2 ] = dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void KeyDown (kbutton_t *b); // HACK
|
|
||||||
extern void KeyUp (kbutton_t *b); // HACK
|
|
||||||
|
|
||||||
void CAM_PitchUpDown(void) { KeyDown( &cam_pitchup ); }
|
|
||||||
void CAM_PitchUpUp(void) { KeyUp( &cam_pitchup ); }
|
|
||||||
void CAM_PitchDownDown(void) { KeyDown( &cam_pitchdown ); }
|
|
||||||
void CAM_PitchDownUp(void) { KeyUp( &cam_pitchdown ); }
|
|
||||||
void CAM_YawLeftDown(void) { KeyDown( &cam_yawleft ); }
|
|
||||||
void CAM_YawLeftUp(void) { KeyUp( &cam_yawleft ); }
|
|
||||||
void CAM_YawRightDown(void) { KeyDown( &cam_yawright ); }
|
|
||||||
void CAM_YawRightUp(void) { KeyUp( &cam_yawright ); }
|
|
||||||
void CAM_InDown(void) { KeyDown( &cam_in ); }
|
|
||||||
void CAM_InUp(void) { KeyUp( &cam_in ); }
|
|
||||||
void CAM_OutDown(void) { KeyDown( &cam_out ); }
|
|
||||||
void CAM_OutUp(void) { KeyUp( &cam_out ); }
|
|
||||||
|
|
||||||
void CAM_ToThirdPerson(void)
|
|
||||||
{
|
|
||||||
vec3_t viewangles;
|
|
||||||
|
|
||||||
#if !defined( _DEBUG )
|
|
||||||
if ( gEngfuncs.GetMaxClients() > 1 )
|
|
||||||
{
|
|
||||||
// no thirdperson in multiplayer.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gEngfuncs.GetViewAngles( (float *)viewangles );
|
|
||||||
|
|
||||||
if( !cam_thirdperson )
|
|
||||||
{
|
|
||||||
cam_thirdperson = 1;
|
|
||||||
|
|
||||||
cam_ofs[ YAW ] = viewangles[ YAW ];
|
|
||||||
cam_ofs[ PITCH ] = viewangles[ PITCH ];
|
|
||||||
cam_ofs[ 2 ] = CAM_MIN_DIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
gEngfuncs.Cvar_SetValue( "cam_command", 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_ToFirstPerson(void)
|
|
||||||
{
|
|
||||||
cam_thirdperson = 0;
|
|
||||||
|
|
||||||
gEngfuncs.Cvar_SetValue( "cam_command", 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_ToggleSnapto( void )
|
|
||||||
{
|
|
||||||
cam_snapto->value = !cam_snapto->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_Init( void )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnAddCommand( "+campitchup", CAM_PitchUpDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-campitchup", CAM_PitchUpUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "+campitchdown", CAM_PitchDownDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-campitchdown", CAM_PitchDownUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "+camyawleft", CAM_YawLeftDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-camyawleft", CAM_YawLeftUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "+camyawright", CAM_YawRightDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-camyawright", CAM_YawRightUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "+camin", CAM_InDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-camin", CAM_InUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "+camout", CAM_OutDown );
|
|
||||||
gEngfuncs.pfnAddCommand( "-camout", CAM_OutUp );
|
|
||||||
gEngfuncs.pfnAddCommand( "thirdperson", CAM_ToThirdPerson );
|
|
||||||
gEngfuncs.pfnAddCommand( "firstperson", CAM_ToFirstPerson );
|
|
||||||
gEngfuncs.pfnAddCommand( "+cammousemove",CAM_StartMouseMove);
|
|
||||||
gEngfuncs.pfnAddCommand( "-cammousemove",CAM_EndMouseMove);
|
|
||||||
gEngfuncs.pfnAddCommand( "+camdistance", CAM_StartDistance );
|
|
||||||
gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance );
|
|
||||||
gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto );
|
|
||||||
|
|
||||||
cam_command = gEngfuncs.pfnRegisterVariable ( "cam_command", "0", 0 ); // tells camera to go to thirdperson
|
|
||||||
cam_snapto = gEngfuncs.pfnRegisterVariable ( "cam_snapto", "0", 0 ); // snap to thirdperson view
|
|
||||||
cam_idealyaw = gEngfuncs.pfnRegisterVariable ( "cam_idealyaw", "90", 0 ); // thirdperson yaw
|
|
||||||
cam_idealpitch = gEngfuncs.pfnRegisterVariable ( "cam_idealpitch", "0", 0 ); // thirperson pitch
|
|
||||||
cam_idealdist = gEngfuncs.pfnRegisterVariable ( "cam_idealdist", "64", 0 ); // thirdperson distance
|
|
||||||
cam_contain = gEngfuncs.pfnRegisterVariable ( "cam_contain", "0", 0 ); // contain camera to world
|
|
||||||
|
|
||||||
c_maxpitch = gEngfuncs.pfnRegisterVariable ( "c_maxpitch", "90.0", 0 );
|
|
||||||
c_minpitch = gEngfuncs.pfnRegisterVariable ( "c_minpitch", "0.0", 0 );
|
|
||||||
c_maxyaw = gEngfuncs.pfnRegisterVariable ( "c_maxyaw", "135.0", 0 );
|
|
||||||
c_minyaw = gEngfuncs.pfnRegisterVariable ( "c_minyaw", "-135.0", 0 );
|
|
||||||
c_maxdistance = gEngfuncs.pfnRegisterVariable ( "c_maxdistance", "200.0", 0 );
|
|
||||||
c_mindistance = gEngfuncs.pfnRegisterVariable ( "c_mindistance", "30.0", 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_ClearStates( void )
|
|
||||||
{
|
|
||||||
vec3_t viewangles;
|
|
||||||
|
|
||||||
gEngfuncs.GetViewAngles( (float *)viewangles );
|
|
||||||
|
|
||||||
cam_pitchup.state = 0;
|
|
||||||
cam_pitchdown.state = 0;
|
|
||||||
cam_yawleft.state = 0;
|
|
||||||
cam_yawright.state = 0;
|
|
||||||
cam_in.state = 0;
|
|
||||||
cam_out.state = 0;
|
|
||||||
|
|
||||||
cam_thirdperson = 0;
|
|
||||||
cam_command->value = 0;
|
|
||||||
cam_mousemove=0;
|
|
||||||
|
|
||||||
cam_snapto->value = 0;
|
|
||||||
cam_distancemove = 0;
|
|
||||||
|
|
||||||
cam_ofs[ 0 ] = 0.0;
|
|
||||||
cam_ofs[ 1 ] = 0.0;
|
|
||||||
cam_ofs[ 2 ] = CAM_MIN_DIST;
|
|
||||||
|
|
||||||
cam_idealpitch->value = viewangles[ PITCH ];
|
|
||||||
cam_idealyaw->value = viewangles[ YAW ];
|
|
||||||
cam_idealdist->value = CAM_MIN_DIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAM_StartMouseMove(void)
|
|
||||||
{
|
|
||||||
float flSensitivity;
|
|
||||||
|
|
||||||
//only move the cam with mouse if we are in third person.
|
|
||||||
if (cam_thirdperson)
|
|
||||||
{
|
|
||||||
//set appropriate flags and initialize the old mouse position
|
|
||||||
//variables for mouse camera movement
|
|
||||||
if (!cam_mousemove)
|
|
||||||
{
|
|
||||||
cam_mousemove=1;
|
|
||||||
iMouseInUse=1;
|
|
||||||
SDL_GetCursorPos (&cam_mouse);
|
|
||||||
|
|
||||||
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
|
|
||||||
{
|
|
||||||
cam_old_mouse_x=cam_mouse.x*flSensitivity;
|
|
||||||
cam_old_mouse_y=cam_mouse.y*flSensitivity;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cam_old_mouse_x=cam_mouse.x;
|
|
||||||
cam_old_mouse_y=cam_mouse.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//we are not in 3rd person view..therefore do not allow camera movement
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cam_mousemove=0;
|
|
||||||
iMouseInUse=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//the key has been released for camera movement
|
|
||||||
//tell the engine that mouse camera movement is off
|
|
||||||
void CAM_EndMouseMove(void)
|
|
||||||
{
|
|
||||||
cam_mousemove=0;
|
|
||||||
iMouseInUse=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
//routines to start the process of moving the cam in or out
|
|
||||||
//using the mouse
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void CAM_StartDistance(void)
|
|
||||||
{
|
|
||||||
//only move the cam with mouse if we are in third person.
|
|
||||||
if (cam_thirdperson)
|
|
||||||
{
|
|
||||||
//set appropriate flags and initialize the old mouse position
|
|
||||||
//variables for mouse camera movement
|
|
||||||
if (!cam_distancemove)
|
|
||||||
{
|
|
||||||
cam_distancemove=1;
|
|
||||||
cam_mousemove=1;
|
|
||||||
iMouseInUse=1;
|
|
||||||
SDL_GetCursorPos (&cam_mouse);
|
|
||||||
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity();
|
|
||||||
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//we are not in 3rd person view..therefore do not allow camera movement
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cam_distancemove=0;
|
|
||||||
cam_mousemove=0;
|
|
||||||
iMouseInUse=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//the key has been released for camera movement
|
|
||||||
//tell the engine that mouse camera movement is off
|
|
||||||
void CAM_EndDistance(void)
|
|
||||||
{
|
|
||||||
cam_distancemove=0;
|
|
||||||
cam_mousemove=0;
|
|
||||||
iMouseInUse=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CL_DLLEXPORT CL_IsThirdPerson( void )
|
|
||||||
{
|
|
||||||
// RecClCL_IsThirdPerson();
|
|
||||||
|
|
||||||
return (cam_thirdperson ? 1 : 0) || (g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CL_DLLEXPORT CL_CameraOffset( float *ofs )
|
|
||||||
{
|
|
||||||
// RecClCL_GetCameraOffsets(ofs);
|
|
||||||
|
|
||||||
VectorCopy( cam_ofs, ofs );
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( IN_DEFSH )
|
|
||||||
#define IN_DEFSH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// up / down
|
|
||||||
#define PITCH 0
|
|
||||||
// left / right
|
|
||||||
#define YAW 1
|
|
||||||
// fall over
|
|
||||||
#define ROLL 2
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,222 +0,0 @@
|
||||||
/************ (C) Copyright 2003 Valve, L.L.C. All rights reserved. ***********
|
|
||||||
**
|
|
||||||
** The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
** The contents may be used and/or copied only with the written permission of
|
|
||||||
** Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
** the agreement/contract under which the contents have been supplied.
|
|
||||||
**
|
|
||||||
*******************************************************************************
|
|
||||||
**
|
|
||||||
** Contents:
|
|
||||||
**
|
|
||||||
** interpolation.cpp: implementation of the interpolation class
|
|
||||||
**
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "interpolation.h"
|
|
||||||
|
|
||||||
// = determinant of matrix a,b,c
|
|
||||||
#define Determinant(a,b,c) ( (a)[2] * ( (b)[0]*(c)[1] - (b)[1]*(c)[0] ) + \
|
|
||||||
(a)[1] * ( (b)[2]*(c)[0] - (b)[0]*(c)[2] ) + \
|
|
||||||
(a)[0] * ( (b)[1]*(c)[2] - (b)[2]*(c)[1] ) )
|
|
||||||
|
|
||||||
// slove 3 vector linear system of equations v0 = x*v1 + y*v2 + z*v3 (if possible)
|
|
||||||
bool SolveLSE (vec3_t v0, vec3_t v1, vec3_t v2, vec3_t v3, float * x, float * y, float * z)
|
|
||||||
{
|
|
||||||
float d = Determinant(v1,v2,v3);
|
|
||||||
|
|
||||||
if (d==0.0f)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( x )
|
|
||||||
*x = Determinant(v0,v2,v3) / d;
|
|
||||||
|
|
||||||
if ( y )
|
|
||||||
*y= Determinant(v1,v0,v3) / d;
|
|
||||||
|
|
||||||
if ( z )
|
|
||||||
*z= Determinant(v1,v2,v0) / d;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// p = closest point between vector lines a1+x*m1 and a2+x*m2
|
|
||||||
bool GetPointBetweenLines(vec3_t &p, vec3_t a1, vec3_t m1, vec3_t a2, vec3_t m2 )
|
|
||||||
{
|
|
||||||
float x,z;
|
|
||||||
|
|
||||||
vec3_t t1 = CrossProduct(m1, m2);
|
|
||||||
vec3_t t2 = a2 - a1;
|
|
||||||
|
|
||||||
if ( !SolveLSE( t2, m1, t1, m2, &x , NULL, &z ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
t1 = a1 + x*m1;
|
|
||||||
t2 = a2 + (-z)*m2;
|
|
||||||
|
|
||||||
p = ( t1 + t2 ) / 2.0f;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bernstein Poynom B(u) with n = 2, i = 0
|
|
||||||
#define BernsteinPolynom20(u) ((1.0f-u)*(1.0f-u))
|
|
||||||
#define BernsteinPolynom21(u) (2.0f*u*(1.0f-u))
|
|
||||||
#define BernsteinPolynom22(u) (u*u)
|
|
||||||
|
|
||||||
CInterpolation::CInterpolation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CInterpolation::~CInterpolation()
|
|
||||||
{
|
|
||||||
m_SmoothStart = m_SmoothEnd = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::SetViewAngles( vec3_t start, vec3_t end )
|
|
||||||
{
|
|
||||||
m_StartAngle = start;
|
|
||||||
m_EndAngle = end;
|
|
||||||
NormalizeAngles( m_StartAngle );
|
|
||||||
NormalizeAngles( m_EndAngle );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::SetFOVs(float start, float end)
|
|
||||||
{
|
|
||||||
m_StartFov = start;
|
|
||||||
m_EndFov = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::SetWaypoints( vec3_t * prev, vec3_t start, vec3_t end, vec3_t * next)
|
|
||||||
{
|
|
||||||
m_StartPoint = start;
|
|
||||||
m_EndPoint = end;
|
|
||||||
|
|
||||||
|
|
||||||
vec3_t a,b,c,d;
|
|
||||||
|
|
||||||
if ( !prev && !next )
|
|
||||||
{
|
|
||||||
// no direction given, straight linear interpolation
|
|
||||||
m_Center = (m_StartPoint + m_EndPoint) / 2.0f;
|
|
||||||
}
|
|
||||||
else if ( !prev )
|
|
||||||
{
|
|
||||||
a = start - end;
|
|
||||||
float dist = a.Length() / 2.0f;
|
|
||||||
a = a.Normalize();
|
|
||||||
b = *next - end;
|
|
||||||
b = b.Normalize();
|
|
||||||
c = a - b;
|
|
||||||
c = c.Normalize();
|
|
||||||
m_Center = end + c*dist;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if ( !next )
|
|
||||||
{
|
|
||||||
a = *prev - start;
|
|
||||||
a = a.Normalize();
|
|
||||||
b = end - start;
|
|
||||||
float dist = b.Length() / 2.0f;
|
|
||||||
b = b.Normalize();
|
|
||||||
c = b - a;
|
|
||||||
c = c.Normalize();
|
|
||||||
m_Center = start + c*dist;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we have a previous and a next point, great!
|
|
||||||
a = *prev - start;
|
|
||||||
a = a.Normalize();
|
|
||||||
b = end - start;
|
|
||||||
b = b.Normalize();
|
|
||||||
c = b - a;
|
|
||||||
|
|
||||||
a = start - end;
|
|
||||||
a = a.Normalize();
|
|
||||||
b = *next - end;
|
|
||||||
b = b.Normalize();
|
|
||||||
d = a - b;
|
|
||||||
|
|
||||||
GetPointBetweenLines( m_Center, start, c, end, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::Interpolate( float t, vec3_t &point, vec3_t &angle, float * fov)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( m_SmoothStart && m_SmoothEnd )
|
|
||||||
{
|
|
||||||
t = (1.0f-t)*(t*t)+t*(1.0f-((t-1.0f)*(t-1.0f)));
|
|
||||||
}
|
|
||||||
else if ( m_SmoothStart )
|
|
||||||
{
|
|
||||||
t = t*t;
|
|
||||||
}
|
|
||||||
else if ( m_SmoothEnd )
|
|
||||||
{
|
|
||||||
t = t - 1.0f;
|
|
||||||
t = -(t*t)+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( point )
|
|
||||||
{
|
|
||||||
BezierInterpolatePoint(t, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( angle )
|
|
||||||
{
|
|
||||||
InterpolateAngle(t, angle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fov )
|
|
||||||
{
|
|
||||||
*fov = m_StartFov + (t * (m_EndFov-m_StartFov));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::BezierInterpolatePoint( float t, vec3_t &point )
|
|
||||||
{
|
|
||||||
point = m_StartPoint * BernsteinPolynom20(t);
|
|
||||||
point = point + m_Center * BernsteinPolynom21(t);
|
|
||||||
point = point + m_EndPoint * BernsteinPolynom22(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::SetSmoothing(bool start, bool end)
|
|
||||||
{
|
|
||||||
m_SmoothStart = start;
|
|
||||||
m_SmoothEnd = end;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolation::InterpolateAngle( float t, vec3_t &angle )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float ang1, ang2;
|
|
||||||
float d;
|
|
||||||
|
|
||||||
for ( i = 0 ; i < 3 ; i++ )
|
|
||||||
{
|
|
||||||
ang1 = m_StartAngle[i];
|
|
||||||
ang2 = m_EndAngle[i];
|
|
||||||
|
|
||||||
d = ang2 - ang1;
|
|
||||||
if ( d > 180 )
|
|
||||||
{
|
|
||||||
d -= 360;
|
|
||||||
}
|
|
||||||
else if ( d < -180 )
|
|
||||||
{
|
|
||||||
d += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
angle[i] = ang1 + d * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
NormalizeAngles( angle );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/************ (C) Copyright 2003 Valve, L.L.C. All rights reserved. ***********
|
|
||||||
**
|
|
||||||
** The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
** The contents may be used and/or copied only with the written permission of
|
|
||||||
** Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
** the agreement/contract under which the contents have been supplied.
|
|
||||||
**
|
|
||||||
*******************************************************************************
|
|
||||||
**
|
|
||||||
** Contents:
|
|
||||||
**
|
|
||||||
** interpolation.h: Bezier inpolation classes
|
|
||||||
**
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef INTERPOLATION_H
|
|
||||||
#define INTERPOLATION_H
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// interpolation class
|
|
||||||
class CInterpolation
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
CInterpolation();
|
|
||||||
virtual ~CInterpolation();
|
|
||||||
|
|
||||||
void SetWaypoints(vec3_t * prev, vec3_t start, vec3_t end, vec3_t * next);
|
|
||||||
void SetViewAngles( vec3_t start, vec3_t end );
|
|
||||||
void SetFOVs(float start, float end);
|
|
||||||
void SetSmoothing(bool start, bool end);
|
|
||||||
|
|
||||||
// get interpolated point 0 =< t =< 1, 0 = start, 1 = end
|
|
||||||
void Interpolate(float t, vec3_t &point, vec3_t &angle, float * fov);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void BezierInterpolatePoint( float t, vec3_t &point );
|
|
||||||
void InterpolateAngle( float t, vec3_t &angle );
|
|
||||||
|
|
||||||
vec3_t m_StartPoint;
|
|
||||||
vec3_t m_EndPoint;
|
|
||||||
vec3_t m_StartAngle;
|
|
||||||
vec3_t m_EndAngle;
|
|
||||||
vec3_t m_Center;
|
|
||||||
float m_StartFov;
|
|
||||||
float m_EndFov;
|
|
||||||
|
|
||||||
bool m_SmoothStart;
|
|
||||||
bool m_SmoothEnd;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // INTERPOLATION_H
|
|
|
@ -1,18 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( KBUTTONH )
|
|
||||||
#define KBUTTONH
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef struct kbutton_s
|
|
||||||
{
|
|
||||||
int down[2]; // key nums holding it down
|
|
||||||
int state; // low bit is down state
|
|
||||||
} kbutton_t;
|
|
||||||
|
|
||||||
#endif // !KBUTTONH
|
|
|
@ -1,283 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// menu.cpp
|
|
||||||
//
|
|
||||||
// generic menu handler
|
|
||||||
//
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
#define MAX_MENU_STRING 512
|
|
||||||
char g_szMenuString[MAX_MENU_STRING];
|
|
||||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
|
||||||
|
|
||||||
int KB_ConvertString( char *in, char **ppout );
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_Menu, ShowMenu );
|
|
||||||
|
|
||||||
int CHudMenu :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( ShowMenu );
|
|
||||||
|
|
||||||
InitHUDData();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudMenu :: InitHUDData( void )
|
|
||||||
{
|
|
||||||
m_fMenuDisplayed = 0;
|
|
||||||
m_bitsValidSlots = 0;
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudMenu :: Reset( void )
|
|
||||||
{
|
|
||||||
g_szPrelocalisedMenuString[0] = 0;
|
|
||||||
m_fWaitingForMore = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudMenu :: VidInit( void )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*=================================
|
|
||||||
ParseEscapeToken
|
|
||||||
|
|
||||||
Interprets the given escape token (backslash followed by a letter). The
|
|
||||||
first character of the token must be a backslash. The second character
|
|
||||||
specifies the operation to perform:
|
|
||||||
|
|
||||||
\w : White text (this is the default)
|
|
||||||
\d : Dim (gray) text
|
|
||||||
\y : Yellow text
|
|
||||||
\r : Red text
|
|
||||||
\R : Right-align (just for the remainder of the current line)
|
|
||||||
=================================*/
|
|
||||||
|
|
||||||
static int menu_r, menu_g, menu_b, menu_x, menu_ralign;
|
|
||||||
|
|
||||||
static inline const char* ParseEscapeToken( const char* token )
|
|
||||||
{
|
|
||||||
if ( *token != '\\' )
|
|
||||||
return token;
|
|
||||||
|
|
||||||
token++;
|
|
||||||
|
|
||||||
switch ( *token )
|
|
||||||
{
|
|
||||||
case '\0':
|
|
||||||
return token;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
menu_r = 255;
|
|
||||||
menu_g = 255;
|
|
||||||
menu_b = 255;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
menu_r = 100;
|
|
||||||
menu_g = 100;
|
|
||||||
menu_b = 100;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'y':
|
|
||||||
menu_r = 255;
|
|
||||||
menu_g = 210;
|
|
||||||
menu_b = 64;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r':
|
|
||||||
menu_r = 210;
|
|
||||||
menu_g = 24;
|
|
||||||
menu_b = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'R':
|
|
||||||
menu_x = ScreenWidth/2;
|
|
||||||
menu_ralign = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ++token;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMenu :: Draw( float flTime )
|
|
||||||
{
|
|
||||||
// check for if menu is set to disappear
|
|
||||||
if ( m_flShutoffTime > 0 )
|
|
||||||
{
|
|
||||||
if ( m_flShutoffTime <= gHUD.m_flTime )
|
|
||||||
{ // times up, shutoff
|
|
||||||
m_fMenuDisplayed = 0;
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't draw the menu if the scoreboard is being shown
|
|
||||||
if ( gViewPort && gViewPort->IsScoreBoardVisible() )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// draw the menu, along the left-hand side of the screen
|
|
||||||
|
|
||||||
// count the number of newlines
|
|
||||||
int nlc = 0;
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
|
|
||||||
{
|
|
||||||
if ( g_szMenuString[i] == '\n' )
|
|
||||||
nlc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// center it
|
|
||||||
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
|
|
||||||
|
|
||||||
menu_r = 255;
|
|
||||||
menu_g = 255;
|
|
||||||
menu_b = 255;
|
|
||||||
menu_x = 20;
|
|
||||||
menu_ralign = FALSE;
|
|
||||||
|
|
||||||
const char* sptr = g_szMenuString;
|
|
||||||
|
|
||||||
while ( *sptr != '\0' )
|
|
||||||
{
|
|
||||||
if ( *sptr == '\\' )
|
|
||||||
{
|
|
||||||
sptr = ParseEscapeToken( sptr );
|
|
||||||
}
|
|
||||||
else if ( *sptr == '\n' )
|
|
||||||
{
|
|
||||||
menu_ralign = FALSE;
|
|
||||||
menu_x = 20;
|
|
||||||
y += (12);
|
|
||||||
|
|
||||||
sptr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char menubuf[ 80 ];
|
|
||||||
const char *ptr = sptr;
|
|
||||||
while ( *sptr != '\0' && *sptr != '\n' && *sptr != '\\')
|
|
||||||
{
|
|
||||||
sptr++;
|
|
||||||
}
|
|
||||||
strncpy( menubuf, ptr, min( ( sptr - ptr), (int)sizeof( menubuf ) ));
|
|
||||||
menubuf[ min( ( sptr - ptr), (int)(sizeof( menubuf )-1) ) ] = '\0';
|
|
||||||
|
|
||||||
if ( menu_ralign )
|
|
||||||
{
|
|
||||||
// IMPORTANT: Right-to-left rendered text does not parse escape tokens!
|
|
||||||
menu_x = gHUD.DrawHudStringReverse( menu_x, y, 0, menubuf, menu_r, menu_g, menu_b );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menu_x = gHUD.DrawHudString( menu_x, y, 320, menubuf, menu_r, menu_g, menu_b );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// selects an item from the menu
|
|
||||||
void CHudMenu :: SelectMenuItem( int menu_item )
|
|
||||||
{
|
|
||||||
// if menu_item is in a valid slot, send a menuselect command to the server
|
|
||||||
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
|
|
||||||
{
|
|
||||||
char szbuf[32];
|
|
||||||
sprintf( szbuf, "menuselect %d\n", menu_item );
|
|
||||||
EngineClientCmd( szbuf );
|
|
||||||
|
|
||||||
// remove the menu
|
|
||||||
m_fMenuDisplayed = 0;
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Message handler for ShowMenu message
|
|
||||||
// takes four values:
|
|
||||||
// short: a bitfield of keys that are valid input
|
|
||||||
// char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
|
|
||||||
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
|
|
||||||
// string: menu string to display
|
|
||||||
// if this message is never received, then scores will simply be the combined totals of the players.
|
|
||||||
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
char *temp = NULL;
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
m_bitsValidSlots = READ_SHORT();
|
|
||||||
int DisplayTime = READ_CHAR();
|
|
||||||
int NeedMore = READ_BYTE();
|
|
||||||
|
|
||||||
if ( DisplayTime > 0 )
|
|
||||||
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
|
|
||||||
else
|
|
||||||
m_flShutoffTime = -1;
|
|
||||||
|
|
||||||
if ( m_bitsValidSlots )
|
|
||||||
{
|
|
||||||
if ( !m_fWaitingForMore ) // this is the start of a new menu
|
|
||||||
{
|
|
||||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // append to the current menu string
|
|
||||||
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
|
|
||||||
}
|
|
||||||
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
|
|
||||||
|
|
||||||
if ( !NeedMore )
|
|
||||||
{ // we have the whole string, so we can localise it now
|
|
||||||
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
|
|
||||||
|
|
||||||
// Swap in characters
|
|
||||||
if ( KB_ConvertString( g_szMenuString, &temp ) )
|
|
||||||
{
|
|
||||||
strcpy( g_szMenuString, temp );
|
|
||||||
free( temp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fMenuDisplayed = 1;
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fWaitingForMore = NeedMore;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,535 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// Message.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudMessage class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_Message, HudText )
|
|
||||||
DECLARE_MESSAGE( m_Message, GameTitle )
|
|
||||||
|
|
||||||
// 1 Global client_textmessage_t for custom messages that aren't in the titles.txt
|
|
||||||
client_textmessage_t g_pCustomMessage;
|
|
||||||
char *g_pCustomName = "Custom";
|
|
||||||
char g_pCustomText[1024];
|
|
||||||
|
|
||||||
int CHudMessage::Init(void)
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( HudText );
|
|
||||||
HOOK_MESSAGE( GameTitle );
|
|
||||||
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudMessage::VidInit( void )
|
|
||||||
{
|
|
||||||
m_HUD_title_half = gHUD.GetSpriteIndex( "title_half" );
|
|
||||||
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void CHudMessage::Reset( void )
|
|
||||||
{
|
|
||||||
memset( m_pMessages, 0, sizeof( m_pMessages[0] ) * maxHUDMessages );
|
|
||||||
memset( m_startTime, 0, sizeof( m_startTime[0] ) * maxHUDMessages );
|
|
||||||
|
|
||||||
m_gameTitleTime = 0;
|
|
||||||
m_pGameTitle = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime )
|
|
||||||
{
|
|
||||||
float fadeTime = fadein + hold;
|
|
||||||
float fadeBlend;
|
|
||||||
|
|
||||||
if ( localTime < 0 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ( localTime < fadein )
|
|
||||||
{
|
|
||||||
fadeBlend = 1 - ((fadein - localTime) / fadein);
|
|
||||||
}
|
|
||||||
else if ( localTime > fadeTime )
|
|
||||||
{
|
|
||||||
if ( fadeout > 0 )
|
|
||||||
fadeBlend = 1 - ((localTime - fadeTime) / fadeout);
|
|
||||||
else
|
|
||||||
fadeBlend = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fadeBlend = 1;
|
|
||||||
|
|
||||||
return fadeBlend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMessage::XPosition( float x, int width, int totalWidth )
|
|
||||||
{
|
|
||||||
int xPos;
|
|
||||||
|
|
||||||
if ( x == -1 )
|
|
||||||
{
|
|
||||||
xPos = (ScreenWidth - width) / 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( x < 0 )
|
|
||||||
xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right
|
|
||||||
else
|
|
||||||
xPos = x * ScreenWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( xPos + width > ScreenWidth )
|
|
||||||
xPos = ScreenWidth - width;
|
|
||||||
else if ( xPos < 0 )
|
|
||||||
xPos = 0;
|
|
||||||
|
|
||||||
return xPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMessage::YPosition( float y, int height )
|
|
||||||
{
|
|
||||||
int yPos;
|
|
||||||
|
|
||||||
if ( y == -1 ) // Centered?
|
|
||||||
yPos = (ScreenHeight - height) * 0.5;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Alight bottom?
|
|
||||||
if ( y < 0 )
|
|
||||||
yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom
|
|
||||||
else // align top
|
|
||||||
yPos = y * ScreenHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( yPos + height > ScreenHeight )
|
|
||||||
yPos = ScreenHeight - height;
|
|
||||||
else if ( yPos < 0 )
|
|
||||||
yPos = 0;
|
|
||||||
|
|
||||||
return yPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudMessage::MessageScanNextChar( void )
|
|
||||||
{
|
|
||||||
int srcRed, srcGreen, srcBlue, destRed, destGreen, destBlue;
|
|
||||||
int blend;
|
|
||||||
|
|
||||||
srcRed = m_parms.pMessage->r1;
|
|
||||||
srcGreen = m_parms.pMessage->g1;
|
|
||||||
srcBlue = m_parms.pMessage->b1;
|
|
||||||
blend = 0; // Pure source
|
|
||||||
destRed = destGreen = destBlue = 0;
|
|
||||||
|
|
||||||
switch( m_parms.pMessage->effect )
|
|
||||||
{
|
|
||||||
// Fade-in / Fade-out
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
blend = m_parms.fadeBlend;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
m_parms.charTime += m_parms.pMessage->fadein;
|
|
||||||
if ( m_parms.charTime > m_parms.time )
|
|
||||||
{
|
|
||||||
srcRed = srcGreen = srcBlue = 0;
|
|
||||||
blend = 0; // pure source
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float deltaTime = m_parms.time - m_parms.charTime;
|
|
||||||
|
|
||||||
if ( m_parms.time > m_parms.fadeTime )
|
|
||||||
{
|
|
||||||
blend = m_parms.fadeBlend;
|
|
||||||
}
|
|
||||||
else if ( deltaTime > m_parms.pMessage->fxtime )
|
|
||||||
blend = 0; // pure dest
|
|
||||||
else
|
|
||||||
{
|
|
||||||
destRed = m_parms.pMessage->r2;
|
|
||||||
destGreen = m_parms.pMessage->g2;
|
|
||||||
destBlue = m_parms.pMessage->b2;
|
|
||||||
blend = 255 - (deltaTime * (1.0/m_parms.pMessage->fxtime) * 255.0 + 0.5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( blend > 255 )
|
|
||||||
blend = 255;
|
|
||||||
else if ( blend < 0 )
|
|
||||||
blend = 0;
|
|
||||||
|
|
||||||
m_parms.r = ((srcRed * (255-blend)) + (destRed * blend)) >> 8;
|
|
||||||
m_parms.g = ((srcGreen * (255-blend)) + (destGreen * blend)) >> 8;
|
|
||||||
m_parms.b = ((srcBlue * (255-blend)) + (destBlue * blend)) >> 8;
|
|
||||||
|
|
||||||
if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 )
|
|
||||||
{
|
|
||||||
if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth )
|
|
||||||
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudMessage::MessageScanStart( void )
|
|
||||||
{
|
|
||||||
switch( m_parms.pMessage->effect )
|
|
||||||
{
|
|
||||||
// Fade-in / out with flicker
|
|
||||||
case 1:
|
|
||||||
case 0:
|
|
||||||
m_parms.fadeTime = m_parms.pMessage->fadein + m_parms.pMessage->holdtime;
|
|
||||||
|
|
||||||
|
|
||||||
if ( m_parms.time < m_parms.pMessage->fadein )
|
|
||||||
{
|
|
||||||
m_parms.fadeBlend = ((m_parms.pMessage->fadein - m_parms.time) * (1.0/m_parms.pMessage->fadein) * 255);
|
|
||||||
}
|
|
||||||
else if ( m_parms.time > m_parms.fadeTime )
|
|
||||||
{
|
|
||||||
if ( m_parms.pMessage->fadeout > 0 )
|
|
||||||
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255);
|
|
||||||
else
|
|
||||||
m_parms.fadeBlend = 255; // Pure dest (off)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_parms.fadeBlend = 0; // Pure source (on)
|
|
||||||
m_parms.charTime = 0;
|
|
||||||
|
|
||||||
if ( m_parms.pMessage->effect == 1 && (rand()%100) < 10 )
|
|
||||||
m_parms.charTime = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime;
|
|
||||||
|
|
||||||
if ( m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0 )
|
|
||||||
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255);
|
|
||||||
else
|
|
||||||
m_parms.fadeBlend = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
|
|
||||||
{
|
|
||||||
int i, j, length, width;
|
|
||||||
const char *pText;
|
|
||||||
unsigned char line[80];
|
|
||||||
|
|
||||||
pText = pMessage->pMessage;
|
|
||||||
// Count lines
|
|
||||||
m_parms.lines = 1;
|
|
||||||
m_parms.time = time;
|
|
||||||
m_parms.pMessage = pMessage;
|
|
||||||
length = 0;
|
|
||||||
width = 0;
|
|
||||||
m_parms.totalWidth = 0;
|
|
||||||
while ( *pText )
|
|
||||||
{
|
|
||||||
if ( *pText == '\n' )
|
|
||||||
{
|
|
||||||
m_parms.lines++;
|
|
||||||
if ( width > m_parms.totalWidth )
|
|
||||||
m_parms.totalWidth = width;
|
|
||||||
width = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
width += gHUD.m_scrinfo.charWidths[*pText];
|
|
||||||
pText++;
|
|
||||||
length++;
|
|
||||||
}
|
|
||||||
m_parms.length = length;
|
|
||||||
m_parms.totalHeight = (m_parms.lines * gHUD.m_scrinfo.iCharHeight);
|
|
||||||
|
|
||||||
|
|
||||||
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight );
|
|
||||||
pText = pMessage->pMessage;
|
|
||||||
|
|
||||||
m_parms.charTime = 0;
|
|
||||||
|
|
||||||
MessageScanStart();
|
|
||||||
|
|
||||||
for ( i = 0; i < m_parms.lines; i++ )
|
|
||||||
{
|
|
||||||
m_parms.lineLength = 0;
|
|
||||||
m_parms.width = 0;
|
|
||||||
while ( *pText && *pText != '\n' )
|
|
||||||
{
|
|
||||||
unsigned char c = *pText;
|
|
||||||
line[m_parms.lineLength] = c;
|
|
||||||
m_parms.width += gHUD.m_scrinfo.charWidths[c];
|
|
||||||
m_parms.lineLength++;
|
|
||||||
pText++;
|
|
||||||
}
|
|
||||||
pText++; // Skip LF
|
|
||||||
line[m_parms.lineLength] = 0;
|
|
||||||
|
|
||||||
m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth );
|
|
||||||
|
|
||||||
for ( j = 0; j < m_parms.lineLength; j++ )
|
|
||||||
{
|
|
||||||
m_parms.text = line[j];
|
|
||||||
int next = m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ];
|
|
||||||
MessageScanNextChar();
|
|
||||||
|
|
||||||
if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth )
|
|
||||||
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b );
|
|
||||||
m_parms.x = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_parms.y += gHUD.m_scrinfo.iCharHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMessage::Draw( float fTime )
|
|
||||||
{
|
|
||||||
int i, drawn;
|
|
||||||
client_textmessage_t *pMessage;
|
|
||||||
float endTime;
|
|
||||||
|
|
||||||
drawn = 0;
|
|
||||||
|
|
||||||
if ( m_gameTitleTime > 0 )
|
|
||||||
{
|
|
||||||
float localTime = gHUD.m_flTime - m_gameTitleTime;
|
|
||||||
float brightness;
|
|
||||||
|
|
||||||
// Maybe timer isn't set yet
|
|
||||||
if ( m_gameTitleTime > gHUD.m_flTime )
|
|
||||||
m_gameTitleTime = gHUD.m_flTime;
|
|
||||||
|
|
||||||
if ( localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout) )
|
|
||||||
m_gameTitleTime = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime );
|
|
||||||
|
|
||||||
int halfWidth = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left;
|
|
||||||
int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left;
|
|
||||||
int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top;
|
|
||||||
|
|
||||||
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
|
|
||||||
int y = YPosition( m_pGameTitle->y, fullHeight );
|
|
||||||
|
|
||||||
|
|
||||||
SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) );
|
|
||||||
|
|
||||||
SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
|
|
||||||
SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) );
|
|
||||||
|
|
||||||
drawn = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fixup level transitions
|
|
||||||
for ( i = 0; i < maxHUDMessages; i++ )
|
|
||||||
{
|
|
||||||
// Assume m_parms.time contains last time
|
|
||||||
if ( m_pMessages[i] )
|
|
||||||
{
|
|
||||||
pMessage = m_pMessages[i];
|
|
||||||
if ( m_startTime[i] > gHUD.m_flTime )
|
|
||||||
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i = 0; i < maxHUDMessages; i++ )
|
|
||||||
{
|
|
||||||
if ( m_pMessages[i] )
|
|
||||||
{
|
|
||||||
pMessage = m_pMessages[i];
|
|
||||||
|
|
||||||
// This is when the message is over
|
|
||||||
switch( pMessage->effect )
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
endTime = m_startTime[i] + pMessage->fadein + pMessage->fadeout + pMessage->holdtime;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Fade in is per character in scanning messages
|
|
||||||
case 2:
|
|
||||||
endTime = m_startTime[i] + (pMessage->fadein * strlen( pMessage->pMessage )) + pMessage->fadeout + pMessage->holdtime;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fTime <= endTime )
|
|
||||||
{
|
|
||||||
float messageTime = fTime - m_startTime[i];
|
|
||||||
|
|
||||||
// Draw the message
|
|
||||||
// effect 0 is fade in/fade out
|
|
||||||
// effect 1 is flickery credits
|
|
||||||
// effect 2 is write out (training room)
|
|
||||||
MessageDrawScan( pMessage, messageTime );
|
|
||||||
|
|
||||||
drawn++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// The message is over
|
|
||||||
m_pMessages[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remember the time -- to fix up level transitions
|
|
||||||
m_parms.time = gHUD.m_flTime;
|
|
||||||
// Don't call until we get another message
|
|
||||||
if ( !drawn )
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudMessage::MessageAdd( const char *pName, float time )
|
|
||||||
{
|
|
||||||
int i,j;
|
|
||||||
client_textmessage_t *tempMessage;
|
|
||||||
|
|
||||||
for ( i = 0; i < maxHUDMessages; i++ )
|
|
||||||
{
|
|
||||||
if ( !m_pMessages[i] )
|
|
||||||
{
|
|
||||||
// Trim off a leading # if it's there
|
|
||||||
if ( pName[0] == '#' )
|
|
||||||
tempMessage = TextMessageGet( pName+1 );
|
|
||||||
else
|
|
||||||
tempMessage = TextMessageGet( pName );
|
|
||||||
// If we couldnt find it in the titles.txt, just create it
|
|
||||||
if ( !tempMessage )
|
|
||||||
{
|
|
||||||
g_pCustomMessage.effect = 2;
|
|
||||||
g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100;
|
|
||||||
g_pCustomMessage.r2 = 240;
|
|
||||||
g_pCustomMessage.g2 = 110;
|
|
||||||
g_pCustomMessage.b2 = 0;
|
|
||||||
g_pCustomMessage.a2 = 0;
|
|
||||||
g_pCustomMessage.x = -1; // Centered
|
|
||||||
g_pCustomMessage.y = 0.7;
|
|
||||||
g_pCustomMessage.fadein = 0.01;
|
|
||||||
g_pCustomMessage.fadeout = 1.5;
|
|
||||||
g_pCustomMessage.fxtime = 0.25;
|
|
||||||
g_pCustomMessage.holdtime = 5;
|
|
||||||
g_pCustomMessage.pName = g_pCustomName;
|
|
||||||
strcpy( g_pCustomText, pName );
|
|
||||||
g_pCustomMessage.pMessage = g_pCustomText;
|
|
||||||
|
|
||||||
tempMessage = &g_pCustomMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( j = 0; j < maxHUDMessages; j++ )
|
|
||||||
{
|
|
||||||
if ( m_pMessages[j] )
|
|
||||||
{
|
|
||||||
// is this message already in the list
|
|
||||||
if ( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get rid of any other messages in same location (only one displays at a time)
|
|
||||||
if ( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 )
|
|
||||||
{
|
|
||||||
if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 )
|
|
||||||
{
|
|
||||||
m_pMessages[j] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pMessages[i] = tempMessage;
|
|
||||||
m_startTime[i] = time;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
char *pString = READ_STRING();
|
|
||||||
|
|
||||||
MessageAdd( pString, gHUD.m_flTime );
|
|
||||||
// Remember the time -- to fix up level transitions
|
|
||||||
m_parms.time = gHUD.m_flTime;
|
|
||||||
|
|
||||||
// Turn on drawing
|
|
||||||
if ( !(m_iFlags & HUD_ACTIVE) )
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
m_pGameTitle = TextMessageGet( "GAMETITLE" );
|
|
||||||
if ( m_pGameTitle != NULL )
|
|
||||||
{
|
|
||||||
m_gameTitleTime = gHUD.m_flTime;
|
|
||||||
|
|
||||||
// Turn on drawing
|
|
||||||
if ( !(m_iFlags & HUD_ACTIVE) )
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudMessage::MessageAdd(client_textmessage_t * newMessage )
|
|
||||||
{
|
|
||||||
m_parms.time = gHUD.m_flTime;
|
|
||||||
|
|
||||||
// Turn on drawing
|
|
||||||
if ( !(m_iFlags & HUD_ACTIVE) )
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
for ( int i = 0; i < maxHUDMessages; i++ )
|
|
||||||
{
|
|
||||||
if ( !m_pMessages[i] )
|
|
||||||
{
|
|
||||||
m_pMessages[i] = newMessage;
|
|
||||||
m_startTime[i] = gHUD.m_flTime;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,160 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "triangleapi.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
// these are included for the math functions
|
|
||||||
#include "com_model.h"
|
|
||||||
#include "studio_util.h"
|
|
||||||
|
|
||||||
#pragma warning(disable: 4244)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose:
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int CHudOverview::Init()
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Loads new icons
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int CHudOverview::VidInit()
|
|
||||||
{
|
|
||||||
m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr");
|
|
||||||
m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose:
|
|
||||||
// Input : flTime -
|
|
||||||
// intermission -
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int CHudOverview::Draw(float flTime)
|
|
||||||
{
|
|
||||||
// only draw in overview mode
|
|
||||||
if (!gEngfuncs.Overview_GetOverviewState())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// make sure we have player info
|
|
||||||
gViewPort->GetAllPlayersInfo();
|
|
||||||
|
|
||||||
// calculate player size on the overview
|
|
||||||
int x1, y1, x2, y2;
|
|
||||||
float v0[3]={0,0,0}, v1[3]={64,64,0};
|
|
||||||
gEngfuncs.Overview_WorldToScreen(v0, &x1, &y1);
|
|
||||||
gEngfuncs.Overview_WorldToScreen(v1, &x2, &y2);
|
|
||||||
float scale = abs(x2 - x1);
|
|
||||||
|
|
||||||
// loop through all the players and draw them on the map
|
|
||||||
for (int i = 1; i < MAX_PLAYERS; i++)
|
|
||||||
{
|
|
||||||
cl_entity_t *pl = gEngfuncs.GetEntityByIndex(i);
|
|
||||||
|
|
||||||
if (pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT)
|
|
||||||
{
|
|
||||||
int x, y, z = 0;
|
|
||||||
float v[3]={pl->origin[0], pl->origin[1], 0};
|
|
||||||
gEngfuncs.Overview_WorldToScreen(v, &x, &y);
|
|
||||||
|
|
||||||
// hack in some team colors
|
|
||||||
float r, g, bc;
|
|
||||||
if (g_PlayerExtraInfo[i].teamnumber == 1)
|
|
||||||
{
|
|
||||||
r = 0.0f; g = 0.0f; bc = 1.0f;
|
|
||||||
}
|
|
||||||
else if (g_PlayerExtraInfo[i].teamnumber == 2)
|
|
||||||
{
|
|
||||||
r = 1.0f; g = 0.0f; bc = 0.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// just use the default orange color if the team isn't set
|
|
||||||
r = 1.0f; g = 0.7f; bc = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the current texture
|
|
||||||
gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(m_hsprPlayer), 0);
|
|
||||||
|
|
||||||
// additive render mode
|
|
||||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd);
|
|
||||||
|
|
||||||
// no culling
|
|
||||||
gEngfuncs.pTriAPI->CullFace(TRI_NONE);
|
|
||||||
|
|
||||||
// draw a square
|
|
||||||
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
||||||
|
|
||||||
// set the color to be that of the team
|
|
||||||
gEngfuncs.pTriAPI->Color4f(r, g, bc, 1.0f);
|
|
||||||
|
|
||||||
// calculate rotational matrix
|
|
||||||
vec3_t a, b, angles;
|
|
||||||
float rmatrix[3][4]; // transformation matrix
|
|
||||||
VectorCopy(pl->angles, angles);
|
|
||||||
angles[0] = 0.0f;
|
|
||||||
angles[1] += 90.f;
|
|
||||||
angles[1] = -angles[1];
|
|
||||||
angles[2] = 0.0f;
|
|
||||||
AngleMatrix(angles, rmatrix);
|
|
||||||
a[2] = 0;
|
|
||||||
|
|
||||||
a[0] = -scale; a[1] = -scale;
|
|
||||||
VectorTransform(a, rmatrix , b );
|
|
||||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
|
||||||
gEngfuncs.pTriAPI->Vertex3f(x + b[0], y + b[1], z);
|
|
||||||
|
|
||||||
a[0]=-scale; a[1] = scale;
|
|
||||||
VectorTransform(a, rmatrix , b );
|
|
||||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
|
||||||
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
|
|
||||||
|
|
||||||
a[0]=scale; a[1] = scale;
|
|
||||||
VectorTransform(a, rmatrix , b );
|
|
||||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
|
||||||
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
|
|
||||||
|
|
||||||
a[0]=scale; a[1] = -scale;
|
|
||||||
VectorTransform(a, rmatrix , b );
|
|
||||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
|
||||||
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
|
|
||||||
|
|
||||||
// finish up
|
|
||||||
gEngfuncs.pTriAPI->End();
|
|
||||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
|
||||||
|
|
||||||
// draw the players name and health underneath
|
|
||||||
char string[256];
|
|
||||||
sprintf(string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health);
|
|
||||||
DrawConsoleString(x, y + (1.1 * scale), string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: called every time a server is connected to
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CHudOverview::InitHUDData()
|
|
||||||
{
|
|
||||||
// this block would force the spectator view to be on
|
|
||||||
// gEngfuncs.Overview_SetDrawOverview( 1 );
|
|
||||||
// gEngfuncs.Overview_SetDrawInset( 0 );
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef OVERVIEW_H
|
|
||||||
#define OVERVIEW_H
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Handles the drawing of the top-down map and all the things on it
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CHudOverview : public CHudBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Init();
|
|
||||||
int VidInit();
|
|
||||||
|
|
||||||
int Draw(float flTime);
|
|
||||||
void InitHUDData( void );
|
|
||||||
|
|
||||||
private:
|
|
||||||
HSPRITE m_hsprPlayer;
|
|
||||||
HSPRITE m_hsprViewcone;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // OVERVIEW_H
|
|
|
@ -1,20 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003', Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
|
|
||||||
extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
|
|
||||||
extern team_info_t g_TeamInfo[MAX_TEAMS+1];
|
|
||||||
extern int g_IsSpectator[MAX_PLAYERS+1];
|
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
client dll readme.txt
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
This file details the structure of the half-life client dll, and
|
|
||||||
how it communicates with the half-life game engine.
|
|
||||||
|
|
||||||
|
|
||||||
Engine callback functions:
|
|
||||||
|
|
||||||
Drawing functions:
|
|
||||||
HSPRITE SPR_Load( char *picname );
|
|
||||||
Loads a sprite into memory, and returns a handle to it.
|
|
||||||
|
|
||||||
int SPR_Frames( HSPRITE sprite );
|
|
||||||
Returns the number of frames stored in the specified sprite.
|
|
||||||
|
|
||||||
int SPR_Height( HSPRITE x, int frame )
|
|
||||||
Returns the height, in pixels, of a sprite at the specified frame.
|
|
||||||
Returns 0 is the frame number or the sprite handle is invalid.
|
|
||||||
|
|
||||||
int SPR_Width( HSPRITE x, int f )
|
|
||||||
Returns the width, in pixels, of a sprite at the specified frame.
|
|
||||||
Returns 0 is the frame number or the sprite handle is invalid.
|
|
||||||
|
|
||||||
int SPR_Set( HSPRITE sprite, int r, int g, int b );
|
|
||||||
Prepares a sprite about to be drawn. RBG color values are applied to the sprite at this time.
|
|
||||||
|
|
||||||
|
|
||||||
void SPR_Draw( int frame, int x, int y );
|
|
||||||
Precondition: SPR_Set has already been called for a sprite.
|
|
||||||
Draws the currently active sprite to the screen, at position (x,y), where (0,0) is
|
|
||||||
the top left-hand corner of the screen.
|
|
||||||
|
|
||||||
|
|
||||||
void SPR_DrawHoles( int frame, int x, int y );
|
|
||||||
Precondition: SPR_Set has already been called for a sprite.
|
|
||||||
Draws the currently active sprite to the screen. Color index #255 is treated as transparent.
|
|
||||||
|
|
||||||
void SPR_DrawAdditive( int frame, int x, int y );
|
|
||||||
Precondition: SPR_Set has already been called for a sprite.
|
|
||||||
Draws the currently active sprite to the screen, adding it's color values to the background.
|
|
||||||
|
|
||||||
void SPR_EnableScissor( int x, int y, int width, int height );
|
|
||||||
Creates a clipping rectangle. No pixels will be drawn outside the specified area. Will
|
|
||||||
stay in effect until either the next frame, or SPR_DisableScissor is called.
|
|
||||||
|
|
||||||
void SPR_DisableScissor( void );
|
|
||||||
Disables the effect of an SPR_EnableScissor call.
|
|
||||||
|
|
||||||
int IsHighRes( void );
|
|
||||||
returns 1 if the res mode is 640x480 or higher; 0 otherwise.
|
|
||||||
|
|
||||||
int ScreenWidth( void );
|
|
||||||
returns the screen width, in pixels.
|
|
||||||
|
|
||||||
int ScreenHeight( void );
|
|
||||||
returns the screen height, in pixels.
|
|
||||||
|
|
||||||
// Sound functions
|
|
||||||
void PlaySound( char *szSound, int volume )
|
|
||||||
plays the sound 'szSound' at the specified volume. Loads the sound if it hasn't been cached.
|
|
||||||
If it can't find the sound, it displays an error message and plays no sound.
|
|
||||||
|
|
||||||
void PlaySound( int iSound, int volume )
|
|
||||||
Precondition: iSound has been precached.
|
|
||||||
Plays the sound, from the precache list.
|
|
||||||
|
|
||||||
|
|
||||||
// Communication functions
|
|
||||||
void SendClientCmd( char *szCmdString );
|
|
||||||
sends a command to the server, just as if the client had typed the szCmdString at the console.
|
|
||||||
|
|
||||||
char *GetPlayerName( int entity_number );
|
|
||||||
returns a pointer to a string, that contains the name of the specified client.
|
|
||||||
Returns NULL if the entity_number is not a client.
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(), HOOK_MESSAGE()
|
|
||||||
These two macros bind the message sending between the entity DLL and the client DLL to
|
|
||||||
the CHud object.
|
|
||||||
|
|
||||||
HOOK_MESSAGE( message_name )
|
|
||||||
This is used inside CHud::Init(). It calls into the engine to hook that message
|
|
||||||
from the incoming message stream.
|
|
||||||
Precondition: There must be a function of name UserMsg_message_name declared
|
|
||||||
for CHud. Eg, CHud::UserMsg_Health() must be declared if you want to
|
|
||||||
use HOOK_MESSAGE( Health );
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( message_name )
|
|
||||||
For each HOOK_MESSAGE you must have an equivalent DECLARE_MESSAGE. This creates
|
|
||||||
a function which passes the hooked messages into the CHud object.
|
|
||||||
|
|
||||||
|
|
||||||
HOOK_COMMAND(), DECLARE_COMMAND()
|
|
||||||
These two functions declare and hook console commands into the client dll.
|
|
||||||
|
|
||||||
HOOK_COMMAND( char *command, command_name )
|
|
||||||
Whenever the user types the 'command' at the console, the function 'command_name'
|
|
||||||
will be called.
|
|
||||||
Precondition: There must be a function of the name UserCmd_command_name declared
|
|
||||||
for CHud. Eg, CHud::UserMsg_ShowScores() must be declared if you want to
|
|
||||||
use HOOK_COMMAND( "+showscores", ShowScores );
|
|
||||||
|
|
||||||
DECLARE_COMMAND( command_name )
|
|
||||||
For each HOOK_COMMAND you must have an equivelant DECLARE_COMMAND. This creates
|
|
||||||
a function which passes the hooked commands into the CHud object.
|
|
||||||
|
|
|
@ -1,326 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// saytext.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudSayText class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <malloc.h> // _alloca
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
extern float *GetClientColor( int clientIndex );
|
|
||||||
|
|
||||||
#define MAX_LINES 5
|
|
||||||
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */
|
|
||||||
|
|
||||||
// allow 20 pixels on either side of the text
|
|
||||||
#define MAX_LINE_WIDTH ( ScreenWidth - 40 )
|
|
||||||
#define LINE_START 10
|
|
||||||
static float SCROLL_SPEED = 5;
|
|
||||||
|
|
||||||
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ];
|
|
||||||
static float *g_pflNameColors[ MAX_LINES + 1 ];
|
|
||||||
static int g_iNameLengths[ MAX_LINES + 1 ];
|
|
||||||
static float flScrollTime = 0; // the time at which the lines next scroll up
|
|
||||||
|
|
||||||
static int Y_START = 0;
|
|
||||||
static int line_height = 0;
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_SayText, SayText );
|
|
||||||
|
|
||||||
int CHudSayText :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( SayText );
|
|
||||||
|
|
||||||
InitHUDData();
|
|
||||||
|
|
||||||
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
|
|
||||||
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
|
|
||||||
|
|
||||||
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudSayText :: InitHUDData( void )
|
|
||||||
{
|
|
||||||
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
|
|
||||||
memset( g_pflNameColors, 0, sizeof g_pflNameColors );
|
|
||||||
memset( g_iNameLengths, 0, sizeof g_iNameLengths );
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudSayText :: VidInit( void )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ScrollTextUp( void )
|
|
||||||
{
|
|
||||||
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
|
|
||||||
g_szLineBuffer[MAX_LINES][0] = 0;
|
|
||||||
memmove( g_szLineBuffer[0], g_szLineBuffer[1], sizeof(g_szLineBuffer) - sizeof(g_szLineBuffer[0]) ); // overwrite the first line
|
|
||||||
memmove( &g_pflNameColors[0], &g_pflNameColors[1], sizeof(g_pflNameColors) - sizeof(g_pflNameColors[0]) );
|
|
||||||
memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
|
|
||||||
g_szLineBuffer[MAX_LINES-1][0] = 0;
|
|
||||||
|
|
||||||
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
|
|
||||||
{
|
|
||||||
g_szLineBuffer[0][0] = 2;
|
|
||||||
return 1 + ScrollTextUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudSayText :: Draw( float flTime )
|
|
||||||
{
|
|
||||||
int y = Y_START;
|
|
||||||
|
|
||||||
if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
|
|
||||||
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
|
|
||||||
|
|
||||||
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
|
|
||||||
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
|
|
||||||
|
|
||||||
if ( flScrollTime <= flTime )
|
|
||||||
{
|
|
||||||
if ( *g_szLineBuffer[0] )
|
|
||||||
{
|
|
||||||
flScrollTime = flTime + m_HUD_saytext_time->value;
|
|
||||||
// push the console up
|
|
||||||
ScrollTextUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // buffer is empty, just disable drawing of this section
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int i = 0; i < MAX_LINES; i++ )
|
|
||||||
{
|
|
||||||
if ( *g_szLineBuffer[i] )
|
|
||||||
{
|
|
||||||
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
|
|
||||||
{
|
|
||||||
// it's a saytext string
|
|
||||||
char *buf = static_cast<char *>( _alloca( strlen( g_szLineBuffer[i] ) ) );
|
|
||||||
if ( buf )
|
|
||||||
{
|
|
||||||
//char buf[MAX_PLAYER_NAME_LENGTH+32];
|
|
||||||
|
|
||||||
// draw the first x characters in the player color
|
|
||||||
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
|
|
||||||
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
|
|
||||||
gEngfuncs.pfnDrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
|
||||||
int x = DrawConsoleString( LINE_START, y, buf + 1 ); // don't draw the control code at the start
|
|
||||||
strncpy( buf, g_szLineBuffer[i] + g_iNameLengths[i], strlen( g_szLineBuffer[i] ));
|
|
||||||
buf[ strlen( g_szLineBuffer[i] + g_iNameLengths[i] ) - 1 ] = '\0';
|
|
||||||
// color is reset after each string draw
|
|
||||||
DrawConsoleString( x, y, buf );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert( "Not able to alloca chat buffer!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// normal draw
|
|
||||||
DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
y += line_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int client_index = READ_BYTE(); // the client who spoke the message
|
|
||||||
SayTextPrint( READ_STRING(), iSize - 1, client_index );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
|
|
||||||
{
|
|
||||||
if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
|
|
||||||
{
|
|
||||||
// Print it straight to the console
|
|
||||||
ConsolePrint( pszBuf );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
// find an empty string slot
|
|
||||||
for ( i = 0; i < MAX_LINES; i++ )
|
|
||||||
{
|
|
||||||
if ( ! *g_szLineBuffer[i] )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( i == MAX_LINES )
|
|
||||||
{
|
|
||||||
// force scroll buffer up
|
|
||||||
ScrollTextUp();
|
|
||||||
i = MAX_LINES - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_iNameLengths[i] = 0;
|
|
||||||
g_pflNameColors[i] = NULL;
|
|
||||||
|
|
||||||
// if it's a say message, search for the players name in the string
|
|
||||||
if ( *pszBuf == 2 && clientIndex > 0 )
|
|
||||||
{
|
|
||||||
gEngfuncs.pfnGetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
|
|
||||||
const char *pName = g_PlayerInfoList[clientIndex].name;
|
|
||||||
|
|
||||||
if ( pName )
|
|
||||||
{
|
|
||||||
const char *nameInString = strstr( pszBuf, pName );
|
|
||||||
|
|
||||||
if ( nameInString )
|
|
||||||
{
|
|
||||||
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf);
|
|
||||||
g_pflNameColors[i] = GetClientColor( clientIndex );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize , MAX_CHARS_PER_LINE) );
|
|
||||||
|
|
||||||
// make sure the text fits in one line
|
|
||||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
|
|
||||||
|
|
||||||
// Set scroll time
|
|
||||||
if ( i == 0 )
|
|
||||||
{
|
|
||||||
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
PlaySound( "misc/talk.wav", 1 );
|
|
||||||
|
|
||||||
Y_START = ScreenHeight - 60 - ( line_height * (MAX_LINES+2) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
|
||||||
{
|
|
||||||
int line_width = 0;
|
|
||||||
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
|
|
||||||
|
|
||||||
if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
|
|
||||||
{ // string is too long to fit on line
|
|
||||||
// scan the string until we find what word is too long, and wrap the end of the sentence after the word
|
|
||||||
int length = LINE_START;
|
|
||||||
int tmp_len = 0;
|
|
||||||
char *last_break = NULL;
|
|
||||||
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ )
|
|
||||||
{
|
|
||||||
// check for a color change, if so skip past it
|
|
||||||
if ( x[0] == '/' && x[1] == '(' )
|
|
||||||
{
|
|
||||||
x += 2;
|
|
||||||
// skip forward until past mode specifier
|
|
||||||
while ( *x != 0 && *x != ')' )
|
|
||||||
x++;
|
|
||||||
|
|
||||||
if ( *x != 0 )
|
|
||||||
x++;
|
|
||||||
|
|
||||||
if ( *x == 0 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buf[2];
|
|
||||||
buf[1] = 0;
|
|
||||||
|
|
||||||
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
|
|
||||||
last_break = x;
|
|
||||||
|
|
||||||
buf[0] = *x; // get the length of the current character
|
|
||||||
GetConsoleStringSize( buf, &tmp_len, &line_height );
|
|
||||||
length += tmp_len;
|
|
||||||
|
|
||||||
if ( length > MAX_LINE_WIDTH )
|
|
||||||
{ // needs to be broken up
|
|
||||||
if ( !last_break )
|
|
||||||
last_break = x-1;
|
|
||||||
|
|
||||||
x = last_break;
|
|
||||||
|
|
||||||
// find an empty string slot
|
|
||||||
int j;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
for ( j = 0; j < MAX_LINES; j++ )
|
|
||||||
{
|
|
||||||
if ( ! *g_szLineBuffer[j] )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( j == MAX_LINES )
|
|
||||||
{
|
|
||||||
// need to make more room to display text, scroll stuff up then fix the pointers
|
|
||||||
int linesmoved = ScrollTextUp();
|
|
||||||
line -= linesmoved;
|
|
||||||
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ( j == MAX_LINES );
|
|
||||||
|
|
||||||
// copy remaining string into next buffer, making sure it starts with a space character
|
|
||||||
if ( (char)*last_break == (char)' ' )
|
|
||||||
{
|
|
||||||
int linelen = strlen(g_szLineBuffer[j]);
|
|
||||||
int remaininglen = strlen(last_break);
|
|
||||||
|
|
||||||
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE )
|
|
||||||
strcat( g_szLineBuffer[j], last_break );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE )
|
|
||||||
{
|
|
||||||
strcat( g_szLineBuffer[j], " " );
|
|
||||||
strcat( g_szLineBuffer[j], last_break );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*last_break = 0; // cut off the last string
|
|
||||||
|
|
||||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( j );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,586 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// Scoreboard.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudScoreboard class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
DECLARE_COMMAND( m_Scoreboard, ShowScores );
|
|
||||||
DECLARE_COMMAND( m_Scoreboard, HideScores );
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_Scoreboard, ScoreInfo );
|
|
||||||
DECLARE_MESSAGE( m_Scoreboard, TeamInfo );
|
|
||||||
DECLARE_MESSAGE( m_Scoreboard, TeamScore );
|
|
||||||
|
|
||||||
int CHudScoreboard :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
// Hook messages & commands here
|
|
||||||
//HOOK_COMMAND( "+showscores", ShowScores );
|
|
||||||
//HOOK_COMMAND( "-showscores", HideScores );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( ScoreInfo );
|
|
||||||
HOOK_MESSAGE( TeamScore );
|
|
||||||
HOOK_MESSAGE( TeamInfo );
|
|
||||||
|
|
||||||
InitHUDData();
|
|
||||||
|
|
||||||
cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudScoreboard :: VidInit( void )
|
|
||||||
{
|
|
||||||
// Load sprites here
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudScoreboard :: InitHUDData( void )
|
|
||||||
{
|
|
||||||
memset( g_PlayerExtraInfo, 0, sizeof g_PlayerExtraInfo );
|
|
||||||
m_iLastKilledBy = 0;
|
|
||||||
m_fLastKillTime = 0;
|
|
||||||
m_iPlayerNum = 0;
|
|
||||||
m_iNumTeams = 0;
|
|
||||||
memset( g_TeamInfo, 0, sizeof g_TeamInfo );
|
|
||||||
|
|
||||||
m_iFlags &= ~HUD_ACTIVE; // starts out inactive
|
|
||||||
|
|
||||||
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The scoreboard
|
|
||||||
We have a minimum width of 1-320 - we could have the field widths scale with it?
|
|
||||||
*/
|
|
||||||
|
|
||||||
// X positions
|
|
||||||
// relative to the side of the scoreboard
|
|
||||||
#define NAME_RANGE_MIN 20
|
|
||||||
#define NAME_RANGE_MAX 145
|
|
||||||
#define KILLS_RANGE_MIN 130
|
|
||||||
#define KILLS_RANGE_MAX 170
|
|
||||||
#define DIVIDER_POS 180
|
|
||||||
#define DEATHS_RANGE_MIN 185
|
|
||||||
#define DEATHS_RANGE_MAX 210
|
|
||||||
#define PING_RANGE_MIN 245
|
|
||||||
#define PING_RANGE_MAX 295
|
|
||||||
#define PL_RANGE_MIN 315
|
|
||||||
#define PL_RANGE_MAX 375
|
|
||||||
|
|
||||||
int SCOREBOARD_WIDTH = 320;
|
|
||||||
|
|
||||||
|
|
||||||
// Y positions
|
|
||||||
#define ROW_GAP 13
|
|
||||||
#define ROW_RANGE_MIN 15
|
|
||||||
#define ROW_RANGE_MAX ( ScreenHeight - 50 )
|
|
||||||
|
|
||||||
int CHudScoreboard :: Draw( float fTime )
|
|
||||||
{
|
|
||||||
int can_show_packetloss = 0;
|
|
||||||
int FAR_RIGHT;
|
|
||||||
|
|
||||||
if ( !m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
GetAllPlayersInfo();
|
|
||||||
|
|
||||||
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders
|
|
||||||
if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) )
|
|
||||||
{
|
|
||||||
can_show_packetloss = 1;
|
|
||||||
SCOREBOARD_WIDTH = 400;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SCOREBOARD_WIDTH = 320;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just sort the list on the fly
|
|
||||||
// list is sorted first by frags, then by deaths
|
|
||||||
float list_slot = 0;
|
|
||||||
int xpos_rel = (ScreenWidth - SCOREBOARD_WIDTH) / 2;
|
|
||||||
|
|
||||||
// print the heading line
|
|
||||||
int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
|
||||||
int xpos = NAME_RANGE_MIN + xpos_rel;
|
|
||||||
|
|
||||||
if ( !gHUD.m_Teamplay )
|
|
||||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 );
|
|
||||||
else
|
|
||||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 );
|
|
||||||
|
|
||||||
gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, "kills", 255, 140, 0 );
|
|
||||||
gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 );
|
|
||||||
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 );
|
|
||||||
gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 );
|
|
||||||
|
|
||||||
if ( can_show_packetloss )
|
|
||||||
{
|
|
||||||
gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
|
|
||||||
FAR_RIGHT += 5;
|
|
||||||
|
|
||||||
list_slot += 1.2;
|
|
||||||
ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
|
||||||
xpos = NAME_RANGE_MIN + xpos_rel;
|
|
||||||
FillRGBA( xpos - 5, ypos, FAR_RIGHT, 1, 255, 140, 0, 255); // draw the seperator line
|
|
||||||
|
|
||||||
list_slot += 0.8;
|
|
||||||
|
|
||||||
if ( !gHUD.m_Teamplay )
|
|
||||||
{
|
|
||||||
// it's not teamplay, so just draw a simple player list
|
|
||||||
DrawPlayers( xpos_rel, list_slot );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear out team scores
|
|
||||||
for ( int i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
if ( !g_TeamInfo[i].scores_overriden )
|
|
||||||
g_TeamInfo[i].frags = g_TeamInfo[i].deaths = 0;
|
|
||||||
g_TeamInfo[i].ping = g_TeamInfo[i].packetloss = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// recalc the team scores, then draw them
|
|
||||||
for ( i = 1; i < MAX_PLAYERS; i++ )
|
|
||||||
{
|
|
||||||
if ( g_PlayerInfoList[i].name == NULL )
|
|
||||||
continue; // empty player slot, skip
|
|
||||||
|
|
||||||
if ( g_PlayerExtraInfo[i].teamname[0] == 0 )
|
|
||||||
continue; // skip over players who are not in a team
|
|
||||||
|
|
||||||
// find what team this player is in
|
|
||||||
for ( int j = 1; j <= m_iNumTeams; j++ )
|
|
||||||
{
|
|
||||||
if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( j > m_iNumTeams ) // player is not in a team, skip to the next guy
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( !g_TeamInfo[j].scores_overriden )
|
|
||||||
{
|
|
||||||
g_TeamInfo[j].frags += g_PlayerExtraInfo[i].frags;
|
|
||||||
g_TeamInfo[j].deaths += g_PlayerExtraInfo[i].deaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_TeamInfo[j].ping += g_PlayerInfoList[i].ping;
|
|
||||||
g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss;
|
|
||||||
|
|
||||||
if ( g_PlayerInfoList[i].thisplayer )
|
|
||||||
g_TeamInfo[j].ownteam = TRUE;
|
|
||||||
else
|
|
||||||
g_TeamInfo[j].ownteam = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find team ping/packetloss averages
|
|
||||||
for ( i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
g_TeamInfo[i].already_drawn = FALSE;
|
|
||||||
|
|
||||||
if ( g_TeamInfo[i].players > 0 )
|
|
||||||
{
|
|
||||||
g_TeamInfo[i].ping /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping
|
|
||||||
g_TeamInfo[i].packetloss /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the teams
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
int highest_frags = -99999; int lowest_deaths = 99999;
|
|
||||||
int best_team = 0;
|
|
||||||
|
|
||||||
for ( i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
if ( g_TeamInfo[i].players < 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags )
|
|
||||||
{
|
|
||||||
if ( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths )
|
|
||||||
{
|
|
||||||
best_team = i;
|
|
||||||
lowest_deaths = g_TeamInfo[i].deaths;
|
|
||||||
highest_frags = g_TeamInfo[i].frags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw the best team on the scoreboard
|
|
||||||
if ( !best_team )
|
|
||||||
break;
|
|
||||||
|
|
||||||
// draw out the best team
|
|
||||||
team_info_t *team_info = &g_TeamInfo[best_team];
|
|
||||||
|
|
||||||
ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
|
||||||
|
|
||||||
// check we haven't drawn too far down
|
|
||||||
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
|
|
||||||
break;
|
|
||||||
|
|
||||||
xpos = NAME_RANGE_MIN + xpos_rel;
|
|
||||||
int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish
|
|
||||||
|
|
||||||
if ( team_info->ownteam ) // if it is their team, draw the background different color
|
|
||||||
{
|
|
||||||
// overlay the background in blue, then draw the score text over it
|
|
||||||
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw their name (left to right)
|
|
||||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b );
|
|
||||||
|
|
||||||
// draw kills (right to left)
|
|
||||||
xpos = KILLS_RANGE_MAX + xpos_rel;
|
|
||||||
gHUD.DrawHudNumberString( xpos, ypos, KILLS_RANGE_MIN + xpos_rel, team_info->frags, r, g, b );
|
|
||||||
|
|
||||||
// draw divider
|
|
||||||
xpos = DIVIDER_POS + xpos_rel;
|
|
||||||
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
|
|
||||||
|
|
||||||
// draw deaths
|
|
||||||
xpos = DEATHS_RANGE_MAX + xpos_rel;
|
|
||||||
gHUD.DrawHudNumberString( xpos, ypos, DEATHS_RANGE_MIN + xpos_rel, team_info->deaths, r, g, b );
|
|
||||||
|
|
||||||
// draw ping
|
|
||||||
// draw ping & packetloss
|
|
||||||
static char buf[64];
|
|
||||||
sprintf( buf, "%d", team_info->ping );
|
|
||||||
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25;
|
|
||||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
|
||||||
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
|
|
||||||
|
|
||||||
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders
|
|
||||||
if ( can_show_packetloss )
|
|
||||||
{
|
|
||||||
xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25;
|
|
||||||
|
|
||||||
sprintf( buf, " %d", team_info->packetloss );
|
|
||||||
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
|
|
||||||
}
|
|
||||||
|
|
||||||
team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again
|
|
||||||
list_slot++;
|
|
||||||
|
|
||||||
// draw all the players that belong to this team, indented slightly
|
|
||||||
list_slot = DrawPlayers( xpos_rel, list_slot, 10, team_info->name );
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw all the players who are not in a team
|
|
||||||
list_slot += 0.5;
|
|
||||||
DrawPlayers( xpos_rel, list_slot, 0, "" );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns the ypos where it finishes drawing
|
|
||||||
int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team )
|
|
||||||
{
|
|
||||||
int can_show_packetloss = 0;
|
|
||||||
int FAR_RIGHT;
|
|
||||||
|
|
||||||
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders
|
|
||||||
if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) )
|
|
||||||
{
|
|
||||||
can_show_packetloss = 1;
|
|
||||||
SCOREBOARD_WIDTH = 400;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SCOREBOARD_WIDTH = 320;
|
|
||||||
}
|
|
||||||
|
|
||||||
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
|
|
||||||
FAR_RIGHT += 5;
|
|
||||||
|
|
||||||
// draw the players, in order, and restricted to team if set
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
// Find the top ranking player
|
|
||||||
int highest_frags = -99999; int lowest_deaths = 99999;
|
|
||||||
int best_player = 0;
|
|
||||||
|
|
||||||
for ( int i = 1; i < MAX_PLAYERS; i++ )
|
|
||||||
{
|
|
||||||
if ( g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags )
|
|
||||||
{
|
|
||||||
if ( !(team && stricmp(g_PlayerExtraInfo[i].teamname, team)) ) // make sure it is the specified team
|
|
||||||
{
|
|
||||||
extra_player_info_t *pl_info = &g_PlayerExtraInfo[i];
|
|
||||||
if ( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths )
|
|
||||||
{
|
|
||||||
best_player = i;
|
|
||||||
lowest_deaths = pl_info->deaths;
|
|
||||||
highest_frags = pl_info->frags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !best_player )
|
|
||||||
break;
|
|
||||||
|
|
||||||
// draw out the best player
|
|
||||||
hud_player_info_t *pl_info = &g_PlayerInfoList[best_player];
|
|
||||||
|
|
||||||
int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
|
||||||
|
|
||||||
// check we haven't drawn too far down
|
|
||||||
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
|
|
||||||
break;
|
|
||||||
|
|
||||||
int xpos = NAME_RANGE_MIN + xpos_rel;
|
|
||||||
int r = 255, g = 255, b = 255;
|
|
||||||
if ( best_player == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime )
|
|
||||||
{
|
|
||||||
if ( pl_info->thisplayer )
|
|
||||||
{ // green is the suicide color? i wish this could do grey...
|
|
||||||
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Highlight the killers name - overlay the background in red, then draw the score text over it
|
|
||||||
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( pl_info->thisplayer ) // if it is their name, draw it a different color
|
|
||||||
{
|
|
||||||
// overlay the background in blue, then draw the score text over it
|
|
||||||
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw their name (left to right)
|
|
||||||
gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b );
|
|
||||||
|
|
||||||
// draw kills (right to left)
|
|
||||||
xpos = KILLS_RANGE_MAX + xpos_rel;
|
|
||||||
gHUD.DrawHudNumberString( xpos, ypos, KILLS_RANGE_MIN + xpos_rel, g_PlayerExtraInfo[best_player].frags, r, g, b );
|
|
||||||
|
|
||||||
// draw divider
|
|
||||||
xpos = DIVIDER_POS + xpos_rel;
|
|
||||||
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
|
|
||||||
|
|
||||||
// draw deaths
|
|
||||||
xpos = DEATHS_RANGE_MAX + xpos_rel;
|
|
||||||
gHUD.DrawHudNumberString( xpos, ypos, DEATHS_RANGE_MIN + xpos_rel, g_PlayerExtraInfo[best_player].deaths, r, g, b );
|
|
||||||
|
|
||||||
// draw ping & packetloss
|
|
||||||
static char buf[64];
|
|
||||||
sprintf( buf, "%d", g_PlayerInfoList[best_player].ping );
|
|
||||||
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25;
|
|
||||||
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
|
|
||||||
|
|
||||||
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders
|
|
||||||
if ( can_show_packetloss )
|
|
||||||
{
|
|
||||||
if ( g_PlayerInfoList[best_player].packetloss >= 63 )
|
|
||||||
{
|
|
||||||
UnpackRGB( r, g, b, RGB_REDISH );
|
|
||||||
sprintf( buf, " !!!!" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf( buf, " %d", g_PlayerInfoList[best_player].packetloss );
|
|
||||||
}
|
|
||||||
|
|
||||||
xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25;
|
|
||||||
|
|
||||||
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
|
|
||||||
}
|
|
||||||
|
|
||||||
pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again
|
|
||||||
list_slot++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return list_slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CHudScoreboard :: GetAllPlayersInfo( void )
|
|
||||||
{
|
|
||||||
for ( int i = 1; i < MAX_PLAYERS; i++ )
|
|
||||||
{
|
|
||||||
GetPlayerInfo( i, &g_PlayerInfoList[i] );
|
|
||||||
|
|
||||||
if ( g_PlayerInfoList[i].thisplayer )
|
|
||||||
m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
short cl = READ_BYTE();
|
|
||||||
short frags = READ_SHORT();
|
|
||||||
short deaths = READ_SHORT();
|
|
||||||
short playerclass = READ_SHORT();
|
|
||||||
short teamnumber = READ_SHORT();
|
|
||||||
|
|
||||||
if ( cl > 0 && cl <= MAX_PLAYERS )
|
|
||||||
{
|
|
||||||
g_PlayerExtraInfo[cl].frags = frags;
|
|
||||||
g_PlayerExtraInfo[cl].deaths = deaths;
|
|
||||||
g_PlayerExtraInfo[cl].playerclass = playerclass;
|
|
||||||
g_PlayerExtraInfo[cl].teamnumber = teamnumber;
|
|
||||||
|
|
||||||
gViewPort->UpdateOnPlayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for TeamInfo message
|
|
||||||
// accepts two values:
|
|
||||||
// byte: client number
|
|
||||||
// string: client team name
|
|
||||||
int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
short cl = READ_BYTE();
|
|
||||||
|
|
||||||
if ( cl > 0 && cl <= MAX_PLAYERS )
|
|
||||||
{ // set the players team
|
|
||||||
strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME );
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild the list of teams
|
|
||||||
|
|
||||||
// clear out player counts from teams
|
|
||||||
for ( int i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
g_TeamInfo[i].players = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild the team list
|
|
||||||
GetAllPlayersInfo();
|
|
||||||
m_iNumTeams = 0;
|
|
||||||
for ( i = 1; i < MAX_PLAYERS; i++ )
|
|
||||||
{
|
|
||||||
if ( g_PlayerInfoList[i].name == NULL )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( g_PlayerExtraInfo[i].teamname[0] == 0 )
|
|
||||||
continue; // skip over players who are not in a team
|
|
||||||
|
|
||||||
// is this player in an existing team?
|
|
||||||
for ( int j = 1; j <= m_iNumTeams; j++ )
|
|
||||||
{
|
|
||||||
if ( g_TeamInfo[j].name[0] == '\0' )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( j > m_iNumTeams )
|
|
||||||
{ // they aren't in a listed team, so make a new one
|
|
||||||
// search through for an empty team slot
|
|
||||||
for ( int j = 1; j <= m_iNumTeams; j++ )
|
|
||||||
{
|
|
||||||
if ( g_TeamInfo[j].name[0] == '\0' )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m_iNumTeams = max( j, m_iNumTeams );
|
|
||||||
|
|
||||||
strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME );
|
|
||||||
g_TeamInfo[j].players = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_TeamInfo[j].players++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear out any empty teams
|
|
||||||
for ( i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
if ( g_TeamInfo[i].players < 1 )
|
|
||||||
memset( &g_TeamInfo[i], 0, sizeof(team_info_t) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for TeamScore message
|
|
||||||
// accepts three values:
|
|
||||||
// string: team name
|
|
||||||
// short: teams kills
|
|
||||||
// short: teams deaths
|
|
||||||
// if this message is never received, then scores will simply be the combined totals of the players.
|
|
||||||
int CHudScoreboard :: MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
char *TeamName = READ_STRING();
|
|
||||||
|
|
||||||
// find the team matching the name
|
|
||||||
for ( int i = 1; i <= m_iNumTeams; i++ )
|
|
||||||
{
|
|
||||||
if ( !stricmp( TeamName, g_TeamInfo[i].name ) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( i > m_iNumTeams )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// use this new score data instead of combined player scores
|
|
||||||
g_TeamInfo[i].scores_overriden = TRUE;
|
|
||||||
g_TeamInfo[i].frags = READ_SHORT();
|
|
||||||
g_TeamInfo[i].deaths = READ_SHORT();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudScoreboard :: DeathMsg( int killer, int victim )
|
|
||||||
{
|
|
||||||
// if we were the one killed, or the world killed us, set the scoreboard to indicate suicide
|
|
||||||
if ( victim == m_iPlayerNum || killer == 0 )
|
|
||||||
{
|
|
||||||
m_iLastKilledBy = killer ? killer : m_iPlayerNum;
|
|
||||||
m_fLastKillTime = gHUD.m_flTime + 10; // display who we were killed by for 10 seconds
|
|
||||||
|
|
||||||
if ( killer == m_iPlayerNum )
|
|
||||||
m_iLastKilledBy = m_iPlayerNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CHudScoreboard :: UserCmd_ShowScores( void )
|
|
||||||
{
|
|
||||||
m_iShowscoresHeld = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudScoreboard :: UserCmd_HideScores( void )
|
|
||||||
{
|
|
||||||
m_iShowscoresHeld = FALSE;
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
//======== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $Log: $
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
#include <windows.h>
|
|
||||||
#include <dsound.h>
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#include "r_studioint.h"
|
|
||||||
|
|
||||||
extern engine_studio_api_t IEngineStudio;
|
|
||||||
|
|
||||||
#define RENDERTYPE_UNDEFINED 0
|
|
||||||
#define RENDERTYPE_SOFTWARE 1
|
|
||||||
#define RENDERTYPE_HARDWARE 2
|
|
||||||
|
|
||||||
#define ENGINE_LAUNCHER_API_VERSION 1
|
|
||||||
|
|
||||||
LPDIRECTSOUND lpDS = NULL;
|
|
||||||
LPDIRECTSOUNDBUFFER lpDSBuf = NULL;
|
|
||||||
LPHWAVEOUT lpHW = NULL;
|
|
||||||
|
|
||||||
static HMODULE hEngine = 0;
|
|
||||||
|
|
||||||
typedef struct engine_api_s
|
|
||||||
{
|
|
||||||
int version;
|
|
||||||
int rendertype;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
void ( *unused1 ) ( void );
|
|
||||||
void ( *unused2 ) ( void );
|
|
||||||
void ( *unused3 ) ( void );
|
|
||||||
void ( *unused4 ) ( void );
|
|
||||||
void ( *unused5 ) ( void );
|
|
||||||
void ( *unused6 ) ( void );
|
|
||||||
void ( *unused7 ) ( void );
|
|
||||||
void ( *unused8 ) ( void );
|
|
||||||
void ( *unused9 ) ( void );
|
|
||||||
void ( *unused10 ) ( void );
|
|
||||||
void ( *unused11 ) ( void );
|
|
||||||
void ( *unused12 ) ( void );
|
|
||||||
void ( *unused13 ) ( void );
|
|
||||||
void ( *unused14 ) ( void );
|
|
||||||
void ( *unused15 ) ( void );
|
|
||||||
void ( *unused16 ) ( void );
|
|
||||||
void ( *unused17 ) ( void );
|
|
||||||
void ( *unused18 ) ( void );
|
|
||||||
void ( *unused19 ) ( void );
|
|
||||||
void ( *unused20 ) ( void );
|
|
||||||
void ( *unused21 ) ( void );
|
|
||||||
void ( *unused22 ) ( void );
|
|
||||||
void ( *unused23 ) ( void );
|
|
||||||
void ( *unused24 ) ( void );
|
|
||||||
void ( *unused25 ) ( void );
|
|
||||||
void ( *unused26 ) ( void );
|
|
||||||
void ( *unused27 ) ( void );
|
|
||||||
void ( *unused28 ) ( void );
|
|
||||||
void ( *unused29 ) ( void );
|
|
||||||
void ( *unused30 ) ( void );
|
|
||||||
void ( *unused31 ) ( void );
|
|
||||||
void ( *unused32 ) ( void );
|
|
||||||
void ( *unused33 ) ( void );
|
|
||||||
void ( *unused34 ) ( void );
|
|
||||||
|
|
||||||
void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf );
|
|
||||||
void *( *S_GetWAVPointer ) ( void );
|
|
||||||
|
|
||||||
void ( *unused35 ) ( void );
|
|
||||||
void ( *unused36 ) ( void );
|
|
||||||
void ( *unused37 ) ( void );
|
|
||||||
void ( *unused38 ) ( void );
|
|
||||||
void ( *unused39 ) ( void );
|
|
||||||
void ( *unused40 ) ( void );
|
|
||||||
void ( *unused41 ) ( void );
|
|
||||||
void ( *unused42 ) ( void );
|
|
||||||
void ( *unused43 ) ( void );
|
|
||||||
void ( *unused44 ) ( void );
|
|
||||||
void ( *unused45 ) ( void );
|
|
||||||
void ( *unused46 ) ( void );
|
|
||||||
void ( *unused47 ) ( void );
|
|
||||||
void ( *unused48 ) ( void );
|
|
||||||
void ( *unused49 ) ( void );
|
|
||||||
void ( *unused50 ) ( void );
|
|
||||||
void ( *unused51 ) ( void );
|
|
||||||
void ( *unused52 ) ( void );
|
|
||||||
void ( *unused53 ) ( void );
|
|
||||||
void ( *unused54 ) ( void );
|
|
||||||
void ( *unused55 ) ( void );
|
|
||||||
} engine_api_t;
|
|
||||||
|
|
||||||
static engine_api_t engineapi;
|
|
||||||
|
|
||||||
typedef int (*engine_api_func)( int version, int size, struct engine_api_s *api );
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Get launcher/engine interface from engine module
|
|
||||||
// Input : hMod -
|
|
||||||
// Output : int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int Eng_LoadFunctions( HMODULE hMod )
|
|
||||||
{
|
|
||||||
engine_api_func pfnEngineAPI;
|
|
||||||
|
|
||||||
pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" );
|
|
||||||
if ( !pfnEngineAPI )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// All is okay
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Load proper engine .dll and get pointer to either DSound and primary buffer or HWAVEOUT ( NT 4.0, e.g. )
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void LoadSoundAPIs( void )
|
|
||||||
{
|
|
||||||
hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" );
|
|
||||||
if ( hEngine )
|
|
||||||
{
|
|
||||||
if ( Eng_LoadFunctions( hEngine ) )
|
|
||||||
{
|
|
||||||
if ( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer )
|
|
||||||
{
|
|
||||||
engineapi.S_GetDSPointer(&lpDS, &lpDSBuf);
|
|
||||||
lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Close engine library, release sound pointers
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ShutdownSoundAPIs( void )
|
|
||||||
{
|
|
||||||
if( hEngine )
|
|
||||||
{
|
|
||||||
FreeLibrary( hEngine );
|
|
||||||
hEngine = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lpDS = 0;
|
|
||||||
lpDSBuf = 0;
|
|
||||||
lpHW = 0;
|
|
||||||
}
|
|
|
@ -1,163 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// status_icons.cpp
|
|
||||||
//
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
#include "event_api.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
|
|
||||||
|
|
||||||
int CHudStatusIcons::Init( void )
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( StatusIcon );
|
|
||||||
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudStatusIcons::VidInit( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudStatusIcons::Reset( void )
|
|
||||||
{
|
|
||||||
memset( m_IconList, 0, sizeof m_IconList );
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw status icons along the left-hand side of the screen
|
|
||||||
int CHudStatusIcons::Draw( float flTime )
|
|
||||||
{
|
|
||||||
if (gEngfuncs.IsSpectateOnly())
|
|
||||||
return 1;
|
|
||||||
// find starting position to draw from, along right-hand side of screen
|
|
||||||
int x = 5;
|
|
||||||
int y = ScreenHeight / 2;
|
|
||||||
|
|
||||||
// loop through icon list, and draw any valid icons drawing up from the middle of screen
|
|
||||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
|
||||||
{
|
|
||||||
if ( m_IconList[i].spr )
|
|
||||||
{
|
|
||||||
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
|
|
||||||
|
|
||||||
SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
|
|
||||||
SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for StatusIcon message
|
|
||||||
// accepts five values:
|
|
||||||
// byte : TRUE = ENABLE icon, FALSE = DISABLE icon
|
|
||||||
// string : the sprite name to display
|
|
||||||
// byte : red
|
|
||||||
// byte : green
|
|
||||||
// byte : blue
|
|
||||||
int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int ShouldEnable = READ_BYTE();
|
|
||||||
char *pszIconName = READ_STRING();
|
|
||||||
if ( ShouldEnable )
|
|
||||||
{
|
|
||||||
int r = READ_BYTE();
|
|
||||||
int g = READ_BYTE();
|
|
||||||
int b = READ_BYTE();
|
|
||||||
EnableIcon( pszIconName, r, g, b );
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DisableIcon( pszIconName );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the icon to the icon list, and set it's drawing color
|
|
||||||
void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
// check to see if the sprite is in the current list
|
|
||||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
|
||||||
{
|
|
||||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( i == MAX_ICONSPRITES )
|
|
||||||
{
|
|
||||||
// icon not in list, so find an empty slot to add to
|
|
||||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
|
||||||
{
|
|
||||||
if ( !m_IconList[i].spr )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we've run out of space in the list, overwrite the first icon
|
|
||||||
if ( i == MAX_ICONSPRITES )
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the sprite and add it to the list
|
|
||||||
// the sprite must be listed in hud.txt
|
|
||||||
int spr_index = gHUD.GetSpriteIndex( pszIconName );
|
|
||||||
m_IconList[i].spr = gHUD.GetSprite( spr_index );
|
|
||||||
m_IconList[i].rc = gHUD.GetSpriteRect( spr_index );
|
|
||||||
m_IconList[i].r = red;
|
|
||||||
m_IconList[i].g = green;
|
|
||||||
m_IconList[i].b = blue;
|
|
||||||
strcpy( m_IconList[i].szSpriteName, pszIconName );
|
|
||||||
|
|
||||||
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
|
|
||||||
if ( strstr(m_IconList[i].szSpriteName, "grenade") )
|
|
||||||
{
|
|
||||||
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
|
|
||||||
gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudStatusIcons::DisableIcon( char *pszIconName )
|
|
||||||
{
|
|
||||||
// find the sprite is in the current list
|
|
||||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
|
||||||
{
|
|
||||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
|
||||||
{
|
|
||||||
// clear the item from the list
|
|
||||||
memset( &m_IconList[i], 0, sizeof(icon_sprite_t) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,265 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// statusbar.cpp
|
|
||||||
//
|
|
||||||
// generic text status bar, set by game dll
|
|
||||||
// runs across bottom of screen
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_StatusBar, StatusText );
|
|
||||||
DECLARE_MESSAGE( m_StatusBar, StatusValue );
|
|
||||||
|
|
||||||
#ifdef _TFC
|
|
||||||
#define STATUSBAR_ID_LINE 2
|
|
||||||
#else
|
|
||||||
#define STATUSBAR_ID_LINE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float *GetClientColor( int clientIndex );
|
|
||||||
extern float g_ColorYellow[3];
|
|
||||||
|
|
||||||
int CHudStatusBar :: Init( void )
|
|
||||||
{
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
HOOK_MESSAGE( StatusText );
|
|
||||||
HOOK_MESSAGE( StatusValue );
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudStatusBar :: VidInit( void )
|
|
||||||
{
|
|
||||||
// Load sprites here
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudStatusBar :: Reset( void )
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
m_iFlags &= ~HUD_ACTIVE; // start out inactive
|
|
||||||
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
|
||||||
m_szStatusText[i][0] = 0;
|
|
||||||
memset( m_iStatusValues, 0, sizeof m_iStatusValues );
|
|
||||||
|
|
||||||
m_iStatusValues[0] = 1; // 0 is the special index, which always returns true
|
|
||||||
|
|
||||||
// reset our colors for the status bar lines (yellow is default)
|
|
||||||
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
|
||||||
m_pflNameColors[i] = g_ColorYellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHudStatusBar :: ParseStatusString( int line_num )
|
|
||||||
{
|
|
||||||
// localise string first
|
|
||||||
char szBuffer[MAX_STATUSTEXT_LENGTH];
|
|
||||||
memset( szBuffer, 0, sizeof szBuffer );
|
|
||||||
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
|
|
||||||
|
|
||||||
// parse m_szStatusText & m_iStatusValues into m_szStatusBar
|
|
||||||
memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH );
|
|
||||||
char *src = szBuffer;
|
|
||||||
char *dst = m_szStatusBar[line_num];
|
|
||||||
|
|
||||||
char *src_start = src, *dst_start = dst;
|
|
||||||
|
|
||||||
while ( *src != 0 )
|
|
||||||
{
|
|
||||||
while ( *src == '\n' )
|
|
||||||
src++; // skip over any newlines
|
|
||||||
|
|
||||||
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
int index = atoi( src );
|
|
||||||
// should we draw this line?
|
|
||||||
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) )
|
|
||||||
{ // parse this line and append result to the status bar
|
|
||||||
while ( *src >= '0' && *src <= '9' )
|
|
||||||
src++;
|
|
||||||
|
|
||||||
if ( *src == '\n' || *src == 0 )
|
|
||||||
continue; // no more left in this text line
|
|
||||||
|
|
||||||
// copy the text, char by char, until we hit a % or a \n
|
|
||||||
while ( *src != '\n' && *src != 0 )
|
|
||||||
{
|
|
||||||
if ( *src != '%' )
|
|
||||||
{ // just copy the character
|
|
||||||
*dst = *src;
|
|
||||||
dst++, src++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// get the descriptor
|
|
||||||
char valtype = *(++src); // move over %
|
|
||||||
|
|
||||||
// if it's a %, draw a % sign
|
|
||||||
if ( valtype == '%' )
|
|
||||||
{
|
|
||||||
*dst = valtype;
|
|
||||||
dst++, src++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// move over descriptor, then get and move over the index
|
|
||||||
index = atoi( ++src );
|
|
||||||
while ( *src >= '0' && *src <= '9' )
|
|
||||||
src++;
|
|
||||||
|
|
||||||
if ( index >= 0 && index < MAX_STATUSBAR_VALUES )
|
|
||||||
{
|
|
||||||
int indexval = m_iStatusValues[index];
|
|
||||||
|
|
||||||
// get the string to substitute in place of the %XX
|
|
||||||
char szRepString[MAX_PLAYER_NAME_LENGTH];
|
|
||||||
switch ( valtype )
|
|
||||||
{
|
|
||||||
case 'p': // player name
|
|
||||||
gEngfuncs.pfnGetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
|
|
||||||
if ( g_PlayerInfoList[indexval].name != NULL )
|
|
||||||
{
|
|
||||||
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
|
|
||||||
m_pflNameColors[line_num] = GetClientColor( indexval );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy( szRepString, "******" );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'i': // number
|
|
||||||
sprintf( szRepString, "%d", indexval );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
szRepString[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ )
|
|
||||||
*dst = *cp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// skip to next line of text
|
|
||||||
while ( *src != 0 && *src != '\n' )
|
|
||||||
src++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CHudStatusBar :: Draw( float fTime )
|
|
||||||
{
|
|
||||||
if ( m_bReparseString )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
|
||||||
{
|
|
||||||
m_pflNameColors[i] = g_ColorYellow;
|
|
||||||
ParseStatusString( i );
|
|
||||||
}
|
|
||||||
m_bReparseString = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Y_START = ScreenHeight - 52;
|
|
||||||
|
|
||||||
// Draw the status bar lines
|
|
||||||
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
|
||||||
{
|
|
||||||
int TextHeight, TextWidth;
|
|
||||||
GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
|
|
||||||
|
|
||||||
int x = 8;
|
|
||||||
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
|
|
||||||
|
|
||||||
// let user set status ID bar centering
|
|
||||||
if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") )
|
|
||||||
{
|
|
||||||
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
|
|
||||||
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_pflNameColors[i] )
|
|
||||||
gEngfuncs.pfnDrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
|
||||||
|
|
||||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for StatusText message
|
|
||||||
// accepts two values:
|
|
||||||
// byte: line number of status bar text
|
|
||||||
// string: status bar text
|
|
||||||
// this string describes how the status bar should be drawn
|
|
||||||
// a semi-regular expression:
|
|
||||||
// ( slotnum ([a..z] [%pX] [%iX])*)*
|
|
||||||
// where slotnum is an index into the Value table (see below)
|
|
||||||
// if slotnum is 0, the string is always drawn
|
|
||||||
// if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline
|
|
||||||
// %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X]
|
|
||||||
// %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X]
|
|
||||||
int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int line = READ_BYTE();
|
|
||||||
|
|
||||||
if ( line < 0 || line > MAX_STATUSBAR_LINES )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
|
|
||||||
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
|
|
||||||
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
m_bReparseString = TRUE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for StatusText message
|
|
||||||
// accepts two values:
|
|
||||||
// byte: index into the status value array
|
|
||||||
// short: value to store
|
|
||||||
int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int index = READ_BYTE();
|
|
||||||
if ( index < 1 || index > MAX_STATUSBAR_VALUES )
|
|
||||||
return 1; // index out of range
|
|
||||||
|
|
||||||
m_iStatusValues[index] = READ_SHORT();
|
|
||||||
|
|
||||||
m_bReparseString = TRUE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,251 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "com_model.h"
|
|
||||||
#include "studio_util.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
AngleMatrix
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void AngleMatrix (const float *angles, float (*matrix)[4] )
|
|
||||||
{
|
|
||||||
float angle;
|
|
||||||
float sr, sp, sy, cr, cp, cy;
|
|
||||||
|
|
||||||
angle = angles[YAW] * (M_PI*2 / 360);
|
|
||||||
sy = sin(angle);
|
|
||||||
cy = cos(angle);
|
|
||||||
angle = angles[PITCH] * (M_PI*2 / 360);
|
|
||||||
sp = sin(angle);
|
|
||||||
cp = cos(angle);
|
|
||||||
angle = angles[ROLL] * (M_PI*2 / 360);
|
|
||||||
sr = sin(angle);
|
|
||||||
cr = cos(angle);
|
|
||||||
|
|
||||||
// matrix = (YAW * PITCH) * ROLL
|
|
||||||
matrix[0][0] = cp*cy;
|
|
||||||
matrix[1][0] = cp*sy;
|
|
||||||
matrix[2][0] = -sp;
|
|
||||||
matrix[0][1] = sr*sp*cy+cr*-sy;
|
|
||||||
matrix[1][1] = sr*sp*sy+cr*cy;
|
|
||||||
matrix[2][1] = sr*cp;
|
|
||||||
matrix[0][2] = (cr*sp*cy+-sr*-sy);
|
|
||||||
matrix[1][2] = (cr*sp*sy+-sr*cy);
|
|
||||||
matrix[2][2] = cr*cp;
|
|
||||||
matrix[0][3] = 0.0;
|
|
||||||
matrix[1][3] = 0.0;
|
|
||||||
matrix[2][3] = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
VectorCompare
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
int VectorCompare (const float *v1, const float *v2)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
if (v1[i] != v2[i])
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CrossProduct
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void CrossProduct (const float *v1, const float *v2, float *cross)
|
|
||||||
{
|
|
||||||
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
|
||||||
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
|
||||||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
VectorTransform
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void VectorTransform (const float *in1, float in2[3][4], float *out)
|
|
||||||
{
|
|
||||||
out[0] = DotProduct(in1, in2[0]) + in2[0][3];
|
|
||||||
out[1] = DotProduct(in1, in2[1]) + in2[1][3];
|
|
||||||
out[2] = DotProduct(in1, in2[2]) + in2[2][3];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
ConcatTransforms
|
|
||||||
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
|
|
||||||
{
|
|
||||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
|
||||||
in1[0][2] * in2[2][0];
|
|
||||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
|
||||||
in1[0][2] * in2[2][1];
|
|
||||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
|
||||||
in1[0][2] * in2[2][2];
|
|
||||||
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
|
|
||||||
in1[0][2] * in2[2][3] + in1[0][3];
|
|
||||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
|
||||||
in1[1][2] * in2[2][0];
|
|
||||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
|
||||||
in1[1][2] * in2[2][1];
|
|
||||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
|
||||||
in1[1][2] * in2[2][2];
|
|
||||||
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
|
|
||||||
in1[1][2] * in2[2][3] + in1[1][3];
|
|
||||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
|
||||||
in1[2][2] * in2[2][0];
|
|
||||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
|
||||||
in1[2][2] * in2[2][1];
|
|
||||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
|
||||||
in1[2][2] * in2[2][2];
|
|
||||||
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
|
||||||
in1[2][2] * in2[2][3] + in1[2][3];
|
|
||||||
}
|
|
||||||
|
|
||||||
// angles index are not the same as ROLL, PITCH, YAW
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
AngleQuaternion
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void AngleQuaternion( float *angles, vec4_t quaternion )
|
|
||||||
{
|
|
||||||
float angle;
|
|
||||||
float sr, sp, sy, cr, cp, cy;
|
|
||||||
|
|
||||||
// FIXME: rescale the inputs to 1/2 angle
|
|
||||||
angle = angles[2] * 0.5;
|
|
||||||
sy = sin(angle);
|
|
||||||
cy = cos(angle);
|
|
||||||
angle = angles[1] * 0.5;
|
|
||||||
sp = sin(angle);
|
|
||||||
cp = cos(angle);
|
|
||||||
angle = angles[0] * 0.5;
|
|
||||||
sr = sin(angle);
|
|
||||||
cr = cos(angle);
|
|
||||||
|
|
||||||
quaternion[0] = sr*cp*cy-cr*sp*sy; // X
|
|
||||||
quaternion[1] = cr*sp*cy+sr*cp*sy; // Y
|
|
||||||
quaternion[2] = cr*cp*sy-sr*sp*cy; // Z
|
|
||||||
quaternion[3] = cr*cp*cy+sr*sp*sy; // W
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
QuaternionSlerp
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float omega, cosom, sinom, sclp, sclq;
|
|
||||||
|
|
||||||
// decide if one of the quaternions is backwards
|
|
||||||
float a = 0;
|
|
||||||
float b = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
a += (p[i]-q[i])*(p[i]-q[i]);
|
|
||||||
b += (p[i]+q[i])*(p[i]+q[i]);
|
|
||||||
}
|
|
||||||
if (a > b)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
q[i] = -q[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3];
|
|
||||||
|
|
||||||
if ((1.0 + cosom) > 0.000001)
|
|
||||||
{
|
|
||||||
if ((1.0 - cosom) > 0.000001)
|
|
||||||
{
|
|
||||||
omega = acos( cosom );
|
|
||||||
sinom = sin( omega );
|
|
||||||
sclp = sin( (1.0 - t)*omega) / sinom;
|
|
||||||
sclq = sin( t*omega ) / sinom;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sclp = 1.0 - t;
|
|
||||||
sclq = t;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
qt[i] = sclp * p[i] + sclq * q[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qt[0] = -q[1];
|
|
||||||
qt[1] = q[0];
|
|
||||||
qt[2] = -q[3];
|
|
||||||
qt[3] = q[2];
|
|
||||||
sclp = sin( (1.0 - t) * (0.5 * M_PI));
|
|
||||||
sclq = sin( t * (0.5 * M_PI));
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
qt[i] = sclp * p[i] + sclq * qt[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
QuaternionMatrix
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] )
|
|
||||||
{
|
|
||||||
matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2];
|
|
||||||
matrix[1][0] = 2.0 * quaternion[0] * quaternion[1] + 2.0 * quaternion[3] * quaternion[2];
|
|
||||||
matrix[2][0] = 2.0 * quaternion[0] * quaternion[2] - 2.0 * quaternion[3] * quaternion[1];
|
|
||||||
|
|
||||||
matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[3] * quaternion[2];
|
|
||||||
matrix[1][1] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2];
|
|
||||||
matrix[2][1] = 2.0 * quaternion[1] * quaternion[2] + 2.0 * quaternion[3] * quaternion[0];
|
|
||||||
|
|
||||||
matrix[0][2] = 2.0 * quaternion[0] * quaternion[2] + 2.0 * quaternion[3] * quaternion[1];
|
|
||||||
matrix[1][2] = 2.0 * quaternion[1] * quaternion[2] - 2.0 * quaternion[3] * quaternion[0];
|
|
||||||
matrix[2][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[1] * quaternion[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
MatrixCopy
|
|
||||||
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
void MatrixCopy( float in[3][4], float out[3][4] )
|
|
||||||
{
|
|
||||||
memcpy( out, in, sizeof( float ) * 3 * 4 );
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( STUDIO_UTIL_H )
|
|
||||||
#define STUDIO_UTIL_H
|
|
||||||
#if defined( WIN32 )
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef M_PI
|
|
||||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PITCH
|
|
||||||
// MOVEMENT INFO
|
|
||||||
// up / down
|
|
||||||
#define PITCH 0
|
|
||||||
// left / right
|
|
||||||
#define YAW 1
|
|
||||||
// fall over
|
|
||||||
#define ROLL 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FDotProduct( a, b ) (fabs((a[0])*(b[0])) + fabs((a[1])*(b[1])) + fabs((a[2])*(b[2])))
|
|
||||||
|
|
||||||
void AngleMatrix (const float *angles, float (*matrix)[4] );
|
|
||||||
int VectorCompare (const float *v1, const float *v2);
|
|
||||||
void CrossProduct (const float *v1, const float *v2, float *cross);
|
|
||||||
void VectorTransform (const float *in1, float in2[3][4], float *out);
|
|
||||||
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
|
||||||
void MatrixCopy( float in[3][4], float out[3][4] );
|
|
||||||
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
|
|
||||||
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
|
|
||||||
void AngleQuaternion( float *angles, vec4_t quaternion );
|
|
||||||
|
|
||||||
#endif // STUDIO_UTIL_H
|
|
|
@ -1,214 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// text_message.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudTextMessage class
|
|
||||||
//
|
|
||||||
// this class routes messages through titles.txt for localisation
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE( m_TextMessage, TextMsg );
|
|
||||||
|
|
||||||
int CHudTextMessage::Init(void)
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( TextMsg );
|
|
||||||
|
|
||||||
gHUD.AddHudElem( this );
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Searches through the string for any msg names (indicated by a '#')
|
|
||||||
// any found are looked up in titles.txt and the new message substituted
|
|
||||||
// the new value is pushed into dst_buffer
|
|
||||||
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
|
|
||||||
{
|
|
||||||
char *dst = dst_buffer;
|
|
||||||
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
|
|
||||||
{
|
|
||||||
if ( *src == '#' )
|
|
||||||
{
|
|
||||||
// cut msg name out of string
|
|
||||||
static char word_buf[255];
|
|
||||||
char *wdst = word_buf, *word_start = src;
|
|
||||||
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ )
|
|
||||||
{
|
|
||||||
*wdst = *src;
|
|
||||||
}
|
|
||||||
*wdst = 0;
|
|
||||||
|
|
||||||
// lookup msg name in titles.txt
|
|
||||||
client_textmessage_t *clmsg = TextMessageGet( word_buf );
|
|
||||||
if ( !clmsg || !(clmsg->pMessage) )
|
|
||||||
{
|
|
||||||
src = word_start;
|
|
||||||
*dst = *src;
|
|
||||||
dst++, src++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy string into message over the msg name
|
|
||||||
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
|
|
||||||
{
|
|
||||||
*dst = *wsrc;
|
|
||||||
}
|
|
||||||
*dst = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*dst = *src;
|
|
||||||
dst++, src++;
|
|
||||||
*dst = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dst_buffer[buffer_size-1] = 0; // ensure null termination
|
|
||||||
return dst_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but with a local static buffer
|
|
||||||
char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
|
|
||||||
{
|
|
||||||
static char dst_buffer[1024];
|
|
||||||
LocaliseTextString( msg, dst_buffer, 1024 );
|
|
||||||
return dst_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simplified version of LocaliseTextString; assumes string is only one word
|
|
||||||
char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
|
|
||||||
{
|
|
||||||
if ( !msg )
|
|
||||||
return "";
|
|
||||||
|
|
||||||
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself
|
|
||||||
if ( msg[0] == '#' )
|
|
||||||
{
|
|
||||||
// this is a message name, so look up the real message
|
|
||||||
client_textmessage_t *clmsg = TextMessageGet( msg+1 );
|
|
||||||
|
|
||||||
if ( !clmsg || !(clmsg->pMessage) )
|
|
||||||
return (char*)msg; // lookup failed, so return the original string
|
|
||||||
|
|
||||||
if ( msg_dest )
|
|
||||||
{
|
|
||||||
// check to see if titles.txt info overrides msg destination
|
|
||||||
// if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination
|
|
||||||
if ( clmsg->effect < 0 ) //
|
|
||||||
*msg_dest = -clmsg->effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (char*)clmsg->pMessage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // nothing special about this message, so just return the same string
|
|
||||||
return (char*)msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StripEndNewlineFromString( char *str )
|
|
||||||
{
|
|
||||||
int s = strlen( str ) - 1;
|
|
||||||
if ( str[s] == '\n' || str[s] == '\r' )
|
|
||||||
str[s] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// converts all '\r' characters to '\n', so that the engine can deal with the properly
|
|
||||||
// returns a pointer to str
|
|
||||||
char* ConvertCRtoNL( char *str )
|
|
||||||
{
|
|
||||||
for ( char *ch = str; *ch != 0; ch++ )
|
|
||||||
if ( *ch == '\r' )
|
|
||||||
*ch = '\n';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for text messages
|
|
||||||
// displays a string, looking them up from the titles.txt file, which can be localised
|
|
||||||
// parameters:
|
|
||||||
// byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
|
|
||||||
// string: message
|
|
||||||
// optional parameters:
|
|
||||||
// string: message parameter 1
|
|
||||||
// string: message parameter 2
|
|
||||||
// string: message parameter 3
|
|
||||||
// string: message parameter 4
|
|
||||||
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
|
|
||||||
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
|
|
||||||
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
int msg_dest = READ_BYTE();
|
|
||||||
|
|
||||||
#define MSG_BUF_SIZE 128
|
|
||||||
static char szBuf[6][MSG_BUF_SIZE];
|
|
||||||
char *msg_text = LookupString( READ_STRING(), &msg_dest );
|
|
||||||
msg_text = safe_strcpy( szBuf[0], msg_text , MSG_BUF_SIZE);
|
|
||||||
|
|
||||||
// keep reading strings and using C format strings for subsituting the strings into the localised text string
|
|
||||||
char *sstr1 = LookupString( READ_STRING() );
|
|
||||||
sstr1 = safe_strcpy( szBuf[1], sstr1 , MSG_BUF_SIZE);
|
|
||||||
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
|
|
||||||
char *sstr2 = LookupString( READ_STRING() );
|
|
||||||
sstr2 = safe_strcpy( szBuf[2], sstr2 , MSG_BUF_SIZE);
|
|
||||||
StripEndNewlineFromString( sstr2 );
|
|
||||||
char *sstr3 = LookupString( READ_STRING() );
|
|
||||||
sstr3 = safe_strcpy( szBuf[3], sstr3 , MSG_BUF_SIZE);
|
|
||||||
StripEndNewlineFromString( sstr3 );
|
|
||||||
char *sstr4 = LookupString( READ_STRING() );
|
|
||||||
sstr4 = safe_strcpy( szBuf[4], sstr4 , MSG_BUF_SIZE);
|
|
||||||
StripEndNewlineFromString( sstr4 );
|
|
||||||
char *psz = szBuf[5];
|
|
||||||
|
|
||||||
if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch ( msg_dest )
|
|
||||||
{
|
|
||||||
case HUD_PRINTCENTER:
|
|
||||||
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
|
||||||
CenterPrint( ConvertCRtoNL( psz ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HUD_PRINTNOTIFY:
|
|
||||||
psz[0] = 1; // mark this message to go into the notify buffer
|
|
||||||
safe_sprintf( psz+1, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
|
||||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HUD_PRINTTALK:
|
|
||||||
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
|
||||||
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HUD_PRINTCONSOLE:
|
|
||||||
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
|
||||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// Train.cpp
|
|
||||||
//
|
|
||||||
// implementation of CHudAmmo class
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
DECLARE_MESSAGE(m_Train, Train )
|
|
||||||
|
|
||||||
|
|
||||||
int CHudTrain::Init(void)
|
|
||||||
{
|
|
||||||
HOOK_MESSAGE( Train );
|
|
||||||
|
|
||||||
m_iPos = 0;
|
|
||||||
m_iFlags = 0;
|
|
||||||
gHUD.AddHudElem(this);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudTrain::VidInit(void)
|
|
||||||
{
|
|
||||||
m_hSprite = 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CHudTrain::Draw(float fTime)
|
|
||||||
{
|
|
||||||
if ( !m_hSprite )
|
|
||||||
m_hSprite = LoadSprite("sprites/%d_train.spr");
|
|
||||||
|
|
||||||
if (m_iPos)
|
|
||||||
{
|
|
||||||
int r, g, b, x, y;
|
|
||||||
|
|
||||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
|
||||||
SPR_Set(m_hSprite, r, g, b );
|
|
||||||
|
|
||||||
// This should show up to the right and part way up the armor number
|
|
||||||
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight;
|
|
||||||
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4;
|
|
||||||
|
|
||||||
SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
|
|
||||||
{
|
|
||||||
BEGIN_READ( pbuf, iSize );
|
|
||||||
|
|
||||||
// update Train data
|
|
||||||
m_iPos = READ_BYTE();
|
|
||||||
|
|
||||||
if (m_iPos)
|
|
||||||
m_iFlags |= HUD_ACTIVE;
|
|
||||||
else
|
|
||||||
m_iFlags &= ~HUD_ACTIVE;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// Triangle rendering, if any
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
|
|
||||||
// Triangle rendering apis are in gEngfuncs.pTriAPI
|
|
||||||
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "triangleapi.h"
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
#include "particleman.h"
|
|
||||||
#include "tri.h"
|
|
||||||
extern IParticleMan *g_pParticleMan;
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
HUD_DrawNormalTriangles
|
|
||||||
|
|
||||||
Non-transparent triangles-- add them here
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_DrawNormalTriangles( void )
|
|
||||||
{
|
|
||||||
// RecClDrawNormalTriangles();
|
|
||||||
|
|
||||||
gHUD.m_Spectator.DrawOverview();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
void RunEventList( void );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
HUD_DrawTransparentTriangles
|
|
||||||
|
|
||||||
Render any triangles with transparent rendermode needs here
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void CL_DLLEXPORT HUD_DrawTransparentTriangles( void )
|
|
||||||
{
|
|
||||||
// RecClDrawTransparentTriangles();
|
|
||||||
|
|
||||||
#if defined( _TFC )
|
|
||||||
RunEventList();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( g_pParticleMan )
|
|
||||||
g_pParticleMan->Update();
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef TRI_H
|
|
||||||
#define TRI_H
|
|
||||||
|
|
||||||
#include "particleman.h"
|
|
||||||
|
|
||||||
extern IParticleMan *g_pParticleMan;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //TRI_H
|
|
|
@ -1,133 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
//
|
|
||||||
// util.cpp
|
|
||||||
//
|
|
||||||
// implementation of class-less helper functions
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef M_PI
|
|
||||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3_t vec3_origin( 0, 0, 0 );
|
|
||||||
|
|
||||||
double sqrt(double x);
|
|
||||||
|
|
||||||
float Length(const float *v)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float length;
|
|
||||||
|
|
||||||
length = 0;
|
|
||||||
for (i=0 ; i< 3 ; i++)
|
|
||||||
length += v[i]*v[i];
|
|
||||||
length = sqrt (length); // FIXME
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorAngles( const float *forward, float *angles )
|
|
||||||
{
|
|
||||||
float tmp, yaw, pitch;
|
|
||||||
|
|
||||||
if (forward[1] == 0 && forward[0] == 0)
|
|
||||||
{
|
|
||||||
yaw = 0;
|
|
||||||
if (forward[2] > 0)
|
|
||||||
pitch = 90;
|
|
||||||
else
|
|
||||||
pitch = 270;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI);
|
|
||||||
if (yaw < 0)
|
|
||||||
yaw += 360;
|
|
||||||
|
|
||||||
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
|
|
||||||
pitch = (atan2(forward[2], tmp) * 180 / M_PI);
|
|
||||||
if (pitch < 0)
|
|
||||||
pitch += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
angles[0] = pitch;
|
|
||||||
angles[1] = yaw;
|
|
||||||
angles[2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float VectorNormalize (float *v)
|
|
||||||
{
|
|
||||||
float length, ilength;
|
|
||||||
|
|
||||||
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
|
||||||
length = sqrt (length); // FIXME
|
|
||||||
|
|
||||||
if (length)
|
|
||||||
{
|
|
||||||
ilength = 1/length;
|
|
||||||
v[0] *= ilength;
|
|
||||||
v[1] *= ilength;
|
|
||||||
v[2] *= ilength;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorInverse ( float *v )
|
|
||||||
{
|
|
||||||
v[0] = -v[0];
|
|
||||||
v[1] = -v[1];
|
|
||||||
v[2] = -v[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorScale (const float *in, float scale, float *out)
|
|
||||||
{
|
|
||||||
out[0] = in[0]*scale;
|
|
||||||
out[1] = in[1]*scale;
|
|
||||||
out[2] = in[2]*scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc)
|
|
||||||
{
|
|
||||||
vecc[0] = veca[0] + scale*vecb[0];
|
|
||||||
vecc[1] = veca[1] + scale*vecb[1];
|
|
||||||
vecc[2] = veca[2] + scale*vecb[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
HSPRITE LoadSprite(const char *pszName)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char sz[256];
|
|
||||||
|
|
||||||
if (ScreenWidth < 640)
|
|
||||||
i = 320;
|
|
||||||
else
|
|
||||||
i = 640;
|
|
||||||
|
|
||||||
sprintf(sz, pszName, i);
|
|
||||||
|
|
||||||
return SPR_Load(sz);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
/***
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
// Vector.h
|
|
||||||
// A subset of the extdll.h in the project HL Entity DLL
|
|
||||||
//
|
|
||||||
|
|
||||||
// Misc C-runtime library headers
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
// Header file containing definition of globalvars_t and entvars_t
|
|
||||||
typedef unsigned int func_t; //
|
|
||||||
typedef unsigned int string_t; // from engine's pr_comp.h;
|
|
||||||
typedef float vec_t; // needed before including progdefs.h
|
|
||||||
|
|
||||||
//=========================================================
|
|
||||||
// 2DVector - used for many pathfinding and many other
|
|
||||||
// operations that are treated as planar rather than 3d.
|
|
||||||
//=========================================================
|
|
||||||
class Vector2D
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline Vector2D(void) { }
|
|
||||||
inline Vector2D(float X, float Y) { x = X; y = Y; }
|
|
||||||
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); }
|
|
||||||
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); }
|
|
||||||
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); }
|
|
||||||
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); }
|
|
||||||
|
|
||||||
inline float Length(void) const { return (float)sqrt(x*x + y*y ); }
|
|
||||||
|
|
||||||
inline Vector2D Normalize ( void ) const
|
|
||||||
{
|
|
||||||
Vector2D vec2;
|
|
||||||
|
|
||||||
float flLen = Length();
|
|
||||||
if ( flLen == 0 )
|
|
||||||
{
|
|
||||||
return Vector2D( (float)0, (float)0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
flLen = 1 / flLen;
|
|
||||||
return Vector2D( x * flLen, y * flLen );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec_t x, y;
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef DotProduct
|
|
||||||
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
|
|
||||||
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
|
|
||||||
|
|
||||||
//=========================================================
|
|
||||||
// 3D Vector
|
|
||||||
//=========================================================
|
|
||||||
class Vector // same data-layout as engine's vec3_t,
|
|
||||||
{ // which is a vec_t[3]
|
|
||||||
public:
|
|
||||||
// Construction/destruction
|
|
||||||
inline Vector(void) { }
|
|
||||||
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; }
|
|
||||||
inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
|
||||||
inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
|
||||||
inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; }
|
|
||||||
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
|
|
||||||
|
|
||||||
// Operators
|
|
||||||
inline Vector operator-(void) const { return Vector(-x,-y,-z); }
|
|
||||||
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; }
|
|
||||||
inline int operator!=(const Vector& v) const { return !(*this==v); }
|
|
||||||
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); }
|
|
||||||
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); }
|
|
||||||
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
|
|
||||||
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
|
|
||||||
inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); }
|
|
||||||
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
|
|
||||||
operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
|
|
||||||
inline Vector Normalize(void) const
|
|
||||||
{
|
|
||||||
float flLen = Length();
|
|
||||||
if (flLen == 0) return Vector(0,0,1); // ????
|
|
||||||
flLen = 1 / flLen;
|
|
||||||
return Vector(x * flLen, y * flLen, z * flLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Vector2D Make2D ( void ) const
|
|
||||||
{
|
|
||||||
Vector2D Vec2;
|
|
||||||
|
|
||||||
Vec2.x = x;
|
|
||||||
Vec2.y = y;
|
|
||||||
|
|
||||||
return Vec2;
|
|
||||||
}
|
|
||||||
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
|
|
||||||
|
|
||||||
// Members
|
|
||||||
vec_t x, y, z;
|
|
||||||
};
|
|
||||||
inline Vector operator*(float fl, const Vector& v) { return v * fl; }
|
|
||||||
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
|
|
||||||
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); }
|
|
||||||
|
|
||||||
#ifndef DID_VEC3_T_DEFINE
|
|
||||||
#define DID_VEC3_T_DEFINE
|
|
||||||
#define vec3_t Vector
|
|
||||||
#endif
|
|
|
@ -1,437 +0,0 @@
|
||||||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// Purpose: TFC Class Menu
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $Log: $
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "VGUI_Font.h"
|
|
||||||
#include <VGUI_TextImage.h>
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "kbutton.h"
|
|
||||||
#include "cvardef.h"
|
|
||||||
#include "usercmd.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "in_defs.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include "vgui_int.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "vgui_ServerBrowser.h"
|
|
||||||
|
|
||||||
// Class Menu Dimensions
|
|
||||||
#define CLASSMENU_TITLE_X XRES(40)
|
|
||||||
#define CLASSMENU_TITLE_Y YRES(32)
|
|
||||||
#define CLASSMENU_TOPLEFT_BUTTON_X XRES(40)
|
|
||||||
#define CLASSMENU_TOPLEFT_BUTTON_Y YRES(80)
|
|
||||||
#define CLASSMENU_BUTTON_SIZE_X XRES(124)
|
|
||||||
#define CLASSMENU_BUTTON_SIZE_Y YRES(24)
|
|
||||||
#define CLASSMENU_BUTTON_SPACER_Y YRES(8)
|
|
||||||
#define CLASSMENU_WINDOW_X XRES(176)
|
|
||||||
#define CLASSMENU_WINDOW_Y YRES(80)
|
|
||||||
#define CLASSMENU_WINDOW_SIZE_X XRES(424)
|
|
||||||
#define CLASSMENU_WINDOW_SIZE_Y YRES(312)
|
|
||||||
#define CLASSMENU_WINDOW_TEXT_X XRES(150)
|
|
||||||
#define CLASSMENU_WINDOW_TEXT_Y YRES(80)
|
|
||||||
#define CLASSMENU_WINDOW_NAME_X XRES(150)
|
|
||||||
#define CLASSMENU_WINDOW_NAME_Y YRES(8)
|
|
||||||
#define CLASSMENU_WINDOW_PLAYERS_Y YRES(42)
|
|
||||||
|
|
||||||
// Creation
|
|
||||||
CClassMenuPanel::CClassMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall)
|
|
||||||
{
|
|
||||||
// don't show class graphics at below 640x480 resolution
|
|
||||||
bool bShowClassGraphic = true;
|
|
||||||
if ( ScreenWidth < 640 )
|
|
||||||
{
|
|
||||||
bShowClassGraphic = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset( m_pClassImages, 0, sizeof(m_pClassImages) );
|
|
||||||
|
|
||||||
// Get the scheme used for the Titles
|
|
||||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
|
||||||
|
|
||||||
// schemes
|
|
||||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
|
||||||
SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle( "Briefing Text" );
|
|
||||||
|
|
||||||
// color schemes
|
|
||||||
int r, g, b, a;
|
|
||||||
|
|
||||||
// Create the title
|
|
||||||
Label *pLabel = new Label( "", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y );
|
|
||||||
pLabel->setParent( this );
|
|
||||||
pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
|
||||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pLabel->setFgColor( r, g, b, a );
|
|
||||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pLabel->setBgColor( r, g, b, a );
|
|
||||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
|
||||||
pLabel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourClass"));
|
|
||||||
|
|
||||||
// Create the Scroll panel
|
|
||||||
m_pScrollPanel = new CTFScrollPanel( CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
|
|
||||||
m_pScrollPanel->setParent(this);
|
|
||||||
//force the scrollbars on, so after the validate clientClip will be smaller
|
|
||||||
m_pScrollPanel->setScrollBarAutoVisible(false, false);
|
|
||||||
m_pScrollPanel->setScrollBarVisible(true, true);
|
|
||||||
m_pScrollPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0) ) );
|
|
||||||
m_pScrollPanel->validate();
|
|
||||||
|
|
||||||
int clientWide=m_pScrollPanel->getClient()->getWide();
|
|
||||||
|
|
||||||
//turn scrollpanel back into auto show scrollbar mode and validate
|
|
||||||
m_pScrollPanel->setScrollBarAutoVisible(false,true);
|
|
||||||
m_pScrollPanel->setScrollBarVisible(false,false);
|
|
||||||
m_pScrollPanel->validate();
|
|
||||||
|
|
||||||
// Create the Class buttons
|
|
||||||
#ifdef _TFC
|
|
||||||
for (int i = 0; i <= PC_RANDOM; i++)
|
|
||||||
{
|
|
||||||
char sz[256];
|
|
||||||
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ( (CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y) * i );
|
|
||||||
|
|
||||||
ActionSignal *pASignal = new CMenuHandler_StringCommandClassSelect( sTFClassSelection[i], true );
|
|
||||||
|
|
||||||
// Class button
|
|
||||||
sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ) );
|
|
||||||
m_pButtons[i] = new ClassButton( i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true);
|
|
||||||
// RandomPC uses '0'
|
|
||||||
if ( i >= 1 && i <= 9 )
|
|
||||||
{
|
|
||||||
sprintf(sz,"%d",i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(sz,"0");
|
|
||||||
}
|
|
||||||
m_pButtons[i]->setBoundKey( sz[0] );
|
|
||||||
m_pButtons[i]->setContentAlignment( vgui::Label::a_west );
|
|
||||||
m_pButtons[i]->addActionSignal( pASignal );
|
|
||||||
m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) );
|
|
||||||
m_pButtons[i]->setParent( this );
|
|
||||||
|
|
||||||
// Create the Class Info Window
|
|
||||||
//m_pClassInfoPanel[i] = new CTransparentPanel( 255, CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
|
|
||||||
m_pClassInfoPanel[i] = new CTransparentPanel( 255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y );
|
|
||||||
m_pClassInfoPanel[i]->setParent( m_pScrollPanel->getClient() );
|
|
||||||
//m_pClassInfoPanel[i]->setVisible( false );
|
|
||||||
|
|
||||||
// don't show class pic in lower resolutions
|
|
||||||
int textOffs = XRES(8);
|
|
||||||
|
|
||||||
if ( bShowClassGraphic )
|
|
||||||
{
|
|
||||||
textOffs = CLASSMENU_WINDOW_NAME_X;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the Class Name Label
|
|
||||||
sprintf(sz, "#Title_%s", sTFClassSelection[i]);
|
|
||||||
char* localName=CHudTextMessage::BufferedLocaliseTextString( sz );
|
|
||||||
Label *pNameLabel = new Label( "", textOffs, CLASSMENU_WINDOW_NAME_Y );
|
|
||||||
pNameLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
|
||||||
pNameLabel->setParent( m_pClassInfoPanel[i] );
|
|
||||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pNameLabel->setFgColor( r, g, b, a );
|
|
||||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pNameLabel->setBgColor( r, g, b, a );
|
|
||||||
pNameLabel->setContentAlignment( vgui::Label::a_west );
|
|
||||||
//pNameLabel->setBorder(new LineBorder());
|
|
||||||
pNameLabel->setText( "%s", localName);
|
|
||||||
|
|
||||||
// Create the Class Image
|
|
||||||
if ( bShowClassGraphic )
|
|
||||||
{
|
|
||||||
for ( int team = 0; team < 2; team++ )
|
|
||||||
{
|
|
||||||
if ( team == 1 )
|
|
||||||
{
|
|
||||||
sprintf( sz, "%sred", sTFClassSelection[i] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf( sz, "%sblue", sTFClassSelection[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pClassImages[team][i] = new CImageLabel( sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y );
|
|
||||||
|
|
||||||
CImageLabel *pLabel = m_pClassImages[team][i];
|
|
||||||
pLabel->setParent( m_pClassInfoPanel[i] );
|
|
||||||
//pLabel->setBorder(new LineBorder());
|
|
||||||
|
|
||||||
if ( team != 1 )
|
|
||||||
{
|
|
||||||
pLabel->setVisible( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reposition it based upon it's size
|
|
||||||
int xOut, yOut;
|
|
||||||
pNameLabel->getTextSize( xOut, yOut );
|
|
||||||
pLabel->setPos( (CLASSMENU_WINDOW_TEXT_X - pLabel->getWide()) / 2, yOut /2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the Player count string
|
|
||||||
gHUD.m_TextMessage.LocaliseTextString( "#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM );
|
|
||||||
m_pPlayers[i] = new Label( "", textOffs, CLASSMENU_WINDOW_PLAYERS_Y );
|
|
||||||
m_pPlayers[i]->setParent( m_pClassInfoPanel[i] );
|
|
||||||
m_pPlayers[i]->setBgColor( 0, 0, 0, 255 );
|
|
||||||
m_pPlayers[i]->setContentAlignment( vgui::Label::a_west );
|
|
||||||
m_pPlayers[i]->setFont( pSchemes->getFont(hClassWindowText) );
|
|
||||||
|
|
||||||
// Open up the Class Briefing File
|
|
||||||
sprintf(sz, "classes/short_%s.txt", sTFClassSelection[i]);
|
|
||||||
char *cText = "Class Description not available.";
|
|
||||||
char *pfile = (char *)gEngfuncs.COM_LoadFile( sz, 5, NULL );
|
|
||||||
if (pfile)
|
|
||||||
{
|
|
||||||
cText = pfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the Text info window
|
|
||||||
TextPanel *pTextWindow = new TextPanel(cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, (CLASSMENU_WINDOW_SIZE_X - textOffs)-5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y);
|
|
||||||
pTextWindow->setParent( m_pClassInfoPanel[i] );
|
|
||||||
pTextWindow->setFont( pSchemes->getFont(hClassWindowText) );
|
|
||||||
pSchemes->getFgColor( hClassWindowText, r, g, b, a );
|
|
||||||
pTextWindow->setFgColor( r, g, b, a );
|
|
||||||
pSchemes->getBgColor( hClassWindowText, r, g, b, a );
|
|
||||||
pTextWindow->setBgColor( r, g, b, a );
|
|
||||||
|
|
||||||
// Resize the Info panel to fit it all
|
|
||||||
int wide,tall;
|
|
||||||
pTextWindow->getTextImage()->getTextSizeWrapped( wide,tall);
|
|
||||||
pTextWindow->setSize(wide,tall);
|
|
||||||
|
|
||||||
int xx,yy;
|
|
||||||
pTextWindow->getPos(xx,yy);
|
|
||||||
int maxX=xx+wide;
|
|
||||||
int maxY=yy+tall;
|
|
||||||
|
|
||||||
//check to see if the image goes lower than the text
|
|
||||||
//just use the red teams [0] images
|
|
||||||
if(m_pClassImages[0][i]!=null)
|
|
||||||
{
|
|
||||||
m_pClassImages[0][i]->getPos(xx,yy);
|
|
||||||
if((yy+m_pClassImages[0][i]->getTall())>maxY)
|
|
||||||
{
|
|
||||||
maxY=yy+m_pClassImages[0][i]->getTall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pClassInfoPanel[i]->setSize( maxX , maxY );
|
|
||||||
if (pfile) gEngfuncs.COM_FreeFile( pfile );
|
|
||||||
//m_pClassInfoPanel[i]->setBorder(new LineBorder());
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Create the Cancel button
|
|
||||||
m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y);
|
|
||||||
m_pCancelButton->setParent( this );
|
|
||||||
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) );
|
|
||||||
|
|
||||||
m_iCurrentInfo = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update
|
|
||||||
void CClassMenuPanel::Update()
|
|
||||||
{
|
|
||||||
// Don't allow the player to join a team if they're not in a team
|
|
||||||
if (!g_iTeamNumber)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y;
|
|
||||||
|
|
||||||
// Cycle through the rest of the buttons
|
|
||||||
#ifdef _TFC
|
|
||||||
for (int i = 0; i <= PC_RANDOM; i++)
|
|
||||||
{
|
|
||||||
bool bCivilian = (gViewPort->GetValidClasses(g_iTeamNumber) == -1);
|
|
||||||
|
|
||||||
if ( bCivilian )
|
|
||||||
{
|
|
||||||
// If this team can only be civilians, only the civilian button's visible
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
m_pButtons[0]->setVisible( true );
|
|
||||||
SetActiveInfo( 0 );
|
|
||||||
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pButtons[i]->setVisible( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( m_pButtons[i]->IsNotValid() || i == 0 )
|
|
||||||
{
|
|
||||||
m_pButtons[i]->setVisible( false );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pButtons[i]->setVisible( true );
|
|
||||||
m_pButtons[i]->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
|
|
||||||
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
|
|
||||||
|
|
||||||
// Start with the first option up
|
|
||||||
if (!m_iCurrentInfo)
|
|
||||||
SetActiveInfo( i );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now count the number of teammembers of this class
|
|
||||||
int iTotal = 0;
|
|
||||||
for ( int j = 1; j < MAX_PLAYERS; j++ )
|
|
||||||
{
|
|
||||||
if ( g_PlayerInfoList[j].name == NULL )
|
|
||||||
continue; // empty player slot, skip
|
|
||||||
if ( g_PlayerExtraInfo[j].teamname[0] == 0 )
|
|
||||||
continue; // skip over players who are not in a team
|
|
||||||
if ( g_PlayerInfoList[j].thisplayer )
|
|
||||||
continue; // skip this player
|
|
||||||
if ( g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber )
|
|
||||||
continue; // skip over players in other teams
|
|
||||||
|
|
||||||
// If this team is forced to be civilians, just count the number of teammates
|
|
||||||
if ( g_PlayerExtraInfo[j].playerclass != i && !bCivilian )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
iTotal++;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sz[256];
|
|
||||||
sprintf(sz, m_sPlayersOnTeamString, iTotal);
|
|
||||||
m_pPlayers[i]->setText( "%s", sz );
|
|
||||||
|
|
||||||
// Set the text color to the teamcolor
|
|
||||||
m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0],
|
|
||||||
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1],
|
|
||||||
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2],
|
|
||||||
0 );
|
|
||||||
|
|
||||||
// set the graphic to be the team pick
|
|
||||||
for ( int team = 0; team < MAX_TEAMS; team++ )
|
|
||||||
{
|
|
||||||
// unset all the other images
|
|
||||||
if ( m_pClassImages[team][i] )
|
|
||||||
{
|
|
||||||
m_pClassImages[team][i]->setVisible( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the current team image
|
|
||||||
if ( m_pClassImages[g_iTeamNumber-1][i] != NULL )
|
|
||||||
{
|
|
||||||
m_pClassImages[g_iTeamNumber-1][i]->setVisible( true );
|
|
||||||
}
|
|
||||||
else if ( m_pClassImages[0][i] )
|
|
||||||
{
|
|
||||||
m_pClassImages[0][i]->setVisible( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If the player already has a class, make the cancel button visible
|
|
||||||
if ( g_iPlayerClass )
|
|
||||||
{
|
|
||||||
m_pCancelButton->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
|
|
||||||
m_pCancelButton->setVisible( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pCancelButton->setVisible( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//======================================
|
|
||||||
// Key inputs for the Class Menu
|
|
||||||
bool CClassMenuPanel::SlotInput( int iSlot )
|
|
||||||
{
|
|
||||||
if ( (iSlot < 0) || (iSlot > 9) )
|
|
||||||
return false;
|
|
||||||
if ( !m_pButtons[ iSlot ] )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Is the button pushable? (0 is special case)
|
|
||||||
if (iSlot == 0)
|
|
||||||
{
|
|
||||||
// Selects Civilian and RandomPC
|
|
||||||
if ( gViewPort->GetValidClasses(g_iTeamNumber) == -1 )
|
|
||||||
{
|
|
||||||
m_pButtons[ 0 ]->fireActionSignal();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Select RandomPC
|
|
||||||
iSlot = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !(m_pButtons[ iSlot ]->IsNotValid()) )
|
|
||||||
{
|
|
||||||
m_pButtons[ iSlot ]->fireActionSignal();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//======================================
|
|
||||||
// Update the Class menu before opening it
|
|
||||||
void CClassMenuPanel::Open( void )
|
|
||||||
{
|
|
||||||
Update();
|
|
||||||
CMenuPanel::Open();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Called each time a new level is started.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CClassMenuPanel::Initialize( void )
|
|
||||||
{
|
|
||||||
setVisible( false );
|
|
||||||
m_pScrollPanel->setScrollValue( 0, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//======================================
|
|
||||||
// Mouse is over a class button, bring up the class info
|
|
||||||
void CClassMenuPanel::SetActiveInfo( int iInput )
|
|
||||||
{
|
|
||||||
// Remove all the Info panels and bring up the specified one
|
|
||||||
#ifdef _TFC
|
|
||||||
for (int i = 0; i <= PC_RANDOM; i++)
|
|
||||||
{
|
|
||||||
m_pButtons[i]->setArmed( false );
|
|
||||||
m_pClassInfoPanel[i]->setVisible( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( iInput > PC_RANDOM || iInput < 0 )
|
|
||||||
#endif
|
|
||||||
iInput = 0;
|
|
||||||
|
|
||||||
m_pButtons[iInput]->setArmed( true );
|
|
||||||
m_pClassInfoPanel[iInput]->setVisible( true );
|
|
||||||
m_iCurrentInfo = iInput;
|
|
||||||
|
|
||||||
m_pScrollPanel->setScrollValue(0,0);
|
|
||||||
m_pScrollPanel->validate();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include"vgui_ConsolePanel.h"
|
|
||||||
#include"hud.h"
|
|
||||||
#include<VGUI_ActionSignal.h>
|
|
||||||
#include<VGUI_TextGrid.h>
|
|
||||||
#include<VGUI_TextEntry.h>
|
|
||||||
#include<VGUI_EtchedBorder.h>
|
|
||||||
#include<VGUI_LoweredBorder.h>
|
|
||||||
|
|
||||||
using namespace vgui;
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
class Handler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
ConsolePanel* _consolePanel;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Handler(ConsolePanel* consolePanel)
|
|
||||||
{
|
|
||||||
_consolePanel=consolePanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void actionPerformed(Panel* panel)
|
|
||||||
{
|
|
||||||
_consolePanel->doExecCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConsolePanel::ConsolePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
|
||||||
{
|
|
||||||
setBorder(new EtchedBorder());
|
|
||||||
|
|
||||||
_textGrid=new TextGrid(80,21,5,5,200,100);
|
|
||||||
_textGrid->setBorder(new LoweredBorder());
|
|
||||||
_textGrid->setParent(this);
|
|
||||||
|
|
||||||
_textEntry=new TextEntry("",5,5,200,20);
|
|
||||||
_textEntry->setParent(this);
|
|
||||||
_textEntry->addActionSignal(new Handler(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConsolePanel::print(const char* text)
|
|
||||||
{
|
|
||||||
return _textGrid->printf("%s",text);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConsolePanel::vprintf(const char* format,va_list argList)
|
|
||||||
{
|
|
||||||
return _textGrid->vprintf(format,argList);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConsolePanel::printf(const char* format,...)
|
|
||||||
{
|
|
||||||
va_list argList;
|
|
||||||
va_start(argList,format);
|
|
||||||
int ret=vprintf(format,argList);
|
|
||||||
va_end(argList);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsolePanel::doExecCommand()
|
|
||||||
{
|
|
||||||
char buf[2048];
|
|
||||||
_textEntry->getText(0,buf,2048);
|
|
||||||
_textEntry->setText(null,0);
|
|
||||||
gEngfuncs.pfnClientCmd(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsolePanel::setSize(int wide,int tall)
|
|
||||||
{
|
|
||||||
Panel::setSize(wide,tall);
|
|
||||||
|
|
||||||
getPaintSize(wide,tall);
|
|
||||||
|
|
||||||
_textGrid->setBounds(5,5,wide-10,tall-35);
|
|
||||||
_textEntry->setBounds(5,tall-25,wide-10,20);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef CONSOLEPANEL_H
|
|
||||||
#define CONSOLEPANEL_H
|
|
||||||
|
|
||||||
#include<stdarg.h>
|
|
||||||
#include<VGUI_Panel.h>
|
|
||||||
|
|
||||||
namespace vgui
|
|
||||||
{
|
|
||||||
class TextGrid;
|
|
||||||
class TextEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ConsolePanel : public vgui::Panel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
vgui::TextGrid* _textGrid;
|
|
||||||
vgui::TextEntry* _textEntry;
|
|
||||||
public:
|
|
||||||
ConsolePanel(int x,int y,int wide,int tall);
|
|
||||||
public:
|
|
||||||
virtual void setSize(int wide,int tall);
|
|
||||||
virtual int print(const char* text);
|
|
||||||
virtual int vprintf(const char* format,va_list argList);
|
|
||||||
virtual int printf(const char* format,...);
|
|
||||||
virtual void doExecCommand();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,212 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include<stdio.h>
|
|
||||||
#include"vgui_ControlConfigPanel.h"
|
|
||||||
#include<VGUI_HeaderPanel.h>
|
|
||||||
#include<VGUI_TablePanel.h>
|
|
||||||
#include<VGUI_Label.h>
|
|
||||||
#include<VGUI_ScrollPanel.h>
|
|
||||||
#include<VGUI_Scheme.h>
|
|
||||||
#include<VGUI_DataInputStream.h>
|
|
||||||
#include<VGUI.h>
|
|
||||||
#include<VGUI_TextEntry.h>
|
|
||||||
|
|
||||||
using namespace vgui;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class FooTablePanel : public TablePanel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Label* _label;
|
|
||||||
TextEntry* _textEntry;
|
|
||||||
ControlConfigPanel* _controlConfigPanel;
|
|
||||||
public:
|
|
||||||
FooTablePanel(ControlConfigPanel* controlConfigPanel,int x,int y,int wide,int tall,int columnCount) : TablePanel(x,y,wide,tall,columnCount)
|
|
||||||
{
|
|
||||||
_controlConfigPanel=controlConfigPanel;
|
|
||||||
_label=new Label("You are a dumb monkey",0,0,100,20);
|
|
||||||
_label->setBgColor(Scheme::sc_primary3);
|
|
||||||
_label->setFgColor(Scheme::sc_primary1);
|
|
||||||
_label->setFont(Scheme::sf_primary3);
|
|
||||||
|
|
||||||
_textEntry=new TextEntry("",0,0,100,20);
|
|
||||||
//_textEntry->setFont(Scheme::sf_primary3);
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
virtual int getRowCount()
|
|
||||||
{
|
|
||||||
return _controlConfigPanel->GetCVarCount();
|
|
||||||
}
|
|
||||||
virtual int getCellTall(int row)
|
|
||||||
{
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
virtual Panel* getCellRenderer(int column,int row,bool columnSelected,bool rowSelected,bool cellSelected)
|
|
||||||
{
|
|
||||||
char cvar[128],desc[128],bind[128],bindAlt[128];
|
|
||||||
_controlConfigPanel->GetCVar(row,cvar,128,desc,128);
|
|
||||||
|
|
||||||
if(cellSelected)
|
|
||||||
{
|
|
||||||
_label->setBgColor(Scheme::sc_primary1);
|
|
||||||
_label->setFgColor(Scheme::sc_primary3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(rowSelected)
|
|
||||||
{
|
|
||||||
_label->setBgColor(Scheme::sc_primary2);
|
|
||||||
_label->setFgColor(Scheme::sc_primary1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_label->setBgColor(Scheme::sc_primary3);
|
|
||||||
_label->setFgColor(Scheme::sc_primary1);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(column)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
_label->setText(desc);
|
|
||||||
_label->setContentAlignment(Label::a_west);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
_controlConfigPanel->GetCVarBind(cvar,bind,128,bindAlt,128);
|
|
||||||
_label->setText(bind);
|
|
||||||
_label->setContentAlignment(Label::a_center);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
_controlConfigPanel->GetCVarBind(cvar,bind,128,bindAlt,128);
|
|
||||||
_label->setText(bindAlt);
|
|
||||||
_label->setContentAlignment(Label::a_center);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
_label->setText("");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _label;
|
|
||||||
}
|
|
||||||
virtual Panel* startCellEditing(int column,int row)
|
|
||||||
{
|
|
||||||
_textEntry->setText("Goat",strlen("Goat"));
|
|
||||||
_textEntry->requestFocus();
|
|
||||||
return _textEntry;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlConfigPanel::ControlConfigPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
|
||||||
{
|
|
||||||
setPaintBorderEnabled(false);
|
|
||||||
setPaintBackgroundEnabled(false);
|
|
||||||
setPaintEnabled(false);
|
|
||||||
|
|
||||||
_actionLabel=new Label("Action");
|
|
||||||
_actionLabel->setBgColor(Scheme::sc_primary3);
|
|
||||||
_actionLabel->setFgColor(Scheme::sc_primary3);
|
|
||||||
|
|
||||||
_keyButtonLabel=new Label("Key / Button");
|
|
||||||
_keyButtonLabel->setBgColor(Scheme::sc_primary3);
|
|
||||||
_keyButtonLabel->setFgColor(Scheme::sc_primary3);
|
|
||||||
|
|
||||||
_alternateLabel=new Label("Alternate");
|
|
||||||
_alternateLabel->setBgColor(Scheme::sc_primary3);
|
|
||||||
_alternateLabel->setFgColor(Scheme::sc_primary3);
|
|
||||||
|
|
||||||
_headerPanel=new HeaderPanel(0,0,wide,20);
|
|
||||||
_headerPanel->setParent(this);
|
|
||||||
|
|
||||||
_headerPanel->addSectionPanel(_actionLabel);
|
|
||||||
_headerPanel->addSectionPanel(_keyButtonLabel);
|
|
||||||
_headerPanel->addSectionPanel(_alternateLabel);
|
|
||||||
|
|
||||||
_headerPanel->setSliderPos( 0, wide/2 );
|
|
||||||
_headerPanel->setSliderPos( 1, (wide/2) + (wide/4) );
|
|
||||||
_headerPanel->setSliderPos( 2, wide );
|
|
||||||
|
|
||||||
_scrollPanel=new ScrollPanel(0,20,wide,tall-20);
|
|
||||||
_scrollPanel->setParent(this);
|
|
||||||
_scrollPanel->setPaintBorderEnabled(false);
|
|
||||||
_scrollPanel->setPaintBackgroundEnabled(false);
|
|
||||||
_scrollPanel->setPaintEnabled(false);
|
|
||||||
_scrollPanel->getClient()->setPaintBorderEnabled(false);
|
|
||||||
_scrollPanel->getClient()->setPaintBackgroundEnabled(false);
|
|
||||||
_scrollPanel->getClient()->setPaintEnabled(false);
|
|
||||||
_scrollPanel->setScrollBarVisible(false,true);
|
|
||||||
|
|
||||||
_tablePanel=new FooTablePanel(this,0,0,_scrollPanel->getClient()->getWide(),800, 3);
|
|
||||||
_tablePanel->setParent(_scrollPanel->getClient());
|
|
||||||
_tablePanel->setHeaderPanel(_headerPanel);
|
|
||||||
_tablePanel->setBgColor(Color(200,0,0,255));
|
|
||||||
_tablePanel->setFgColor(Color(Scheme::sc_primary2));
|
|
||||||
_tablePanel->setGridVisible(true,true);
|
|
||||||
_tablePanel->setGridSize(1,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlConfigPanel::AddCVar(const char* cvar,const char* desc)
|
|
||||||
{
|
|
||||||
_cvarDar.addElement(vgui_strdup(cvar));
|
|
||||||
_descDar.addElement(vgui_strdup(desc));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ControlConfigPanel::GetCVarCount()
|
|
||||||
{
|
|
||||||
return _cvarDar.getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlConfigPanel::GetCVar(int index,char* cvar,int cvarLen,char* desc,int descLen)
|
|
||||||
{
|
|
||||||
vgui_strcpy(cvar,cvarLen,_cvarDar[index]);
|
|
||||||
vgui_strcpy(desc,descLen,_descDar[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlConfigPanel::AddCVarFromInputStream(InputStream* is)
|
|
||||||
{
|
|
||||||
if(is==null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataInputStream dis(is);
|
|
||||||
|
|
||||||
bool success;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
char buf[256],cvar[128],desc[128];
|
|
||||||
dis.readLine(buf,256,success);
|
|
||||||
if(!success)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(sscanf(buf,"\"%[^\"]\" \"%[^\"]\"",cvar,desc)==2)
|
|
||||||
{
|
|
||||||
AddCVar(cvar,desc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlConfigPanel::GetCVarBind(const char* cvar,char* bind,int bindLen,char* bindAlt,int bindAltLen)
|
|
||||||
{
|
|
||||||
sprintf(bind,"%s : Bind",cvar);
|
|
||||||
sprintf(bindAlt,"%s : BindAlt",cvar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControlConfigPanel::SetCVarBind(const char* cvar,const char* bind,const char* bindAlt)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef CONTROLCONFIGPANEL_H
|
|
||||||
#define CONTROLCONFIGPANEL_H
|
|
||||||
|
|
||||||
#include<VGUI_Panel.h>
|
|
||||||
#include<VGUI_Dar.h>
|
|
||||||
|
|
||||||
namespace vgui
|
|
||||||
{
|
|
||||||
class HeaderPanel;
|
|
||||||
class TablePanel;
|
|
||||||
class ScrollPanel;
|
|
||||||
class InputStream;
|
|
||||||
class Label;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ControlConfigPanel : public vgui::Panel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
vgui::HeaderPanel* _headerPanel;
|
|
||||||
vgui::TablePanel* _tablePanel;
|
|
||||||
vgui::ScrollPanel* _scrollPanel;
|
|
||||||
vgui::Dar<char*> _cvarDar;
|
|
||||||
vgui::Dar<char*> _descDar;
|
|
||||||
vgui::Label* _actionLabel;
|
|
||||||
vgui::Label* _keyButtonLabel;
|
|
||||||
vgui::Label* _alternateLabel;
|
|
||||||
public:
|
|
||||||
ControlConfigPanel(int x,int y,int wide,int tall);
|
|
||||||
public:
|
|
||||||
void AddCVar(const char* cvar,const char* desc);
|
|
||||||
void AddCVarFromInputStream(vgui::InputStream* is);
|
|
||||||
int GetCVarCount();
|
|
||||||
void GetCVar(int index,char* cvar,int cvarLen,char* desc,int descLen);
|
|
||||||
void GetCVarBind(const char* cvar,char* bind,int bindLen,char* bindAlt,int bindAltLen);
|
|
||||||
void SetCVarBind(const char* cvar,const char* bind,const char* bindAlt);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,547 +0,0 @@
|
||||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// Purpose: Contains implementation of various VGUI-derived objects
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $Log: $
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "VGUI_Font.h"
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "kbutton.h"
|
|
||||||
#include "cvardef.h"
|
|
||||||
#include "usercmd.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "in_defs.h"
|
|
||||||
#include "parsemsg.h"
|
|
||||||
|
|
||||||
#include "vgui_int.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "vgui_ServerBrowser.h"
|
|
||||||
#include "vgui_loadtga.h"
|
|
||||||
|
|
||||||
// Arrow filenames
|
|
||||||
char *sArrowFilenames[] =
|
|
||||||
{
|
|
||||||
"arrowup",
|
|
||||||
"arrowdn",
|
|
||||||
"arrowlt",
|
|
||||||
"arrowrt",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the name of TGA file, without a gamedir
|
|
||||||
char *GetTGANameForRes(const char *pszName)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char sz[256];
|
|
||||||
static char gd[256];
|
|
||||||
if (ScreenWidth < 640)
|
|
||||||
i = 320;
|
|
||||||
else
|
|
||||||
i = 640;
|
|
||||||
sprintf(sz, pszName, i);
|
|
||||||
sprintf(gd, "gfx/vgui/%s.tga", sz);
|
|
||||||
return gd;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
BitmapTGA *LoadTGAForRes( const char* pImageName )
|
|
||||||
{
|
|
||||||
BitmapTGA *pTGA;
|
|
||||||
|
|
||||||
char sz[256];
|
|
||||||
sprintf(sz, "%%d_%s", pImageName);
|
|
||||||
pTGA = vgui_LoadTGA(GetTGANameForRes(sz));
|
|
||||||
|
|
||||||
return pTGA;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================
|
|
||||||
// All TFC Hud buttons are derived from this one.
|
|
||||||
CommandButton::CommandButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight) : Button("",x,y,wide,tall)
|
|
||||||
{
|
|
||||||
m_iPlayerClass = 0;
|
|
||||||
m_bNoHighlight = bNoHighlight;
|
|
||||||
m_bFlat = false;
|
|
||||||
Init();
|
|
||||||
setText( text );
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandButton::CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall, bool bFlat) : Button("",x,y,wide,tall)
|
|
||||||
{
|
|
||||||
m_iPlayerClass = iPlayerClass;
|
|
||||||
m_bNoHighlight = false;
|
|
||||||
m_bFlat = bFlat;
|
|
||||||
Init();
|
|
||||||
setText( text );
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandButton::CommandButton(const char *text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat) : Button("",x,y,wide,tall)
|
|
||||||
{
|
|
||||||
m_iPlayerClass = 0;
|
|
||||||
m_bFlat = bFlat;
|
|
||||||
m_bNoHighlight = bNoHighlight;
|
|
||||||
Init();
|
|
||||||
setText( text );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::Init( void )
|
|
||||||
{
|
|
||||||
m_pSubMenu = NULL;
|
|
||||||
m_pSubLabel = NULL;
|
|
||||||
m_pParentMenu = NULL;
|
|
||||||
|
|
||||||
// Set text color to orange
|
|
||||||
setFgColor(Scheme::sc_primary1);
|
|
||||||
|
|
||||||
// left align
|
|
||||||
setContentAlignment( vgui::Label::a_west );
|
|
||||||
|
|
||||||
// Add the Highlight signal
|
|
||||||
if (!m_bNoHighlight)
|
|
||||||
addInputSignal( new CHandler_CommandButtonHighlight(this) );
|
|
||||||
|
|
||||||
// not bound to any button yet
|
|
||||||
m_cBoundKey = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Prepends the button text with the current bound key
|
|
||||||
// if no bound key, then a clear space ' ' instead
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CommandButton::RecalculateText( void )
|
|
||||||
{
|
|
||||||
char szBuf[128];
|
|
||||||
|
|
||||||
if ( m_cBoundKey != 0 )
|
|
||||||
{
|
|
||||||
if ( m_cBoundKey == (char)255 )
|
|
||||||
{
|
|
||||||
strcpy( szBuf, m_sMainText );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText );
|
|
||||||
}
|
|
||||||
szBuf[MAX_BUTTON_SIZE-1] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// just draw a space if no key bound
|
|
||||||
sprintf( szBuf, " %s", m_sMainText );
|
|
||||||
szBuf[MAX_BUTTON_SIZE-1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button::setText( szBuf );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::setText( const char *text )
|
|
||||||
{
|
|
||||||
strncpy( m_sMainText, text, MAX_BUTTON_SIZE );
|
|
||||||
m_sMainText[MAX_BUTTON_SIZE-1] = 0;
|
|
||||||
|
|
||||||
RecalculateText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::setBoundKey( char boundKey )
|
|
||||||
{
|
|
||||||
m_cBoundKey = boundKey;
|
|
||||||
RecalculateText();
|
|
||||||
}
|
|
||||||
|
|
||||||
char CommandButton::getBoundKey( void )
|
|
||||||
{
|
|
||||||
return m_cBoundKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::AddSubMenu( CCommandMenu *pNewMenu )
|
|
||||||
{
|
|
||||||
m_pSubMenu = pNewMenu;
|
|
||||||
|
|
||||||
// Prevent this button from being pushed
|
|
||||||
setMouseClickEnabled( MOUSE_LEFT, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::UpdateSubMenus( int iAdjustment )
|
|
||||||
{
|
|
||||||
if ( m_pSubMenu )
|
|
||||||
m_pSubMenu->RecalculatePositions( iAdjustment );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::paint()
|
|
||||||
{
|
|
||||||
// Make the sub label paint the same as the button
|
|
||||||
if ( m_pSubLabel )
|
|
||||||
{
|
|
||||||
if ( isSelected() )
|
|
||||||
m_pSubLabel->PushDown();
|
|
||||||
else
|
|
||||||
m_pSubLabel->PushUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw armed button text in white
|
|
||||||
if ( isArmed() )
|
|
||||||
{
|
|
||||||
setFgColor( Scheme::sc_secondary2 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setFgColor( Scheme::sc_primary1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
Button::paint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandButton::paintBackground()
|
|
||||||
{
|
|
||||||
if ( m_bFlat )
|
|
||||||
{
|
|
||||||
if ( isArmed() )
|
|
||||||
{
|
|
||||||
// Orange Border
|
|
||||||
drawSetColor( Scheme::sc_secondary1 );
|
|
||||||
drawOutlinedRect(0,0,_size[0],_size[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( isArmed() )
|
|
||||||
{
|
|
||||||
// Orange highlight background
|
|
||||||
drawSetColor( Scheme::sc_primary2 );
|
|
||||||
drawFilledRect(0,0,_size[0],_size[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Orange Border
|
|
||||||
drawSetColor( Scheme::sc_secondary1 );
|
|
||||||
drawOutlinedRect(0,0,_size[0],_size[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Highlights the current button, and all it's parent menus
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CommandButton::cursorEntered( void )
|
|
||||||
{
|
|
||||||
// unarm all the other buttons in this menu
|
|
||||||
CCommandMenu *containingMenu = getParentMenu();
|
|
||||||
if ( containingMenu )
|
|
||||||
{
|
|
||||||
containingMenu->ClearButtonsOfArmedState();
|
|
||||||
|
|
||||||
// make all our higher buttons armed
|
|
||||||
CCommandMenu *pCParent = containingMenu->GetParentMenu();
|
|
||||||
if ( pCParent )
|
|
||||||
{
|
|
||||||
CommandButton *pParentButton = pCParent->FindButtonWithSubmenu( containingMenu );
|
|
||||||
|
|
||||||
pParentButton->cursorEntered();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// arm ourselves
|
|
||||||
setArmed( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose:
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CommandButton::cursorExited( void )
|
|
||||||
{
|
|
||||||
// only clear ourselves if we have do not have a containing menu
|
|
||||||
// only stay armed if we have a sub menu
|
|
||||||
// the buttons only unarm themselves when another button is armed instead
|
|
||||||
if ( !getParentMenu() || !GetSubMenu() )
|
|
||||||
{
|
|
||||||
setArmed( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Returns the command menu that the button is part of, if any
|
|
||||||
// Output : CCommandMenu *
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CCommandMenu *CommandButton::getParentMenu( void )
|
|
||||||
{
|
|
||||||
return m_pParentMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Sets the menu that contains this button
|
|
||||||
// Input : *pParentMenu -
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CommandButton::setParentMenu( CCommandMenu *pParentMenu )
|
|
||||||
{
|
|
||||||
m_pParentMenu = pParentMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================
|
|
||||||
int ClassButton::IsNotValid()
|
|
||||||
{
|
|
||||||
// If this is the main ChangeClass button, remove it if the player's only able to be civilians
|
|
||||||
if ( m_iPlayerClass == -1 )
|
|
||||||
{
|
|
||||||
if (gViewPort->GetValidClasses(g_iTeamNumber) == -1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is it an illegal class?
|
|
||||||
#ifdef _TFC
|
|
||||||
if ((gViewPort->GetValidClasses(0) & sTFValidClassInts[ m_iPlayerClass ]) || (gViewPort->GetValidClasses(g_iTeamNumber) & sTFValidClassInts[ m_iPlayerClass ]))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Only check current class if they've got autokill on
|
|
||||||
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
|
|
||||||
if ( bAutoKill )
|
|
||||||
{
|
|
||||||
// Is it the player's current class?
|
|
||||||
if (
|
|
||||||
#ifdef _TFC
|
|
||||||
(gViewPort->IsRandomPC() && m_iPlayerClass == PC_RANDOM) ||
|
|
||||||
#endif
|
|
||||||
(!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================
|
|
||||||
// Button with Class image beneath it
|
|
||||||
CImageLabel::CImageLabel( const char* pImageName,int x,int y ) : Label( "", x,y )
|
|
||||||
{
|
|
||||||
setContentFitted(true);
|
|
||||||
m_pTGA = LoadTGAForRes(pImageName);
|
|
||||||
setImage( m_pTGA );
|
|
||||||
}
|
|
||||||
|
|
||||||
CImageLabel::CImageLabel( const char* pImageName,int x,int y,int wide,int tall ) : Label( "", x,y,wide,tall )
|
|
||||||
{
|
|
||||||
setContentFitted(true);
|
|
||||||
m_pTGA = LoadTGAForRes(pImageName);
|
|
||||||
setImage( m_pTGA );
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================
|
|
||||||
// Image size
|
|
||||||
int CImageLabel::getImageWide( void )
|
|
||||||
{
|
|
||||||
if( m_pTGA )
|
|
||||||
{
|
|
||||||
int iXSize, iYSize;
|
|
||||||
m_pTGA->getSize( iXSize, iYSize );
|
|
||||||
return iXSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CImageLabel::getImageTall( void )
|
|
||||||
{
|
|
||||||
if( m_pTGA )
|
|
||||||
{
|
|
||||||
int iXSize, iYSize;
|
|
||||||
m_pTGA->getSize( iXSize, iYSize );
|
|
||||||
return iYSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageLabel::LoadImage(const char * pImageName)
|
|
||||||
{
|
|
||||||
if ( m_pTGA )
|
|
||||||
delete m_pTGA;
|
|
||||||
|
|
||||||
// Load the Image
|
|
||||||
m_pTGA = LoadTGAForRes(pImageName);
|
|
||||||
|
|
||||||
if ( m_pTGA == NULL )
|
|
||||||
{
|
|
||||||
// we didn't find a matching image file for this resolution
|
|
||||||
// try to load file resolution independent
|
|
||||||
|
|
||||||
char sz[256];
|
|
||||||
sprintf(sz, "%s/%s",gEngfuncs.pfnGetGameDirectory(), pImageName );
|
|
||||||
FileInputStream* fis = new FileInputStream( sz, false );
|
|
||||||
m_pTGA = new BitmapTGA(fis,true);
|
|
||||||
fis->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_pTGA == NULL )
|
|
||||||
return; // unable to load image
|
|
||||||
|
|
||||||
int w,t;
|
|
||||||
|
|
||||||
m_pTGA->getSize( w, t );
|
|
||||||
|
|
||||||
setSize( XRES (w),YRES (t) );
|
|
||||||
setImage( m_pTGA );
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================
|
|
||||||
// Various overloaded paint functions for Custom VGUI objects
|
|
||||||
void CCommandMenu::paintBackground()
|
|
||||||
{
|
|
||||||
// Transparent black background
|
|
||||||
|
|
||||||
if ( m_iSpectCmdMenu )
|
|
||||||
drawSetColor( 0, 0, 0, 64 );
|
|
||||||
else
|
|
||||||
drawSetColor(Scheme::sc_primary3);
|
|
||||||
|
|
||||||
drawFilledRect(0,0,_size[0],_size[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// CUSTOM SCROLLPANEL
|
|
||||||
//=================================================================================
|
|
||||||
CTFScrollButton::CTFScrollButton(int iArrow, const char* text,int x,int y,int wide,int tall) : CommandButton(text,x,y,wide,tall)
|
|
||||||
{
|
|
||||||
// Set text color to orange
|
|
||||||
setFgColor(Scheme::sc_primary1);
|
|
||||||
|
|
||||||
// Load in the arrow
|
|
||||||
m_pTGA = LoadTGAForRes( sArrowFilenames[iArrow] );
|
|
||||||
setImage( m_pTGA );
|
|
||||||
|
|
||||||
// Highlight signal
|
|
||||||
InputSignal *pISignal = new CHandler_CommandButtonHighlight(this);
|
|
||||||
addInputSignal(pISignal);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTFScrollButton::paint( void )
|
|
||||||
{
|
|
||||||
if (!m_pTGA)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// draw armed button text in white
|
|
||||||
if ( isArmed() )
|
|
||||||
{
|
|
||||||
m_pTGA->setColor( Color(255,255,255, 0) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pTGA->setColor( Color(255,255,255, 128) );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pTGA->doPaint(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTFScrollButton::paintBackground( void )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if ( isArmed() )
|
|
||||||
{
|
|
||||||
// Orange highlight background
|
|
||||||
drawSetColor( Scheme::sc_primary2 );
|
|
||||||
drawFilledRect(0,0,_size[0],_size[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Orange Border
|
|
||||||
drawSetColor( Scheme::sc_secondary1 );
|
|
||||||
drawOutlinedRect(0,0,_size[0]-1,_size[1]);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTFSlider::paintBackground( void )
|
|
||||||
{
|
|
||||||
int wide,tall,nobx,noby;
|
|
||||||
getPaintSize(wide,tall);
|
|
||||||
getNobPos(nobx,noby);
|
|
||||||
|
|
||||||
// Border
|
|
||||||
drawSetColor( Scheme::sc_secondary1 );
|
|
||||||
drawOutlinedRect( 0,0,wide,tall );
|
|
||||||
|
|
||||||
if( isVertical() )
|
|
||||||
{
|
|
||||||
// Nob Fill
|
|
||||||
drawSetColor( Scheme::sc_primary2 );
|
|
||||||
drawFilledRect( 0,nobx,wide,noby );
|
|
||||||
|
|
||||||
// Nob Outline
|
|
||||||
drawSetColor( Scheme::sc_primary1 );
|
|
||||||
drawOutlinedRect( 0,nobx,wide,noby );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Nob Fill
|
|
||||||
drawSetColor( Scheme::sc_primary2 );
|
|
||||||
drawFilledRect( nobx,0,noby,tall );
|
|
||||||
|
|
||||||
// Nob Outline
|
|
||||||
drawSetColor( Scheme::sc_primary1 );
|
|
||||||
drawOutlinedRect( nobx,0,noby,tall );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CTFScrollPanel::CTFScrollPanel(int x,int y,int wide,int tall) : ScrollPanel(x,y,wide,tall)
|
|
||||||
{
|
|
||||||
ScrollBar *pScrollBar = getVerticalScrollBar();
|
|
||||||
pScrollBar->setButton( new CTFScrollButton( ARROW_UP, "", 0,0,16,16 ), 0 );
|
|
||||||
pScrollBar->setButton( new CTFScrollButton( ARROW_DOWN, "", 0,0,16,16 ), 1 );
|
|
||||||
pScrollBar->setSlider( new CTFSlider(0,wide-1,wide,(tall-(wide*2))+2,true) );
|
|
||||||
pScrollBar->setPaintBorderEnabled(false);
|
|
||||||
pScrollBar->setPaintBackgroundEnabled(false);
|
|
||||||
pScrollBar->setPaintEnabled(false);
|
|
||||||
|
|
||||||
pScrollBar = getHorizontalScrollBar();
|
|
||||||
pScrollBar->setButton( new CTFScrollButton( ARROW_LEFT, "", 0,0,16,16 ), 0 );
|
|
||||||
pScrollBar->setButton( new CTFScrollButton( ARROW_RIGHT, "", 0,0,16,16 ), 1 );
|
|
||||||
pScrollBar->setSlider( new CTFSlider(tall,0,wide-(tall*2),tall,false) );
|
|
||||||
pScrollBar->setPaintBorderEnabled(false);
|
|
||||||
pScrollBar->setPaintBackgroundEnabled(false);
|
|
||||||
pScrollBar->setPaintEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// CUSTOM HANDLERS
|
|
||||||
//=================================================================================
|
|
||||||
void CHandler_MenuButtonOver::cursorEntered(Panel *panel)
|
|
||||||
{
|
|
||||||
if ( gViewPort && m_pMenuPanel )
|
|
||||||
{
|
|
||||||
m_pMenuPanel->SetActiveInfo( m_iButton );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMenuHandler_StringCommandClassSelect::actionPerformed(Panel* panel)
|
|
||||||
{
|
|
||||||
CMenuHandler_StringCommand::actionPerformed( panel );
|
|
||||||
|
|
||||||
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
|
|
||||||
// HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS".
|
|
||||||
|
|
||||||
#if !defined _TFC
|
|
||||||
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
|
|
||||||
if ( bAutoKill && g_iPlayerClass != 0 )
|
|
||||||
gEngfuncs.pfnClientCmd("kill");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $Log: $
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "VGUI_Font.h"
|
|
||||||
#include "VGUI_ScrollPanel.h"
|
|
||||||
#include "VGUI_TextImage.h"
|
|
||||||
|
|
||||||
#include<VGUI_StackLayout.h>
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "camera.h"
|
|
||||||
#include "kbutton.h"
|
|
||||||
#include "const.h"
|
|
||||||
|
|
||||||
#include "vgui_int.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "vgui_ServerBrowser.h"
|
|
||||||
|
|
||||||
#define MOTD_TITLE_X XRES(16)
|
|
||||||
#define MOTD_TITLE_Y YRES(16)
|
|
||||||
|
|
||||||
#define MOTD_WINDOW_X XRES(112)
|
|
||||||
#define MOTD_WINDOW_Y YRES(80)
|
|
||||||
#define MOTD_WINDOW_SIZE_X XRES(424)
|
|
||||||
#define MOTD_WINDOW_SIZE_Y YRES(312)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Displays the MOTD and basic server information
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CMessageWindowPanel : public CMenuPanel
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullScreen, int iRemoveMe, int x, int y, int wide, int tall );
|
|
||||||
|
|
||||||
private:
|
|
||||||
CTransparentPanel *m_pBackgroundPanel;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Creates a new CMessageWindowPanel
|
|
||||||
// Output : CMenuPanel - interface to the panel
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall )
|
|
||||||
{
|
|
||||||
return new CMessageWindowPanel( szMOTD, szTitle, iShadeFullscreen, iRemoveMe, x, y, wide, tall );
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Constructs a message panel
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall )
|
|
||||||
{
|
|
||||||
// Get the scheme used for the Titles
|
|
||||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
|
||||||
|
|
||||||
// schemes
|
|
||||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
|
||||||
SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" );
|
|
||||||
|
|
||||||
// color schemes
|
|
||||||
int r, g, b, a;
|
|
||||||
|
|
||||||
// Create the window
|
|
||||||
m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y );
|
|
||||||
m_pBackgroundPanel->setParent( this );
|
|
||||||
m_pBackgroundPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
|
|
||||||
m_pBackgroundPanel->setVisible( true );
|
|
||||||
|
|
||||||
int iXSize,iYSize,iXPos,iYPos;
|
|
||||||
m_pBackgroundPanel->getPos( iXPos,iYPos );
|
|
||||||
m_pBackgroundPanel->getSize( iXSize,iYSize );
|
|
||||||
|
|
||||||
// Create the title
|
|
||||||
Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y );
|
|
||||||
pLabel->setParent( this );
|
|
||||||
pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
|
||||||
pLabel->setFont( Scheme::sf_primary1 );
|
|
||||||
|
|
||||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pLabel->setFgColor( r, g, b, a );
|
|
||||||
pLabel->setFgColor( Scheme::sc_primary1 );
|
|
||||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
|
||||||
pLabel->setBgColor( r, g, b, a );
|
|
||||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
|
||||||
pLabel->setText( "%s", szTitle);
|
|
||||||
|
|
||||||
// Create the Scroll panel
|
|
||||||
ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES(16), iYPos + MOTD_TITLE_Y*2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y*2) );
|
|
||||||
pScrollPanel->setParent(this);
|
|
||||||
|
|
||||||
//force the scrollbars on so clientClip will take them in account after the validate
|
|
||||||
pScrollPanel->setScrollBarAutoVisible(false, false);
|
|
||||||
pScrollPanel->setScrollBarVisible(true, true);
|
|
||||||
pScrollPanel->validate();
|
|
||||||
|
|
||||||
// Create the text panel
|
|
||||||
TextPanel *pText = new TextPanel( "", 0,0, 64,64);
|
|
||||||
pText->setParent( pScrollPanel->getClient() );
|
|
||||||
|
|
||||||
// get the font and colors from the scheme
|
|
||||||
pText->setFont( pSchemes->getFont(hMOTDText) );
|
|
||||||
pSchemes->getFgColor( hMOTDText, r, g, b, a );
|
|
||||||
pText->setFgColor( r, g, b, a );
|
|
||||||
pSchemes->getBgColor( hMOTDText, r, g, b, a );
|
|
||||||
pText->setBgColor( r, g, b, a );
|
|
||||||
pText->setText( szMOTD);
|
|
||||||
|
|
||||||
// Get the total size of the MOTD text and resize the text panel
|
|
||||||
int iScrollSizeX, iScrollSizeY;
|
|
||||||
|
|
||||||
// First, set the size so that the client's wdith is correct at least because the
|
|
||||||
// width is critical for getting the "wrapped" size right.
|
|
||||||
// You'll see a horizontal scroll bar if there is a single word that won't wrap in the
|
|
||||||
// specified width.
|
|
||||||
pText->getTextImage()->setSize(pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall());
|
|
||||||
pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY );
|
|
||||||
|
|
||||||
// Now resize the textpanel to fit the scrolled size
|
|
||||||
pText->setSize( iScrollSizeX , iScrollSizeY );
|
|
||||||
|
|
||||||
//turn the scrollbars back into automode
|
|
||||||
pScrollPanel->setScrollBarAutoVisible(true, true);
|
|
||||||
pScrollPanel->setScrollBarVisible(false, false);
|
|
||||||
|
|
||||||
pScrollPanel->validate();
|
|
||||||
|
|
||||||
CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES(16), iYPos + iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
|
|
||||||
pButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW));
|
|
||||||
pButton->setParent(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,556 +0,0 @@
|
||||||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
|
||||||
//
|
|
||||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
|
||||||
// The contents may be used and/or copied only with the written permission of
|
|
||||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
|
||||||
// the agreement/contract under which the contents have been supplied.
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $Log: $
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "vgui_SchemeManager.h"
|
|
||||||
#include "cvardef.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
cvar_t *g_CV_BitmapFonts;
|
|
||||||
|
|
||||||
|
|
||||||
void Scheme_Init()
|
|
||||||
{
|
|
||||||
g_CV_BitmapFonts = gEngfuncs.pfnRegisterVariable("bitmapfonts", "1", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Scheme managers data container
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CSchemeManager::CScheme
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
SCHEME_NAME_LENGTH = 32,
|
|
||||||
FONT_NAME_LENGTH = 48,
|
|
||||||
FONT_FILENAME_LENGTH = 64,
|
|
||||||
};
|
|
||||||
|
|
||||||
// name
|
|
||||||
char schemeName[SCHEME_NAME_LENGTH];
|
|
||||||
|
|
||||||
// font
|
|
||||||
char fontName[FONT_NAME_LENGTH];
|
|
||||||
|
|
||||||
int fontSize;
|
|
||||||
int fontWeight;
|
|
||||||
|
|
||||||
vgui::Font *font;
|
|
||||||
int ownFontPointer; // true if the font is ours to delete
|
|
||||||
|
|
||||||
// scheme
|
|
||||||
byte fgColor[4];
|
|
||||||
byte bgColor[4];
|
|
||||||
byte armedFgColor[4];
|
|
||||||
byte armedBgColor[4];
|
|
||||||
byte mousedownFgColor[4];
|
|
||||||
byte mousedownBgColor[4];
|
|
||||||
byte borderColor[4];
|
|
||||||
|
|
||||||
// construction/destruction
|
|
||||||
CScheme();
|
|
||||||
~CScheme();
|
|
||||||
};
|
|
||||||
|
|
||||||
CSchemeManager::CScheme::CScheme()
|
|
||||||
{
|
|
||||||
schemeName[0] = 0;
|
|
||||||
fontName[0] = 0;
|
|
||||||
fontSize = 0;
|
|
||||||
fontWeight = 0;
|
|
||||||
font = NULL;
|
|
||||||
ownFontPointer = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CSchemeManager::CScheme::~CScheme()
|
|
||||||
{
|
|
||||||
// only delete our font pointer if we own it
|
|
||||||
if ( ownFontPointer )
|
|
||||||
{
|
|
||||||
delete font;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: resolution information
|
|
||||||
// !! needs to be shared out
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
static int g_ResArray[] =
|
|
||||||
{
|
|
||||||
320,
|
|
||||||
400,
|
|
||||||
512,
|
|
||||||
640,
|
|
||||||
800,
|
|
||||||
1024,
|
|
||||||
1152,
|
|
||||||
1280,
|
|
||||||
1600
|
|
||||||
};
|
|
||||||
static int g_NumReses = sizeof(g_ResArray) / sizeof(int);
|
|
||||||
|
|
||||||
static byte *LoadFileByResolution( const char *filePrefix, int xRes, const char *filePostfix )
|
|
||||||
{
|
|
||||||
// find our resolution in the res array
|
|
||||||
int resNum = g_NumReses - 1;
|
|
||||||
while ( g_ResArray[resNum] > xRes )
|
|
||||||
{
|
|
||||||
resNum--;
|
|
||||||
|
|
||||||
if ( resNum < 0 )
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// try open the file
|
|
||||||
byte *pFile = NULL;
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
|
|
||||||
// try load
|
|
||||||
char fname[256];
|
|
||||||
sprintf( fname, "%s%d%s", filePrefix, g_ResArray[resNum], filePostfix );
|
|
||||||
pFile = gEngfuncs.COM_LoadFile( fname, 5, NULL );
|
|
||||||
|
|
||||||
if ( pFile )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ( resNum == 0 )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
resNum--;
|
|
||||||
};
|
|
||||||
|
|
||||||
return pFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ParseRGBAFromString( byte colorArray[4], const char *colorVector )
|
|
||||||
{
|
|
||||||
int r, g, b, a;
|
|
||||||
sscanf( colorVector, "%d %d %d %d", &r, &g, &b, &a );
|
|
||||||
colorArray[0] = r;
|
|
||||||
colorArray[1] = g;
|
|
||||||
colorArray[2] = b;
|
|
||||||
colorArray[3] = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: initializes the scheme manager
|
|
||||||
// loading the scheme files for the current resolution
|
|
||||||
// Input : xRes -
|
|
||||||
// yRes - dimensions of output window
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CSchemeManager::CSchemeManager( int xRes, int yRes )
|
|
||||||
{
|
|
||||||
// basic setup
|
|
||||||
m_pSchemeList = NULL;
|
|
||||||
m_iNumSchemes = 0;
|
|
||||||
|
|
||||||
// find the closest matching scheme file to our resolution
|
|
||||||
char token[1024];
|
|
||||||
char *pFile = (char*)LoadFileByResolution( "", xRes, "_textscheme.txt" );
|
|
||||||
m_xRes = xRes;
|
|
||||||
|
|
||||||
char *pFileStart = pFile;
|
|
||||||
|
|
||||||
byte *pFontData;
|
|
||||||
int fontFileLength;
|
|
||||||
char fontFilename[512];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Read the scheme descriptions from the text file, into a temporary array
|
|
||||||
// format is simply:
|
|
||||||
// <paramName name> = <paramValue>
|
|
||||||
//
|
|
||||||
// a <paramName name> of "SchemeName" signals a new scheme is being described
|
|
||||||
//
|
|
||||||
|
|
||||||
const static int numTmpSchemes = 64;
|
|
||||||
static CScheme tmpSchemes[numTmpSchemes];
|
|
||||||
memset( tmpSchemes, 0, sizeof(tmpSchemes) );
|
|
||||||
int currentScheme = -1;
|
|
||||||
CScheme *pScheme = NULL;
|
|
||||||
|
|
||||||
if ( !pFile )
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n");
|
|
||||||
goto buildDefaultFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
// record what has been entered so we can create defaults from the different values
|
|
||||||
bool hasFgColor, hasBgColor, hasArmedFgColor, hasArmedBgColor, hasMouseDownFgColor, hasMouseDownBgColor;
|
|
||||||
|
|
||||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
|
||||||
while ( strlen(token) > 0 && (currentScheme < numTmpSchemes) )
|
|
||||||
{
|
|
||||||
// get the paramName name
|
|
||||||
static const int tokenSize = 64;
|
|
||||||
char paramName[tokenSize], paramValue[tokenSize];
|
|
||||||
|
|
||||||
strncpy( paramName, token, tokenSize );
|
|
||||||
paramName[tokenSize-1] = 0; // ensure null termination
|
|
||||||
|
|
||||||
// get the '=' character
|
|
||||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
|
||||||
if ( stricmp( token, "=" ) )
|
|
||||||
{
|
|
||||||
if ( currentScheme < 0 )
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_Printf( "error parsing font scheme text file at file start - expected '=', found '%s''\n", token );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_Printf( "error parsing font scheme text file at scheme '%s' - expected '=', found '%s''\n", tmpSchemes[currentScheme].schemeName, token );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get paramValue
|
|
||||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
|
||||||
strncpy( paramValue, token, tokenSize );
|
|
||||||
paramValue[tokenSize-1] = 0; // ensure null termination
|
|
||||||
|
|
||||||
// is this a new scheme?
|
|
||||||
if ( !stricmp(paramName, "SchemeName") )
|
|
||||||
{
|
|
||||||
// setup the defaults for the current scheme
|
|
||||||
if ( pScheme )
|
|
||||||
{
|
|
||||||
// foreground color defaults (normal -> armed -> mouse down)
|
|
||||||
if ( !hasFgColor )
|
|
||||||
{
|
|
||||||
pScheme->fgColor[0] = pScheme->fgColor[1] = pScheme->fgColor[2] = pScheme->fgColor[3] = 255;
|
|
||||||
}
|
|
||||||
if ( !hasArmedFgColor )
|
|
||||||
{
|
|
||||||
memcpy( pScheme->armedFgColor, pScheme->fgColor, sizeof(pScheme->armedFgColor) );
|
|
||||||
}
|
|
||||||
if ( !hasMouseDownFgColor )
|
|
||||||
{
|
|
||||||
memcpy( pScheme->mousedownFgColor, pScheme->armedFgColor, sizeof(pScheme->mousedownFgColor) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// background color (normal -> armed -> mouse down)
|
|
||||||
if ( !hasBgColor )
|
|
||||||
{
|
|
||||||
pScheme->bgColor[0] = pScheme->bgColor[1] = pScheme->bgColor[2] = pScheme->bgColor[3] = 0;
|
|
||||||
}
|
|
||||||
if ( !hasArmedBgColor )
|
|
||||||
{
|
|
||||||
memcpy( pScheme->armedBgColor, pScheme->bgColor, sizeof(pScheme->armedBgColor) );
|
|
||||||
}
|
|
||||||
if ( !hasMouseDownBgColor )
|
|
||||||
{
|
|
||||||
memcpy( pScheme->mousedownBgColor, pScheme->armedBgColor, sizeof(pScheme->mousedownBgColor) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// font size
|
|
||||||
if ( !pScheme->fontSize )
|
|
||||||
{
|
|
||||||
pScheme->fontSize = 17;
|
|
||||||
}
|
|
||||||
if ( !pScheme->fontName[0] )
|
|
||||||
{
|
|
||||||
strcpy( pScheme->fontName, "Arial" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the new scheme
|
|
||||||
currentScheme++;
|
|
||||||
pScheme = &tmpSchemes[currentScheme];
|
|
||||||
hasFgColor = hasBgColor = hasArmedFgColor = hasArmedBgColor = hasMouseDownFgColor = hasMouseDownBgColor = false;
|
|
||||||
|
|
||||||
strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH );
|
|
||||||
pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH-1] = '\0'; // ensure null termination of string
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !pScheme )
|
|
||||||
{
|
|
||||||
gEngfuncs.Con_Printf( "font scheme text file MUST start with a 'SchemeName'\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull the data out into the scheme
|
|
||||||
if ( !stricmp(paramName, "FontName") )
|
|
||||||
{
|
|
||||||
strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH );
|
|
||||||
pScheme->fontName[CScheme::FONT_NAME_LENGTH-1] = 0;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "FontSize") )
|
|
||||||
{
|
|
||||||
pScheme->fontSize = atoi( paramValue );
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "FontWeight") )
|
|
||||||
{
|
|
||||||
pScheme->fontWeight = atoi( paramValue );
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "FgColor") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->fgColor, paramValue );
|
|
||||||
hasFgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "BgColor") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->bgColor, paramValue );
|
|
||||||
hasBgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "FgColorArmed") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->armedFgColor, paramValue );
|
|
||||||
hasArmedFgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "BgColorArmed") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->armedBgColor, paramValue );
|
|
||||||
hasArmedBgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "FgColorMousedown") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->mousedownFgColor, paramValue );
|
|
||||||
hasMouseDownFgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "BgColorMousedown") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->mousedownBgColor, paramValue );
|
|
||||||
hasMouseDownBgColor = true;
|
|
||||||
}
|
|
||||||
else if ( !stricmp(paramName, "BorderColor") )
|
|
||||||
{
|
|
||||||
ParseRGBAFromString( pScheme->borderColor, paramValue );
|
|
||||||
hasMouseDownBgColor = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the new token last, so we now if the loop needs to be continued or not
|
|
||||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
|
||||||
}
|
|
||||||
|
|
||||||
// free the file
|
|
||||||
gEngfuncs.COM_FreeFile( pFileStart );
|
|
||||||
|
|
||||||
|
|
||||||
buildDefaultFont:
|
|
||||||
|
|
||||||
// make sure we have at least 1 valid font
|
|
||||||
if ( currentScheme < 0 )
|
|
||||||
{
|
|
||||||
currentScheme = 0;
|
|
||||||
strcpy( tmpSchemes[0].schemeName, "Default Scheme" );
|
|
||||||
strcpy( tmpSchemes[0].fontName, "Arial" );
|
|
||||||
tmpSchemes[0].fontSize = 0;
|
|
||||||
tmpSchemes[0].fgColor[0] = tmpSchemes[0].fgColor[1] = tmpSchemes[0].fgColor[2] = tmpSchemes[0].fgColor[3] = 255;
|
|
||||||
tmpSchemes[0].armedFgColor[0] = tmpSchemes[0].armedFgColor[1] = tmpSchemes[0].armedFgColor[2] = tmpSchemes[0].armedFgColor[3] = 255;
|
|
||||||
tmpSchemes[0].mousedownFgColor[0] = tmpSchemes[0].mousedownFgColor[1] = tmpSchemes[0].mousedownFgColor[2] = tmpSchemes[0].mousedownFgColor[3] = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we have the full list of schemes in the tmpSchemes array
|
|
||||||
// now allocate the correct sized list
|
|
||||||
m_iNumSchemes = currentScheme + 1; // 0-based index
|
|
||||||
m_pSchemeList = new CScheme[ m_iNumSchemes ];
|
|
||||||
|
|
||||||
// copy in the data
|
|
||||||
memcpy( m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes );
|
|
||||||
|
|
||||||
// create the fonts
|
|
||||||
for ( int i = 0; i < m_iNumSchemes; i++ )
|
|
||||||
{
|
|
||||||
m_pSchemeList[i].font = NULL;
|
|
||||||
|
|
||||||
// see if the current font values exist in a previously loaded font
|
|
||||||
for ( int j = 0; j < i; j++ )
|
|
||||||
{
|
|
||||||
// check if the font name, size, and weight are the same
|
|
||||||
if ( !stricmp(m_pSchemeList[i].fontName, m_pSchemeList[j].fontName)
|
|
||||||
&& m_pSchemeList[i].fontSize == m_pSchemeList[j].fontSize
|
|
||||||
&& m_pSchemeList[i].fontWeight == m_pSchemeList[j].fontWeight )
|
|
||||||
{
|
|
||||||
// copy the pointer, but mark i as not owning it
|
|
||||||
m_pSchemeList[i].font = m_pSchemeList[j].font;
|
|
||||||
m_pSchemeList[i].ownFontPointer = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we haven't found the font already, load it ourselves
|
|
||||||
if ( !m_pSchemeList[i].font )
|
|
||||||
{
|
|
||||||
fontFileLength = -1;
|
|
||||||
pFontData = NULL;
|
|
||||||
|
|
||||||
if(g_CV_BitmapFonts && g_CV_BitmapFonts->value)
|
|
||||||
{
|
|
||||||
int fontRes = 640;
|
|
||||||
if ( m_xRes >= 1600 )
|
|
||||||
fontRes = 1600;
|
|
||||||
else if ( m_xRes >= 1280 )
|
|
||||||
fontRes = 1280;
|
|
||||||
else if ( m_xRes >= 1152 )
|
|
||||||
fontRes = 1152;
|
|
||||||
else if ( m_xRes >= 1024 )
|
|
||||||
fontRes = 1024;
|
|
||||||
else if ( m_xRes >= 800 )
|
|
||||||
fontRes = 800;
|
|
||||||
|
|
||||||
sprintf(fontFilename, "gfx\\vgui\\fonts\\%d_%s.tga", fontRes, m_pSchemeList[i].schemeName);
|
|
||||||
pFontData = gEngfuncs.COM_LoadFile( fontFilename, 5, &fontFileLength );
|
|
||||||
if(!pFontData)
|
|
||||||
gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pSchemeList[i].font = new vgui::Font(
|
|
||||||
m_pSchemeList[i].fontName,
|
|
||||||
pFontData,
|
|
||||||
fontFileLength,
|
|
||||||
m_pSchemeList[i].fontSize,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
m_pSchemeList[i].fontWeight,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
m_pSchemeList[i].ownFontPointer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix up alpha values; VGUI uses 1-A (A=0 being solid, A=255 transparent)
|
|
||||||
m_pSchemeList[i].fgColor[3] = 255 - m_pSchemeList[i].fgColor[3];
|
|
||||||
m_pSchemeList[i].bgColor[3] = 255 - m_pSchemeList[i].bgColor[3];
|
|
||||||
m_pSchemeList[i].armedFgColor[3] = 255 - m_pSchemeList[i].armedFgColor[3];
|
|
||||||
m_pSchemeList[i].armedBgColor[3] = 255 - m_pSchemeList[i].armedBgColor[3];
|
|
||||||
m_pSchemeList[i].mousedownFgColor[3] = 255 - m_pSchemeList[i].mousedownFgColor[3];
|
|
||||||
m_pSchemeList[i].mousedownBgColor[3] = 255 - m_pSchemeList[i].mousedownBgColor[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: frees all the memory used by the scheme manager
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CSchemeManager::~CSchemeManager()
|
|
||||||
{
|
|
||||||
delete [] m_pSchemeList;
|
|
||||||
m_iNumSchemes = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Finds a scheme in the list, by name
|
|
||||||
// Input : char *schemeName - string name of the scheme
|
|
||||||
// Output : SchemeHandle_t handle to the scheme
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
SchemeHandle_t CSchemeManager::getSchemeHandle( const char *schemeName )
|
|
||||||
{
|
|
||||||
// iterate through the list
|
|
||||||
for ( int i = 0; i < m_iNumSchemes; i++ )
|
|
||||||
{
|
|
||||||
if ( !stricmp(schemeName, m_pSchemeList[i].schemeName) )
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: always returns a valid scheme handle
|
|
||||||
// Input : schemeHandle -
|
|
||||||
// Output : CScheme
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
CSchemeManager::CScheme *CSchemeManager::getSafeScheme( SchemeHandle_t schemeHandle )
|
|
||||||
{
|
|
||||||
if ( schemeHandle < m_iNumSchemes )
|
|
||||||
return m_pSchemeList + schemeHandle;
|
|
||||||
|
|
||||||
return m_pSchemeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Returns the schemes pointer to a font
|
|
||||||
// Input : schemeHandle -
|
|
||||||
// Output : vgui::Font
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
vgui::Font *CSchemeManager::getFont( SchemeHandle_t schemeHandle )
|
|
||||||
{
|
|
||||||
return getSafeScheme( schemeHandle )->font;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->fgColor[0];
|
|
||||||
g = pScheme->fgColor[1];
|
|
||||||
b = pScheme->fgColor[2];
|
|
||||||
a = pScheme->fgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->bgColor[0];
|
|
||||||
g = pScheme->bgColor[1];
|
|
||||||
b = pScheme->bgColor[2];
|
|
||||||
a = pScheme->bgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->armedFgColor[0];
|
|
||||||
g = pScheme->armedFgColor[1];
|
|
||||||
b = pScheme->armedFgColor[2];
|
|
||||||
a = pScheme->armedFgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->armedBgColor[0];
|
|
||||||
g = pScheme->armedBgColor[1];
|
|
||||||
b = pScheme->armedBgColor[2];
|
|
||||||
a = pScheme->armedBgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->mousedownFgColor[0];
|
|
||||||
g = pScheme->mousedownFgColor[1];
|
|
||||||
b = pScheme->mousedownFgColor[2];
|
|
||||||
a = pScheme->mousedownFgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->mousedownBgColor[0];
|
|
||||||
g = pScheme->mousedownBgColor[1];
|
|
||||||
b = pScheme->mousedownBgColor[2];
|
|
||||||
a = pScheme->mousedownBgColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSchemeManager::getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
|
||||||
{
|
|
||||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
|
||||||
r = pScheme->borderColor[0];
|
|
||||||
g = pScheme->borderColor[1];
|
|
||||||
b = pScheme->borderColor[2];
|
|
||||||
a = pScheme->borderColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include <VGUI_Font.h>
|
|
||||||
|
|
||||||
|
|
||||||
// handle to an individual scheme
|
|
||||||
typedef int SchemeHandle_t;
|
|
||||||
|
|
||||||
|
|
||||||
// Register console variables, etc..
|
|
||||||
void Scheme_Init();
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Handles the loading of text scheme description from disk
|
|
||||||
// supports different font/color/size schemes at different resolutions
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CSchemeManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// initialization
|
|
||||||
CSchemeManager( int xRes, int yRes );
|
|
||||||
virtual ~CSchemeManager();
|
|
||||||
|
|
||||||
// scheme handling
|
|
||||||
SchemeHandle_t getSchemeHandle( const char *schemeName );
|
|
||||||
|
|
||||||
// getting info from schemes
|
|
||||||
vgui::Font *getFont( SchemeHandle_t schemeHandle );
|
|
||||||
void getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
void getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
|
||||||
|
|
||||||
private:
|
|
||||||
class CScheme;
|
|
||||||
CScheme *m_pSchemeList;
|
|
||||||
int m_iNumSchemes;
|
|
||||||
|
|
||||||
// Resolution we were initted at.
|
|
||||||
int m_xRes;
|
|
||||||
|
|
||||||
CScheme *getSafeScheme( SchemeHandle_t schemeHandle );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,310 +0,0 @@
|
||||||
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef SCOREPANEL_H
|
|
||||||
#define SCOREPANEL_H
|
|
||||||
|
|
||||||
#include<VGUI_Panel.h>
|
|
||||||
#include<VGUI_TablePanel.h>
|
|
||||||
#include<VGUI_HeaderPanel.h>
|
|
||||||
#include<VGUI_TextGrid.h>
|
|
||||||
#include<VGUI_Label.h>
|
|
||||||
#include<VGUI_TextImage.h>
|
|
||||||
#include "../game_shared/vgui_listbox.h"
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#define MAX_SCORES 10
|
|
||||||
#define MAX_SCOREBOARD_TEAMS 5
|
|
||||||
|
|
||||||
// Scoreboard cells
|
|
||||||
#define COLUMN_TRACKER 0
|
|
||||||
#define COLUMN_NAME 1
|
|
||||||
#define COLUMN_CLASS 2
|
|
||||||
#define COLUMN_KILLS 3
|
|
||||||
#define COLUMN_DEATHS 4
|
|
||||||
#define COLUMN_LATENCY 5
|
|
||||||
#define COLUMN_VOICE 6
|
|
||||||
#define COLUMN_BLANK 7
|
|
||||||
#define NUM_COLUMNS 8
|
|
||||||
#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2))
|
|
||||||
|
|
||||||
using namespace vgui;
|
|
||||||
|
|
||||||
class CTextImage2 : public Image
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CTextImage2()
|
|
||||||
{
|
|
||||||
_image[0] = new TextImage("");
|
|
||||||
_image[1] = new TextImage("");
|
|
||||||
}
|
|
||||||
|
|
||||||
~CTextImage2()
|
|
||||||
{
|
|
||||||
delete _image[0];
|
|
||||||
delete _image[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
TextImage *GetImage(int image)
|
|
||||||
{
|
|
||||||
return _image[image];
|
|
||||||
}
|
|
||||||
|
|
||||||
void getSize(int &wide, int &tall)
|
|
||||||
{
|
|
||||||
int w1, w2, t1, t2;
|
|
||||||
_image[0]->getTextSize(w1, t1);
|
|
||||||
_image[1]->getTextSize(w2, t2);
|
|
||||||
|
|
||||||
wide = w1 + w2;
|
|
||||||
tall = max(t1, t2);
|
|
||||||
setSize(wide, tall);
|
|
||||||
}
|
|
||||||
|
|
||||||
void doPaint(Panel *panel)
|
|
||||||
{
|
|
||||||
_image[0]->doPaint(panel);
|
|
||||||
_image[1]->doPaint(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPos(int x, int y)
|
|
||||||
{
|
|
||||||
_image[0]->setPos(x, y);
|
|
||||||
|
|
||||||
int swide, stall;
|
|
||||||
_image[0]->getSize(swide, stall);
|
|
||||||
|
|
||||||
int wide, tall;
|
|
||||||
_image[1]->getSize(wide, tall);
|
|
||||||
_image[1]->setPos(x + wide, y + (stall * 0.9) - tall);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setColor(Color color)
|
|
||||||
{
|
|
||||||
_image[0]->setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setColor2(Color color)
|
|
||||||
{
|
|
||||||
_image[1]->setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
TextImage *_image[2];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Custom label for cells in the Scoreboard's Table Header
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CLabelHeader : public Label
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CLabelHeader() : Label("")
|
|
||||||
{
|
|
||||||
_dualImage = new CTextImage2();
|
|
||||||
_dualImage->setColor2(Color(255, 170, 0, 0));
|
|
||||||
_row = -2;
|
|
||||||
_useFgColorAsImageColor = true;
|
|
||||||
_offset[0] = 0;
|
|
||||||
_offset[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
~CLabelHeader()
|
|
||||||
{
|
|
||||||
delete _dualImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRow(int row)
|
|
||||||
{
|
|
||||||
_row = row;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFgColorAsImageColor(bool state)
|
|
||||||
{
|
|
||||||
_useFgColorAsImageColor = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void setText(int textBufferLen, const char* text)
|
|
||||||
{
|
|
||||||
_dualImage->GetImage(0)->setText(text);
|
|
||||||
|
|
||||||
// calculate the text size
|
|
||||||
Font *font = _dualImage->GetImage(0)->getFont();
|
|
||||||
_gap = 0;
|
|
||||||
for (const char *ch = text; *ch != 0; ch++)
|
|
||||||
{
|
|
||||||
int a, b, c;
|
|
||||||
font->getCharABCwide(*ch, a, b, c);
|
|
||||||
_gap += (a + b + c);
|
|
||||||
}
|
|
||||||
|
|
||||||
_gap += XRES(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void setText(const char* text)
|
|
||||||
{
|
|
||||||
// strip any non-alnum characters from the end
|
|
||||||
char buf[512];
|
|
||||||
strcpy(buf, text);
|
|
||||||
|
|
||||||
int len = strlen(buf);
|
|
||||||
while (len && isspace(buf[--len]))
|
|
||||||
{
|
|
||||||
buf[len] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLabelHeader::setText(0, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setText2(const char *text)
|
|
||||||
{
|
|
||||||
_dualImage->GetImage(1)->setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void getTextSize(int &wide, int &tall)
|
|
||||||
{
|
|
||||||
_dualImage->getSize(wide, tall);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFgColor(int r,int g,int b,int a)
|
|
||||||
{
|
|
||||||
Label::setFgColor(r,g,b,a);
|
|
||||||
Color color(r,g,b,a);
|
|
||||||
_dualImage->setColor(color);
|
|
||||||
_dualImage->setColor2(color);
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFgColor(Scheme::SchemeColor sc)
|
|
||||||
{
|
|
||||||
int r, g, b, a;
|
|
||||||
Label::setFgColor(sc);
|
|
||||||
Label::getFgColor( r, g, b, a );
|
|
||||||
|
|
||||||
// Call the r,g,b,a version so it sets the color in the dualImage..
|
|
||||||
setFgColor( r, g, b, a );
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFont(Font *font)
|
|
||||||
{
|
|
||||||
_dualImage->GetImage(0)->setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFont2(Font *font)
|
|
||||||
{
|
|
||||||
_dualImage->GetImage(1)->setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this adjust the absolute position of the text after alignment is calculated
|
|
||||||
void setTextOffset(int x, int y)
|
|
||||||
{
|
|
||||||
_offset[0] = x;
|
|
||||||
_offset[1] = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint();
|
|
||||||
void paintBackground();
|
|
||||||
void calcAlignment(int iwide, int itall, int &x, int &y);
|
|
||||||
|
|
||||||
private:
|
|
||||||
CTextImage2 *_dualImage;
|
|
||||||
int _row;
|
|
||||||
int _gap;
|
|
||||||
int _offset[2];
|
|
||||||
bool _useFgColorAsImageColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ScoreTablePanel;
|
|
||||||
|
|
||||||
#include "../game_shared/vgui_grid.h"
|
|
||||||
#include "../game_shared/vgui_defaultinputsignal.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Scoreboard back panel
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ScorePanel : public Panel, public vgui::CDefaultInputSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Default panel implementation doesn't forward mouse messages when there is no cursor and we need them.
|
|
||||||
class HitTestPanel : public Panel
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void internalMousePressed(MouseCode code);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Label m_TitleLabel;
|
|
||||||
|
|
||||||
// Here is how these controls are arranged hierarchically.
|
|
||||||
// m_HeaderGrid
|
|
||||||
// m_HeaderLabels
|
|
||||||
|
|
||||||
// m_PlayerGridScroll
|
|
||||||
// m_PlayerGrid
|
|
||||||
// m_PlayerEntries
|
|
||||||
|
|
||||||
CGrid m_HeaderGrid;
|
|
||||||
CLabelHeader m_HeaderLabels[NUM_COLUMNS]; // Labels above the
|
|
||||||
CLabelHeader *m_pCurrentHighlightLabel;
|
|
||||||
int m_iHighlightRow;
|
|
||||||
|
|
||||||
vgui::CListBox m_PlayerList;
|
|
||||||
CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info.
|
|
||||||
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
|
|
||||||
|
|
||||||
ScorePanel::HitTestPanel m_HitTestPanel;
|
|
||||||
CommandButton *m_pCloseButton;
|
|
||||||
CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
int m_iNumTeams;
|
|
||||||
int m_iPlayerNum;
|
|
||||||
int m_iShowscoresHeld;
|
|
||||||
|
|
||||||
int m_iRows;
|
|
||||||
int m_iSortedRows[NUM_ROWS];
|
|
||||||
int m_iIsATeam[NUM_ROWS];
|
|
||||||
bool m_bHasBeenSorted[MAX_PLAYERS];
|
|
||||||
int m_iLastKilledBy;
|
|
||||||
int m_fLastKillTime;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ScorePanel(int x,int y,int wide,int tall);
|
|
||||||
|
|
||||||
void Update( void );
|
|
||||||
|
|
||||||
void SortTeams( void );
|
|
||||||
void SortPlayers( int iTeam, char *team );
|
|
||||||
void RebuildTeams( void );
|
|
||||||
|
|
||||||
void FillGrid();
|
|
||||||
|
|
||||||
void DeathMsg( int killer, int victim );
|
|
||||||
|
|
||||||
void Initialize( void );
|
|
||||||
|
|
||||||
void Open( void );
|
|
||||||
|
|
||||||
void MouseOverCell(int row, int col);
|
|
||||||
|
|
||||||
// InputSignal overrides.
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void mousePressed(MouseCode code, Panel* panel);
|
|
||||||
virtual void cursorMoved(int x, int y, Panel *panel);
|
|
||||||
|
|
||||||
friend class CLabelHeader;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,623 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#include<VGUI_HeaderPanel.h>
|
|
||||||
#include<VGUI_TablePanel.h>
|
|
||||||
#include<VGUI_LineBorder.h>
|
|
||||||
#include<VGUI_Label.h>
|
|
||||||
#include<VGUI_Button.h>
|
|
||||||
#include<VGUI_ActionSignal.h>
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "hud_servers.h"
|
|
||||||
#include "net_api.h"
|
|
||||||
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "vgui_ServerBrowser.h"
|
|
||||||
|
|
||||||
using namespace vgui;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
#define MAX_SB_ROWS 24
|
|
||||||
|
|
||||||
#define NUM_COLUMNS 5
|
|
||||||
|
|
||||||
#define HEADER_SIZE_Y YRES(18)
|
|
||||||
|
|
||||||
// Column sizes
|
|
||||||
#define CSIZE_ADDRESS XRES(200)
|
|
||||||
#define CSIZE_SERVER XRES(400)
|
|
||||||
#define CSIZE_MAP XRES(500)
|
|
||||||
#define CSIZE_CURRENT XRES(570)
|
|
||||||
#define CSIZE_PING XRES(640)
|
|
||||||
|
|
||||||
#define CELL_HEIGHT YRES(15)
|
|
||||||
|
|
||||||
class ServerBrowserTablePanel;
|
|
||||||
|
|
||||||
class CBrowser_InputSignal : public InputSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
public:
|
|
||||||
CBrowser_InputSignal( ServerBrowserTablePanel *pBrowser )
|
|
||||||
{
|
|
||||||
m_pBrowser = pBrowser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void cursorMoved(int x,int y,Panel* panel) {};
|
|
||||||
virtual void cursorEntered(Panel* panel){};
|
|
||||||
virtual void cursorExited(Panel* Panel) {};
|
|
||||||
|
|
||||||
virtual void mousePressed(MouseCode code,Panel* panel);
|
|
||||||
|
|
||||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel);
|
|
||||||
virtual void mouseReleased(MouseCode code,Panel* panel) {};
|
|
||||||
virtual void mouseWheeled(int delta,Panel* panel) {};
|
|
||||||
virtual void keyPressed(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyTyped(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyReleased(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyFocusTicked(Panel* panel) {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class ServerBrowserTablePanel : public TablePanel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Label *m_pLabel;
|
|
||||||
int m_nMouseOverRow;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ServerBrowserTablePanel( int x,int y,int wide,int tall,int columnCount) : TablePanel( x,y,wide,tall,columnCount)
|
|
||||||
{
|
|
||||||
m_pLabel = new Label( "", 0, 0 /*,wide, tall*/ );
|
|
||||||
|
|
||||||
m_nMouseOverRow = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setMouseOverRow( int row )
|
|
||||||
{
|
|
||||||
m_nMouseOverRow = row;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoSort( char *sortkey )
|
|
||||||
{
|
|
||||||
// Request server list and refresh servers...
|
|
||||||
SortServers( sortkey );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoRefresh( void )
|
|
||||||
{
|
|
||||||
// Request server list and refresh servers...
|
|
||||||
ServersList();
|
|
||||||
BroadcastServersList( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoBroadcastRefresh( void )
|
|
||||||
{
|
|
||||||
// Request server list and refresh servers...
|
|
||||||
BroadcastServersList( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoStop( void )
|
|
||||||
{
|
|
||||||
// Stop requesting
|
|
||||||
ServersCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoCancel( void )
|
|
||||||
{
|
|
||||||
EngineClientCmd( "togglebrowser\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoConnect( void )
|
|
||||||
{
|
|
||||||
const char *info;
|
|
||||||
const char *address;
|
|
||||||
char sz[ 256 ];
|
|
||||||
|
|
||||||
info = ServersGetInfo( m_nMouseOverRow );
|
|
||||||
if ( !info )
|
|
||||||
return;
|
|
||||||
|
|
||||||
address = gEngfuncs.pNetAPI->ValueForKey( info, "address" );
|
|
||||||
//gEngfuncs.Con_Printf( "Connecting to %s\n", address );
|
|
||||||
|
|
||||||
sprintf( sz, "connect %s\n", address );
|
|
||||||
|
|
||||||
EngineClientCmd( sz );
|
|
||||||
|
|
||||||
DoCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoPing( void )
|
|
||||||
{
|
|
||||||
ServerPing( 0 );
|
|
||||||
ServerRules( 0 );
|
|
||||||
ServerPlayers( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int getRowCount()
|
|
||||||
{
|
|
||||||
int rowcount;
|
|
||||||
int height, width;
|
|
||||||
|
|
||||||
getSize( width, height );
|
|
||||||
|
|
||||||
// Space for buttons
|
|
||||||
height -= YRES(20);
|
|
||||||
height = max( 0, height );
|
|
||||||
|
|
||||||
rowcount = height / CELL_HEIGHT;
|
|
||||||
|
|
||||||
return rowcount;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int getCellTall(int row)
|
|
||||||
{
|
|
||||||
return CELL_HEIGHT - 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Panel* getCellRenderer(int column,int row,bool columnSelected,bool rowSelected,bool cellSelected)
|
|
||||||
{
|
|
||||||
const char *info;
|
|
||||||
const char *val, *val2;
|
|
||||||
char sz[ 32 ];
|
|
||||||
|
|
||||||
info = ServersGetInfo( row );
|
|
||||||
|
|
||||||
if ( row == m_nMouseOverRow )
|
|
||||||
{
|
|
||||||
m_pLabel->setFgColor( 200, 240, 63, 100 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pLabel->setFgColor( 255, 255, 255, 0 );
|
|
||||||
}
|
|
||||||
m_pLabel->setBgColor( 0, 0, 0, 200 );
|
|
||||||
m_pLabel->setContentAlignment( vgui::Label::a_west );
|
|
||||||
m_pLabel->setFont( Scheme::sf_primary2 );
|
|
||||||
|
|
||||||
if ( info )
|
|
||||||
{
|
|
||||||
// Fill out with the correct data
|
|
||||||
switch ( column )
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
val = gEngfuncs.pNetAPI->ValueForKey( info, "address" );
|
|
||||||
if ( val )
|
|
||||||
{
|
|
||||||
strncpy( sz, val, 31 );
|
|
||||||
sz[ 31 ] = '\0';
|
|
||||||
// Server Name;
|
|
||||||
m_pLabel->setText( sz );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
val = gEngfuncs.pNetAPI->ValueForKey( info, "hostname" );
|
|
||||||
if ( val )
|
|
||||||
{
|
|
||||||
strncpy( sz, val, 31 );
|
|
||||||
sz[ 31 ] = '\0';
|
|
||||||
// Server Map;
|
|
||||||
m_pLabel->setText( sz );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
val = gEngfuncs.pNetAPI->ValueForKey( info, "map" );
|
|
||||||
if ( val )
|
|
||||||
{
|
|
||||||
strncpy( sz, val, 31 );
|
|
||||||
sz[ 31 ] = '\0';
|
|
||||||
// Server Name;
|
|
||||||
m_pLabel->setText( sz );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
val = gEngfuncs.pNetAPI->ValueForKey( info, "current" );
|
|
||||||
val2 = gEngfuncs.pNetAPI->ValueForKey( info, "max" );
|
|
||||||
if ( val && val2 )
|
|
||||||
{
|
|
||||||
sprintf( sz, "%s/%s", val, val2 );
|
|
||||||
sz[ 31 ] = '\0';
|
|
||||||
// Server Map;
|
|
||||||
m_pLabel->setText( sz );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
val = gEngfuncs.pNetAPI->ValueForKey( info, "ping" );
|
|
||||||
if ( val )
|
|
||||||
{
|
|
||||||
strncpy( sz, val, 31 );
|
|
||||||
sz[ 31 ] = '\0';
|
|
||||||
// Server Name;
|
|
||||||
m_pLabel->setText( sz );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !row && !column )
|
|
||||||
{
|
|
||||||
if ( ServersIsQuerying() )
|
|
||||||
{
|
|
||||||
m_pLabel->setText( "Waiting for servers to respond..." );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pLabel->setText( "Press 'Refresh' to search for servers..." );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pLabel->setText( "" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_pLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Panel* startCellEditing(int column,int row)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class ConnectHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ConnectHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoConnect();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class RefreshHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
RefreshHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoRefresh();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class BroadcastRefreshHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
BroadcastRefreshHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoBroadcastRefresh();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class StopHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
StopHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoStop();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CancelHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CancelHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoCancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class PingHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PingHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoPing();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SortHandler : public ActionSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SortHandler( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void actionPerformed( Panel *panel )
|
|
||||||
{
|
|
||||||
m_pBrowser->DoSort( "map" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class LabelSortInputHandler : public InputSignal
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
char m_szSortKey[ 64 ];
|
|
||||||
|
|
||||||
public:
|
|
||||||
LabelSortInputHandler( ServerBrowserTablePanel *pBrowser, char *name )
|
|
||||||
{
|
|
||||||
m_pBrowser = pBrowser;
|
|
||||||
strcpy( m_szSortKey, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void cursorMoved(int x,int y,Panel* panel) {};
|
|
||||||
virtual void cursorEntered(Panel* panel){};
|
|
||||||
virtual void cursorExited(Panel* Panel) {};
|
|
||||||
|
|
||||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
|
||||||
{
|
|
||||||
m_pBrowser->DoSort( m_szSortKey );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
|
||||||
{
|
|
||||||
m_pBrowser->DoSort( m_szSortKey );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void mouseReleased(MouseCode code,Panel* panel) {};
|
|
||||||
virtual void mouseWheeled(int delta,Panel* panel) {};
|
|
||||||
virtual void keyPressed(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyTyped(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyReleased(KeyCode code,Panel* panel) {};
|
|
||||||
virtual void keyFocusTicked(Panel* panel) {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSBLabel : public Label
|
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
|
||||||
char m_szSortKey[ 64 ];
|
|
||||||
ServerBrowserTablePanel *m_pBrowser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CSBLabel( char *name, char *sortkey ) : Label( name )
|
|
||||||
{
|
|
||||||
m_pBrowser = NULL;
|
|
||||||
|
|
||||||
strcpy( m_szSortKey, sortkey );
|
|
||||||
|
|
||||||
int label_bg_r = 120,
|
|
||||||
label_bg_g = 75,
|
|
||||||
label_bg_b = 32,
|
|
||||||
label_bg_a = 200;
|
|
||||||
|
|
||||||
int label_fg_r = 255,
|
|
||||||
label_fg_g = 0,
|
|
||||||
label_fg_b = 0,
|
|
||||||
label_fg_a = 0;
|
|
||||||
|
|
||||||
setContentAlignment( vgui::Label::a_west );
|
|
||||||
setFgColor( label_fg_r, label_fg_g, label_fg_b, label_fg_a );
|
|
||||||
setBgColor( label_bg_r, label_bg_g, label_bg_b, label_bg_a );
|
|
||||||
setFont( Scheme::sf_primary2 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTable( ServerBrowserTablePanel *browser )
|
|
||||||
{
|
|
||||||
m_pBrowser = browser;
|
|
||||||
|
|
||||||
addInputSignal( new LabelSortInputHandler( (ServerBrowserTablePanel * )m_pBrowser, m_szSortKey ) );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerBrowser::ServerBrowser(int x,int y,int wide,int tall) : CTransparentPanel( 100, x,y,wide,tall )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
_headerPanel = new HeaderPanel(0,0,wide,HEADER_SIZE_Y);
|
|
||||||
_headerPanel->setParent(this);
|
|
||||||
_headerPanel->setFgColor( 100,100,100, 100 );
|
|
||||||
_headerPanel->setBgColor( 0, 0, 0, 100 );
|
|
||||||
|
|
||||||
CSBLabel *pLabel[5];
|
|
||||||
|
|
||||||
pLabel[0] = new CSBLabel( "Address", "address" );
|
|
||||||
pLabel[1] = new CSBLabel( "Server", "hostname" );
|
|
||||||
pLabel[2] = new CSBLabel( "Map", "map" );
|
|
||||||
pLabel[3] = new CSBLabel( "Current", "current" );
|
|
||||||
pLabel[4] = new CSBLabel( "Latency", "ping" );
|
|
||||||
|
|
||||||
for ( i = 0; i < 5; i++ )
|
|
||||||
{
|
|
||||||
_headerPanel->addSectionPanel( pLabel[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// _headerPanel->setFont( Scheme::sf_primary1 );
|
|
||||||
|
|
||||||
_headerPanel->setSliderPos( 0, CSIZE_ADDRESS );
|
|
||||||
_headerPanel->setSliderPos( 1, CSIZE_SERVER );
|
|
||||||
_headerPanel->setSliderPos( 2, CSIZE_MAP );
|
|
||||||
_headerPanel->setSliderPos( 3, CSIZE_CURRENT );
|
|
||||||
_headerPanel->setSliderPos( 4, CSIZE_PING );
|
|
||||||
|
|
||||||
_tablePanel = new ServerBrowserTablePanel( 0, HEADER_SIZE_Y, wide, tall - HEADER_SIZE_Y, NUM_COLUMNS );
|
|
||||||
_tablePanel->setParent(this);
|
|
||||||
_tablePanel->setHeaderPanel(_headerPanel);
|
|
||||||
_tablePanel->setFgColor( 100,100,100, 100 );
|
|
||||||
_tablePanel->setBgColor( 0, 0, 0, 100 );
|
|
||||||
|
|
||||||
_tablePanel->addInputSignal( new CBrowser_InputSignal( (ServerBrowserTablePanel *)_tablePanel ) );
|
|
||||||
|
|
||||||
for ( i = 0; i < 5; i++ )
|
|
||||||
{
|
|
||||||
pLabel[i]->setTable( (ServerBrowserTablePanel * )_tablePanel );
|
|
||||||
}
|
|
||||||
|
|
||||||
int bw = 80, bh = 15;
|
|
||||||
int by = tall - HEADER_SIZE_Y;
|
|
||||||
|
|
||||||
int btnx = 10;
|
|
||||||
|
|
||||||
_connectButton = new CommandButton( "Connect", btnx, by, bw, bh );
|
|
||||||
_connectButton->setParent( this );
|
|
||||||
_connectButton->addActionSignal( new ConnectHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_refreshButton = new CommandButton( "Refresh", btnx, by, bw, bh );
|
|
||||||
_refreshButton->setParent( this );
|
|
||||||
_refreshButton->addActionSignal( new RefreshHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
|
|
||||||
/*
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_broadcastRefreshButton = new CommandButton( "LAN", btnx, by, bw, bh );
|
|
||||||
_broadcastRefreshButton->setParent( this );
|
|
||||||
_broadcastRefreshButton->addActionSignal( new BroadcastRefreshHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
*/
|
|
||||||
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_stopButton = new CommandButton( "Stop", btnx, by, bw, bh );
|
|
||||||
_stopButton->setParent( this );
|
|
||||||
_stopButton->addActionSignal( new StopHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
|
|
||||||
/*
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_pingButton = new CommandButton( "Test", btnx, by, bw, bh );
|
|
||||||
_pingButton->setParent( this );
|
|
||||||
_pingButton->addActionSignal( new PingHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_sortButton = new CommandButton( "Sort", btnx, by, bw, bh );
|
|
||||||
_sortButton->setParent( this );
|
|
||||||
_sortButton->addActionSignal( new SortHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
*/
|
|
||||||
|
|
||||||
btnx += bw;
|
|
||||||
|
|
||||||
_cancelButton = new CommandButton( "Close", btnx, by, bw, bh );
|
|
||||||
_cancelButton->setParent( this );
|
|
||||||
_cancelButton->addActionSignal( new CancelHandler( (ServerBrowserTablePanel * )_tablePanel ) );
|
|
||||||
|
|
||||||
setPaintBorderEnabled(false);
|
|
||||||
setPaintBackgroundEnabled(false);
|
|
||||||
setPaintEnabled(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerBrowser::setSize(int wide,int tall)
|
|
||||||
{
|
|
||||||
Panel::setSize(wide,tall);
|
|
||||||
|
|
||||||
_headerPanel->setBounds(0,0,wide,HEADER_SIZE_Y);
|
|
||||||
_tablePanel->setBounds(0,HEADER_SIZE_Y,wide,tall - HEADER_SIZE_Y);
|
|
||||||
|
|
||||||
_connectButton->setBounds( 5, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
_refreshButton->setBounds( 85, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
/*
|
|
||||||
_broadcastRefreshButton->setBounds( 165, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
*/
|
|
||||||
_stopButton->setBounds( 165, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
/*
|
|
||||||
_pingButton->setBounds( 325, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
*/
|
|
||||||
_cancelButton->setBounds( 245, tall - HEADER_SIZE_Y, 75, 15 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrowser_InputSignal::mousePressed(MouseCode code,Panel* panel)
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
int therow = 2;
|
|
||||||
|
|
||||||
if ( code != MOUSE_LEFT )
|
|
||||||
return;
|
|
||||||
|
|
||||||
panel->getApp()->getCursorPos(x,y);
|
|
||||||
panel->screenToLocal( x, y );
|
|
||||||
|
|
||||||
therow = y / CELL_HEIGHT;
|
|
||||||
|
|
||||||
// Figure out which row it's on
|
|
||||||
m_pBrowser->setMouseOverRow( therow );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrowser_InputSignal::mouseDoublePressed(MouseCode code,Panel* panel)
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
int therow = 2;
|
|
||||||
|
|
||||||
if ( code != MOUSE_LEFT )
|
|
||||||
return;
|
|
||||||
|
|
||||||
panel->getApp()->getCursorPos(x,y);
|
|
||||||
panel->screenToLocal( x, y );
|
|
||||||
|
|
||||||
therow = y / CELL_HEIGHT;
|
|
||||||
|
|
||||||
// Figure out which row it's on
|
|
||||||
m_pBrowser->setMouseOverRow( therow );
|
|
||||||
m_pBrowser->DoConnect();
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#ifndef ServerBrowser_H
|
|
||||||
#define ServerBrowser_H
|
|
||||||
|
|
||||||
#include<VGUI_Panel.h>
|
|
||||||
|
|
||||||
namespace vgui
|
|
||||||
{
|
|
||||||
class Button;
|
|
||||||
class TablePanel;
|
|
||||||
class HeaderPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CTransparentPanel;
|
|
||||||
class CommandButton;
|
|
||||||
|
|
||||||
// Scoreboard positions
|
|
||||||
#define SB_X_INDENT (20 * ((float)ScreenHeight / 640))
|
|
||||||
#define SB_Y_INDENT (20 * ((float)ScreenHeight / 480))
|
|
||||||
|
|
||||||
class ServerBrowser : public CTransparentPanel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
HeaderPanel * _headerPanel;
|
|
||||||
TablePanel* _tablePanel;
|
|
||||||
|
|
||||||
CommandButton* _connectButton;
|
|
||||||
CommandButton* _refreshButton;
|
|
||||||
CommandButton* _broadcastRefreshButton;
|
|
||||||
CommandButton* _stopButton;
|
|
||||||
CommandButton* _sortButton;
|
|
||||||
CommandButton* _cancelButton;
|
|
||||||
|
|
||||||
CommandButton* _pingButton;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ServerBrowser(int x,int y,int wide,int tall);
|
|
||||||
public:
|
|
||||||
virtual void setSize(int wide,int tall);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,426 +0,0 @@
|
||||||
// vgui_SpectatorPanel.cpp: implementation of the SpectatorPanel class.
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "hud.h"
|
|
||||||
#include "cl_util.h"
|
|
||||||
#include "const.h"
|
|
||||||
#include "entity_state.h"
|
|
||||||
#include "cl_entity.h"
|
|
||||||
#include "pm_shared.h"
|
|
||||||
#include "vgui_TeamFortressViewport.h"
|
|
||||||
#include "vgui_SpectatorPanel.h"
|
|
||||||
#include "vgui_ScorePanel.h"
|
|
||||||
|
|
||||||
#include "Exports.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
==========================
|
|
||||||
HUD_ChatInputPosition
|
|
||||||
|
|
||||||
Sets the location of the input for chat text
|
|
||||||
==========================
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
|
|
||||||
{
|
|
||||||
// RecClChatInputPosition( x, y );
|
|
||||||
|
|
||||||
if ( g_iUser1 != 0 || gEngfuncs.IsSpectateOnly() )
|
|
||||||
{
|
|
||||||
if ( gHUD.m_Spectator.m_pip->value == INSET_OFF )
|
|
||||||
{
|
|
||||||
*y = YRES( PANEL_HEIGHT );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*y = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowHeight + 5 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Construction/Destruction
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SpectatorPanel::SpectatorPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SpectatorPanel::~SpectatorPanel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpectatorPanel::ActionSignal(int cmd)
|
|
||||||
{
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case SPECTATOR_PANEL_CMD_NONE : break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_OPTIONS : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorOptionsMenu );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_NEXTPLAYER : gHUD.m_Spectator.FindNextPlayer(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_PREVPLAYER : gHUD.m_Spectator.FindNextPlayer(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_PLAYERS : gViewPort->ShowCommandMenu( gViewPort->m_PlayerMenu );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_HIDEMENU : ShowMenu(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_CAMERA : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorCameraMenu );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPECTATOR_PANEL_CMD_TOGGLE_INSET : gHUD.m_Spectator.SetModes( -1,
|
|
||||||
gHUD.m_Spectator.ToggleInset(false) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
default : gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n",cmd); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SpectatorPanel::Initialize()
|
|
||||||
{
|
|
||||||
int x,y,wide,tall;
|
|
||||||
|
|
||||||
getBounds(x,y,wide,tall);
|
|
||||||
|
|
||||||
CSchemeManager * pSchemes = gViewPort->GetSchemeManager();
|
|
||||||
|
|
||||||
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Team Info Text" );
|
|
||||||
|
|
||||||
m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, PANEL_HEIGHT);
|
|
||||||
m_TopBorder->setParent(this);
|
|
||||||
|
|
||||||
m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight - PANEL_HEIGHT, ScreenWidth, PANEL_HEIGHT);
|
|
||||||
m_BottomBorder->setParent(this);
|
|
||||||
|
|
||||||
setPaintBackgroundEnabled(false);
|
|
||||||
|
|
||||||
m_ExtraInfo = new Label( "Extra Info", 0, 0, wide, PANEL_HEIGHT );
|
|
||||||
m_ExtraInfo->setParent(m_TopBorder);
|
|
||||||
m_ExtraInfo->setFont( pSchemes->getFont(hSmallScheme) );
|
|
||||||
|
|
||||||
m_ExtraInfo->setPaintBackgroundEnabled(false);
|
|
||||||
m_ExtraInfo->setFgColor( 143, 143, 54, 0 );
|
|
||||||
m_ExtraInfo->setContentAlignment( vgui::Label::a_west );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_TimerImage = new CImageLabel( "timer", 0, 0, 14, 14 );
|
|
||||||
m_TimerImage->setParent(m_TopBorder);
|
|
||||||
|
|
||||||
m_TopBanner = new CImageLabel( "banner", 0, 0, XRES(BANNER_WIDTH), YRES(BANNER_HEIGHT) );
|
|
||||||
m_TopBanner->setParent(this);
|
|
||||||
|
|
||||||
m_CurrentTime = new Label( "00:00", 0, 0, wide, PANEL_HEIGHT );
|
|
||||||
m_CurrentTime->setParent(m_TopBorder);
|
|
||||||
m_CurrentTime->setFont( pSchemes->getFont(hSmallScheme) );
|
|
||||||
m_CurrentTime->setPaintBackgroundEnabled(false);
|
|
||||||
m_CurrentTime->setFgColor( 143, 143, 54, 0 );
|
|
||||||
m_CurrentTime->setContentAlignment( vgui::Label::a_west );
|
|
||||||
|
|
||||||
m_Separator = new Panel( 0, 0, XRES( 64 ), YRES( 96 ));
|
|
||||||
m_Separator->setParent( m_TopBorder );
|
|
||||||
m_Separator->setFgColor( 59, 58, 34, 48 );
|
|
||||||
m_Separator->setBgColor( 59, 58, 34, 48 );
|
|
||||||
|
|
||||||
for ( int j= 0; j < TEAM_NUMBER; j++ )
|
|
||||||
{
|
|
||||||
m_TeamScores[j] = new Label( " ", 0, 0, wide, PANEL_HEIGHT );
|
|
||||||
m_TeamScores[j]->setParent( m_TopBorder );
|
|
||||||
m_TeamScores[j]->setFont( pSchemes->getFont(hSmallScheme) );
|
|
||||||
m_TeamScores[j]->setPaintBackgroundEnabled(false);
|
|
||||||
m_TeamScores[j]->setFgColor( 143, 143, 54, 0 );
|
|
||||||
m_TeamScores[j]->setContentAlignment( vgui::Label::a_west );
|
|
||||||
m_TeamScores[j]->setVisible ( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize command buttons.
|
|
||||||
// m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
|
|
||||||
m_OptionButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
|
|
||||||
m_OptionButton->setParent( m_BottomBorder );
|
|
||||||
m_OptionButton->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_OptionButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
|
||||||
m_OptionButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_OPTIONS) );
|
|
||||||
m_OptionButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_OptionButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_OptionButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_OptionButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
m_CamButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#CAM_OPTIONS" ), ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ), YRES(6), XRES ( CAMOPTIONS_BUTTON_X ), YRES(20), false, false );
|
|
||||||
m_CamButton->setParent( m_BottomBorder );
|
|
||||||
m_CamButton->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_CamButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
|
||||||
m_CamButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_CAMERA ) );
|
|
||||||
m_CamButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_CamButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_CamButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_CamButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
// m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
|
|
||||||
m_PrevPlayerButton= new CImageButton("arrowleft", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
|
|
||||||
m_PrevPlayerButton->setParent( m_BottomBorder );
|
|
||||||
m_PrevPlayerButton->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_PrevPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
|
||||||
m_PrevPlayerButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PREVPLAYER) );
|
|
||||||
m_PrevPlayerButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_PrevPlayerButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_PrevPlayerButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_PrevPlayerButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
// m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
|
|
||||||
m_NextPlayerButton= new CImageButton("arrowright", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
|
|
||||||
m_NextPlayerButton->setParent( m_BottomBorder );
|
|
||||||
m_NextPlayerButton->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_NextPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
|
||||||
m_NextPlayerButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_NEXTPLAYER) );
|
|
||||||
m_NextPlayerButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_NextPlayerButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_NextPlayerButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_NextPlayerButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
// Initialize the bottom title.
|
|
||||||
|
|
||||||
float flLabelSize = ( (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ) ) - XRES( (15 + OPTIONS_BUTTON_X + 15) + 38 );
|
|
||||||
|
|
||||||
m_BottomMainButton = new DropDownButton("Spectator Bottom",
|
|
||||||
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20),
|
|
||||||
false, false );
|
|
||||||
|
|
||||||
m_BottomMainButton->setParent(m_BottomBorder);
|
|
||||||
m_BottomMainButton->setPaintBackgroundEnabled(false);
|
|
||||||
m_BottomMainButton->setFgColor( Scheme::sc_primary1 );
|
|
||||||
m_BottomMainButton->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_BottomMainButton->setBorder( new LineBorder( Color( 59, 58, 34, 48 ) ) );
|
|
||||||
m_BottomMainButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
|
||||||
m_BottomMainButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PLAYERS) );
|
|
||||||
m_BottomMainButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_BottomMainButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_BottomMainButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_BottomMainButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
|
|
||||||
m_BottomMainLabel = new Label("Spectator Bottom",
|
|
||||||
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20));
|
|
||||||
|
|
||||||
m_BottomMainLabel->setParent(m_BottomBorder);
|
|
||||||
m_BottomMainLabel->setPaintBackgroundEnabled(false);
|
|
||||||
m_BottomMainLabel->setFgColor( Scheme::sc_primary1 );
|
|
||||||
m_BottomMainLabel->setContentAlignment( vgui::Label::a_center );
|
|
||||||
m_BottomMainLabel->setBorder( NULL );
|
|
||||||
m_BottomMainLabel->setVisible(false);
|
|
||||||
|
|
||||||
m_InsetViewButton = new ColorButton("", XRES(2), YRES(2), XRES(240), YRES(180), false, false );
|
|
||||||
m_InsetViewButton->setParent( this );
|
|
||||||
m_InsetViewButton->setBoundKey( (char)255 );
|
|
||||||
m_InsetViewButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_TOGGLE_INSET) );
|
|
||||||
m_InsetViewButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
|
||||||
m_InsetViewButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
|
||||||
m_InsetViewButton->setUnArmedColor ( 143, 143, 54, 0 );
|
|
||||||
m_InsetViewButton->setArmedColor ( 194, 202, 54, 0 );
|
|
||||||
|
|
||||||
|
|
||||||
m_menuVisible = false;
|
|
||||||
m_insetVisible = false;
|
|
||||||
// m_HideButton->setVisible(false);
|
|
||||||
m_CamButton->setVisible(false);
|
|
||||||
m_OptionButton->setVisible(false);
|
|
||||||
m_NextPlayerButton->setVisible(false);
|
|
||||||
m_PrevPlayerButton->setVisible(false);
|
|
||||||
m_TopBanner->setVisible( false );
|
|
||||||
m_ExtraInfo->setVisible( false );
|
|
||||||
m_Separator->setVisible( false );
|
|
||||||
m_TimerImage->setVisible( false );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpectatorPanel::ShowMenu(bool isVisible)
|
|
||||||
{
|
|
||||||
// m_HideButton->setVisible(isVisible); m_HideButton->setArmed( false );
|
|
||||||
m_OptionButton->setVisible(isVisible); m_OptionButton->setArmed( false );
|
|
||||||
m_CamButton->setVisible(isVisible); m_CamButton->setArmed( false );
|
|
||||||
m_NextPlayerButton->setVisible(isVisible); m_NextPlayerButton->setArmed( false );
|
|
||||||
m_PrevPlayerButton->setVisible(isVisible); m_PrevPlayerButton->setArmed( false );
|
|
||||||
|
|
||||||
if ( !isVisible )
|
|
||||||
{
|
|
||||||
int iLabelSizeX, iLabelSizeY;
|
|
||||||
m_BottomMainLabel->setVisible(true);
|
|
||||||
m_BottomMainButton->setVisible(false);
|
|
||||||
|
|
||||||
m_BottomMainLabel->getSize( iLabelSizeX, iLabelSizeY );
|
|
||||||
m_BottomMainLabel->setPos( ( ScreenWidth / 2 ) - (iLabelSizeX/2), YRES(6) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_BottomMainButton->setPos( XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6) );
|
|
||||||
m_BottomMainLabel->setVisible(false);
|
|
||||||
m_BottomMainButton->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !isVisible )
|
|
||||||
{
|
|
||||||
gViewPort->HideCommandMenu();
|
|
||||||
|
|
||||||
// if switching from visible menu to invisible menu, show help text
|
|
||||||
if ( m_menuVisible && this->isVisible() )
|
|
||||||
{
|
|
||||||
char string[ 64 ];
|
|
||||||
|
|
||||||
_snprintf( string, sizeof( string ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
|
|
||||||
string[ sizeof( string ) - 1 ] = '\0';
|
|
||||||
|
|
||||||
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_menuVisible = isVisible;
|
|
||||||
|
|
||||||
gViewPort->UpdateCursorState();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char *GetSpectatorLabel ( int iMode )
|
|
||||||
{
|
|
||||||
switch ( iMode )
|
|
||||||
{
|
|
||||||
case OBS_CHASE_LOCKED:
|
|
||||||
return "#OBS_CHASE_LOCKED";
|
|
||||||
|
|
||||||
case OBS_CHASE_FREE:
|
|
||||||
return "#OBS_CHASE_FREE";
|
|
||||||
|
|
||||||
case OBS_ROAMING:
|
|
||||||
return "#OBS_ROAMING";
|
|
||||||
|
|
||||||
case OBS_IN_EYE:
|
|
||||||
return "#OBS_IN_EYE";
|
|
||||||
|
|
||||||
case OBS_MAP_FREE:
|
|
||||||
return "#OBS_MAP_FREE";
|
|
||||||
|
|
||||||
case OBS_MAP_CHASE:
|
|
||||||
return "#OBS_MAP_CHASE";
|
|
||||||
|
|
||||||
case OBS_NONE:
|
|
||||||
default:
|
|
||||||
return "#OBS_NONE";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpectatorPanel::EnableInsetView(bool isEnabled)
|
|
||||||
{
|
|
||||||
int x = gHUD.m_Spectator.m_OverviewData.insetWindowX;
|
|
||||||
int y = gHUD.m_Spectator.m_OverviewData.insetWindowY;
|
|
||||||
int wide = gHUD.m_Spectator.m_OverviewData.insetWindowWidth;
|
|
||||||
int tall = gHUD.m_Spectator.m_OverviewData.insetWindowHeight;
|
|
||||||
int offset = x + wide + 2;
|
|
||||||
|
|
||||||
if ( isEnabled )
|
|
||||||
{
|
|
||||||
// short black bar to see full inset
|
|
||||||
m_TopBorder->setBounds( XRES(offset), 0, XRES(640 - offset ), PANEL_HEIGHT );
|
|
||||||
|
|
||||||
if ( gEngfuncs.IsSpectateOnly() )
|
|
||||||
{
|
|
||||||
m_TopBanner->setVisible( true );
|
|
||||||
m_TopBanner->setPos( XRES(offset), 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_TopBanner->setVisible( false );
|
|
||||||
|
|
||||||
m_InsetViewButton->setBounds( XRES( x -1 ), YRES( y ),
|
|
||||||
XRES( wide +2), YRES( tall ) );
|
|
||||||
m_InsetViewButton->setVisible(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// full black bar, no inset border
|
|
||||||
// show banner only in real HLTV mode
|
|
||||||
if ( gEngfuncs.IsSpectateOnly() )
|
|
||||||
{
|
|
||||||
m_TopBanner->setVisible( true );
|
|
||||||
m_TopBanner->setPos( 0,0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_TopBanner->setVisible( false );
|
|
||||||
|
|
||||||
m_TopBorder->setBounds( 0, 0, ScreenWidth, PANEL_HEIGHT );
|
|
||||||
|
|
||||||
m_InsetViewButton->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_insetVisible = isEnabled;
|
|
||||||
|
|
||||||
Update();
|
|
||||||
|
|
||||||
m_CamButton->setText( CHudTextMessage::BufferedLocaliseTextString( GetSpectatorLabel( g_iUser1 ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SpectatorPanel::Update()
|
|
||||||
{
|
|
||||||
int iTextWidth, iTextHeight;
|
|
||||||
int iTimeHeight, iTimeWidth;
|
|
||||||
int offset,j;
|
|
||||||
|
|
||||||
if ( m_insetVisible )
|
|
||||||
offset = gHUD.m_Spectator.m_OverviewData.insetWindowX + gHUD.m_Spectator.m_OverviewData.insetWindowWidth + 2;
|
|
||||||
else
|
|
||||||
offset = 0;
|
|
||||||
|
|
||||||
bool visible = gHUD.m_Spectator.m_drawstatus->value != 0;
|
|
||||||
|
|
||||||
m_ExtraInfo->setVisible( visible );
|
|
||||||
m_TimerImage->setVisible( visible );
|
|
||||||
m_CurrentTime->setVisible( visible );
|
|
||||||
m_Separator->setVisible( visible );
|
|
||||||
|
|
||||||
for ( j= 0; j < TEAM_NUMBER; j++ )
|
|
||||||
m_TeamScores[j]->setVisible( visible );
|
|
||||||
|
|
||||||
if ( !visible )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_ExtraInfo->getTextSize( iTextWidth, iTextHeight );
|
|
||||||
m_CurrentTime->getTextSize( iTimeWidth, iTimeHeight );
|
|
||||||
|
|
||||||
iTimeWidth += XRES ( SEPERATOR_WIDTH*2 + 1 ); // +timer icon
|
|
||||||
iTimeWidth += ( SEPERATOR_WIDTH-(iTimeWidth%SEPERATOR_WIDTH) );
|
|
||||||
|
|
||||||
if ( iTimeWidth > iTextWidth )
|
|
||||||
iTextWidth = iTimeWidth;
|
|
||||||
|
|
||||||
int xPos = ScreenWidth - ( iTextWidth + XRES ( SEPERATOR_WIDTH + offset ) );
|
|
||||||
|
|
||||||
m_ExtraInfo->setBounds( xPos, YRES( SEPERATOR_HEIGHT ), iTextWidth, iTextHeight );
|
|
||||||
|
|
||||||
m_TimerImage->setBounds( xPos, YRES( SEPERATOR_HEIGHT ) + iTextHeight , XRES(SEPERATOR_WIDTH*2 + 1), YRES(SEPERATOR_HEIGHT + 1) );
|
|
||||||
|
|
||||||
m_CurrentTime->setBounds( xPos + XRES ( SEPERATOR_WIDTH*2 + 1 ), YRES( SEPERATOR_HEIGHT ) + iTextHeight , iTimeWidth, iTimeHeight );
|
|
||||||
|
|
||||||
m_Separator->setPos( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+SEPERATOR_WIDTH/2+offset ) ) , YRES( 5 ) );
|
|
||||||
m_Separator->setSize( XRES( 1 ), PANEL_HEIGHT - 10 );
|
|
||||||
|
|
||||||
for ( j= 0; j < TEAM_NUMBER; j++ )
|
|
||||||
{
|
|
||||||
int iwidth, iheight;
|
|
||||||
|
|
||||||
m_TeamScores[j]->getTextSize( iwidth, iheight );
|
|
||||||
m_TeamScores[j]->setBounds( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+2*SEPERATOR_WIDTH/2+offset ) + iwidth ), YRES( SEPERATOR_HEIGHT ) + ( iheight * j ), iwidth, iheight );
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue