CDemoEditor: added new buttons to demo player

This commit is contained in:
east 2014-08-13 16:35:15 +02:00
parent 64810cf11c
commit 65b2426349
6 changed files with 65 additions and 15 deletions

BIN
data/demo_buttons2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

View file

@ -234,6 +234,7 @@ image_fileicons = Image("fileicons", "file_icons.png")
image_guibuttons = Image("guibuttons", "gui_buttons.png")
image_guiicons = Image("guiicons", "gui_icons.png")
image_arrow = Image("arrow", "arrow.png")
image_demobuttons2 = Image("demobuttons2", "demo_buttons2.png")
container.images.Add(image_null)
container.images.Add(image_game)
@ -250,6 +251,7 @@ container.images.Add(image_fileicons)
container.images.Add(image_guibuttons)
container.images.Add(image_guiicons)
container.images.Add(image_arrow)
container.images.Add(image_demobuttons2)
container.pickups.Add(Pickup("health"))
container.pickups.Add(Pickup("armor"))
@ -266,6 +268,7 @@ set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1)
set_guibuttons = SpriteSet("guibuttons", image_guibuttons, 12, 4)
set_guiicons = SpriteSet("guiicons", image_guiicons, 8, 2)
set_demobuttons2 = SpriteSet("demobuttons2", image_demobuttons2, 3, 1)
container.spritesets.Add(set_particles)
container.spritesets.Add(set_game)
@ -277,6 +280,7 @@ container.spritesets.Add(set_demobuttons)
container.spritesets.Add(set_fileicons)
container.spritesets.Add(set_guibuttons)
container.spritesets.Add(set_guiicons)
container.spritesets.Add(set_demobuttons2)
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1))
@ -396,6 +400,9 @@ container.sprites.Add(Sprite("demobutton_stop", set_demobuttons, 2,0,1,1))
container.sprites.Add(Sprite("demobutton_slower", set_demobuttons, 3,0,1,1))
container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1))
container.sprites.Add(Sprite("demobutton_slice_begin", set_demobuttons2, 0,0,1,1))
container.sprites.Add(Sprite("demobutton_slice_end", set_demobuttons2, 1,0,1,1))
container.sprites.Add(Sprite("file_demo1", set_fileicons, 0,0,1,1))
container.sprites.Add(Sprite("file_demo2", set_fileicons, 1,0,1,1))
container.sprites.Add(Sprite("file_folder", set_fileicons, 2,0,1,1))

View file

@ -155,6 +155,10 @@ public:
virtual const char* RaceRecordStart(const char *pFilename) = 0;
virtual void RaceRecordStop() = 0;
virtual bool DemoIsRecording() = 0;
virtual void DemoSliceBegin() = 0;
virtual void DemoSliceEnd() = 0;
virtual void DemoSlice() = 0;
};
class IGameClient : public IInterface

View file

@ -2752,42 +2752,56 @@ void CClient::Con_RemoveFavorite(IConsole::IResult *pResult, void *pUserData)
pSelf->m_ServerBrowser.RemoveFavorite(Addr);
}
void CClient::Con_DemoSliceStart(IConsole::IResult *pResult, void *pUserData)
void CClient::DemoSliceBegin()
{
const CDemoPlayer::CPlaybackInfo *pInfo = m_DemoPlayer.Info();
g_Config.m_ClDemoSliceStart = pInfo->m_Info.m_CurrentTick;
}
void CClient::DemoSliceEnd()
{
const CDemoPlayer::CPlaybackInfo *pInfo = m_DemoPlayer.Info();
g_Config.m_ClDemoSliceEnd = pInfo->m_Info.m_CurrentTick;
}
void CClient::Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
const CDemoPlayer::CPlaybackInfo *pInfo = pSelf->m_DemoPlayer.Info();
g_Config.m_ClDemoSliceStart = pInfo->m_Info.m_CurrentTick;
pSelf->DemoSliceBegin();
}
void CClient::Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
const CDemoPlayer::CPlaybackInfo *pInfo = pSelf->m_DemoPlayer.Info();
g_Config.m_ClDemoSliceEnd = pInfo->m_Info.m_CurrentTick;
pSelf->DemoSliceEnd();
}
void CClient::Con_DemoSlice(IConsole::IResult *pResult, void *pUserData)
void CClient::DemoSlice()
{
CClient *pSelf = (CClient *)pUserData;
if (pSelf->m_DemoPlayer.IsPlaying())
if (m_DemoPlayer.IsPlaying())
{
const char *pDemoFileName = pSelf->m_DemoPlayer.GetDemoFileName();
const char *pDemoFileName = m_DemoPlayer.GetDemoFileName();
char aPathNoExt[512];
str_copy(aPathNoExt, pDemoFileName, str_length(pDemoFileName)-5+1);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "slice '%s'", pDemoFileName);
pSelf->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_editor", aBuf);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_editor", aBuf);
char aDstName[256];
str_format(aDstName, sizeof(aDstName), "%s_sliced.demo", aPathNoExt);
pSelf->m_DemoEditor.Slice(pDemoFileName, aDstName, g_Config.m_ClDemoSliceStart, g_Config.m_ClDemoSliceEnd);
m_DemoEditor.Slice(pDemoFileName, aDstName, g_Config.m_ClDemoSliceStart, g_Config.m_ClDemoSliceEnd);
}
}
void CClient::Con_DemoSlice(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
pSelf->DemoSlice();
}
const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType)
@ -2958,7 +2972,7 @@ void CClient::RegisterCommands()
m_pConsole->Register("add_favorite", "s", CFGFLAG_CLIENT, Con_AddFavorite, this, "Add a server as a favorite");
m_pConsole->Register("remove_favorite", "s", CFGFLAG_CLIENT, Con_RemoveFavorite, this, "Remove a server from favorites");
m_pConsole->Register("demo_slice", "", CFGFLAG_CLIENT, Con_DemoSlice, this, "");
m_pConsole->Register("demo_slice_start", "", CFGFLAG_CLIENT, Con_DemoSliceStart, this, "");
m_pConsole->Register("demo_slice_start", "", CFGFLAG_CLIENT, Con_DemoSliceBegin, this, "");
m_pConsole->Register("demo_slice_end", "", CFGFLAG_CLIENT, Con_DemoSliceEnd, this, "");
// used for server browser update

View file

@ -320,7 +320,7 @@ public:
static void ConchainServerBrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void Con_DemoSlice(IConsole::IResult *pResult, void *pUserData);
static void Con_DemoSliceStart(IConsole::IResult *pResult, void *pUserData);
static void Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData);
static void Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData);
void RegisterCommands();
@ -343,5 +343,9 @@ public:
virtual const char* RaceRecordStart(const char *pFilename);
virtual void RaceRecordStop();
virtual bool DemoIsRecording();
virtual void DemoSliceBegin();
virtual void DemoSliceEnd();
virtual void DemoSlice();
};
#endif

View file

@ -223,6 +223,27 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
str_format(aBuffer, sizeof(aBuffer), "x%.2f", pInfo->m_Speed);
UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, -1);
// slice begin button
ButtonBar.VSplitLeft(Margins*10, 0, &ButtonBar);
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
static int s_SliceBeginButton = 0;
if(DoButton_Sprite(&s_SliceBeginButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_BEGIN, 0, &Button, CUI::CORNER_ALL))
Client()->DemoSliceBegin();
// slice end button
ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
static int s_SliceEndButton = 0;
if(DoButton_Sprite(&s_SliceEndButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_END, 0, &Button, CUI::CORNER_ALL))
Client()->DemoSliceEnd();
// slice save button
ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
static int s_SliceSaveButton = 0;
if(DoButton_Sprite(&s_SliceSaveButton, IMAGE_FILEICONS, SPRITE_FILE_DEMO2, 0, &Button, CUI::CORNER_ALL))
Client()->DemoSlice();
// close button
ButtonBar.VSplitRight(ButtonbarHeight*3, &ButtonBar, &Button);
static int s_ExitButton = 0;