mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
add button to adjust render speed
This commit is contained in:
parent
1c150106f8
commit
605da124d4
|
@ -103,7 +103,7 @@ public:
|
||||||
virtual void Quit() = 0;
|
virtual void Quit() = 0;
|
||||||
virtual const char *DemoPlayer_Play(const char *pFilename, int StorageType) = 0;
|
virtual const char *DemoPlayer_Play(const char *pFilename, int StorageType) = 0;
|
||||||
#if defined(CONF_VIDEORECORDER)
|
#if defined(CONF_VIDEORECORDER)
|
||||||
virtual const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName) = 0;
|
virtual const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName, int SpeedIndex) = 0;
|
||||||
#endif
|
#endif
|
||||||
virtual void DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int Recorder) = 0;
|
virtual void DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int Recorder) = 0;
|
||||||
virtual void DemoRecorder_HandleAutoStart() = 0;
|
virtual void DemoRecorder_HandleAutoStart() = 0;
|
||||||
|
|
|
@ -3531,7 +3531,7 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if defined(CONF_VIDEORECORDER)
|
#if defined(CONF_VIDEORECORDER)
|
||||||
const char *CClient::DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName)
|
const char *CClient::DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName, int SpeedIndex)
|
||||||
{
|
{
|
||||||
int Crc;
|
int Crc;
|
||||||
const char *pError;
|
const char *pError;
|
||||||
|
@ -3580,6 +3580,7 @@ const char *CClient::DemoPlayer_Render(const char *pFilename, int StorageType, c
|
||||||
|
|
||||||
this->CClient::StartVideo(NULL, this, pVideoName);
|
this->CClient::StartVideo(NULL, this, pVideoName);
|
||||||
m_DemoPlayer.Play();
|
m_DemoPlayer.Play();
|
||||||
|
m_DemoPlayer.SetSpeed(g_aSpeeds[SpeedIndex]);
|
||||||
//m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "demo_recorder", "demo eof");
|
//m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "demo_recorder", "demo eof");
|
||||||
GameClient()->OnEnterGame();
|
GameClient()->OnEnterGame();
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ public:
|
||||||
static void StartVideo(IConsole::IResult *pResult, void *pUserData, const char *pVideName);
|
static void StartVideo(IConsole::IResult *pResult, void *pUserData, const char *pVideName);
|
||||||
static void Con_StartVideo(IConsole::IResult *pResult, void *pUserData);
|
static void Con_StartVideo(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void Con_StopVideo(IConsole::IResult *pResult, void *pUserData);
|
static void Con_StopVideo(IConsole::IResult *pResult, void *pUserData);
|
||||||
const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName);
|
const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName, int SpeedIndex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void Con_Rcon(IConsole::IResult *pResult, void *pUserData);
|
static void Con_Rcon(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
|
|
@ -1542,7 +1542,7 @@ int CMenus::Render()
|
||||||
#if defined(CONF_VIDEORECORDER)
|
#if defined(CONF_VIDEORECORDER)
|
||||||
else if(m_Popup == POPUP_RENDER_DEMO)
|
else if(m_Popup == POPUP_RENDER_DEMO)
|
||||||
{
|
{
|
||||||
CUIRect Label, TextBox, Ok, Abort;
|
CUIRect Label, TextBox, Ok, Abort, IncSpeed, DecSpeed, Button;
|
||||||
|
|
||||||
Box.HSplitBottom(20.f, &Box, &Part);
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
@ -1586,15 +1586,69 @@ int CMenus::Render()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *pError = Client()->DemoPlayer_Render(aBufOld, m_lDemos[m_DemolistSelectedIndex].m_StorageType, m_aCurrentDemoFile);
|
const char *pError = Client()->DemoPlayer_Render(aBufOld, m_lDemos[m_DemolistSelectedIndex].m_StorageType, m_aCurrentDemoFile, m_Speed);
|
||||||
|
m_Speed = 4;
|
||||||
//Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "demo_render_path", aWholePath);
|
//Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "demo_render_path", aWholePath);
|
||||||
if(pError)
|
if(pError)
|
||||||
PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok"));
|
PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box.HSplitBottom(60.f, &Box, &Part);
|
Box.HSplitBottom(60.f, &Box, &Part);
|
||||||
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
|
Part.VSplitLeft(60.0f, 0, &Part);
|
||||||
|
Part.VSplitLeft(60.0f, 0, &Label);
|
||||||
|
Part.VSplitMid(&IncSpeed, &DecSpeed);
|
||||||
|
|
||||||
|
IncSpeed.VMargin(20.0f, &IncSpeed);
|
||||||
|
DecSpeed.VMargin(20.0f, &DecSpeed);
|
||||||
|
|
||||||
|
Part.VSplitLeft(20.0f, &Button, &Part);
|
||||||
|
bool IncDemoSpeed = false, DecDemoSpeed = false;
|
||||||
|
// slowdown
|
||||||
|
Part.VSplitLeft(5.0f, 0, &Part);
|
||||||
|
Part.VSplitLeft(Button.h, &Button, &Part);
|
||||||
|
static int s_SlowDownButton = 0;
|
||||||
|
if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL))
|
||||||
|
DecDemoSpeed = true;
|
||||||
|
|
||||||
|
// fastforward
|
||||||
|
Part.VSplitLeft(5.0f, 0, &Part);
|
||||||
|
Part.VSplitLeft(Button.h, &Button, &Part);
|
||||||
|
static int s_FastForwardButton = 0;
|
||||||
|
if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL))
|
||||||
|
IncDemoSpeed = true;
|
||||||
|
|
||||||
|
// speed meter
|
||||||
|
Part.VSplitLeft(15.0f, 0, &Part);
|
||||||
|
char aBuffer[64];
|
||||||
|
str_format(aBuffer, sizeof(aBuffer), "Speed: ×%g", g_aSpeeds[m_Speed]);
|
||||||
|
//str_format(aBuffer, sizeof(aBuffer), "Speed: ×%g", Speed);
|
||||||
|
UI()->DoLabel(&Part, aBuffer, Button.h*0.7f, -1);
|
||||||
|
|
||||||
|
if(IncDemoSpeed)
|
||||||
|
m_Speed = clamp(m_Speed + 1, 0, (int)(sizeof(g_aSpeeds)/sizeof(g_aSpeeds[0])-1));
|
||||||
|
else if(DecDemoSpeed)
|
||||||
|
m_Speed = clamp(m_Speed - 1, 0, (int)(sizeof(g_aSpeeds)/sizeof(g_aSpeeds[0])-1));
|
||||||
|
|
||||||
|
/*
|
||||||
|
static int s_ButtonInc = 0;
|
||||||
|
if(DoButton_Menu(&s_ButtonInc, Localize("IncSpeed"), 0, &IncSpeed))
|
||||||
|
m_Popup = POPUP_NONE;
|
||||||
|
|
||||||
|
static int s_ButtonDec = 0;
|
||||||
|
if(DoButton_Menu(&s_ButtonDec, Localize("DecSpeed"), 0, &DecSpeed))
|
||||||
|
m_Popup = POPUP_NONE;
|
||||||
|
*/
|
||||||
|
//Abort.VMargin(20.0f, &Abort);
|
||||||
|
//SpeedBox.VSplitLeft(40.0f, 0, &SpeedBox);
|
||||||
|
//SpeedBox.VSplitRight(80.0f, &SpeedBox, 0);
|
||||||
|
//UI()->DoLabel(&Label, Localize("Video speed:"), 18.0f, -1);
|
||||||
|
//static float Offset2 = 0.0f;
|
||||||
|
//char Speed[10] = "1";
|
||||||
|
//DoEditBox(&Offset2, &SpeedBox, Speed, sizeof(Speed), 12.0f, &Offset2);
|
||||||
|
|
||||||
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
Box.HSplitBottom(60.f, &Box, &Part);
|
Box.HSplitBottom(60.f, &Box, &Part);
|
||||||
#else
|
#else
|
||||||
|
@ -1636,7 +1690,8 @@ int CMenus::Render()
|
||||||
// render video
|
// render video
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename);
|
str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename);
|
||||||
const char *pError = Client()->DemoPlayer_Render(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType, m_aCurrentDemoFile);
|
const char *pError = Client()->DemoPlayer_Render(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType, m_aCurrentDemoFile, m_Speed);
|
||||||
|
m_Speed = 4;
|
||||||
if(pError)
|
if(pError)
|
||||||
PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok"));
|
PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,7 @@ class CMenus : public CComponent
|
||||||
int m_DemolistSelectedIndex;
|
int m_DemolistSelectedIndex;
|
||||||
bool m_DemolistSelectedIsDir;
|
bool m_DemolistSelectedIsDir;
|
||||||
int m_DemolistStorageType;
|
int m_DemolistStorageType;
|
||||||
|
int m_Speed = 4;
|
||||||
|
|
||||||
void DemolistOnUpdate(bool Reset);
|
void DemolistOnUpdate(bool Reset);
|
||||||
//void DemolistPopulate();
|
//void DemolistPopulate();
|
||||||
|
|
Loading…
Reference in a new issue