From 6934b285e215c864c86f4de3d17abeda2129b2af Mon Sep 17 00:00:00 2001 From: timon Date: Fri, 26 Nov 2010 13:23:02 +0200 Subject: [PATCH] Changed: #1193 If switch between the located and sound properties in a workspace erroneously marked that the particle system has been changed. --- .../3d/object_viewer_qt/src/located_page.cpp | 43 ++++++++++--------- .../3d/object_viewer_qt/src/located_page.h | 14 ++---- .../src/particle_sound_page.cpp | 17 +++++--- .../src/particle_sound_page.h | 11 +---- 4 files changed, 38 insertions(+), 47 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/located_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/located_page.cpp index d6b5f6eaa..85fec4126 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/located_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/located_page.cpp @@ -55,7 +55,6 @@ CLocatedPage::CLocatedPage(QWidget *parent) _ui.maxNumParticleWidget->setRange(1, 501); _ui.maxNumParticleWidget->enableUpperBound(1 << 16, true); - _ui.maxNumParticleWidget->setWrapper(&_MaxNbParticlesWrapper); connect(_ui.coordSystemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setMatrixMode(int))); connect(_ui.disgradeWithLODCheckBox, SIGNAL(toggled(bool)), this, SLOT(setDisgradeWithLod(bool))); @@ -63,7 +62,9 @@ CLocatedPage::CLocatedPage(QWidget *parent) connect(_ui.trigerOnDeathCheckBox, SIGNAL(toggled(bool)), this, SLOT(setTriggerOnDeath(bool))); connect(_ui.editPushButton, SIGNAL(clicked()), this, SLOT(editTriggerOnDeath())); connect(_ui.limitedLifeTimeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setLimitedLifeTime(bool))); - connect(_ui.setCurrentCountPushButton, SIGNAL(clicked()), this, SLOT(setCount())); + connect(_ui.setCurrentCountPushButton, SIGNAL(clicked()), this, SLOT(setCurrentCount())); + + connect(_ui.maxNumParticleWidget, SIGNAL(valueChanged(uint32)), this, SLOT(setNewMaxSize(uint32))); } CLocatedPage::~CLocatedPage() @@ -91,9 +92,7 @@ void CLocatedPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocated *lo if (_Located->getOwner()) _ui.maxNumParticleWidget->setEnabled(!_Located->getOwner()->getAutoCountFlag()); - _MaxNbParticlesWrapper.Located = _Located; - _MaxNbParticlesWrapper.Node = _Node; - _ui.maxNumParticleWidget->updateUi(); + _ui.maxNumParticleWidget->setValue(_Located->getMaxSize(), false); _ui.coordSystemComboBox->setCurrentIndex(int(_Located->getMatrixMode())); _ui.limitedLifeTimeCheckBox->setChecked(!_Located->getLastForever()); @@ -217,10 +216,25 @@ void CLocatedPage::setMatrixMode(int index) } } -void CLocatedPage::setCount() +void CLocatedPage::setCurrentCount() { - _Located->resize(_Located->getSize()); // set new max size - _ui.maxNumParticleWidget->updateUi(); + // set new max size + _ui.maxNumParticleWidget->setValue(_Located->getSize()); + updateModifiedFlag(); +} + +void CLocatedPage::setNewMaxSize(uint32 value) +{ + // if the max new size is lower than the current number of instance, we must suppress item + // in the CParticleTreeCtrl + if (value < _Located->getSize()) + { + nlassert(_Node); + /// WARNING: + ///TreeCtrl->suppressLocatedInstanceNbItem(*Node, v); + } + _Located->resize(value); + updateModifiedFlag(); } @@ -238,19 +252,6 @@ void CLocatedPage::updateTriggerOnDeath(void) _ui.editPushButton->setEnabled(enable && _Located->isTriggerOnDeathEnabled()); } -void CLocatedPage::CMaxNbParticlesWrapper::set(const uint32 &v) -{ - // if the max new size is lower than the current number of instance, we must suppress item - // in the CParticleTreeCtrl - if (v < Located->getSize()) - { - nlassert(Node); - /// WARNING: - ///TreeCtrl->suppressLocatedInstanceNbItem(*Node, v); - } - Located->resize(v); -} - void CLocatedPage::CLifeWrapper::set(const float &v) { Located->setInitialLife(v); diff --git a/code/nel/tools/3d/object_viewer_qt/src/located_page.h b/code/nel/tools/3d/object_viewer_qt/src/located_page.h index ba5100114..157cada89 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/located_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/located_page.h @@ -61,20 +61,12 @@ private Q_SLOTS: void editTriggerOnDeath(); void setTriggerOnDeath(bool state); void setMatrixMode(int index); - void setCount(); + void setCurrentCount(); + + void setNewMaxSize(uint32 value); private: - /// wrapper to tune the max number of particles - struct CMaxNbParticlesWrapper : public IPSWrapperUInt - { - CWorkspaceNode *Node; - NL3D::CPSLocated *Located; - uint32 get(void) const { return Located->getMaxSize(); } - void set(const uint32 &v); - } _MaxNbParticlesWrapper; - - /// wrapper to tune the mass of particles struct CMassWrapper : public IPSWrapperFloat, IPSSchemeWrapperFloat { diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.cpp index daa9896e7..d710eb3c2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.cpp @@ -53,14 +53,15 @@ CSoundPage::CSoundPage(QWidget *parent) // setup dialog the percent of sound emissions _ui.emissionWidget->setRange(0.f, 1.f); - _ui.emissionWidget->setWrapper(&_EmissionPercentWrapper); - + connect(_ui.browsePushButton ,SIGNAL(clicked()), this, SLOT(browse())); connect(_ui.playPushButton ,SIGNAL(clicked()), this, SLOT(play())); connect(_ui.spawnCheckBox ,SIGNAL(toggled(bool)), this, SLOT(setSpawn(bool))); connect(_ui.muteCheckBox ,SIGNAL(toggled(bool)), this, SLOT(setMute(bool))); connect(_ui.keepPitchCheckBox ,SIGNAL(toggled(bool)), this, SLOT(setKeepPitch(bool))); connect(_ui.soundNameLineEdit ,SIGNAL(textChanged(QString)), this, SLOT(setSoundName(QString))); + + connect(_ui.emissionWidget, SIGNAL(valueChanged(float)), this, SLOT(setEmissionPercent(float))); } CSoundPage::~CSoundPage() @@ -73,10 +74,8 @@ void CSoundPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab _Node = ownerNode; nlassert(_Sound); - - _EmissionPercentWrapper.OwnerNode = _Node; - _EmissionPercentWrapper.S = _Sound; - _ui.emissionWidget->updateUi(); + + _ui.emissionWidget->setValue(_Sound->getEmissionPercent(), false); _GainWrapper.S = _Sound; _ui.gainWidget->setWorkspaceNode(_Node); @@ -165,4 +164,10 @@ void CSoundPage::setSoundName(const QString &text) _Sound->setSoundName(NLMISC::CStringMapper::map(text.toStdString())); } +void CSoundPage::setEmissionPercent(float value) +{ + _Sound->setEmissionPercent(value); + updateModifiedFlag(); +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.h b/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.h index 825bdb7c6..fd30747e0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_sound_page.h @@ -62,7 +62,8 @@ private Q_SLOTS: void setMute(bool state); void setKeepPitch(bool state); void setSoundName(const QString &text); - + void setEmissionPercent(float value); + private: /// wrapper to set the gain of sounds @@ -85,14 +86,6 @@ private: void setScheme(scheme_type *s) { S->setPitchScheme(s); } } _PitchWrapper; - /// wrapper to set the percentage of sound emissions - struct CEmissionPercentWrapper : public IPSWrapperFloat - { - NL3D::CPSSound *S; - float get(void) const { return S->getEmissionPercent(); } - void set(const float &v) { S->setEmissionPercent(v); } - } _EmissionPercentWrapper; - void updateModifiedFlag() { if (_Node) _Node->setModified(true); } /// the sound being edited