20 Mar 2011
This commit is contained in:
parent
1b476deab0
commit
f917c776a7
|
@ -108,10 +108,9 @@ void VGui_Startup()
|
|||
gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall());
|
||||
gViewPort->setParent(root);
|
||||
}
|
||||
/*
|
||||
|
||||
TexturePanel* texturePanel=new TexturePanel();
|
||||
texturePanel->setParent(gViewPort);
|
||||
*/
|
||||
}
|
||||
|
||||
void VGui_Shutdown()
|
||||
|
|
|
@ -598,18 +598,12 @@ void R_ShowTextures( void )
|
|||
pglClear( GL_COLOR_BUFFER_BIT );
|
||||
pglFinish();
|
||||
|
||||
if( gl_showtextures->integer == TEX_LIGHTMAP )
|
||||
if( gl_showtextures->integer == TEX_LIGHTMAP || gl_showtextures->integer == TEX_VGUI )
|
||||
{
|
||||
// draw lightmaps as big images
|
||||
base_w = 5;
|
||||
base_h = 4;
|
||||
}
|
||||
else if( gl_showtextures->integer == TEX_VGUI )
|
||||
{
|
||||
// draw lightmaps as big images
|
||||
base_w = 4;
|
||||
base_h = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
base_w = 16;
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2011 ©
|
||||
// vgui_draw.h - vgui draw methods
|
||||
//=======================================================================
|
||||
#ifndef FONT_CACHE_H
|
||||
#define FONT_CACHE_H
|
||||
|
||||
#include "utlvector.h"
|
||||
#include "utlrbtree.h"
|
||||
|
||||
#include<VGUI.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_Cursor.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
#include<VGUI_App.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class FontCache
|
||||
{
|
||||
public:
|
||||
FontCache();
|
||||
~FontCache() { }
|
||||
|
||||
// returns a texture ID and a pointer to an array of 4 texture coords for the given character & font
|
||||
// uploads more texture if necessary
|
||||
bool GetTextureForChar( Font *font, char ch, int *textureID, float **texCoords );
|
||||
private:
|
||||
// NOTE: If you change this, change s_pFontPageSize
|
||||
enum
|
||||
{
|
||||
FONT_PAGE_SIZE_16,
|
||||
FONT_PAGE_SIZE_32,
|
||||
FONT_PAGE_SIZE_64,
|
||||
FONT_PAGE_SIZE_128,
|
||||
FONT_PAGE_SIZE_COUNT,
|
||||
};
|
||||
|
||||
// a single character in the cache
|
||||
typedef unsigned short HCacheEntry;
|
||||
struct CacheEntry_t
|
||||
{
|
||||
Font *font;
|
||||
char ch;
|
||||
byte page;
|
||||
float texCoords[4];
|
||||
|
||||
HCacheEntry nextEntry; // doubly-linked list for use in the LRU
|
||||
HCacheEntry prevEntry;
|
||||
};
|
||||
|
||||
// a single texture page
|
||||
struct Page_t
|
||||
{
|
||||
short textureID;
|
||||
short fontHeight;
|
||||
short wide, tall; // total size of the page
|
||||
short nextX, nextY; // position to draw any new character positions
|
||||
};
|
||||
|
||||
// allocates a new page for a given character
|
||||
bool AllocatePageForChar( int charWide, int charTall, int &pageIndex, int &drawX, int &drawY, int &twide, int &ttall );
|
||||
|
||||
// Computes the page size given a character height
|
||||
int ComputePageType( int charTall ) const;
|
||||
|
||||
static bool CacheEntryLessFunc( const CacheEntry_t &lhs, const CacheEntry_t &rhs );
|
||||
|
||||
// cache
|
||||
typedef CUtlVector<Page_t> FontPageList_t;
|
||||
|
||||
CUtlRBTree<CacheEntry_t, HCacheEntry> m_CharCache;
|
||||
FontPageList_t m_PageList;
|
||||
int m_pCurrPage[FONT_PAGE_SIZE_COUNT];
|
||||
HCacheEntry m_LRUListHeadIndex;
|
||||
|
||||
static int s_pFontPageSize[FONT_PAGE_SIZE_COUNT];
|
||||
};
|
||||
|
||||
#endif//FONT_CACHE_H
|
|
@ -93,7 +93,7 @@ void VGUI_CreateTexture( int id, int width, int height )
|
|||
r_image.height = height;
|
||||
r_image.type = PF_RGBA_32;
|
||||
r_image.size = r_image.width * r_image.height * 4;
|
||||
r_image.flags = IMAGE_HAS_COLOR;
|
||||
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
|
||||
r_image.buffer = NULL;
|
||||
|
||||
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE, false );
|
||||
|
@ -113,30 +113,31 @@ void VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, in
|
|||
g_iBoundTexture = id;
|
||||
}
|
||||
|
||||
void VGUI_SetupDrawingRect( byte *pColor )
|
||||
void VGUI_SetupDrawingRect( int *pColor )
|
||||
{
|
||||
pglEnable( GL_BLEND );
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglBlendFunc( GL_ONE, GL_SRC_ALPHA );
|
||||
pglColor4ub( pColor[0], pColor[1], pColor[2], pColor[3] );
|
||||
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
|
||||
}
|
||||
|
||||
void VGUI_SetupDrawingText( byte *pColor )
|
||||
void VGUI_SetupDrawingText( int *pColor )
|
||||
{
|
||||
pglEnable( GL_BLEND );
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglBlendFunc( GL_ONE, GL_SRC_ALPHA );
|
||||
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 );
|
||||
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
}
|
||||
|
||||
void VGUI_SetupDrawingImage( void )
|
||||
void VGUI_SetupDrawingImage( int *pColor )
|
||||
{
|
||||
pglDisable( GL_BLEND );
|
||||
pglEnable( GL_BLEND );
|
||||
pglEnable( GL_ALPHA_TEST );
|
||||
pglAlphaFunc( GL_GEQUAL, 0.5f );
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
||||
pglColor4ub( 255, 255, 255, 255 );
|
||||
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
|
||||
}
|
||||
|
||||
void VGUI_BindTexture( int id )
|
||||
|
|
|
@ -23,17 +23,19 @@ typedef struct
|
|||
//
|
||||
|
||||
void VGUI_DrawInit( void );
|
||||
void VGUI_SetupDrawingText( byte *pColor );
|
||||
void VGUI_SetupDrawingRect( byte *pColor );
|
||||
void VGUI_SetupDrawingImage( void );
|
||||
void VGUI_SetupDrawingText( int *pColor );
|
||||
void VGUI_SetupDrawingRect( int *pColor );
|
||||
void VGUI_SetupDrawingImage( int *pColor );
|
||||
void VGUI_BindTexture( int id );
|
||||
void VGUI_EnableTexture( qboolean enable );
|
||||
void VGUI_CreateTexture( int id, int width, int height );
|
||||
void VGUI_UploadTexture( int id, const char *buffer, int width, int height );
|
||||
void VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight );
|
||||
long VGUI_SurfaceWndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
void VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr );
|
||||
void VGUI_GetTextureSizes( int *width, int *height );
|
||||
int VGUI_GenerateTexture( void );
|
||||
void *VGui_GetPanel( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
void EnableScissor( qboolean enable );
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "font_cache.h"
|
||||
#include "vgui_main.h"
|
||||
|
||||
int FontCache::s_pFontPageSize[FONT_PAGE_SIZE_COUNT] = { 16, 32, 64, 128 };
|
||||
|
||||
|
|
|
@ -0,0 +1,292 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2011 ©
|
||||
// vgui_input.cpp - handle kb & mouse
|
||||
//=======================================================================
|
||||
|
||||
#define OEMRESOURCE // for OCR_* cursor junk
|
||||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "vgui_main.h"
|
||||
#include "input.h"
|
||||
|
||||
static KeyCode s_pVirtualKeyTrans[256];
|
||||
static HICON s_pDefaultCursor[20];
|
||||
static HICON s_hCurrentCursor = NULL;
|
||||
|
||||
void VGUI_InitCursors( void )
|
||||
{
|
||||
// load up all default cursors
|
||||
s_pDefaultCursor[Cursor::dc_none] = NULL;
|
||||
s_pDefaultCursor[Cursor::dc_arrow] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_NORMAL );
|
||||
s_pDefaultCursor[Cursor::dc_ibeam] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_IBEAM );
|
||||
s_pDefaultCursor[Cursor::dc_hourglass]= (HICON)LoadCursor( NULL, (LPCTSTR)OCR_WAIT );
|
||||
s_pDefaultCursor[Cursor::dc_crosshair]= (HICON)LoadCursor( NULL, (LPCTSTR)OCR_CROSS );
|
||||
s_pDefaultCursor[Cursor::dc_up] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_UP );
|
||||
s_pDefaultCursor[Cursor::dc_sizenwse] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_SIZENWSE );
|
||||
s_pDefaultCursor[Cursor::dc_sizenesw] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_SIZENESW );
|
||||
s_pDefaultCursor[Cursor::dc_sizewe] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_SIZEWE );
|
||||
s_pDefaultCursor[Cursor::dc_sizens] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_SIZENS );
|
||||
s_pDefaultCursor[Cursor::dc_sizeall] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_SIZEALL );
|
||||
s_pDefaultCursor[Cursor::dc_no] = (HICON)LoadCursor( NULL, (LPCTSTR)OCR_NO );
|
||||
s_pDefaultCursor[Cursor::dc_hand] = (HICON)LoadCursor( NULL, (LPCTSTR)32649 );
|
||||
|
||||
host.mouse_visible = true;
|
||||
s_hCurrentCursor = s_pDefaultCursor[Cursor::dc_arrow];
|
||||
}
|
||||
|
||||
void VGUI_CursorSelect( Cursor *cursor )
|
||||
{
|
||||
Assert( cursor != NULL );
|
||||
|
||||
host.mouse_visible = true;
|
||||
|
||||
switch( cursor->getDefaultCursor( ))
|
||||
{
|
||||
case Cursor::dc_user:
|
||||
case Cursor::dc_none:
|
||||
host.mouse_visible = false;
|
||||
break;
|
||||
case Cursor::dc_arrow:
|
||||
case Cursor::dc_ibeam:
|
||||
case Cursor::dc_hourglass:
|
||||
case Cursor::dc_crosshair:
|
||||
case Cursor::dc_up:
|
||||
case Cursor::dc_sizenwse:
|
||||
case Cursor::dc_sizenesw:
|
||||
case Cursor::dc_sizewe:
|
||||
case Cursor::dc_sizens:
|
||||
case Cursor::dc_sizeall:
|
||||
case Cursor::dc_no:
|
||||
case Cursor::dc_hand:
|
||||
s_hCurrentCursor = s_pDefaultCursor[cursor->getDefaultCursor()];
|
||||
break;
|
||||
default:
|
||||
host.mouse_visible = false;
|
||||
Assert( 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
VGUI_ActivateCurrentCursor();
|
||||
}
|
||||
|
||||
void VGUI_ActivateCurrentCursor( void )
|
||||
{
|
||||
if( cls.key_dest != key_game )
|
||||
return;
|
||||
|
||||
if( host.mouse_visible )
|
||||
{
|
||||
while( ShowCursor( true ) < 0 );
|
||||
SetCursor( s_hCurrentCursor );
|
||||
}
|
||||
else
|
||||
{
|
||||
while( ShowCursor( false ) >= 0 );
|
||||
SetCursor( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
void VGUI_InitKeyTranslationTable( void )
|
||||
{
|
||||
static bool bInitted = false;
|
||||
|
||||
if( bInitted ) return;
|
||||
bInitted = true;
|
||||
|
||||
// set virtual key translation table
|
||||
Q_memset( s_pVirtualKeyTrans, -1, sizeof( s_pVirtualKeyTrans ));
|
||||
|
||||
s_pVirtualKeyTrans['0'] = KEY_0;
|
||||
s_pVirtualKeyTrans['1'] = KEY_1;
|
||||
s_pVirtualKeyTrans['2'] = KEY_2;
|
||||
s_pVirtualKeyTrans['3'] = KEY_3;
|
||||
s_pVirtualKeyTrans['4'] = KEY_4;
|
||||
s_pVirtualKeyTrans['5'] = KEY_5;
|
||||
s_pVirtualKeyTrans['6'] = KEY_6;
|
||||
s_pVirtualKeyTrans['7'] = KEY_7;
|
||||
s_pVirtualKeyTrans['8'] = KEY_8;
|
||||
s_pVirtualKeyTrans['9'] = KEY_9;
|
||||
s_pVirtualKeyTrans['A'] = s_pVirtualKeyTrans['a'] = KEY_A;
|
||||
s_pVirtualKeyTrans['B'] = s_pVirtualKeyTrans['b'] = KEY_B;
|
||||
s_pVirtualKeyTrans['C'] = s_pVirtualKeyTrans['c'] = KEY_C;
|
||||
s_pVirtualKeyTrans['D'] = s_pVirtualKeyTrans['d'] = KEY_D;
|
||||
s_pVirtualKeyTrans['E'] = s_pVirtualKeyTrans['e'] = KEY_E;
|
||||
s_pVirtualKeyTrans['F'] = s_pVirtualKeyTrans['f'] = KEY_F;
|
||||
s_pVirtualKeyTrans['G'] = s_pVirtualKeyTrans['g'] = KEY_G;
|
||||
s_pVirtualKeyTrans['H'] = s_pVirtualKeyTrans['h'] = KEY_H;
|
||||
s_pVirtualKeyTrans['I'] = s_pVirtualKeyTrans['i'] = KEY_I;
|
||||
s_pVirtualKeyTrans['J'] = s_pVirtualKeyTrans['j'] = KEY_J;
|
||||
s_pVirtualKeyTrans['K'] = s_pVirtualKeyTrans['k'] = KEY_K;
|
||||
s_pVirtualKeyTrans['L'] = s_pVirtualKeyTrans['l'] = KEY_L;
|
||||
s_pVirtualKeyTrans['M'] = s_pVirtualKeyTrans['m'] = KEY_M;
|
||||
s_pVirtualKeyTrans['N'] = s_pVirtualKeyTrans['n'] = KEY_N;
|
||||
s_pVirtualKeyTrans['O'] = s_pVirtualKeyTrans['o'] = KEY_O;
|
||||
s_pVirtualKeyTrans['P'] = s_pVirtualKeyTrans['p'] = KEY_P;
|
||||
s_pVirtualKeyTrans['Q'] = s_pVirtualKeyTrans['q'] = KEY_Q;
|
||||
s_pVirtualKeyTrans['R'] = s_pVirtualKeyTrans['r'] = KEY_R;
|
||||
s_pVirtualKeyTrans['S'] = s_pVirtualKeyTrans['s'] = KEY_S;
|
||||
s_pVirtualKeyTrans['T'] = s_pVirtualKeyTrans['t'] = KEY_T;
|
||||
s_pVirtualKeyTrans['U'] = s_pVirtualKeyTrans['u'] = KEY_U;
|
||||
s_pVirtualKeyTrans['V'] = s_pVirtualKeyTrans['v'] = KEY_V;
|
||||
s_pVirtualKeyTrans['W'] = s_pVirtualKeyTrans['w'] = KEY_W;
|
||||
s_pVirtualKeyTrans['X'] = s_pVirtualKeyTrans['x'] = KEY_X;
|
||||
s_pVirtualKeyTrans['Y'] = s_pVirtualKeyTrans['y'] = KEY_Y;
|
||||
s_pVirtualKeyTrans['Z'] = s_pVirtualKeyTrans['z'] = KEY_Z;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD0] = KEY_PAD_0;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD1] = KEY_PAD_1;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD2] = KEY_PAD_2;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD3] = KEY_PAD_3;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD4] = KEY_PAD_4;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD5] = KEY_PAD_5;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD6] = KEY_PAD_6;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD7] = KEY_PAD_7;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD8] = KEY_PAD_8;
|
||||
s_pVirtualKeyTrans[VK_NUMPAD9] = KEY_PAD_9;
|
||||
s_pVirtualKeyTrans[VK_DIVIDE] = KEY_PAD_DIVIDE;
|
||||
s_pVirtualKeyTrans[VK_MULTIPLY] = KEY_PAD_MULTIPLY;
|
||||
s_pVirtualKeyTrans[VK_SUBTRACT] = KEY_PAD_MINUS;
|
||||
s_pVirtualKeyTrans[VK_ADD] = KEY_PAD_PLUS;
|
||||
s_pVirtualKeyTrans[VK_RETURN] = KEY_PAD_ENTER;
|
||||
s_pVirtualKeyTrans[VK_DECIMAL] = KEY_PAD_DECIMAL;
|
||||
s_pVirtualKeyTrans[0xdb] = KEY_LBRACKET;
|
||||
s_pVirtualKeyTrans[0xdd] = KEY_RBRACKET;
|
||||
s_pVirtualKeyTrans[0xba] = KEY_SEMICOLON;
|
||||
s_pVirtualKeyTrans[0xde] = KEY_APOSTROPHE;
|
||||
s_pVirtualKeyTrans[0xc0] = KEY_BACKQUOTE;
|
||||
s_pVirtualKeyTrans[0xbc] = KEY_COMMA;
|
||||
s_pVirtualKeyTrans[0xbe] = KEY_PERIOD;
|
||||
s_pVirtualKeyTrans[0xbf] = KEY_SLASH;
|
||||
s_pVirtualKeyTrans[0xdc] = KEY_BACKSLASH;
|
||||
s_pVirtualKeyTrans[0xbd] = KEY_MINUS;
|
||||
s_pVirtualKeyTrans[0xbb] = KEY_EQUAL;
|
||||
s_pVirtualKeyTrans[VK_RETURN] = KEY_ENTER;
|
||||
s_pVirtualKeyTrans[VK_SPACE] = KEY_SPACE;
|
||||
s_pVirtualKeyTrans[VK_BACK] = KEY_BACKSPACE;
|
||||
s_pVirtualKeyTrans[VK_TAB] = KEY_TAB;
|
||||
s_pVirtualKeyTrans[VK_CAPITAL] = KEY_CAPSLOCK;
|
||||
s_pVirtualKeyTrans[VK_NUMLOCK] = KEY_NUMLOCK;
|
||||
s_pVirtualKeyTrans[VK_ESCAPE] = KEY_ESCAPE;
|
||||
s_pVirtualKeyTrans[VK_SCROLL] = KEY_SCROLLLOCK;
|
||||
s_pVirtualKeyTrans[VK_INSERT] = KEY_INSERT;
|
||||
s_pVirtualKeyTrans[VK_DELETE] = KEY_DELETE;
|
||||
s_pVirtualKeyTrans[VK_HOME] = KEY_HOME;
|
||||
s_pVirtualKeyTrans[VK_END] = KEY_END;
|
||||
s_pVirtualKeyTrans[VK_PRIOR] = KEY_PAGEUP;
|
||||
s_pVirtualKeyTrans[VK_NEXT] = KEY_PAGEDOWN;
|
||||
s_pVirtualKeyTrans[VK_PAUSE] = KEY_BREAK;
|
||||
s_pVirtualKeyTrans[VK_SHIFT] = KEY_RSHIFT;
|
||||
s_pVirtualKeyTrans[VK_SHIFT] = KEY_LSHIFT; // SHIFT -> left SHIFT
|
||||
s_pVirtualKeyTrans[VK_MENU] = KEY_RALT;
|
||||
s_pVirtualKeyTrans[VK_MENU] = KEY_LALT; // ALT -> left ALT
|
||||
s_pVirtualKeyTrans[VK_CONTROL] = KEY_RCONTROL;
|
||||
s_pVirtualKeyTrans[VK_CONTROL] = KEY_LCONTROL; // CTRL -> left CTRL
|
||||
s_pVirtualKeyTrans[VK_LWIN] = KEY_LWIN;
|
||||
s_pVirtualKeyTrans[VK_RWIN] = KEY_RWIN;
|
||||
s_pVirtualKeyTrans[VK_APPS] = KEY_APP;
|
||||
s_pVirtualKeyTrans[VK_UP] = KEY_UP;
|
||||
s_pVirtualKeyTrans[VK_LEFT] = KEY_LEFT;
|
||||
s_pVirtualKeyTrans[VK_DOWN] = KEY_DOWN;
|
||||
s_pVirtualKeyTrans[VK_RIGHT] = KEY_RIGHT;
|
||||
s_pVirtualKeyTrans[VK_F1] = KEY_F1;
|
||||
s_pVirtualKeyTrans[VK_F2] = KEY_F2;
|
||||
s_pVirtualKeyTrans[VK_F3] = KEY_F3;
|
||||
s_pVirtualKeyTrans[VK_F4] = KEY_F4;
|
||||
s_pVirtualKeyTrans[VK_F5] = KEY_F5;
|
||||
s_pVirtualKeyTrans[VK_F6] = KEY_F6;
|
||||
s_pVirtualKeyTrans[VK_F7] = KEY_F7;
|
||||
s_pVirtualKeyTrans[VK_F8] = KEY_F8;
|
||||
s_pVirtualKeyTrans[VK_F9] = KEY_F9;
|
||||
s_pVirtualKeyTrans[VK_F10] = KEY_F10;
|
||||
s_pVirtualKeyTrans[VK_F11] = KEY_F11;
|
||||
s_pVirtualKeyTrans[VK_F12] = KEY_F12;
|
||||
}
|
||||
|
||||
KeyCode VGUI_MapKey( int keyCode )
|
||||
{
|
||||
VGUI_InitKeyTranslationTable();
|
||||
|
||||
if( keyCode < 0 || keyCode >= sizeof( s_pVirtualKeyTrans ) / sizeof( s_pVirtualKeyTrans[0] ))
|
||||
{
|
||||
Assert( false );
|
||||
return (KeyCode)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return s_pVirtualKeyTrans[keyCode];
|
||||
}
|
||||
}
|
||||
|
||||
long VGUI_SurfaceWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
SurfaceBase *surface = NULL;
|
||||
CEnginePanel *panel = NULL;
|
||||
App *pApp= NULL;
|
||||
|
||||
if( !VGui_GetPanel( ))
|
||||
return 0;
|
||||
|
||||
panel = (CEnginePanel *)VGui_GetPanel();
|
||||
surface = panel->getSurfaceBase();
|
||||
pApp = panel->getApp();
|
||||
|
||||
ASSERT( pApp != NULL );
|
||||
ASSERT( surface != NULL );
|
||||
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_SETCURSOR:
|
||||
VGUI_ActivateCurrentCursor();
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
pApp->internalCursorMoved((short)LOWORD( lParam ), (short)HIWORD( lParam ), surface );
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
pApp->internalMousePressed( MOUSE_LEFT, surface );
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
pApp->internalMousePressed( MOUSE_RIGHT, surface );
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
pApp->internalMousePressed( MOUSE_MIDDLE, surface );
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
pApp->internalMouseReleased( MOUSE_LEFT, surface );
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
pApp->internalMouseReleased( MOUSE_RIGHT, surface );
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
pApp->internalMouseReleased( MOUSE_MIDDLE, surface );
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
pApp->internalMouseDoublePressed( MOUSE_LEFT, surface );
|
||||
break;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
pApp->internalMouseDoublePressed( MOUSE_RIGHT, surface );
|
||||
break;
|
||||
case WM_MBUTTONDBLCLK:
|
||||
pApp->internalMouseDoublePressed( MOUSE_MIDDLE, surface );
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
pApp->internalMouseWheeled(((short)HIWORD( wParam )) / 120, surface );
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
if(!( lParam & ( 1 << 30 )))
|
||||
pApp->internalKeyPressed( VGUI_MapKey( wParam ), surface );
|
||||
else pApp->internalKeyTyped( VGUI_MapKey( wParam ), surface );
|
||||
break;
|
||||
case WM_SYSCHAR:
|
||||
case WM_CHAR:
|
||||
pApp->internalKeyTyped( VGUI_MapKey( wParam ), surface );
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
pApp->internalKeyReleased( VGUI_MapKey( wParam ), surface );
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -7,386 +7,45 @@
|
|||
#include "client.h"
|
||||
#include "const.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "font_cache.h"
|
||||
|
||||
static FontCache g_FontCache;
|
||||
|
||||
class CEngineSurface : public SurfaceBase
|
||||
{
|
||||
private:
|
||||
struct paintState_t
|
||||
{
|
||||
Panel *m_pPanel;
|
||||
int iTranslateX;
|
||||
int iTranslateY;
|
||||
int iScissorLeft;
|
||||
int iScissorRight;
|
||||
int iScissorTop;
|
||||
int iScissorBottom;
|
||||
};
|
||||
|
||||
// point translation for current panel
|
||||
int _translateX;
|
||||
int _translateY;
|
||||
|
||||
// the size of the window to draw into
|
||||
int _surfaceExtents[4];
|
||||
|
||||
CUtlVector <paintState_t> _paintStack;
|
||||
|
||||
void SetupPaintState( const paintState_t &paintState )
|
||||
{
|
||||
_translateX = paintState.iTranslateX;
|
||||
_translateY = paintState.iTranslateY;
|
||||
SetScissorRect( paintState.iScissorLeft, paintState.iScissorTop,
|
||||
paintState.iScissorRight, paintState.iScissorBottom );
|
||||
}
|
||||
|
||||
void InitVertex( vpoint_t &vertex, int x, int y, float u, float v )
|
||||
{
|
||||
vertex.point[0] = x + _translateX;
|
||||
vertex.point[1] = y + _translateY;
|
||||
vertex.coord[0] = u;
|
||||
vertex.coord[1] = v;
|
||||
}
|
||||
public:
|
||||
CEngineSurface( Panel *embeddedPanel ):SurfaceBase( embeddedPanel )
|
||||
{
|
||||
_embeddedPanel = embeddedPanel;
|
||||
_drawColor[0] = _drawColor[1] = _drawColor[2] = _drawColor[3] = 255;
|
||||
_drawTextColor[0] = _drawTextColor[1] = _drawTextColor[2] = _drawTextColor[3] = 255;
|
||||
|
||||
// FIXME: this is right?
|
||||
_surfaceExtents[0] = _surfaceExtents[1] = 0;
|
||||
_surfaceExtents[2] = menu.globals->scrWidth;
|
||||
_surfaceExtents[3] = menu.globals->scrHeight;
|
||||
_drawTextPos[0] = _drawTextPos[1] = 0;
|
||||
_hCurrentFont = null;
|
||||
}
|
||||
public:
|
||||
virtual void setTitle( const char *title )
|
||||
{
|
||||
Msg( "SetTitle: %s\n", title );
|
||||
}
|
||||
|
||||
virtual Panel *GetEmbeddedPanel( void )
|
||||
{
|
||||
return _embeddedPanel;
|
||||
}
|
||||
|
||||
virtual bool setFullscreenMode( int wide, int tall, int bpp )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void setWindowedMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void setAsTopMost( bool state )
|
||||
{
|
||||
}
|
||||
|
||||
virtual int getModeInfoCount( void )
|
||||
{
|
||||
Msg( "getModeInfoCount()\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void createPopup( Panel* embeddedPanel )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool hasFocus( void )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool isWithin( int x, int y )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
virtual int createNewTextureID( void )
|
||||
{
|
||||
return VGUI_GenerateTexture();
|
||||
}
|
||||
|
||||
virtual void drawSetColor( int r, int g, int b, int a )
|
||||
{
|
||||
_drawColor[0] = (byte)r;
|
||||
_drawColor[1] = (byte)g;
|
||||
_drawColor[2] = (byte)b;
|
||||
_drawColor[3] = (byte)a;
|
||||
}
|
||||
|
||||
virtual void drawSetTextColor( int r, int g, int b, int a )
|
||||
{
|
||||
_drawTextColor[0] = (byte)r;
|
||||
_drawTextColor[1] = (byte)g;
|
||||
_drawTextColor[2] = (byte)b;
|
||||
_drawTextColor[3] = (byte)a;
|
||||
}
|
||||
|
||||
virtual void drawFilledRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
vpoint_t rect[2];
|
||||
vpoint_t clippedRect[2];
|
||||
|
||||
InitVertex( rect[0], x0, y0, 0, 0 );
|
||||
InitVertex( rect[1], x1, y1, 0, 0 );
|
||||
|
||||
// fully clipped?
|
||||
if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
|
||||
return;
|
||||
|
||||
VGUI_SetupDrawingRect( _drawColor );
|
||||
VGUI_EnableTexture( false );
|
||||
VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
|
||||
VGUI_EnableTexture( true );
|
||||
}
|
||||
virtual void drawOutlinedRect( int x0,int y0,int x1,int y1 )
|
||||
{
|
||||
drawFilledRect( x0, y0, x1, y0 + 1 ); // top
|
||||
drawFilledRect( x0, y1 - 1, x1, y1 ); // bottom
|
||||
drawFilledRect( x0, y0 + 1, x0 + 1, y1 - 1 ); // left
|
||||
drawFilledRect( x1 - 1, y0 + 1, x1, y1 - 1 ); // right
|
||||
}
|
||||
|
||||
virtual void drawSetTextFont( Font *font )
|
||||
{
|
||||
_hCurrentFont = font;
|
||||
}
|
||||
|
||||
virtual void drawSetTextPos( int x, int y )
|
||||
{
|
||||
_drawTextPos[0] = x;
|
||||
_drawTextPos[1] = y;
|
||||
}
|
||||
|
||||
virtual void drawPrintText( const char* text, int textLen )
|
||||
{
|
||||
if( !text || !_hCurrentFont )
|
||||
return;
|
||||
|
||||
int x = _drawTextPos[0] + _translateX;
|
||||
int y = _drawTextPos[1] + _translateY;
|
||||
|
||||
int iTall = _hCurrentFont->getTall();
|
||||
|
||||
int iTotalWidth = 0;
|
||||
for( int i = 0; i < textLen; i++ )
|
||||
{
|
||||
char ch = text[i];
|
||||
|
||||
int abcA,abcB,abcC;
|
||||
_hCurrentFont->getCharABCwide( ch, abcA, abcB, abcC );
|
||||
|
||||
iTotalWidth += abcA;
|
||||
int iWide = abcB;
|
||||
|
||||
if( !iswspace( ch ))
|
||||
{
|
||||
// get the character texture from the cache
|
||||
int iTexId = 0;
|
||||
float *texCoords = NULL;
|
||||
|
||||
if( !g_FontCache.GetTextureForChar( _hCurrentFont, ch, &iTexId, &texCoords ))
|
||||
continue;
|
||||
|
||||
Assert( texCoords != NULL );
|
||||
|
||||
vpoint_t ul, lr;
|
||||
|
||||
ul.point[0] = x + iTotalWidth;
|
||||
ul.point[1] = y;
|
||||
lr.point[0] = ul.point[0] + iWide;
|
||||
lr.point[1] = ul.point[1] + iTall;
|
||||
|
||||
// gets at the texture coords for this character in its texture page
|
||||
ul.coord[0] = texCoords[0];
|
||||
ul.coord[1] = texCoords[1];
|
||||
lr.coord[0] = texCoords[2];
|
||||
lr.coord[1] = texCoords[3];
|
||||
|
||||
drawSetTexture( iTexId );
|
||||
VGUI_SetupDrawingText( _drawTextColor );
|
||||
VGUI_DrawQuad( &ul, &lr ); // draw the letter
|
||||
}
|
||||
|
||||
iTotalWidth += iWide + abcC;
|
||||
}
|
||||
|
||||
_drawTextPos[0] += iTotalWidth;
|
||||
}
|
||||
|
||||
virtual void drawSetTextureRGBA( int id, const char* rgba, int wide, int tall )
|
||||
{
|
||||
VGUI_UploadTexture( id, rgba, wide, tall );
|
||||
}
|
||||
|
||||
virtual void drawSetTexture( int id )
|
||||
{
|
||||
VGUI_BindTexture( id );
|
||||
}
|
||||
|
||||
virtual void drawTexturedRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
vpoint_t rect[2];
|
||||
vpoint_t clippedRect[2];
|
||||
|
||||
InitVertex( rect[0], x0, y0, 0, 0 );
|
||||
InitVertex( rect[1], x1, y1, 1, 1 );
|
||||
|
||||
// fully clipped?
|
||||
if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
|
||||
return;
|
||||
|
||||
VGUI_SetupDrawingImage();
|
||||
VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
|
||||
}
|
||||
|
||||
virtual void invalidate( Panel *panel )
|
||||
{
|
||||
// Msg( "invalidate()\n" );
|
||||
}
|
||||
|
||||
virtual bool createPlat()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool recreateContext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void enableMouseCapture(bool state)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void setCursor(Cursor* cursor)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void swapBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void pushMakeCurrent( Panel* panel, bool useInsets )
|
||||
{
|
||||
int inSets[4] = { 0, 0, 0, 0 };
|
||||
int absExtents[4];
|
||||
int clipRect[4];
|
||||
|
||||
if( useInsets )
|
||||
{
|
||||
panel->getInset( inSets[0], inSets[1], inSets[2], inSets[3] );
|
||||
}
|
||||
|
||||
panel->getAbsExtents( absExtents[0], absExtents[1], absExtents[2], absExtents[3] );
|
||||
panel->getClipRect( clipRect[0], clipRect[1], clipRect[2], clipRect[3] );
|
||||
|
||||
int i = _paintStack.AddToTail();
|
||||
paintState_t &paintState = _paintStack[i];
|
||||
paintState.m_pPanel = panel;
|
||||
|
||||
// determine corrected top left origin
|
||||
paintState.iTranslateX = inSets[0] + absExtents[0] - _surfaceExtents[0];
|
||||
paintState.iTranslateY = inSets[1] + absExtents[1] - _surfaceExtents[1];
|
||||
|
||||
// setup clipping rectangle for scissoring
|
||||
paintState.iScissorLeft = clipRect[0] - _surfaceExtents[0];
|
||||
paintState.iScissorTop = clipRect[1] - _surfaceExtents[1];
|
||||
paintState.iScissorRight = clipRect[2] - _surfaceExtents[0];
|
||||
paintState.iScissorBottom = clipRect[3] - _surfaceExtents[1];
|
||||
|
||||
SetupPaintState( paintState );
|
||||
}
|
||||
|
||||
virtual void popMakeCurrent( Panel* panel )
|
||||
{
|
||||
int top = _paintStack.Count() - 1;
|
||||
|
||||
// more pops that pushes?
|
||||
Assert( top >= 0 );
|
||||
|
||||
// didn't pop in reverse order of push?
|
||||
Assert( _paintStack[top].m_pPanel == panel );
|
||||
|
||||
_paintStack.Remove( top );
|
||||
|
||||
if( top > 0 ) SetupPaintState( _paintStack[top-1] );
|
||||
}
|
||||
|
||||
virtual void applyChanges( void )
|
||||
{
|
||||
}
|
||||
protected:
|
||||
Font* _hCurrentFont;
|
||||
int _drawTextPos[2];
|
||||
uchar _drawColor[4];
|
||||
uchar _drawTextColor[4];
|
||||
friend class App;
|
||||
friend class Panel;
|
||||
};
|
||||
|
||||
class CEngineApp : public App
|
||||
{
|
||||
public:
|
||||
CEngineApp( bool externalMain = true ):App( externalMain )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void main( int argc, char* argv[] )
|
||||
{
|
||||
Msg( "App main()\n" );
|
||||
}
|
||||
|
||||
virtual void setCursorPos( int x, int y )
|
||||
{
|
||||
App::setCursorPos( x, y );
|
||||
}
|
||||
|
||||
virtual void getCursorPos( int &x,int &y )
|
||||
{
|
||||
App::getCursorPos( x, y );
|
||||
}
|
||||
virtual App* getApp( void )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
#include "vgui_main.h"
|
||||
|
||||
CEnginePanel *rootpanel = NULL;
|
||||
CEngineSurface *surface = NULL;
|
||||
CEngineApp *pApp = NULL;
|
||||
|
||||
class CEnginePanel : public Panel
|
||||
SurfaceBase* CEnginePanel::getSurfaceBase( void )
|
||||
{
|
||||
public:
|
||||
CEnginePanel()
|
||||
{
|
||||
vgui::Panel();
|
||||
}
|
||||
CEnginePanel( int x, int y, int wide, int tall )
|
||||
{
|
||||
vgui::Panel( x, y, wide, tall );
|
||||
}
|
||||
virtual SurfaceBase* getSurfaceBase( void )
|
||||
{
|
||||
return surface;
|
||||
}
|
||||
virtual App* getApp( void )
|
||||
{
|
||||
return pApp;
|
||||
}
|
||||
friend class Panel;
|
||||
friend class App;
|
||||
friend class SurfaceBase;
|
||||
friend class Image;
|
||||
};
|
||||
return surface;
|
||||
}
|
||||
|
||||
CEnginePanel *rootpanel = NULL;
|
||||
App* CEnginePanel::getApp( void )
|
||||
{
|
||||
return pApp;
|
||||
}
|
||||
|
||||
void CEngineApp :: setCursorPos( int x, int y )
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
pt.x = x;
|
||||
pt.y = y;
|
||||
|
||||
ClientToScreen( (HWND)host.hWnd, &pt );
|
||||
|
||||
::SetCursorPos( pt.x, pt.y );
|
||||
}
|
||||
|
||||
void CEngineApp :: getCursorPos( int &x,int &y )
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
// find mouse movement
|
||||
::GetCursorPos( &pt );
|
||||
ScreenToClient((HWND)host.hWnd, &pt );
|
||||
|
||||
x = pt.x;
|
||||
y = pt.y;
|
||||
}
|
||||
|
||||
void VGui_SetBounds( void )
|
||||
{
|
||||
|
@ -437,14 +96,14 @@ void Vgui_Paint( int x, int y, int right, int bottom )
|
|||
if( !rootpanel ) return;
|
||||
|
||||
// setup the base panel to cover the screen
|
||||
Panel *pVPanel = surface->GetEmbeddedPanel();
|
||||
Panel *pVPanel = surface->getEmbeddedPanel();
|
||||
if( !pVPanel ) return;
|
||||
|
||||
if( cls.key_dest == key_game )
|
||||
pApp->externalTick();
|
||||
|
||||
pVPanel->setBounds( 0, 0, right, bottom );
|
||||
pVPanel->repaint();
|
||||
pVPanel->repaintAll();
|
||||
|
||||
// paint everything
|
||||
pVPanel->paintTraverse();
|
||||
|
@ -458,6 +117,7 @@ void VGui_Paint( void )
|
|||
if( cls.state != ca_active || !rootpanel )
|
||||
return;
|
||||
|
||||
host.input_enabled = rootpanel->isVisible();
|
||||
ClientToScreen( host.hWnd, &pnt );
|
||||
GetClientRect( host.hWnd, &rect );
|
||||
EnableScissor( true );
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2011 ©
|
||||
// vgui_main.h - vgui main header
|
||||
//=======================================================================
|
||||
#ifndef VGUI_MAIN_H
|
||||
#define VGUI_MAIN_H
|
||||
|
||||
#include "utlvector.h"
|
||||
#include "utlrbtree.h"
|
||||
|
||||
#include<VGUI.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_Cursor.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_MouseCode.h>
|
||||
#include<VGUI_KeyCode.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class FontCache
|
||||
{
|
||||
public:
|
||||
FontCache();
|
||||
~FontCache() { }
|
||||
|
||||
// returns a texture ID and a pointer to an array of 4 texture coords for the given character & font
|
||||
// uploads more texture if necessary
|
||||
bool GetTextureForChar( Font *font, char ch, int *textureID, float **texCoords );
|
||||
private:
|
||||
// NOTE: If you change this, change s_pFontPageSize
|
||||
enum
|
||||
{
|
||||
FONT_PAGE_SIZE_16,
|
||||
FONT_PAGE_SIZE_32,
|
||||
FONT_PAGE_SIZE_64,
|
||||
FONT_PAGE_SIZE_128,
|
||||
FONT_PAGE_SIZE_COUNT,
|
||||
};
|
||||
|
||||
// a single character in the cache
|
||||
typedef unsigned short HCacheEntry;
|
||||
struct CacheEntry_t
|
||||
{
|
||||
Font *font;
|
||||
char ch;
|
||||
byte page;
|
||||
float texCoords[4];
|
||||
|
||||
HCacheEntry nextEntry; // doubly-linked list for use in the LRU
|
||||
HCacheEntry prevEntry;
|
||||
};
|
||||
|
||||
// a single texture page
|
||||
struct Page_t
|
||||
{
|
||||
short textureID;
|
||||
short fontHeight;
|
||||
short wide, tall; // total size of the page
|
||||
short nextX, nextY; // position to draw any new character positions
|
||||
};
|
||||
|
||||
// allocates a new page for a given character
|
||||
bool AllocatePageForChar( int charWide, int charTall, int &pageIndex, int &drawX, int &drawY, int &twide, int &ttall );
|
||||
|
||||
// Computes the page size given a character height
|
||||
int ComputePageType( int charTall ) const;
|
||||
|
||||
static bool CacheEntryLessFunc( const CacheEntry_t &lhs, const CacheEntry_t &rhs );
|
||||
|
||||
// cache
|
||||
typedef CUtlVector<Page_t> FontPageList_t;
|
||||
|
||||
CUtlRBTree<CacheEntry_t, HCacheEntry> m_CharCache;
|
||||
FontPageList_t m_PageList;
|
||||
int m_pCurrPage[FONT_PAGE_SIZE_COUNT];
|
||||
HCacheEntry m_LRUListHeadIndex;
|
||||
|
||||
static int s_pFontPageSize[FONT_PAGE_SIZE_COUNT];
|
||||
};
|
||||
|
||||
class CEngineSurface : public SurfaceBase
|
||||
{
|
||||
private:
|
||||
struct paintState_t
|
||||
{
|
||||
Panel *m_pPanel;
|
||||
int iTranslateX;
|
||||
int iTranslateY;
|
||||
int iScissorLeft;
|
||||
int iScissorRight;
|
||||
int iScissorTop;
|
||||
int iScissorBottom;
|
||||
};
|
||||
|
||||
// point translation for current panel
|
||||
int _translateX;
|
||||
int _translateY;
|
||||
|
||||
// the size of the window to draw into
|
||||
int _surfaceExtents[4];
|
||||
|
||||
CUtlVector <paintState_t> _paintStack;
|
||||
|
||||
void SetupPaintState( const paintState_t &paintState );
|
||||
void InitVertex( vpoint_t &vertex, int x, int y, float u, float v );
|
||||
public:
|
||||
CEngineSurface( Panel *embeddedPanel );
|
||||
~CEngineSurface();
|
||||
public:
|
||||
virtual void setTitle( const char *title );
|
||||
virtual Panel *getEmbeddedPanel( void );
|
||||
virtual bool setFullscreenMode( int wide, int tall, int bpp );
|
||||
virtual void setWindowedMode( void );
|
||||
virtual void createPopup( Panel* embeddedPanel );
|
||||
virtual bool isWithin( int x, int y ) { return true; }
|
||||
virtual bool hasFocus( void );
|
||||
protected:
|
||||
virtual int createNewTextureID( void );
|
||||
virtual void drawSetColor( int r, int g, int b, int a );
|
||||
virtual void drawSetTextColor( int r, int g, int b, int a );
|
||||
virtual void drawFilledRect( int x0, int y0, int x1, int y1 );
|
||||
virtual void drawOutlinedRect( int x0,int y0,int x1,int y1 );
|
||||
virtual void drawSetTextFont( Font *font );
|
||||
virtual void drawSetTextPos( int x, int y );
|
||||
virtual void drawPrintText( const char* text, int textLen );
|
||||
virtual void drawSetTextureRGBA( int id, const char* rgba, int wide, int tall );
|
||||
virtual void drawSetTexture( int id );
|
||||
virtual void drawTexturedRect( int x0, int y0, int x1, int y1 );
|
||||
virtual bool createPlat( void ) { return false; }
|
||||
virtual bool recreateContext( void ) { return false; }
|
||||
virtual void setCursor( Cursor* cursor );
|
||||
virtual void pushMakeCurrent( Panel* panel, bool useInsets );
|
||||
virtual void popMakeCurrent( Panel* panel );
|
||||
|
||||
// not used in engine instance
|
||||
virtual void enableMouseCapture( bool state ) { }
|
||||
virtual void invalidate( Panel *panel ) { }
|
||||
virtual void setAsTopMost( bool state ) { }
|
||||
virtual void applyChanges( void ) { }
|
||||
virtual void swapBuffers( void ) { }
|
||||
protected:
|
||||
Font* _hCurrentFont;
|
||||
Cursor* _hCurrentCursor;
|
||||
int _drawTextPos[2];
|
||||
int _drawColor[4];
|
||||
int _drawTextColor[4];
|
||||
friend class App;
|
||||
friend class Panel;
|
||||
};
|
||||
|
||||
// initialize VGUI::App as external (part of engine)
|
||||
class CEngineApp : public App
|
||||
{
|
||||
public:
|
||||
CEngineApp( bool externalMain = true ) : App( externalMain ) { }
|
||||
virtual void main( int argc, char* argv[] ) { } // stub
|
||||
virtual void setCursorPos( int x, int y ); // we need to recompute abs position to window
|
||||
virtual void getCursorPos( int &x,int &y );
|
||||
};
|
||||
|
||||
class CEnginePanel : public Panel
|
||||
{
|
||||
public:
|
||||
virtual SurfaceBase* getSurfaceBase( void );
|
||||
virtual App* getApp( void );
|
||||
};
|
||||
|
||||
//
|
||||
// vgui_input.cpp
|
||||
//
|
||||
void VGUI_InitCursors( void );
|
||||
void VGUI_CursorSelect( Cursor *cursor );
|
||||
void VGUI_ActivateCurrentCursor( void );
|
||||
|
||||
#endif//FONT_CACHE_H
|
|
@ -0,0 +1,277 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2011 ©
|
||||
// vgui_surf.cpp - main vgui layer
|
||||
//=======================================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "vgui_main.h"
|
||||
|
||||
static FontCache g_FontCache;
|
||||
|
||||
CEngineSurface :: CEngineSurface( Panel *embeddedPanel ):SurfaceBase( embeddedPanel )
|
||||
{
|
||||
_embeddedPanel = embeddedPanel;
|
||||
_drawColor[0] = _drawColor[1] = _drawColor[2] = _drawColor[3] = 255;
|
||||
_drawTextColor[0] = _drawTextColor[1] = _drawTextColor[2] = _drawTextColor[3] = 255;
|
||||
|
||||
// FIXME: this is right?
|
||||
_surfaceExtents[0] = _surfaceExtents[1] = 0;
|
||||
_surfaceExtents[2] = menu.globals->scrWidth;
|
||||
_surfaceExtents[3] = menu.globals->scrHeight;
|
||||
_drawTextPos[0] = _drawTextPos[1] = 0;
|
||||
_hCurrentFont = null;
|
||||
|
||||
VGUI_InitCursors ();
|
||||
}
|
||||
|
||||
CEngineSurface :: ~CEngineSurface( void )
|
||||
{
|
||||
// TODO: release all vgui textures here
|
||||
}
|
||||
|
||||
Panel *CEngineSurface :: getEmbeddedPanel( void )
|
||||
{
|
||||
return _embeddedPanel;
|
||||
}
|
||||
|
||||
void CEngineSurface :: setTitle( const char *title )
|
||||
{
|
||||
Msg( "SetTitle: %s\n", title );
|
||||
}
|
||||
|
||||
void CEngineSurface :: createPopup( Panel* embeddedPanel )
|
||||
{
|
||||
Msg( "Create Popup\n" );
|
||||
}
|
||||
|
||||
bool CEngineSurface :: hasFocus( void )
|
||||
{
|
||||
// FIXME: check for HOST_NOFOUCS ?
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEngineSurface :: setCursor( Cursor *cursor )
|
||||
{
|
||||
_currentCursor = cursor;
|
||||
VGUI_CursorSelect( cursor );
|
||||
}
|
||||
|
||||
void CEngineSurface :: SetupPaintState( const paintState_t &paintState )
|
||||
{
|
||||
_translateX = paintState.iTranslateX;
|
||||
_translateY = paintState.iTranslateY;
|
||||
SetScissorRect( paintState.iScissorLeft, paintState.iScissorTop,
|
||||
paintState.iScissorRight, paintState.iScissorBottom );
|
||||
}
|
||||
|
||||
void CEngineSurface :: InitVertex( vpoint_t &vertex, int x, int y, float u, float v )
|
||||
{
|
||||
vertex.point[0] = x + _translateX;
|
||||
vertex.point[1] = y + _translateY;
|
||||
vertex.coord[0] = u;
|
||||
vertex.coord[1] = v;
|
||||
}
|
||||
|
||||
int CEngineSurface :: createNewTextureID( void )
|
||||
{
|
||||
return VGUI_GenerateTexture();
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetColor( int r, int g, int b, int a )
|
||||
{
|
||||
_drawColor[0] = r;
|
||||
_drawColor[1] = g;
|
||||
_drawColor[2] = b;
|
||||
_drawColor[3] = a;
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetTextColor( int r, int g, int b, int a )
|
||||
{
|
||||
_drawTextColor[0] = r;
|
||||
_drawTextColor[1] = g;
|
||||
_drawTextColor[2] = b;
|
||||
_drawTextColor[3] = a;
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawFilledRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
vpoint_t rect[2];
|
||||
vpoint_t clippedRect[2];
|
||||
|
||||
InitVertex( rect[0], x0, y0, 0, 0 );
|
||||
InitVertex( rect[1], x1, y1, 0, 0 );
|
||||
|
||||
// fully clipped?
|
||||
if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
|
||||
return;
|
||||
|
||||
VGUI_SetupDrawingRect( _drawColor );
|
||||
VGUI_EnableTexture( false );
|
||||
VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
|
||||
VGUI_EnableTexture( true );
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawOutlinedRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
drawFilledRect( x0, y0, x1, y0 + 1 ); // top
|
||||
drawFilledRect( x0, y1 - 1, x1, y1 ); // bottom
|
||||
drawFilledRect( x0, y0 + 1, x0 + 1, y1 - 1 ); // left
|
||||
drawFilledRect( x1 - 1, y0 + 1, x1, y1 - 1 ); // right
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetTextFont( Font *font )
|
||||
{
|
||||
_hCurrentFont = font;
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetTextPos( int x, int y )
|
||||
{
|
||||
_drawTextPos[0] = x;
|
||||
_drawTextPos[1] = y;
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawPrintText( const char* text, int textLen )
|
||||
{
|
||||
if( !text || !_hCurrentFont )
|
||||
return;
|
||||
|
||||
int x = _drawTextPos[0] + _translateX;
|
||||
int y = _drawTextPos[1] + _translateY;
|
||||
|
||||
int iTall = _hCurrentFont->getTall();
|
||||
|
||||
int iTotalWidth = 0;
|
||||
for( int i = 0; i < textLen; i++ )
|
||||
{
|
||||
char ch = text[i];
|
||||
|
||||
int abcA,abcB,abcC;
|
||||
_hCurrentFont->getCharABCwide( ch, abcA, abcB, abcC );
|
||||
|
||||
iTotalWidth += abcA;
|
||||
int iWide = abcB;
|
||||
|
||||
if( !iswspace( ch ))
|
||||
{
|
||||
// get the character texture from the cache
|
||||
int iTexId = 0;
|
||||
float *texCoords = NULL;
|
||||
|
||||
if( !g_FontCache.GetTextureForChar( _hCurrentFont, ch, &iTexId, &texCoords ))
|
||||
continue;
|
||||
|
||||
Assert( texCoords != NULL );
|
||||
|
||||
vpoint_t ul, lr;
|
||||
|
||||
ul.point[0] = x + iTotalWidth;
|
||||
ul.point[1] = y;
|
||||
lr.point[0] = ul.point[0] + iWide;
|
||||
lr.point[1] = ul.point[1] + iTall;
|
||||
|
||||
// gets at the texture coords for this character in its texture page
|
||||
ul.coord[0] = texCoords[0];
|
||||
ul.coord[1] = texCoords[1];
|
||||
lr.coord[0] = texCoords[2];
|
||||
lr.coord[1] = texCoords[3];
|
||||
|
||||
vpoint_t clippedRect[2];
|
||||
|
||||
if( !ClipRect( ul, lr, &clippedRect[0], &clippedRect[1] ))
|
||||
continue;
|
||||
|
||||
drawSetTexture( iTexId );
|
||||
VGUI_SetupDrawingText( _drawTextColor );
|
||||
VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] ); // draw the letter
|
||||
}
|
||||
|
||||
iTotalWidth += iWide + abcC;
|
||||
}
|
||||
|
||||
_drawTextPos[0] += iTotalWidth;
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetTextureRGBA( int id, const char* rgba, int wide, int tall )
|
||||
{
|
||||
VGUI_UploadTexture( id, rgba, wide, tall );
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawSetTexture( int id )
|
||||
{
|
||||
VGUI_BindTexture( id );
|
||||
}
|
||||
|
||||
void CEngineSurface :: drawTexturedRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
vpoint_t rect[2];
|
||||
vpoint_t clippedRect[2];
|
||||
|
||||
InitVertex( rect[0], x0, y0, 0, 0 );
|
||||
InitVertex( rect[1], x1, y1, 1, 1 );
|
||||
|
||||
// fully clipped?
|
||||
if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
|
||||
return;
|
||||
|
||||
VGUI_SetupDrawingImage( _drawColor );
|
||||
VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
|
||||
}
|
||||
|
||||
void CEngineSurface :: pushMakeCurrent( Panel* panel, bool useInsets )
|
||||
{
|
||||
int inSets[4] = { 0, 0, 0, 0 };
|
||||
int absExtents[4];
|
||||
int clipRect[4];
|
||||
|
||||
if( useInsets )
|
||||
{
|
||||
panel->getInset( inSets[0], inSets[1], inSets[2], inSets[3] );
|
||||
}
|
||||
|
||||
panel->getAbsExtents( absExtents[0], absExtents[1], absExtents[2], absExtents[3] );
|
||||
panel->getClipRect( clipRect[0], clipRect[1], clipRect[2], clipRect[3] );
|
||||
|
||||
int i = _paintStack.AddToTail();
|
||||
paintState_t &paintState = _paintStack[i];
|
||||
paintState.m_pPanel = panel;
|
||||
|
||||
// determine corrected top left origin
|
||||
paintState.iTranslateX = inSets[0] + absExtents[0] - _surfaceExtents[0];
|
||||
paintState.iTranslateY = inSets[1] + absExtents[1] - _surfaceExtents[1];
|
||||
|
||||
// setup clipping rectangle for scissoring
|
||||
paintState.iScissorLeft = clipRect[0] - _surfaceExtents[0];
|
||||
paintState.iScissorTop = clipRect[1] - _surfaceExtents[1];
|
||||
paintState.iScissorRight = clipRect[2] - _surfaceExtents[0];
|
||||
paintState.iScissorBottom = clipRect[3] - _surfaceExtents[1];
|
||||
|
||||
SetupPaintState( paintState );
|
||||
}
|
||||
|
||||
void CEngineSurface :: popMakeCurrent( Panel *panel )
|
||||
{
|
||||
int top = _paintStack.Count() - 1;
|
||||
|
||||
// more pops that pushes?
|
||||
Assert( top >= 0 );
|
||||
|
||||
// didn't pop in reverse order of push?
|
||||
Assert( _paintStack[top].m_pPanel == panel );
|
||||
|
||||
_paintStack.Remove( top );
|
||||
|
||||
if( top > 0 ) SetupPaintState( _paintStack[top-1] );
|
||||
}
|
||||
|
||||
bool CEngineSurface :: setFullscreenMode( int wide, int tall, int bpp )
|
||||
{
|
||||
Msg( "setFullscreenMode( %i x %i %i bpp)\n", wide, tall, bpp );
|
||||
return false;
|
||||
}
|
||||
|
||||
void CEngineSurface :: setWindowedMode( void )
|
||||
{
|
||||
Msg( "setWindowedMode()\n" );
|
||||
}
|
|
@ -263,6 +263,8 @@ typedef struct host_parm_s
|
|||
qboolean stuffcmdsrun; // execute stuff commands
|
||||
qboolean con_showalways; // show console always (developer and dedicated)
|
||||
qboolean change_game; // initialize when game is changed
|
||||
qboolean mouse_visible; // vgui override cursor control
|
||||
qboolean input_enabled; // vgui override mouse & keyboard input
|
||||
qboolean shutdown_issued; // engine is shutting down
|
||||
|
||||
char gamefolder[64]; // it's a default gamefolder
|
||||
|
|
|
@ -503,6 +503,13 @@ void Host_Error( const char *error, ... )
|
|||
static qboolean recursive = false;
|
||||
va_list argptr;
|
||||
|
||||
if( host.mouse_visible )
|
||||
{
|
||||
// hide mouse
|
||||
while( ShowCursor( false ) >= 0 );
|
||||
host.mouse_visible = false;
|
||||
}
|
||||
|
||||
va_start( argptr, error );
|
||||
Q_vsprintf( hosterror1, error, argptr );
|
||||
va_end( argptr );
|
||||
|
|
|
@ -6,15 +6,7 @@
|
|||
#include "common.h"
|
||||
#include "input.h"
|
||||
#include "client.h"
|
||||
|
||||
#define WM_MOUSEWHEEL ( WM_MOUSELAST + 1 ) // message that will be supported by the OS
|
||||
#define MK_XBUTTON1 0x0020
|
||||
#define MK_XBUTTON2 0x0040
|
||||
#define MK_XBUTTON3 0x0080
|
||||
#define MK_XBUTTON4 0x0100
|
||||
#define MK_XBUTTON5 0x0200
|
||||
#define WM_XBUTTONUP 0x020C
|
||||
#define WM_XBUTTONDOWN 0x020B
|
||||
#include "vgui_draw.h"
|
||||
|
||||
#define WND_HEADSIZE wnd_caption // some offset
|
||||
#define WND_BORDER 3 // sentinel border in pixels
|
||||
|
@ -184,6 +176,9 @@ void IN_ActivateMouse( void )
|
|||
if( !in_mouseinitialized )
|
||||
return;
|
||||
|
||||
if( CL_Active() && host.mouse_visible )
|
||||
return; // VGUI controls
|
||||
|
||||
if( cls.key_dest == key_menu && !Cvar_VariableInteger( "fullscreen" ))
|
||||
{
|
||||
// check for mouse leave-entering
|
||||
|
@ -234,7 +229,9 @@ void IN_ActivateMouse( void )
|
|||
clgame.dllFuncs.IN_ActivateMouse();
|
||||
}
|
||||
else if( in_mouseparmsvalid )
|
||||
{
|
||||
in_restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, in_newmouseparms, 0 );
|
||||
}
|
||||
|
||||
width = GetSystemMetrics( SM_CXSCREEN );
|
||||
height = GetSystemMetrics( SM_CYSCREEN );
|
||||
|
@ -251,7 +248,7 @@ void IN_ActivateMouse( void )
|
|||
|
||||
SetCapture( host.hWnd );
|
||||
ClipCursor( &window_rect );
|
||||
while( ShowCursor(false) >= 0 );
|
||||
while( ShowCursor( false ) >= 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -432,6 +429,8 @@ long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam )
|
|||
if( uMsg == in_mouse_wheel )
|
||||
uMsg = WM_MOUSEWHEEL;
|
||||
|
||||
VGUI_SurfaceWndProc( hWnd, uMsg, wParam, lParam );
|
||||
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_KILLFOCUS:
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
||||
|
@ -16,6 +20,15 @@ INPUT
|
|||
|
||||
#include "keydefs.h"
|
||||
|
||||
#define WM_MOUSEWHEEL ( WM_MOUSELAST + 1 ) // message that will be supported by the OS
|
||||
#define MK_XBUTTON1 0x0020
|
||||
#define MK_XBUTTON2 0x0040
|
||||
#define MK_XBUTTON3 0x0080
|
||||
#define MK_XBUTTON4 0x0100
|
||||
#define MK_XBUTTON5 0x0200
|
||||
#define WM_XBUTTONUP 0x020C
|
||||
#define WM_XBUTTONDOWN 0x020B
|
||||
|
||||
//
|
||||
// input.c
|
||||
//
|
||||
|
@ -28,4 +41,7 @@ void IN_DeactivateMouse( void );
|
|||
void IN_ToggleClientMouse( int newstate, int oldstate );
|
||||
long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif//INPUT_H
|
|
@ -578,6 +578,10 @@ void Key_Event( int key, qboolean down )
|
|||
if( key >= 200 )
|
||||
Msg( "%s is unbound, use controls menu to set.\n", Key_KeynumToString( key ));
|
||||
}
|
||||
else if( !clgame.dllFuncs.pfnKey_Event( down, key, keys[key].binding ))
|
||||
{
|
||||
// handled in client.dll
|
||||
}
|
||||
else if( kb[0] == '+' )
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -494,10 +494,18 @@ SOURCE=.\client\vgui\vgui_font.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vgui\vgui_input.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vgui\vgui_int.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vgui\vgui_surf.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\world.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -534,10 +542,6 @@ SOURCE=.\common\filesystem.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vgui\font_cache.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\gl_export.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -590,6 +594,10 @@ SOURCE=.\client\vgui\vgui_draw.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vgui\vgui_main.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\vox.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -519,6 +519,7 @@ int pfnIndexOfEdict( const edict_t *pEdict );
|
|||
void SV_UpdateBaseVelocity( edict_t *ent );
|
||||
int pfnPrecacheModel( const char *s );
|
||||
int pfnDecalIndex( const char *m );
|
||||
int pfnNumberOfEntities( void );
|
||||
|
||||
_inline edict_t *SV_EDICT_NUM( int n, const char * file, const int line )
|
||||
{
|
||||
|
|
|
@ -770,6 +770,16 @@ void SV_PlayersOnly_f( void )
|
|||
else SV_BroadcastPrintf( D_INFO, "Freeze server physic" );
|
||||
}
|
||||
|
||||
void SV_EdictsInfo_f( void )
|
||||
{
|
||||
int active;
|
||||
|
||||
active = pfnNumberOfEntities();
|
||||
Msg( "%5i edicts is used\n", active );
|
||||
Msg( "%5i edicts is free\n", svgame.globals->maxEntities - active );
|
||||
Msg( "%5i total\n", svgame.globals->maxEntities );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_InitOperatorCommands
|
||||
|
@ -794,6 +804,7 @@ void SV_InitOperatorCommands( void )
|
|||
Cmd_AddCommand( "reload", SV_Reload_f, "continue from latest save or restart level" );
|
||||
Cmd_AddCommand( "entpatch", SV_EntPatch_f, "write entity patch to allow external editing" );
|
||||
Cmd_AddCommand( "map_background", SV_MapBackground_f, "set background map" );
|
||||
Cmd_AddCommand( "edicts_info", SV_EdictsInfo_f, "show info about edicts" );
|
||||
|
||||
if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
|
@ -830,6 +841,7 @@ void SV_KillOperatorCommands( void )
|
|||
Cmd_RemoveCommand( "reload" );
|
||||
Cmd_RemoveCommand( "entpatch" );
|
||||
Cmd_RemoveCommand( "map_background" );
|
||||
Cmd_RemoveCommand( "edicts_info" );
|
||||
|
||||
if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
|
|
|
@ -661,7 +661,7 @@ edict_t *SV_AllocEdict( void )
|
|||
pEdict = EDICT_NUM( i );
|
||||
// the first couple seconds of server time can involve a lot of
|
||||
// freeing and allocating, so relax the replacement policy
|
||||
if( pEdict->free && ( pEdict->freetime < 2.0 || sv.time - pEdict->freetime > 0.5 ))
|
||||
if( pEdict->free && ( pEdict->freetime < 2.0f || sv.time - pEdict->freetime > 0.5f ))
|
||||
{
|
||||
SV_InitEdict( pEdict );
|
||||
return pEdict;
|
||||
|
@ -1206,7 +1206,7 @@ edict_t* pfnFindClientInPVS( edict_t *pEdict )
|
|||
int i;
|
||||
|
||||
if( !SV_IsValidEdict( pEdict ))
|
||||
return NULL;
|
||||
return svgame.edicts;
|
||||
|
||||
for( i = 0; i < svgame.globals->maxClients; i++ )
|
||||
{
|
||||
|
@ -1222,7 +1222,7 @@ edict_t* pfnFindClientInPVS( edict_t *pEdict )
|
|||
if( SV_OriginIn( DVIS_PVS, pEdict->v.origin, org ))
|
||||
return pClient;
|
||||
}
|
||||
return NULL;
|
||||
return svgame.edicts;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1240,7 +1240,7 @@ edict_t* pfnFindClientInPHS( edict_t *pEdict )
|
|||
int i;
|
||||
|
||||
if( !SV_IsValidEdict( pEdict ))
|
||||
return NULL;
|
||||
return svgame.edicts;
|
||||
|
||||
for( i = 0; i < svgame.globals->maxClients; i++ )
|
||||
{
|
||||
|
@ -1256,7 +1256,7 @@ edict_t* pfnFindClientInPHS( edict_t *pEdict )
|
|||
if( SV_OriginIn( DVIS_PHS, pEdict->v.origin, org ))
|
||||
return pClient;
|
||||
}
|
||||
return NULL;
|
||||
return svgame.edicts;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Reference in New Issue