mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 06:06:50 +00:00
game(client): make touch more transparent in cutscenes
This commit is contained in:
parent
d4e0a8108b
commit
653e08bce4
@ -32,6 +32,7 @@ extern IMatSystemSurface *g_pMatSystemSurface;
|
||||
extern ConVar sensitivity;
|
||||
|
||||
#define TOUCH_DEFAULT_CFG "touch_default.cfg"
|
||||
#define MIN_ALPHA_IN_CUTSCENE 20
|
||||
|
||||
ConVar touch_enable( "touch_enable", TOUCH_DEFAULT, FCVAR_ARCHIVE );
|
||||
ConVar touch_draw( "touch_draw", "1", FCVAR_ARCHIVE );
|
||||
@ -75,7 +76,6 @@ CTouchPanel::CTouchPanel( vgui::VPANEL parent ) : BaseClass( NULL, "TouchPanel"
|
||||
SetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
void CTouchPanel::Paint()
|
||||
{
|
||||
gTouch.Frame();
|
||||
@ -374,6 +374,7 @@ void CTouchControls::Init()
|
||||
m_flPreviousYaw = m_flPreviousPitch = 0.f;
|
||||
gridcolor = rgba_t(255, 0, 0, 50);
|
||||
|
||||
m_bCutScene = false;
|
||||
showtexture = hidetexture = resettexture = closetexture = joytexture = 0;
|
||||
configchanged = false;
|
||||
|
||||
@ -419,6 +420,7 @@ void CTouchControls::Init()
|
||||
textureList.AddToTail(texture);
|
||||
|
||||
CreateAtlasTexture();
|
||||
m_flHideTouch = 0.f;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
@ -621,10 +623,29 @@ void CTouchControls::Frame()
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
if( pPlayer && (pPlayer->GetFlags() & FL_FROZEN || g_pIntroData != NULL) )
|
||||
{
|
||||
if( !m_bCutScene )
|
||||
{
|
||||
m_bCutScene = true;
|
||||
m_AlphaDiff = 0;
|
||||
}
|
||||
}
|
||||
else if( !pPlayer )
|
||||
{
|
||||
m_bCutScene = false;
|
||||
m_AlphaDiff = 0;
|
||||
m_flHideTouch = 0;
|
||||
}
|
||||
else
|
||||
m_bCutScene = false;
|
||||
|
||||
if( touch_enable.GetBool() && touch_draw.GetBool() && !enginevgui->IsGameUIVisible() ) Paint();
|
||||
}
|
||||
|
||||
void CTouchControls::Paint( )
|
||||
void CTouchControls::Paint()
|
||||
{
|
||||
if (!initialized)
|
||||
return;
|
||||
@ -680,7 +701,10 @@ void CTouchControls::Paint( )
|
||||
m_pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, g_pMatSystemSurface->DrawGetTextureMaterial(t->textureID) );
|
||||
|
||||
meshBuilder.Begin( m_pMesh, MATERIAL_QUADS, 1 );
|
||||
rgba_t color(btn->color.r, btn->color.g, btn->color.b, btn->color.a);
|
||||
|
||||
int alpha = (btn->color.a > MIN_ALPHA_IN_CUTSCENE) ? max(MIN_ALPHA_IN_CUTSCENE, btn->color.a-m_AlphaDiff) : btn->color.a;
|
||||
rgba_t color(btn->color.r, btn->color.g, btn->color.b, alpha);
|
||||
|
||||
meshBuilder.Position3f( btn->x1*screen_w, btn->y1*screen_h, 0 );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, 0, 0 );
|
||||
@ -724,7 +748,9 @@ void CTouchControls::Paint( )
|
||||
{
|
||||
CTouchTexture *t = btn->texture;
|
||||
|
||||
rgba_t color(btn->color.r, btn->color.g, btn->color.b, btn->color.a);
|
||||
int alpha = (btn->color.a > MIN_ALPHA_IN_CUTSCENE) ? max(MIN_ALPHA_IN_CUTSCENE, btn->color.a-m_AlphaDiff) : btn->color.a;
|
||||
rgba_t color(btn->color.r, btn->color.g, btn->color.b, alpha);
|
||||
|
||||
meshBuilder.Position3f( btn->x1*screen_w, btn->y1*screen_h, 0 );
|
||||
meshBuilder.Color4ubv( color );
|
||||
meshBuilder.TexCoord2f( 0, t->X0, t->Y0 );
|
||||
@ -749,6 +775,17 @@ void CTouchControls::Paint( )
|
||||
|
||||
meshBuilder.End();
|
||||
m_pMesh->Draw();
|
||||
|
||||
|
||||
if( m_flHideTouch < gpGlobals->curtime )
|
||||
{
|
||||
if( m_bCutScene && m_AlphaDiff < 255-MIN_ALPHA_IN_CUTSCENE )
|
||||
m_AlphaDiff++;
|
||||
else if( !m_bCutScene && m_AlphaDiff > 0 )
|
||||
m_AlphaDiff--;
|
||||
|
||||
m_flHideTouch = gpGlobals->curtime + 0.002f;
|
||||
}
|
||||
}
|
||||
|
||||
void CTouchControls::AddButton( const char *name, const char *texturefile, const char *command, float x1, float y1, float x2, float y2, rgba_t color, int round, float aspect, int flags )
|
||||
|
@ -238,6 +238,10 @@ private:
|
||||
bool config_loaded;
|
||||
vgui::HFont textfont;
|
||||
int mouse_events;
|
||||
|
||||
bool m_bCutScene;
|
||||
float m_flHideTouch;
|
||||
int m_AlphaDiff;
|
||||
};
|
||||
|
||||
extern CTouchControls gTouch;
|
||||
|
Loading…
Reference in New Issue
Block a user