Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
David Capello 2014-04-26 16:05:55 -03:00
commit 3935b10467
2 changed files with 21 additions and 21 deletions

View File

@ -190,7 +190,20 @@ void MiniEditorWindow::onClose(ui::CloseEvent& ev)
void MiniEditorWindow::onPlayClicked()
{
resetTimer();
if (m_playButton->isPlaying()) {
Editor* miniEditor = (m_docView ? m_docView->getEditor(): NULL);
if (miniEditor && miniEditor->getDocument() != NULL)
m_nextFrameTime = miniEditor->getSprite()->getFrameDuration(miniEditor->getFrame());
else
m_nextFrameTime = -1;
m_curFrameTick = ji_clock;
m_playTimer.start();
}
else {
m_playTimer.stop();
}
}
void MiniEditorWindow::updateUsingEditor(Editor* editor)
@ -234,22 +247,6 @@ void MiniEditorWindow::hideWindow()
closeWindow(NULL);
}
void MiniEditorWindow::resetTimer()
{
if (m_playButton->isPlaying()) {
m_playTimer.start();
Editor* miniEditor = (m_docView ? m_docView->getEditor(): NULL);
if (miniEditor && miniEditor->getDocument() != NULL)
m_nextFrameTime = miniEditor->getSprite()->getFrameDuration(miniEditor->getFrame());
else
m_nextFrameTime = -1;
}
else {
m_playTimer.stop();
}
}
void MiniEditorWindow::onPlaybackTick()
{
Editor* miniEditor = (m_docView ? m_docView->getEditor(): NULL);
@ -257,15 +254,18 @@ void MiniEditorWindow::onPlaybackTick()
return;
if (m_nextFrameTime >= 0) {
m_nextFrameTime -= 10; // onPlaybackTick()
if (m_nextFrameTime <= 0) {
m_nextFrameTime -= (ji_clock - m_curFrameTick);
while (m_nextFrameTime <= 0) {
FrameNumber frame = miniEditor->getFrame().next();
if (frame > miniEditor->getSprite()->getLastFrame())
frame = FrameNumber(0);
miniEditor->setFrame(frame);
m_nextFrameTime = miniEditor->getSprite()->getFrameDuration(miniEditor->getFrame());
m_nextFrameTime += miniEditor->getSprite()->getFrameDuration(miniEditor->getFrame());
}
m_curFrameTick = ji_clock;
}
invalidate();
}

View File

@ -45,7 +45,6 @@ namespace app {
void onPlayClicked();
void onPlaybackTick();
void hideWindow();
void resetTimer();
bool m_isEnabled;
DocumentView* m_docView;
@ -55,6 +54,7 @@ namespace app {
// Number of milliseconds to go to the next frame if m_playTimer
// is activated.
int m_nextFrameTime;
int m_curFrameTick;
};
} // namespace app