mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Demo name is now showed while playing a demo file
This commit is contained in:
parent
ea25972e21
commit
56c4081da4
|
@ -24,6 +24,7 @@ public:
|
|||
virtual void Pause() = 0;
|
||||
virtual void Unpause() = 0;
|
||||
virtual const CInfo *BaseInfo() const = 0;
|
||||
virtual char *GetDemoName() = 0;
|
||||
};
|
||||
|
||||
class IDemoRecorder : public IInterface
|
||||
|
|
|
@ -516,6 +516,9 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
return -1;
|
||||
}
|
||||
|
||||
// store the filename
|
||||
str_copy(m_aFilename, pFilename, sizeof(m_aFilename));
|
||||
|
||||
// clear the playback info
|
||||
mem_zero(&m_Info, sizeof(m_Info));
|
||||
m_Info.m_Info.m_FirstTick = -1;
|
||||
|
@ -722,7 +725,19 @@ int CDemoPlayer::Stop()
|
|||
m_File = 0;
|
||||
mem_free(m_pKeyFrames);
|
||||
m_pKeyFrames = 0;
|
||||
str_copy(m_aFilename, "", sizeof(m_aFilename));
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *CDemoPlayer::GetDemoName()
|
||||
{
|
||||
// get the name of the demo without its path
|
||||
char *pDemoShortName = &m_aFilename[0];
|
||||
for(int i = 0; i < str_length(m_aFilename)-1; i++)
|
||||
{
|
||||
if(m_aFilename[i] == '/' || m_aFilename[i] == '\\')
|
||||
pDemoShortName = &m_aFilename[i+1];
|
||||
}
|
||||
return pDemoShortName;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ private:
|
|||
|
||||
class IConsole *m_pConsole;
|
||||
IOHANDLE m_File;
|
||||
char m_aFilename[256];
|
||||
CKeyFrame *m_pKeyFrames;
|
||||
|
||||
CPlaybackInfo m_Info;
|
||||
|
@ -109,6 +110,7 @@ public:
|
|||
void SetSpeed(float Speed);
|
||||
int SetPos(float Precent);
|
||||
const CInfo *BaseInfo() const { return &m_Info.m_Info; }
|
||||
char *GetDemoName();
|
||||
|
||||
int Update();
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <engine/demo.h>
|
||||
#include <engine/keys.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/storage.h>
|
||||
|
||||
#include <game/client/render.h>
|
||||
|
@ -42,11 +43,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
|
||||
const float SeekBarHeight = 15.0f;
|
||||
const float ButtonbarHeight = 20.0f;
|
||||
const float NameBarHeight = 20.0f;
|
||||
const float Margins = 5.0f;
|
||||
float TotalHeight;
|
||||
|
||||
if(m_MenuActive)
|
||||
TotalHeight = SeekBarHeight+ButtonbarHeight+Margins*3;
|
||||
TotalHeight = SeekBarHeight+ButtonbarHeight+NameBarHeight+Margins*3;
|
||||
else
|
||||
TotalHeight = SeekBarHeight+Margins*2;
|
||||
|
||||
|
@ -58,7 +60,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
|
||||
MainView.Margin(5.0f, &MainView);
|
||||
|
||||
CUIRect SeekBar, ButtonBar;
|
||||
CUIRect SeekBar, ButtonBar, NameBar;
|
||||
|
||||
int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick;
|
||||
int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick;
|
||||
|
@ -67,6 +69,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
{
|
||||
MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar);
|
||||
ButtonBar.HSplitTop(Margins, 0, &ButtonBar);
|
||||
ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar);
|
||||
NameBar.HSplitTop(3.5f, 0, &NameBar);
|
||||
}
|
||||
else
|
||||
SeekBar = MainView;
|
||||
|
@ -198,6 +202,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
static int s_ExitButton = 0;
|
||||
if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button))
|
||||
Client()->Disconnect();
|
||||
|
||||
// demo name
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "Demofile: %s", DemoPlayer()->GetDemoName());
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.7f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
||||
Cursor.m_LineWidth = 450.0f;
|
||||
TextRender()->TextEx(&Cursor, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue