Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / edit_ps_sound.cpp
blobfa72853cbaa0ad958d2aa8c6ac30328934f8e711
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "std_afx.h"
24 #include "nel/3d/ps_located.h"
25 #include "nel/3d/u_particle_system_sound.h"
26 #include "nel/3d/particle_system.h"
27 #include "object_viewer.h"
28 #include "edit_ps_sound.h"
29 #include "attrib_dlg.h"
30 #include "pick_sound.h"
31 #include "sound_system.h"
32 #include "editable_range.h"
34 using namespace std;
36 /// particle system sound system initialisation
37 void setPSSoundSystem(NLSOUND::UAudioMixer *am)
39 NL3D::UParticleSystemSound::setPSSound(am);
42 void releasePSSoundSystem(void)
44 // nothing to do for now
53 /////////////////////////////////////////////////////////////////////////////
54 // CEditPSSound dialog
58 CEditPSSound::CEditPSSound(CParticleWorkspace::CNode *ownerNode, NL3D::CPSSound *sound)
59 : _Node(ownerNode),
60 _Sound(sound),
61 _GainDlg(NULL),
62 _PitchDlg(NULL),
63 _PercentDlg(NULL)
65 nlassert(sound);
68 CEditPSSound::~CEditPSSound()
70 if (_GainDlg)
72 _GainDlg->DestroyWindow();
73 delete _GainDlg;
75 if (_PitchDlg)
77 _PitchDlg->DestroyWindow();
78 delete _PitchDlg;
80 if (_PercentDlg)
82 _PercentDlg->DestroyWindow();
83 delete _PercentDlg;
87 void CEditPSSound::init(CWnd* pParent /*= NULL*/)
89 Create(IDD_SOUND, pParent);
91 const uint posX = 3;
92 uint posY = 52;
93 RECT r;
95 nlassert(_Sound);
97 _PercentDlg = new CEditableRangeFloat(std::string("SOUND_EMISSION_PERCENT"), _Node, 0, 1);
98 _EmissionPercentWrapper.S = _Sound;
99 _PercentDlg->setWrapper(&_EmissionPercentWrapper);
100 _PercentDlg->init(posX + 95, posY, this);
102 posY += 35;
104 _GainWrapper.S = _Sound;
105 _GainDlg = new CAttribDlgFloat(std::string("SOUND VOLUME"), _Node, 0, 1);
106 _GainDlg->setWrapper(&_GainWrapper);
107 _GainDlg->setSchemeWrapper(&_GainWrapper);
108 HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SOUND_VOLUME));
109 _GainDlg->init(bmh, posX, posY, this);
110 _GainDlg->GetClientRect(&r);
111 posY += r.bottom + 3;
114 _PitchWrapper.S = _Sound;
115 _PitchDlg = new CAttribDlgFloat(std::string("SOUND PITCH"), _Node, 0.001f, 5);
116 _PitchDlg->setWrapper(&_PitchWrapper);
117 _PitchDlg->setSchemeWrapper(&_PitchWrapper);
118 bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SOUND_FREQ));
119 _PitchDlg->init(bmh, posX, posY, this);
120 _PitchDlg->GetClientRect(&r);
121 posY += r.bottom + 3;
123 m_Spawn = _Sound->getSpawn();
124 m_Mute = _Sound->getMute();
125 m_KeepOriginalPitch = _Sound->getUseOriginalPitchFlag();
126 _PitchDlg->EnableWindow(!m_KeepOriginalPitch);
128 ShowWindow(SW_SHOW);
129 UpdateData(FALSE);
136 void CEditPSSound::DoDataExchange(CDataExchange* pDX)
138 CDialog::DoDataExchange(pDX);
139 //{{AFX_DATA_MAP(CEditPSSound)
140 DDX_Text(pDX, IDC_SOUND_NAME, m_SoundName);
141 DDX_Check(pDX, IDC_SPAWN, m_Spawn);
142 DDX_Check(pDX, IDC_MUTE, m_Mute);
143 DDX_Check(pDX, IDC_KEEP_ORIGINAL_PITCH, m_KeepOriginalPitch);
144 //}}AFX_DATA_MAP
148 BEGIN_MESSAGE_MAP(CEditPSSound, CDialog)
149 //{{AFX_MSG_MAP(CEditPSSound)
150 ON_BN_CLICKED(IDC_BROWSE_SOUND, OnBrowseSound)
151 ON_EN_CHANGE(IDC_SOUND_NAME, OnChangeSoundName)
152 ON_BN_CLICKED(IDC_SPAWN, OnSpawn)
153 ON_BN_CLICKED(IDC_BUTTON1, OnPlaySound)
154 ON_BN_CLICKED(IDC_MUTE, OnMute)
155 ON_BN_CLICKED(IDC_KEEP_ORIGINAL_PITCH, OnKeepOriginalPitch)
156 //}}AFX_MSG_MAP
157 END_MESSAGE_MAP()
159 /////////////////////////////////////////////////////////////////////////////
160 // CEditPSSound message handlers
162 void CEditPSSound::OnBrowseSound()
164 // CPickSound::TNameVect names;
165 vector<NLMISC::TStringId> names;
168 NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer();
169 if (audioMixer)
171 audioMixer->getSoundNames(names);
174 CPickSound ps(names, this);
176 if (ps.DoModal() == IDOK)
178 m_SoundName = NLMISC::CStringMapper::unmap(ps.getName()).c_str();
179 _Sound->setSoundName(ps.getName());
180 updateModifiedFlag();
181 UpdateData(FALSE);
185 BOOL CEditPSSound::OnInitDialog()
187 CDialog::OnInitDialog();
189 nlassert(_Sound);
190 m_SoundName = NLMISC::CStringMapper::unmap(_Sound->getSoundName()).c_str();
192 UpdateData(FALSE);
193 return TRUE; // return TRUE unless you set the focus to a control
194 // EXCEPTION: OCX Property Pages should return FALSE
197 void CEditPSSound::OnChangeSoundName()
199 nlassert(_Sound);
200 UpdateData();
201 _Sound->setSoundName(NLMISC::CStringMapper::map(NLMISC::tStrToUtf8(m_SoundName)));
202 updateModifiedFlag();
205 void CEditPSSound::OnSpawn()
207 UpdateData(TRUE);
208 _Sound->setSpawn(m_Spawn ? true : false /* to avoid VCC warning*/);
209 updateModifiedFlag();
212 // play the currently selected sound
213 void CEditPSSound::OnPlaySound()
215 CSoundSystem::play(NLMISC::tStrToUtf8(m_SoundName));
218 void CEditPSSound::OnMute()
220 UpdateData(TRUE);
221 _Sound->setMute(m_Mute ? true : false /* to avoid VCC warning*/);
222 updateModifiedFlag();
225 void CEditPSSound::OnKeepOriginalPitch()
227 UpdateData(TRUE);
228 bool hadScheme = _PitchWrapper.getScheme() != NULL;
229 _Sound->setUseOriginalPitchFlag(m_KeepOriginalPitch ? true : false /* to avoid VCC warning*/);
230 nlassert(_PitchDlg);
231 if (m_KeepOriginalPitch)
233 if (hadScheme) _PitchDlg->update();
234 _PitchDlg->closeEditWindow();
236 _PitchDlg->EnableWindow(!m_KeepOriginalPitch);
237 updateModifiedFlag();