1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
7 #include <Models/CharacterAnimationsModel.h>
8 #include <Dialogs/TreeViewDialog.h>
9 #include "IResourceSelectorHost.h"
11 #include <CryAnimation/ICryAnimation.h>
13 dll_string
CharacterAnimationSelector(const SResourceSelectorContext
& x
, const char* previousValue
, IEntity
* pEntity
)
15 if (!pEntity
|| !pEntity
->GetCharacter(0) || !pEntity
->GetCharacter(0)->GetIAnimationSet())
18 IAnimationSet
* pAnimSet
= pEntity
->GetCharacter(0)->GetIAnimationSet();
19 CCharacterAnimationsModel
* pModel
= new CCharacterAnimationsModel(*pAnimSet
);
20 CTreeViewDialog
dialog(x
.parentWidget
);
21 QString
selectedValue(previousValue
);
23 dialog
.Initialize(pModel
, 0);
25 for (int32 row
= pModel
->rowCount(); row
--; )
27 const QModelIndex index
= pModel
->index(row
, 0);
28 if (pModel
->data(index
, Qt::DisplayRole
).value
<QString
>() == selectedValue
)
30 dialog
.SetSelectedValue(index
, false);
36 QModelIndex index
= dialog
.GetSelected();
39 return index
.data().value
<QString
>().toLocal8Bit().data();
46 dll_string
ValidateCharacterAnimation(const SResourceSelectorContext
& x
, const char* newValue
, const char* previousValue
, IEntity
* pEntity
)
48 if (!newValue
|| !*newValue
)
51 if (!pEntity
|| !pEntity
->GetCharacter(0) || !pEntity
->GetCharacter(0)->GetIAnimationSet())
54 IAnimationSet
* pAnimSet
= pEntity
->GetCharacter(0)->GetIAnimationSet();
55 CCharacterAnimationsModel
* pModel
= new CCharacterAnimationsModel(*pAnimSet
);
56 int itemCount
= pModel
->rowCount();
57 for (int i
= 0; i
< itemCount
; ++i
)
59 QModelIndex index
= pModel
->index(i
, 0);
60 if (pModel
->data(index
, Qt::DisplayRole
).value
<QString
>() == newValue
)
67 dll_string
ValidateTrackCharacterAnimation(const SResourceSelectorContext
& x
, const char* newValue
, const char* previousValue
, IEntity
* pEntity
)
72 REGISTER_RESOURCE_VALIDATING_SELECTOR("TrackCharacterAnimation", CharacterAnimationSelector
, ValidateTrackCharacterAnimation
, "")
73 REGISTER_RESOURCE_VALIDATING_SELECTOR("CharacterAnimation", CharacterAnimationSelector
, ValidateCharacterAnimation
, "")