Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / slot_dlg.cpp
blobaba65d8bb79d7343251e6f881d5e64bfd88c4359
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 "select_string.h"
23 #include "slot_dlg.h"
24 #include <nel/misc/common.h>
27 #define DELTA_BLEND 0.1f
28 #define DELTA_TIME (getTimeIncrement ())
29 #define DELTA_MUL 0.1f
31 using namespace NLMISC;
32 using namespace NL3D;
34 /////////////////////////////////////////////////////////////////////////////
35 // CSlotDlg dialog
38 CSlotDlg::CSlotDlg(CWnd* pParent /*=NULL*/)
39 : CDialog(CSlotDlg::IDD, pParent)
41 //{{AFX_DATA_INIT(CSlotDlg)
42 EndBlend = 1.0f;
43 Smoothness = 0.0f;
44 SpeedFactor = 1.0f;
45 StartBlend = 1.0f;
46 ClampMode = 0;
47 SkeletonWeightInverted = FALSE;
48 Offset = 0;
49 StartTime = 0;
50 EndTime = 0;
51 StartAnimTime=0.f;
52 EndAnimTime=1.f;
53 enable = TRUE;
54 //}}AFX_DATA_INIT
55 MainDlg=NULL;
58 void CSlotDlg::init (uint id, CObjectViewer* mainDlg)
60 Id=id;
61 MainDlg=mainDlg;
64 void CSlotDlg::DoDataExchange(CDataExchange* pDX)
66 CDialog::DoDataExchange(pDX);
67 //{{AFX_DATA_MAP(CSlotDlg)
68 DDX_Control(pDX, IDC_INVERT_SKELETON_WEIGHT, InvertSkeletonWeightCtrl);
69 DDX_Control(pDX, IDC_ALIGN_BLEND, AlignBlendCtrl);
70 DDX_Control(pDX, IDC_CLAMP, ClampCtrl);
71 DDX_Control(pDX, IDC_SCROLLBAR, ScrollBarCtrl);
72 DDX_Control(pDX, IDC_OFFSET_SPIN, OffsetSpinCtrl);
73 DDX_Control(pDX, IDC_OFFSET, OffsetCtrl);
74 DDX_Control(pDX, IDC_START_TIME_SPIN, StartTimeSpinCtrl);
75 DDX_Control(pDX, IDC_START_BLEND_SPIN, StartBlendSpinCtrl);
76 DDX_Control(pDX, IDC_SPEED_FACTOR_SPIN, SpeedFactorSpinCtrl);
77 DDX_Control(pDX, IDC_SMOOTHNESS_SPIN, SmoothnessSpinCtrl);
78 DDX_Control(pDX, IDC_END_TIME_SPIN, EndTimeSpinCtrl);
79 DDX_Control(pDX, IDC_END_BLEND_SPIN, EndBlendSpinCtrl);
80 DDX_Control(pDX, IDC_START_TIME, StartTimeCtrl);
81 DDX_Control(pDX, IDC_START_BLEND, StartBlendCtrl);
82 DDX_Control(pDX, IDC_SPEED_FACTOR, SpeddFactorCtrl);
83 DDX_Control(pDX, IDC_SMOOTHNESS, SmoothnessCtrl);
84 DDX_Control(pDX, IDC_END_TIME, EndTimeCtrl);
85 DDX_Control(pDX, IDC_END_BLEND, EndBlendCtrl);
86 DDX_Text(pDX, IDC_END_BLEND, EndBlend);
87 DDX_Text(pDX, IDC_SMOOTHNESS, Smoothness);
88 DDV_MinMaxFloat(pDX, Smoothness, 0.f, 1.f);
89 DDX_Text(pDX, IDC_SPEED_FACTOR, SpeedFactor);
90 DDV_MinMaxFloat(pDX, SpeedFactor, 1.e-002f, 100.f);
91 DDX_Text(pDX, IDC_START_BLEND, StartBlend);
92 DDV_MinMaxFloat(pDX, StartBlend, 0.f, 1.f);
93 DDX_Radio(pDX, IDC_CLAMP, ClampMode);
94 DDX_Check(pDX, IDC_INVERT_SKELETON_WEIGHT, SkeletonWeightInverted);
95 DDX_Text(pDX, IDC_OFFSET, Offset);
96 DDX_Text(pDX, IDC_START_TIME, StartTime);
97 DDX_Text(pDX, IDC_END_TIME, EndTime);
98 DDX_Check(pDX, IDC_ENABLE, enable);
99 //}}AFX_DATA_MAP
103 BEGIN_MESSAGE_MAP(CSlotDlg, CDialog)
104 //{{AFX_MSG_MAP(CSlotDlg)
105 ON_WM_PAINT()
106 ON_NOTIFY(UDN_DELTAPOS, IDC_END_BLEND_SPIN, OnDeltaposEndBlendSpin)
107 ON_NOTIFY(UDN_DELTAPOS, IDC_END_TIME_SPIN, OnDeltaposEndTimeSpin)
108 ON_NOTIFY(UDN_DELTAPOS, IDC_SMOOTHNESS_SPIN, OnDeltaposSmoothnessSpin)
109 ON_NOTIFY(UDN_DELTAPOS, IDC_SPEED_FACTOR_SPIN, OnDeltaposSpeedFactorSpin)
110 ON_NOTIFY(UDN_DELTAPOS, IDC_START_BLEND_SPIN, OnDeltaposStartBlendSpin)
111 ON_NOTIFY(UDN_DELTAPOS, IDC_START_TIME_SPIN, OnDeltaposStartTimeSpin)
112 ON_EN_CHANGE(IDC_END_BLEND, OnChangeEndBlend)
113 ON_EN_CHANGE(IDC_END_TIME, OnChangeEndTime)
114 ON_EN_CHANGE(IDC_SMOOTHNESS, OnChangeSmoothness)
115 ON_EN_CHANGE(IDC_SPEED_FACTOR, OnChangeSpeedFactor)
116 ON_EN_CHANGE(IDC_START_BLEND, OnChangeStartBlend)
117 ON_EN_CHANGE(IDC_START_TIME, OnChangeStartTime)
118 ON_BN_CLICKED(IDC_SET_ANIMATION, OnSetAnimation)
119 ON_BN_CLICKED(IDC_SET_SKELETON, OnSetSkeleton)
120 ON_EN_CHANGE(IDC_OFFSET, OnChangeOffset)
121 ON_NOTIFY(UDN_DELTAPOS, IDC_OFFSET_SPIN, OnDeltaposOffsetSpin)
122 ON_WM_HSCROLL()
123 ON_BN_CLICKED(IDC_CLAMP, OnClamp)
124 ON_BN_CLICKED(IDC_REPEAT, OnRepeat)
125 ON_BN_CLICKED(IDC_DISABLE, OnDisable)
126 ON_BN_CLICKED(IDC_ALIGN_BLEND, OnAlignBlend)
127 ON_WM_DESTROY()
128 ON_BN_CLICKED(IDC_ENABLE, OnEnable)
129 ON_BN_CLICKED(IDC_INVERT_SKELETON_WEIGHT, OnInvertSkeletonWeight)
130 //}}AFX_MSG_MAP
131 END_MESSAGE_MAP()
133 /////////////////////////////////////////////////////////////////////////////
134 // CSlotDlg message handlers
136 BOOL CSlotDlg::OnInitDialog()
138 CDialog::OnInitDialog();
140 // Init the blend window
141 setWindowName ();
143 return TRUE; // return TRUE unless you set the focus to a control
144 // EXCEPTION: OCX Property Pages should return FALSE
147 // ***************************************************************************
149 void CSlotDlg::OnPaint()
151 //CPaintDC dc(this); // device context for painting
152 PAINTSTRUCT paint;
153 CDC* pDc=BeginPaint(&paint);
155 // TODO: Add your message handler code here
156 // Draw the blend
157 RECT rect;
158 GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&rect);
159 ScreenToClient (&rect);
160 Blend.OnPaint (rect, pDc, StartBlend, EndBlend, (float)StartTime, (float)EndTime,
161 Smoothness, StartAnimTime, EndAnimTime, !isEmpty());
163 // Do not call CDialog::OnPaint() for painting messages
164 EndPaint(&paint);
167 // ***************************************************************************
169 void CSlotDlg::OnDeltaposEndBlendSpin(NMHDR* pNMHDR, LRESULT* pResult)
171 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
172 // TODO: Add your control notification handler code here
174 *pResult = 0;
176 UpdateData ();
178 if (pNMUpDown->iDelta<0)
179 EndBlend+=DELTA_BLEND;
180 if (pNMUpDown->iDelta>0)
181 EndBlend-=DELTA_BLEND;
182 clamp (EndBlend, 0.f, 1.f);
184 refresh (FALSE);
187 // ***************************************************************************
189 void CSlotDlg::OnDeltaposEndTimeSpin(NMHDR* pNMHDR, LRESULT* pResult)
191 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
192 // TODO: Add your control notification handler code here
194 *pResult = 0;
196 UpdateData ();
198 if (pNMUpDown->iDelta<0)
199 EndTime++;
200 if (pNMUpDown->iDelta>0)
201 EndTime--;
202 clamp (EndTime, (int)StartAnimTime, (int)EndAnimTime);
203 if (EndTime<StartTime)
204 StartTime=EndTime;
206 refresh (FALSE);
209 // ***************************************************************************
211 void CSlotDlg::OnDeltaposSmoothnessSpin(NMHDR* pNMHDR, LRESULT* pResult)
213 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
214 // TODO: Add your control notification handler code here
216 *pResult = 0;
218 UpdateData ();
220 if (pNMUpDown->iDelta<0)
221 Smoothness+=DELTA_BLEND;
222 if (pNMUpDown->iDelta>0)
223 Smoothness-=DELTA_BLEND;
224 clamp (Smoothness, 0.f, 1.f);
226 refresh (FALSE);
229 // ***************************************************************************
231 void CSlotDlg::OnDeltaposSpeedFactorSpin(NMHDR* pNMHDR, LRESULT* pResult)
233 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
234 // TODO: Add your control notification handler code here
236 *pResult = 0;
238 UpdateData ();
240 if (pNMUpDown->iDelta<0)
241 SpeedFactor+=DELTA_MUL;
242 if (pNMUpDown->iDelta>0)
243 SpeedFactor-=DELTA_MUL;
244 clamp (SpeedFactor, 0.01f, 100.f);
246 refresh (FALSE);
248 validateTime ();
249 updateScrollBar ();
252 // ***************************************************************************
254 void CSlotDlg::OnDeltaposStartBlendSpin(NMHDR* pNMHDR, LRESULT* pResult)
256 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
257 // TODO: Add your control notification handler code here
259 *pResult = 0;
261 UpdateData ();
263 if (pNMUpDown->iDelta<0)
264 StartBlend+=DELTA_BLEND;
265 if (pNMUpDown->iDelta>0)
266 StartBlend-=DELTA_BLEND;
267 clamp (StartBlend, 0.f, 1.f);
269 refresh (FALSE);
272 // ***************************************************************************
274 void CSlotDlg::OnDeltaposStartTimeSpin(NMHDR* pNMHDR, LRESULT* pResult)
276 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
277 // TODO: Add your control notification handler code here
279 *pResult = 0;
281 UpdateData ();
283 if (pNMUpDown->iDelta<0)
284 StartTime++;
285 if (pNMUpDown->iDelta>0)
286 StartTime--;
287 clamp (StartTime, (int)StartAnimTime, (int)EndAnimTime);
288 if (EndTime<StartTime)
289 EndTime=StartTime;
291 refresh (FALSE);
294 // ***************************************************************************
296 void CSlotDlg::OnChangeEndBlend()
298 // TODO: If this is a RICHEDIT control, the control will not
299 // send this notification unless you override the CDialog::OnInitDialog()
300 // function and call CRichEditCtrl().SetEventMask()
301 // with the ENM_CHANGE flag ORed into the mask.
303 // TODO: Add your control notification handler code here
304 UpdateData ();
306 clamp (EndBlend, 0.f, 1.f);
308 refresh (FALSE);
311 // ***************************************************************************
313 void CSlotDlg::OnChangeEndTime()
315 // TODO: If this is a RICHEDIT control, the control will not
316 // send this notification unless you override the CDialog::OnInitDialog()
317 // function and call CRichEditCtrl().SetEventMask()
318 // with the ENM_CHANGE flag ORed into the mask.
320 // TODO: Add your control notification handler code here
321 UpdateData ();
323 clamp (EndTime, (int)StartAnimTime, (int)EndAnimTime);
324 if (EndTime<StartTime)
325 StartTime=EndTime;
327 refresh (FALSE);
330 // ***************************************************************************
332 void CSlotDlg::OnChangeSmoothness()
334 // TODO: If this is a RICHEDIT control, the control will not
335 // send this notification unless you override the CDialog::OnInitDialog()
336 // function and call CRichEditCtrl().SetEventMask()
337 // with the ENM_CHANGE flag ORed into the mask.
339 // TODO: Add your control notification handler code here
340 UpdateData ();
342 clamp (Smoothness, 0.f, 1.f);
344 refresh (FALSE);
347 // ***************************************************************************
349 void CSlotDlg::OnChangeSpeedFactor()
351 // TODO: If this is a RICHEDIT control, the control will not
352 // send this notification unless you override the CDialog::OnInitDialog()
353 // function and call CRichEditCtrl().SetEventMask()
354 // with the ENM_CHANGE flag ORed into the mask.
356 // TODO: Add your control notification handler code here
357 UpdateData ();
359 clamp (SpeedFactor, 0.01f, 100.f);
361 refresh (FALSE);
362 validateTime ();
363 updateScrollBar ();
366 // ***************************************************************************
368 void CSlotDlg::OnChangeStartBlend()
370 // TODO: If this is a RICHEDIT control, the control will not
371 // send this notification unless you override the CDialog::OnInitDialog()
372 // function and call CRichEditCtrl().SetEventMask()
373 // with the ENM_CHANGE flag ORed into the mask.
375 // TODO: Add your control notification handler code here
376 UpdateData ();
378 clamp (StartBlend, 0.f, 1.f);
380 refresh (FALSE);
383 // ***************************************************************************
385 void CSlotDlg::OnChangeStartTime()
387 // TODO: If this is a RICHEDIT control, the control will not
388 // send this notification unless you override the CDialog::OnInitDialog()
389 // function and call CRichEditCtrl().SetEventMask()
390 // with the ENM_CHANGE flag ORed into the mask.
392 // TODO: Add your control notification handler code here
393 UpdateData ();
395 clamp (StartTime, (int)StartAnimTime, (int)EndAnimTime);
396 if (EndTime<StartTime)
397 EndTime=StartTime;
399 refresh (FALSE);
403 // ***************************************************************************
405 void CSlotDlg::OnSetAnimation()
407 // List of string
408 std::vector<std::string> vectString;
410 // Build a list of string
411 for (uint a=0; a<getAnimationSetPointer()->getNumAnimation (); a++)
412 vectString.push_back (getAnimationSetPointer()->getAnimationName (a));
414 // Select a string
415 CSelectString select (vectString, "Select your animation", this, true);
416 if (select.DoModal ()==IDOK)
418 // Set the animation
419 if (select.Selection!=-1)
421 getSlotInformation ()->Animation = vectString[select.Selection];
422 validateTime ();
423 updateScrollBar ();
425 else
426 getSlotInformation ()->Animation.clear();
428 refresh (TRUE);
431 // ***************************************************************************
433 void CSlotDlg::OnSetSkeleton()
435 // List of string
436 std::vector<std::string> vectString;
438 // Build a list of string
439 for (uint s=0; s<getAnimationSetPointer()->getNumSkeletonWeight (); s++)
440 vectString.push_back (getAnimationSetPointer()->getSkeletonWeightName (s));
442 // Select a string
443 CSelectString select (vectString, "Select your skeleton weight template", this, true);
444 if (select.DoModal ()==IDOK)
446 // Set the animation
447 if (select.Selection!=-1)
448 getSlotInformation ()->Skeleton = vectString[select.Selection].c_str();
449 else
450 getSlotInformation ()->Skeleton.clear();
452 setWindowName ();
453 Invalidate ();
457 // ***************************************************************************
459 void CSlotDlg::setWindowName ()
461 std::string tmp = NLMISC::toString("Slot %d : ", Id);
463 if (isEmpty())
464 tmp += "empty";
465 else
466 tmp += getSlotInformation ()->Animation;
468 CSlotInfo *information = getSlotInformation ();
469 if (information)
471 std::string SkeletonName = information->Skeleton;
472 if (!SkeletonName.empty())
474 tmp += " (" + SkeletonName + ")";
478 GetDlgItem(IDC_SLOT_NAME)->SetWindowText(nlUtf8ToTStr(tmp));
481 // ***************************************************************************
483 void CSlotDlg::OnChangeOffset()
485 // TODO: If this is a RICHEDIT control, the control will not
486 // send this notification unless you override the CDialog::OnInitDialog()
487 // function and call CRichEditCtrl().SetEventMask()
488 // with the ENM_CHANGE flag ORed into the mask.
490 // TODO: Add your control notification handler code here
491 validateTime ();
492 updateScrollBar ();
494 refresh (FALSE);
497 // ***************************************************************************
499 void CSlotDlg::OnDeltaposOffsetSpin(NMHDR* pNMHDR, LRESULT* pResult)
501 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
502 // TODO: Add your control notification handler code here
504 UpdateData ();
505 if (pNMUpDown->iDelta<0)
506 Offset++;
507 if (pNMUpDown->iDelta>0)
508 Offset--;
510 validateTime ();
511 updateScrollBar ();
513 *pResult = 0;
514 refresh (FALSE);
517 // ***************************************************************************
519 void CSlotDlg::validateTime ()
521 bool reinit=false;
522 if ((float)Offset<StartAnimTime)
524 StartAnimTime=(float)Offset;
525 reinit=true;
527 if ((float)Offset+AnimationLength/SpeedFactor>EndAnimTime)
529 EndAnimTime=(float)Offset+AnimationLength/SpeedFactor;
530 reinit=true;
532 if (reinit)
533 MainDlg->setAnimTime (StartAnimTime, EndAnimTime);
536 // ***************************************************************************
538 void CSlotDlg::updateScrollBar ()
540 // Scroll info
541 SCROLLINFO info;
542 memset (&info, 0, sizeof (info));
544 // Fill the infos
545 info.fMask=SIF_ALL;
546 info.nMin=0;
547 info.nMax=10000;
548 if (fabs(EndAnimTime-StartAnimTime)<0.00001f)
550 info.nPage=1;
551 info.nPos=0;
553 else
555 info.nPage=(int)(10000.f*(AnimationLength/SpeedFactor)/(EndAnimTime-StartAnimTime));
556 info.nPos=(int)(10000.f*((float)Offset-StartAnimTime)/(EndAnimTime-StartAnimTime));
559 // Set scrollbar infos
560 ScrollBarCtrl.SetScrollInfo (&info, TRUE);
562 // Invalidate blend bar
563 RECT bar;
564 GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
565 ScreenToClient (&bar);
566 InvalidateRect (&bar);
569 // ***************************************************************************
571 void CSlotDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
573 // TODO: Add your message handler code here and/or call default
574 if (pScrollBar==GetDlgItem (IDC_SCROLLBAR))
576 // Only drag and drop
577 if (nSBCode==SB_THUMBTRACK)
579 int DeltaOffset=Offset;
580 UpdateData ();
581 Offset=(int)((EndAnimTime-StartAnimTime)*(float)nPos/10000.f+StartAnimTime);
582 DeltaOffset=Offset-DeltaOffset;
583 StartTime+=DeltaOffset;
584 EndTime+=DeltaOffset;
585 refresh (FALSE);
586 updateScrollBar ();
589 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
592 // ***************************************************************************
594 void CSlotDlg::setAnimTime (float animStart, float animEnd)
596 StartAnimTime=animStart;
597 EndAnimTime=animEnd;
598 updateScrollBar ();
599 computeLength ();
602 // ***************************************************************************
604 float CSlotDlg::getTimeIncrement ()
606 return (EndAnimTime-StartAnimTime)/100.f;
609 // ***************************************************************************
611 void CSlotDlg::OnClamp()
613 refresh (FALSE);
616 // ***************************************************************************
618 void CSlotDlg::OnRepeat()
620 refresh (FALSE);
623 // ***************************************************************************
625 void CSlotDlg::OnDisable()
627 refresh (FALSE);
630 // ***************************************************************************
632 void CSlotDlg::OnAlignBlend()
634 // Refresh data
635 UpdateData ();
637 // Change some of them
638 StartTime=Offset;
639 EndTime=(int)((float)Offset+AnimationLength/SpeedFactor);
641 // Invalidate UI
642 refresh (FALSE);
644 // Invalidate blend bar
645 RECT bar;
646 GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
647 ScreenToClient (&bar);
648 InvalidateRect (&bar);
651 // ***************************************************************************
653 float CSlotDlg::getStartTime ()
655 return (float)StartTime/MainDlg->getFrameRate ();
658 // ***************************************************************************
660 float CSlotDlg::getEndTime ()
662 return (float)EndTime/MainDlg->getFrameRate ();
665 // ***************************************************************************
667 void CSlotDlg::computeLength ()
669 if (getAnimationPointer())
670 AnimationLength=(getAnimationPointer()->getEndTime()-getAnimationPointer()->getBeginTime())*MainDlg->getFrameRate();
673 // ***************************************************************************
675 void CSlotDlg::OnDestroy()
677 // TODO: Add your message handler code here
678 CDialog::OnDestroy();
681 // ***************************************************************************
683 void CSlotDlg::refresh (BOOL update)
685 CSlotInfo *slotInfo = getSlotInformation ();
687 if (update)
689 CDialog::UpdateData (update);
691 // Update from slot information
692 if (slotInfo)
694 EndBlend = slotInfo->EndBlend;
695 Smoothness = slotInfo->Smoothness;
696 SpeedFactor = slotInfo->SpeedFactor;
697 StartBlend = slotInfo->StartBlend;
698 ClampMode = slotInfo->ClampMode;
699 SkeletonWeightInverted = slotInfo->SkeletonInverted?TRUE:FALSE;
700 StartTime = slotInfo->StartTime;
701 Offset = slotInfo->Offset;
702 EndTime = slotInfo->EndTime;
703 enable = slotInfo->Enable?TRUE:FALSE;
705 else
707 EndBlend = 1;
708 Smoothness = 1;
709 SpeedFactor = 1;
710 StartBlend = 1;
711 ClampMode = 0;
712 SkeletonWeightInverted = FALSE;
713 StartTime = 0;
714 Offset = 0;
715 EndTime = 0;
716 enable = TRUE;
719 // Compute length
720 computeLength ();
722 // Slot frozen
723 bool frozen = (slotInfo == NULL) || (getAnimationPointer () == NULL);
725 // Enable / disable windows
726 OffsetCtrl.EnableWindow (!frozen);
727 StartTimeCtrl.EnableWindow (!frozen);
728 StartBlendCtrl.EnableWindow (!frozen);
729 SpeddFactorCtrl.EnableWindow (!frozen);
730 SmoothnessCtrl.EnableWindow (!frozen);
731 EndTimeCtrl.EnableWindow (!frozen);
732 EndBlendCtrl.EnableWindow (!frozen);
733 OffsetSpinCtrl.EnableWindow (!frozen);
734 StartTimeSpinCtrl.EnableWindow (!frozen);
735 StartBlendSpinCtrl.EnableWindow (!frozen);
736 SpeedFactorSpinCtrl.EnableWindow (!frozen);
737 SmoothnessSpinCtrl.EnableWindow (!frozen);
738 EndTimeSpinCtrl.EnableWindow (!frozen);
739 EndBlendSpinCtrl.EnableWindow (!frozen);
740 ScrollBarCtrl.EnableWindow (!frozen);
741 AlignBlendCtrl.EnableWindow (!frozen);
742 InvertSkeletonWeightCtrl.EnableWindow (!frozen);
743 GetDlgItem (IDC_CLAMP)->EnableWindow (!frozen);
744 GetDlgItem (IDC_REPEAT)->EnableWindow (!frozen);
745 GetDlgItem (IDC_DISABLE)->EnableWindow (!frozen);
746 setWindowName ();
747 updateScrollBar ();
749 RECT bar;
750 GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
751 ScreenToClient (&bar);
752 InvalidateRect (&bar);
754 CDialog::UpdateData (FALSE);
756 else
758 CDialog::UpdateData (TRUE);
760 // Update from slot information
761 slotInfo->EndBlend = EndBlend;
762 slotInfo->Smoothness = Smoothness;
763 slotInfo->SpeedFactor = SpeedFactor;
764 slotInfo->StartBlend = StartBlend;
765 slotInfo->ClampMode = ClampMode;
766 slotInfo->SkeletonInverted = SkeletonWeightInverted?true:false;
767 slotInfo->StartTime = StartTime;
768 slotInfo->Offset = Offset;
769 slotInfo->EndTime = EndTime;
770 slotInfo->Enable = enable?true:false;
772 CDialog::UpdateData (update);
774 RECT bar;
775 GetDlgItem (IDC_DOOMY_BLEND)->GetWindowRect (&bar);
776 ScreenToClient (&bar);
777 InvalidateRect (&bar);
781 // ***************************************************************************
783 const CAnimation *CSlotDlg::getAnimationPointer () const
785 // The animation pointer
786 const CAnimation *pointer = NULL;
788 // Get an instance pointer
789 CInstanceInfo *instance = getInstanceInformation ();
790 if (instance)
792 // Get a slot pointer
793 CSlotInfo *slot = getSlotInformation ();
794 uint animId = instance->AnimationSet.getAnimationIdByName (slot->Animation);
795 if (animId != CAnimationSet::NotFound)
797 // Get the animation pointer
798 pointer = instance->AnimationSet.getAnimation (animId);
802 // Return the pointer
803 return pointer;
806 // ***************************************************************************
808 const CSkeletonWeight *CSlotDlg::getSkeletonPointer () const
810 // The skeleton pointer
811 const CSkeletonWeight *pointer = NULL;
813 // Get an instance pointer
814 CInstanceInfo *instance = getInstanceInformation ();
815 if (instance)
817 // Get a slot pointer
818 CSlotInfo *slot = getSlotInformation ();
819 uint animId = instance->AnimationSet.getSkeletonWeightIdByName (slot->Skeleton);
820 if (animId != CAnimationSet::NotFound)
822 // Get the skeleton pointer
823 pointer = instance->AnimationSet.getSkeletonWeight (animId);
827 // Return the pointer
828 return pointer;
831 // ***************************************************************************
833 const NL3D::CAnimationSet *CSlotDlg::getAnimationSetPointer () const
835 // Get an instance pointer
836 CInstanceInfo *instance = getInstanceInformation ();
837 if (instance)
838 return &instance->AnimationSet;
839 else
840 return NULL;
843 // ***************************************************************************
845 CSlotInfo *CSlotDlg::getSlotInformation () const
847 // Get the instance
848 CInstanceInfo *instance = getInstanceInformation ();
849 if (instance)
851 return &instance->Saved.SlotInfo[Id];
853 else
854 return NULL;
857 // ***************************************************************************
859 CInstanceInfo *CSlotDlg::getInstanceInformation () const
861 if (MainDlg)
863 uint instance = MainDlg->getEditedObject ();
864 if (instance != 0xffffffff)
865 return MainDlg->getInstance (instance);
867 return NULL;
870 // ***************************************************************************
872 bool CSlotDlg::isEmpty()
874 return (getInstanceInformation () == NULL) || (getAnimationPointer () == NULL);
877 // ***************************************************************************
879 void CSlotDlg::OnEnable()
881 refresh (FALSE);
884 // ***************************************************************************
886 void CSlotDlg::OnInvertSkeletonWeight()
888 refresh (FALSE);