Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / sound_anim_dlg.cpp
blob472659c6403c948326b8c72c955e368969141ffb
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/>.
20 #include "std_afx.h"
21 #include "object_viewer.h"
22 #include "sound_anim_dlg.h"
23 #include "pick_sound.h"
24 #include "sound_system.h"
26 #include "nel/sound/u_audio_mixer.h"
27 #include "nel/sound/sound_anim_marker.h"
29 using namespace std;
30 using namespace NLMISC;
31 using namespace NLSOUND;
35 // ********************************************************
37 CSoundAnimDlg::CSoundAnimDlg(CObjectViewer* objView, CAnimationDlg* animDlg, CWnd* pParent/*=NULL*/)
38 : CDialog(CSoundAnimDlg::IDD, pParent)
40 //{{AFX_DATA_INIT(CSoundAnimDlg)
41 // NOTE: the ClassWizard will add member initialization here
42 //}}AFX_DATA_INIT
44 _ObjView = objView;
45 _AnimationDlg = animDlg;
46 _SelectedMarker = 0;
49 // ********************************************************
51 int CSoundAnimDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
53 if (CDialog::OnCreate(lpCreateStruct) == -1)
55 return -1;
58 RECT r;
59 r.top = 3;
60 r.bottom = 53;
61 r.left = 150;
62 r.right = 674;
64 _AnimView.Create(_ObjView, _AnimationDlg, this, r);
66 return 0;
69 // ********************************************************
71 BOOL CSoundAnimDlg::OnInitDialog()
73 CDialog::OnInitDialog();
75 return TRUE;
78 // ********************************************************
80 void CSoundAnimDlg::handle()
82 float sec = _AnimationDlg->getTime();
83 std::string text = toString("time: %.3f", sec);
84 GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(nlUtf8ToTStr(text));
86 _AnimView.updateCursor();
89 // ********************************************************
91 void CSoundAnimDlg::setAnimTime(float animStart, float animEnd)
93 nlwarning("START=%.3f - END=%.3f", animStart, animEnd);
94 _AnimView.setAnimTime(animStart, animEnd);
97 // ********************************************************
99 void CSoundAnimDlg::updateScroll(uint pos, uint min, uint max)
101 CScrollBar* scroll = (CScrollBar*) GetDlgItem(IDC_SOUND_ANIM_SCROLLBAR);
103 scroll->SetScrollRange(min, max, FALSE);
104 scroll->SetScrollPos(pos, TRUE);
107 // ********************************************************
109 void CSoundAnimDlg::DoDataExchange(CDataExchange* pDX)
111 CDialog::DoDataExchange(pDX);
112 //{{AFX_DATA_MAP(CSoundAnimDlg)
113 // NOTE: the ClassWizard will add DDX and DDV calls here
114 //}}AFX_DATA_MAP
117 // ********************************************************
119 void CSoundAnimDlg::selectMarker(CSoundAnimMarker* marker)
121 _SelectedMarker = marker;
122 updateSounds();
125 // ********************************************************
127 void CSoundAnimDlg::updateSounds()
129 if (_SelectedMarker != 0)
131 vector<NLMISC::TStringId> sounds;
133 _SelectedMarker->getSounds(sounds);
135 CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST);
136 list->ResetContent();
138 vector<NLMISC::TStringId>::iterator iter;
140 for (iter = sounds.begin(); iter != sounds.end(); iter++)
142 list->AddString(nlUtf8ToTStr(CStringMapper::unmap(*iter).c_str()));
145 list->UpdateData();
149 // ********************************************************
151 void CSoundAnimDlg::OnAddSound()
153 if (_SelectedMarker != 0)
155 // CPickSound::TNameVect names;
156 vector<NLMISC::TStringId> names;
159 NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer();
160 if (audioMixer)
162 audioMixer->getSoundNames(names);
165 CPickSound ps(names, this);
167 if (ps.DoModal() == IDOK)
169 // string name = ps.getName();
170 _SelectedMarker->addSound(ps.getName());
171 updateSounds();
176 // ********************************************************
178 void CSoundAnimDlg::OnRemoveSound()
180 if (_SelectedMarker != 0)
182 TCHAR s[256];
183 CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST);
185 if (list->GetText(list->GetCurSel(), s) != LB_ERR)
187 _SelectedMarker->removeSound(CStringMapper::map(tStrToUtf8(s)));
188 updateSounds();
193 // ********************************************************
195 void CSoundAnimDlg::OnSave()
197 _AnimView.save();
200 // ********************************************************
202 void CSoundAnimDlg::OnZoomOut()
204 _AnimView.zoomOut();
207 // ********************************************************
209 void CSoundAnimDlg::OnZoomIn()
211 _AnimView.zoomIn();
214 // ********************************************************
216 void CSoundAnimDlg::OnMark()
218 _AnimView.mark();
221 // ********************************************************
223 void CSoundAnimDlg::OnDelete()
225 _AnimView.deleteMarker();
228 // ********************************************************
230 void CSoundAnimDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
232 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
234 nlwarning("CSoundAnimDlg::OnHScroll");
236 // Get the minimum and maximum scroll-bar positions.
237 int minpos;
238 int maxpos;
239 pScrollBar->GetScrollRange(&minpos, &maxpos);
240 maxpos = pScrollBar->GetScrollLimit();
242 // Get the current position of scroll box.
243 int curpos = pScrollBar->GetScrollPos();
245 // Determine the new position of scroll box.
246 switch (nSBCode)
248 case SB_LEFT: // Scroll to far left.
249 curpos = minpos;
250 break;
252 case SB_RIGHT: // Scroll to far right.
253 curpos = maxpos;
254 break;
256 case SB_ENDSCROLL: // End scroll.
257 break;
259 case SB_LINELEFT: // Scroll left.
260 curpos -= 5;
261 if (curpos < minpos)
263 curpos = minpos;
265 break;
267 case SB_LINERIGHT: // Scroll right.
268 curpos += 5;
269 if (curpos > maxpos)
271 curpos = maxpos;
273 break;
275 case SB_PAGELEFT: // Scroll one page left.
277 // Get the page size.
278 SCROLLINFO info;
279 pScrollBar->GetScrollInfo(&info, SIF_ALL);
281 if (curpos > minpos)
283 curpos = std::max(minpos, curpos - (int) info.nPage);
286 break;
288 case SB_PAGERIGHT: // Scroll one page right.
290 // Get the page size.
291 SCROLLINFO info;
292 pScrollBar->GetScrollInfo(&info, SIF_ALL);
294 if (curpos < maxpos)
296 curpos = std::min(maxpos, curpos + (int) info.nPage);
299 break;
301 case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
302 curpos = nPos; // of the scroll box at the end of the drag operation.
303 break;
305 case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is the
306 curpos = nPos; // position that the scroll box has been dragged to.
307 break;
310 // Set the new position of the thumb (scroll box).
311 pScrollBar->SetScrollPos(curpos);
313 _AnimView.changeScroll(curpos);
315 CWnd::OnHScroll(nSBCode, nPos, pScrollBar);
318 // ********************************************************
320 BEGIN_MESSAGE_MAP(CSoundAnimDlg, CDialog)
321 //{{AFX_MSG_MAP(CSoundAnimDlg)
322 ON_BN_CLICKED(IDC_ANIM_SOUND_ADD, OnAddSound)
323 ON_BN_CLICKED(IDC_ANIM_SOUND_REMOVE, OnRemoveSound)
324 ON_BN_CLICKED(IDC_ANIM_SOUND_SAVE, OnSave)
325 ON_BN_CLICKED(IDC_ANIM_SOUND_ZOOMIN, OnZoomIn)
326 ON_BN_CLICKED(IDC_ANIM_SOUND_ZOOMOUT, OnZoomOut)
327 ON_BN_CLICKED(IDC_ANIM_SOUND_MARK, OnMark)
328 ON_BN_CLICKED(IDC_ANIM_SOUND_DELETE, OnDelete)
329 ON_WM_CREATE()
330 ON_WM_HSCROLL()
331 //}}AFX_MSG_MAP
332 END_MESSAGE_MAP()