Skip to content

Commit

Permalink
Improved demo player another bit.
Browse files Browse the repository at this point in the history
* Replaced the reset button by more common stop button
* Made the demo player automatically reset after demo ended
  • Loading branch information
larsfu authored and oy committed Sep 4, 2010
1 parent 538d968 commit 4123f28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Binary file modified data/demo_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion datasrc/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def FileList(format, num):

container.sprites.Add(Sprite("demobutton_play", set_demobuttons, 0,0,1,1))
container.sprites.Add(Sprite("demobutton_pause", set_demobuttons, 1,0,1,1))
container.sprites.Add(Sprite("demobutton_reset", set_demobuttons, 2,0,1,1))
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))

Expand Down
18 changes: 13 additions & 5 deletions src/game/client/components/menus_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)

CUIRect SeekBar, ButtonBar;

int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick;
int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick;

if(m_MenuActive)
{
MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar);
Expand All @@ -75,9 +78,6 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)

RenderTools()->DrawUIRect(&SeekBar, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 5.0f);

int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick;
int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick;

float Amount = CurrentTick/(float)TotalTicks;

CUIRect FilledBar = SeekBar;
Expand Down Expand Up @@ -120,7 +120,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(Inside)
UI()->SetHotItem(id);
}


if(CurrentTick == TotalTicks)
{
DemoPlayer()->Pause();
DemoPlayer()->SetPos(0);
}

if(m_MenuActive)
{
Expand All @@ -141,11 +146,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
DemoPlayer()->Unpause();
}

// stop button

ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
static int s_ResetButton = 0;
if(DoButton_DemoPlayer_Sprite(&s_ResetButton, SPRITE_DEMOBUTTON_RESET, false, &Button))
if(DoButton_DemoPlayer_Sprite(&s_ResetButton, SPRITE_DEMOBUTTON_STOP, false, &Button))
{
DemoPlayer()->Pause();
DemoPlayer()->SetPos(0);
}

Expand Down

0 comments on commit 4123f28

Please sign in to comment.