This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/client/vgui/vgui_int.cpp

129 lines
2.9 KiB
C++
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
2018-02-08 22:00:00 +01:00
vgui_int.cpp - vgui dll interaction
2011-05-09 22:00:00 +02:00
Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
2011-03-18 22:00:00 +01:00
#include "common.h"
#include "client.h"
#include "const.h"
#include "vgui_draw.h"
2011-03-19 22:00:00 +01:00
#include "vgui_main.h"
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
Panel *rootPanel = NULL;
CEngineSurface *engSurface = NULL;
CEngineApp staticApp, *engApp;
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
void CEngineApp :: setCursorPos( int x, int y )
{
POINT pt;
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
pt.x = x;
pt.y = y;
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
ClientToScreen( (HWND)host.hWnd, &pt );
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
::SetCursorPos( pt.x, pt.y );
}
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
void CEngineApp :: getCursorPos( int &x,int &y )
2011-03-18 22:00:00 +01:00
{
2011-03-19 22:00:00 +01:00
POINT pt;
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
// find mouse movement
::GetCursorPos( &pt );
ScreenToClient((HWND)host.hWnd, &pt );
2011-03-18 22:00:00 +01:00
2011-03-19 22:00:00 +01:00
x = pt.x;
y = pt.y;
}
2011-03-18 22:00:00 +01:00
2011-03-30 22:00:00 +02:00
void VGui_RunFrame( void )
2011-03-18 22:00:00 +01:00
{
2012-12-23 21:00:00 +01:00
if( GetModuleHandle( "fraps32.dll" ) || GetModuleHandle( "fraps64.dll" ))
host.force_draw_version = true;
else host.force_draw_version = false;
2011-03-18 22:00:00 +01:00
}
2018-02-08 22:00:00 +01:00
void VGui_SetRootPanelSize( void )
2011-03-18 22:00:00 +01:00
{
2018-02-08 22:00:00 +01:00
if( rootPanel != NULL )
rootPanel->setBounds( 0, 0, gameui.globals->scrWidth, gameui.globals->scrHeight );
}
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
void VGui_Startup( void )
{
if( engSurface ) return;
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
engApp = (CEngineApp *)App::getInstance();
engApp->reset();
engApp->setMinimumTickMillisInterval( 0 ); // paint every frame
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
rootPanel = new Panel( 0, 0, 320, 240 ); // size will be changed in VGui_SetRootPanelSize
rootPanel->setPaintBorderEnabled( false );
rootPanel->setPaintBackgroundEnabled( false );
rootPanel->setPaintEnabled( false );
rootPanel->setCursor( engApp->getScheme()->getCursor( Scheme::scu_none ));
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
engSurface = new CEngineSurface( rootPanel );
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
VGui_SetRootPanelSize ();
2011-03-18 22:00:00 +01:00
VGUI_DrawInit ();
}
void VGui_Shutdown( void )
{
2018-02-08 22:00:00 +01:00
delete rootPanel;
delete engSurface;
engSurface = NULL;
rootPanel = NULL;
2011-03-18 22:00:00 +01:00
}
2018-02-08 22:00:00 +01:00
void VGui_Paint( int paintAll )
2011-03-18 22:00:00 +01:00
{
2018-02-08 22:00:00 +01:00
int extents[4];
2011-03-20 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
if( cls.state != ca_active || !rootPanel )
2011-03-20 22:00:00 +01:00
return;
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
VGui_SetRootPanelSize ();
rootPanel->repaint();
2011-03-20 22:00:00 +01:00
EnableScissor( true );
2011-03-18 22:00:00 +01:00
if( cls.key_dest == key_game )
2011-03-20 22:00:00 +01:00
{
2018-02-08 22:00:00 +01:00
App::getInstance()->externalTick();
2011-03-20 22:00:00 +01:00
}
2011-03-18 22:00:00 +01:00
2018-02-08 22:00:00 +01:00
if( paintAll )
{
// paint everything
rootPanel->paintTraverse();
}
else
{
rootPanel->getAbsExtents( extents[0], extents[1], extents[2], extents[3] );
VGui_ViewportPaintBackground( extents );
}
2011-03-18 22:00:00 +01:00
EnableScissor( false );
}
void VGui_ViewportPaintBackground( int extents[4] )
{
// Msg( "Vgui_ViewportPaintBackground( %i, %i, %i, %i )\n", extents[0], extents[1], extents[2], extents[3] );
}
void *VGui_GetPanel( void )
{
2018-02-08 22:00:00 +01:00
return (void *)rootPanel;
2011-03-18 22:00:00 +01:00
}