-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimatorInspector.cpp
More file actions
53 lines (44 loc) · 1.33 KB
/
Copy pathAnimatorInspector.cpp
File metadata and controls
53 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "AnimatorInspector.h"
#include "Editor/UI/Inspector.h"
#include "Editor/DragDropHelper.hpp"
#include <limits>
namespace sh::editor
{
SH_EDIT_API void AnimatorInspector::RenderUI(const std::vector<core::SObject*>& objs, int idx)
{
CustomInspector::RenderUI(objs, idx);
game::Animator& animator = *reinterpret_cast<game::Animator*>(objs.back());
if (animator.IsPendingKill())
return;
ImGui::Text("animation/condition");
for (int i = 0; i < animator.anims.size(); ++i)
{
auto& animPtr = animator.anims[i].anim;
int& condition = animator.anims[i].condition;
std::string name = core::IsValid(animPtr) ? animPtr->GetName().ToString() : "None";
if (ImGui::Button(name.c_str()))
{
}
if (ImGui::BeginDragDropTarget())
{
if (game::AnimationData* animationDataPtr = editor::dragdrop::AcceptAsset<game::AnimationData>())
animPtr = animationDataPtr;
}
ImGui::SameLine();
ImGui::SetNextItemWidth(40);
ImGui::InputInt(fmt::format("##delay{}", i).c_str(), &condition, 0);
ImGui::SameLine();
if (ImGui::Button(fmt::format("-##{}", i).c_str()))
{
animator.anims.erase(animator.anims.begin() + i);
break;
}
}
ImGui::Separator();
if (ImGui::Button("Add"))
{
animator.anims.emplace_back();
}
Inspector::RenderProperties(animator.GetType(), animator, idx);
}
}//namespace