mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-06 14:43:47 +00:00
Character editor UI improvements
This commit is contained in:
parent
feace9e38c
commit
61afbabfa4
@ -9,6 +9,7 @@ CCharacterEditor::CCharacterEditor(QWidget *parent)
|
|||||||
, ui(new Ui::CCharacterEditor)
|
, ui(new Ui::CCharacterEditor)
|
||||||
, mpScene(new CScene())
|
, mpScene(new CScene())
|
||||||
, mpCharNode(new CCharacterNode(mpScene, -1))
|
, mpCharNode(new CCharacterNode(mpScene, -1))
|
||||||
|
, mAnimTime(0.f)
|
||||||
, mPlayAnim(true)
|
, mPlayAnim(true)
|
||||||
, mLoopAnim(true)
|
, mLoopAnim(true)
|
||||||
, mPlaybackSpeed(1.f)
|
, mPlaybackSpeed(1.f)
|
||||||
@ -42,8 +43,8 @@ CCharacterEditor::CCharacterEditor(QWidget *parent)
|
|||||||
connect(mpAnimComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetActiveAnimation(int)));
|
connect(mpAnimComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetActiveAnimation(int)));
|
||||||
|
|
||||||
connect(ui->AnimSlider, SIGNAL(valueChanged(int)), this, SLOT(SetAnimTime(int)));
|
connect(ui->AnimSlider, SIGNAL(valueChanged(int)), this, SLOT(SetAnimTime(int)));
|
||||||
connect(ui->PlayPauseButton, SIGNAL(pressed()), this, SLOT(PlayPauseButtonPressed()));
|
connect(ui->PlayPauseButton, SIGNAL(pressed()), this, SLOT(TogglePlay()));
|
||||||
connect(ui->LoopButton, SIGNAL(toggled(bool)), this, SLOT(LoopButtonToggled(bool)));
|
connect(ui->LoopButton, SIGNAL(toggled(bool)), this, SLOT(ToggleLoop(bool)));
|
||||||
connect(ui->AnimSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(AnimSpeedSpinBoxChanged(double)));
|
connect(ui->AnimSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(AnimSpeedSpinBoxChanged(double)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +59,9 @@ void CCharacterEditor::UpdateAnimTime()
|
|||||||
double DeltaTime = Time - mLastAnimUpdate;
|
double DeltaTime = Time - mLastAnimUpdate;
|
||||||
mLastAnimUpdate = Time;
|
mLastAnimUpdate = Time;
|
||||||
|
|
||||||
if (mPlayAnim && !ui->AnimSlider->isSliderDown())
|
CAnimation *pAnim = CurrentAnimation();
|
||||||
|
|
||||||
|
if (pAnim && mPlayAnim && !ui->AnimSlider->isSliderDown())
|
||||||
{
|
{
|
||||||
mAnimTime += DeltaTime * mPlaybackSpeed;
|
mAnimTime += DeltaTime * mPlaybackSpeed;
|
||||||
|
|
||||||
@ -68,17 +71,27 @@ void CCharacterEditor::UpdateAnimTime()
|
|||||||
if (mAnimTime > AnimLength)
|
if (mAnimTime > AnimLength)
|
||||||
{
|
{
|
||||||
if (mLoopAnim)
|
if (mLoopAnim)
|
||||||
|
{
|
||||||
mAnimTime = fmodf(mAnimTime, AnimLength);
|
mAnimTime = fmodf(mAnimTime, AnimLength);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
mAnimTime = AnimLength;
|
mAnimTime = AnimLength;
|
||||||
|
TogglePlay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAnimTime < 0.f)
|
if (mAnimTime < 0.f)
|
||||||
{
|
{
|
||||||
if (mLoopAnim)
|
if (mLoopAnim)
|
||||||
|
{
|
||||||
mAnimTime = AnimLength + fmodf(mAnimTime, AnimLength);
|
mAnimTime = AnimLength + fmodf(mAnimTime, AnimLength);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
mAnimTime = 0.f;
|
mAnimTime = 0.f;
|
||||||
|
TogglePlay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetAnimTime(mAnimTime);
|
SetAnimTime(mAnimTime);
|
||||||
@ -191,19 +204,32 @@ void CCharacterEditor::SetAnimTime(float Time)
|
|||||||
CurKey = Math::Min<u32>((u32) (Time / pAnim->TickInterval()) + 1, NumKeys - 1);
|
CurKey = Math::Min<u32>((u32) (Time / pAnim->TickInterval()) + 1, NumKeys - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->FrameLabel->setText(QString("Frame %1 / %2").arg(CurKey).arg(NumKeys - 1));
|
ui->FrameLabel->setText(QString("Frame %1 / %2 (%3s/%4s)").arg(CurKey).arg(NumKeys - 1).arg(mAnimTime, 0, 'f', 3).arg(pAnim ? pAnim->Duration() : 0.f, 0, 'f', 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterEditor::PlayPauseButtonPressed()
|
void CCharacterEditor::TogglePlay()
|
||||||
{
|
{
|
||||||
mPlayAnim = !mPlayAnim;
|
mPlayAnim = !mPlayAnim;
|
||||||
QString NewText = (mPlayAnim ? "Pause" : "Play");
|
QString NewText = (mPlayAnim ? "Pause" : "Play");
|
||||||
ui->PlayPauseButton->setText(NewText);
|
ui->PlayPauseButton->setText(NewText);
|
||||||
|
|
||||||
|
CAnimation *pAnim = CurrentAnimation();
|
||||||
|
|
||||||
|
if (pAnim && mPlayAnim)
|
||||||
|
{
|
||||||
|
if (mPlaybackSpeed < 0.f && mAnimTime == 0.f)
|
||||||
|
SetAnimTime(pAnim->Duration());
|
||||||
|
if (mPlaybackSpeed >= 0.f && mAnimTime == pAnim->Duration())
|
||||||
|
SetAnimTime(0.f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterEditor::LoopButtonToggled(bool Checked)
|
void CCharacterEditor::ToggleLoop(bool Loop)
|
||||||
{
|
{
|
||||||
mLoopAnim = Checked;
|
mLoopAnim = Loop;
|
||||||
|
|
||||||
|
if (sender() != ui->LoopButton)
|
||||||
|
ui->LoopButton->setChecked(Loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterEditor::AnimSpeedSpinBoxChanged(double NewVal)
|
void CCharacterEditor::AnimSpeedSpinBoxChanged(double NewVal)
|
||||||
|
@ -51,8 +51,8 @@ public slots:
|
|||||||
void SetAnimTime(int Time);
|
void SetAnimTime(int Time);
|
||||||
void SetAnimTime(float Time);
|
void SetAnimTime(float Time);
|
||||||
|
|
||||||
void PlayPauseButtonPressed();
|
void TogglePlay();
|
||||||
void LoopButtonToggled(bool Checked);
|
void ToggleLoop(bool Loop);
|
||||||
void AnimSpeedSpinBoxChanged(double NewVal);
|
void AnimSpeedSpinBoxChanged(double NewVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Frame 0 / 0</string>
|
<string>Frame 0 / 0 (0.000s/0.000s)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::PlainText</enum>
|
<enum>Qt::PlainText</enum>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user