Commit 81fc13f0 authored by Mike Kremer's avatar Mike Kremer

Change an animation's name out of the toolbox.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13129 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c2dc2f2c
......@@ -40,6 +40,9 @@
* *
\*===========================================================================*/
#include <QInputDialog>
#include <QMessageBox>
#include "SkeletalAnimationPlugin.hh"
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "OpenFlipper/common/GlobalOptions.hh"
......@@ -98,8 +101,11 @@ void SkeletalAnimationPlugin::initializePlugin()
connect( pToolbox_->pbAddAnimation, SIGNAL(clicked()), this, SLOT(slotAddAnimation()) );
connect( pToolbox_->pbDeleteAnimation, SIGNAL(clicked()), this, SLOT(slotDeleteAnimation()) );
connect( pToolbox_->pbEditAnimation, SIGNAL(clicked()), this, SLOT(slotAnimationNameChanged()));
pToolbox_->pbAddAnimation->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"addAnimation.png") );
pToolbox_->pbDeleteAnimation->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"deleteAnimation.png") );
pToolbox_->pbEditAnimation->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"editAnimation.png") );
pToolbox_->cbMethod->addItem("Linear Blend Skinning");
pToolbox_->cbMethod->addItem("Dual Quaternion Blend Skinning");
......@@ -247,6 +253,45 @@ void SkeletalAnimationPlugin::checkObjectSelection(){
//------------------------------------------------------------------------------
void SkeletalAnimationPlugin::slotAnimationNameChanged() {
if(pToolbox_->cbAnimation->currentText() == "Reference Pose") {
QMessageBox::warning(0, "Not editable!", "You cannot change the reference pose's name!");
return;
}
QString newName = QInputDialog::getText(0, tr("Change Animation's Name"), tr("New Name:"),
QLineEdit::Normal, pToolbox_->cbAnimation->currentText());
// Set animation's name
for (unsigned int i=0; i < activeSkeletons_.size(); i++){
// Get active skeleton
BaseObjectData* baseObject = 0;
PluginFunctions::getObject(activeSkeletons_[i], baseObject);
if ( baseObject == 0 )
continue;
SkeletonObject* skeletonObject = dynamic_cast<SkeletonObject*>(baseObject);
if(!skeletonObject) continue;
Skeleton* skeleton = PluginFunctions::skeleton(skeletonObject);
AnimationHandle h = skeleton->animationHandle(pToolbox_->cbAnimation->currentText().toStdString());
if(skeleton != 0 && h.isValid()) {
skeleton->animation(h)->setName(newName.toStdString());
skeleton->replaceAnimationName(pToolbox_->cbAnimation->currentText().toStdString(), newName.toStdString());
} else {
return;
}
}
pToolbox_->cbAnimation->setItemText(pToolbox_->cbAnimation->currentIndex(), newName);
}
//------------------------------------------------------------------------------
/**
* @brief Returns the number of frames in the currently active animation
*/
......
......@@ -128,6 +128,8 @@ public slots:
void setComboBoxPosition(unsigned int _animationIndex);
void checkObjectSelection();
void slotAnimationNameChanged();
private slots:
void setDescriptions();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>284</height>
<width>467</width>
<height>296</height>
</rect>
</property>
<property name="windowTitle">
......@@ -58,20 +58,30 @@
<item row="1" column="1">
<widget class="QComboBox" name="cbMethod"/>
</item>
<item row="0" column="2">
<item row="0" column="3">
<widget class="QToolButton" name="pbAddAnimation">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="5">
<widget class="QToolButton" name="pbDeleteAnimation">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="pbEditAnimation">
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment