changed demo animations according to demo speed and added some demo speeds. (fixes #206)

This commit is contained in:
SushiTee 2010-10-19 13:37:36 +02:00 committed by oy
parent d7a8b94f77
commit 314cda05c7
5 changed files with 88 additions and 9 deletions

View file

@ -1,3 +1,5 @@
#include <engine/demo.h>
#include <game/generated/client_data.h>
#include <game/client/components/particles.h>
@ -238,6 +240,32 @@ void CEffects::OnRender()
static int64 LastUpdate100hz = 0;
static int64 LastUpdate50hz = 0;
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
if(time_get()-LastUpdate100hz > time_freq()/(100*pInfo->m_Speed))
{
m_Add100hz = true;
LastUpdate100hz = time_get();
}
else
m_Add100hz = false;
if(time_get()-LastUpdate50hz > time_freq()/(100*pInfo->m_Speed))
{
m_Add50hz = true;
LastUpdate50hz = time_get();
}
else
m_Add50hz = false;
if(m_Add50hz)
m_pClient->m_pFlow->Update();
return;
}
if(time_get()-LastUpdate100hz > time_freq()/100)
{
m_Add100hz = true;

View file

@ -58,7 +58,22 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemId)
{
m_pClient->m_pEffects->SmokeTrail(Pos, Vel*-1);
m_pClient->m_pFlow->Add(Pos, Vel*1000*Client()->FrameTime(), 10.0f);
Graphics()->QuadsSetRotation(Client()->LocalTime()*pi*2*2 + ItemId);
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
static float Time = 0;
static float LastLocalTime = Client()->LocalTime();
if(!pInfo->m_Paused)
Time += (Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed;
Graphics()->QuadsSetRotation(Time*pi*2*2 + ItemId);
LastLocalTime = Client()->LocalTime();
}
else
Graphics()->QuadsSetRotation(Client()->LocalTime()*pi*2*2 + ItemId);
}
else
{
@ -115,12 +130,16 @@ void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCu
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
static float Time = 0;
static float LastLocalTime = Client()->LocalTime();
if(!pInfo->m_Paused)
{
Pos.x += cosf(Client()->LocalTime()*pInfo->m_Speed*2.0f+Offset)*2.5f;
Pos.y += sinf(Client()->LocalTime()*pInfo->m_Speed*2.0f+Offset)*2.5f;
}
Time += (Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed;
Pos.x += cosf(Time*2.0f+Offset)*2.5f;
Pos.y += sinf(Time*2.0f+Offset)*2.5f;
LastLocalTime = Client()->LocalTime();
}
else
{

View file

@ -1,5 +1,6 @@
#include <engine/graphics.h>
#include <engine/keys.h>
#include <engine/demo.h>
#include <engine/serverbrowser.h>
#include <engine/shared/config.h>
#include <engine/storage.h>
@ -59,7 +60,22 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
return;
CMapItemEnvelope *pItem = (CMapItemEnvelope *)pThis->m_pLayers->Map()->GetItem(Start+Env, 0, 0);
pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, pThis->Client()->LocalTime()+TimeOffset, pChannels);
if(pThis->Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
const IDemoPlayer::CInfo *pInfo = pThis->DemoPlayer()->BaseInfo();
static float Time = 0;
static float LastLocalTime = pThis->Client()->LocalTime();
if(!pInfo->m_Paused)
Time += (pThis->Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed;
pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels);
LastLocalTime = pThis->Client()->LocalTime();
}
else
pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, pThis->Client()->LocalTime()+TimeOffset, pChannels);
}
void CMapLayers::OnRender()

View file

@ -171,7 +171,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(pInfo->m_Speed > 4.0f) DemoPlayer()->SetSpeed(4.0f);
else if(pInfo->m_Speed > 2.0f) DemoPlayer()->SetSpeed(2.0f);
else if(pInfo->m_Speed > 1.0f) DemoPlayer()->SetSpeed(1.0f);
else if(pInfo->m_Speed > 0.75f) DemoPlayer()->SetSpeed(0.75f);
else if(pInfo->m_Speed > 0.5f) DemoPlayer()->SetSpeed(0.5f);
else if(pInfo->m_Speed > 0.25f) DemoPlayer()->SetSpeed(0.25f);
else if(pInfo->m_Speed > 0.1f) DemoPlayer()->SetSpeed(0.1f);
else DemoPlayer()->SetSpeed(0.05f);
}
@ -181,7 +184,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
static int s_FastForwardButton = 0;
if(DoButton_DemoPlayer_Sprite(&s_FastForwardButton, SPRITE_DEMOBUTTON_FASTER, 0, &Button))
{
if(pInfo->m_Speed < 0.5f) DemoPlayer()->SetSpeed(0.5f);
if(pInfo->m_Speed < 0.1f) DemoPlayer()->SetSpeed(0.1f);
else if(pInfo->m_Speed < 0.25f) DemoPlayer()->SetSpeed(0.25f);
else if(pInfo->m_Speed < 0.5f) DemoPlayer()->SetSpeed(0.5f);
else if(pInfo->m_Speed < 0.75f) DemoPlayer()->SetSpeed(0.75f);
else if(pInfo->m_Speed < 1.0f) DemoPlayer()->SetSpeed(1.0f);
else if(pInfo->m_Speed < 2.0f) DemoPlayer()->SetSpeed(2.0f);
else if(pInfo->m_Speed < 4.0f) DemoPlayer()->SetSpeed(4.0f);
@ -194,7 +200,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(pInfo->m_Speed >= 1.0f)
str_format(aBuffer, sizeof(aBuffer), "x%.0f", pInfo->m_Speed);
else
str_format(aBuffer, sizeof(aBuffer), "x%.1f", pInfo->m_Speed);
str_format(aBuffer, sizeof(aBuffer), "x%.2f", pInfo->m_Speed);
UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, -1);
// close button

View file

@ -1,5 +1,6 @@
#include <base/math.h>
#include <engine/graphics.h>
#include <engine/demo.h>
#include <game/generated/client_data.h>
#include <game/client/render.h>
@ -120,7 +121,16 @@ void CParticles::OnRender()
{
static int64 LastTime = 0;
int64 t = time_get();
Update((float)((t-LastTime)/(double)time_freq()));
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
if(!pInfo->m_Paused)
Update((float)((t-LastTime)/(double)time_freq())*pInfo->m_Speed);
}
else
Update((float)((t-LastTime)/(double)time_freq()));
LastTime = t;
}