Implemented Animation Clip asset and animation controller #410

Merged
XiaoQiDigipen merged 66 commits from SP3-22-AnimationController into main 2023-03-09 16:19:40 +08:00
2 changed files with 83 additions and 2 deletions
Showing only changes of commit 9a8114f5dd - Show all commits

View File

@ -52,6 +52,13 @@ namespace SHADE
">", ">",
">=" ">="
}; };
typesList =
{
"Boolean",
"Trigger",
"Float",
"Integer"
};
// Set up sample animation controller for testing // Set up sample animation controller for testing
SHAnimationController controller; SHAnimationController controller;
@ -101,7 +108,7 @@ namespace SHADE
ImGui::TableNextRow(); ImGui::TableNextRow();
{ {
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("Parameters"); drawParamsPanel();
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
drawNodeEditor(); drawNodeEditor();
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
@ -147,6 +154,79 @@ namespace SHADE
} }
} }
void SHAnimationControllerEditor::drawParamsPanel()
{
// Add Parameter Button
if (ImGui::BeginCombo("##Type", "Add Parameter", ImGuiComboFlags_None))
{
// All other options
for (int i = 0; i < static_cast<int>(typesList.size()); ++i)
{
if (ImGui::Selectable(typesList[i].c_str()))
{
controllerData->Params.emplace("New", static_cast<SHAnimationController::AnimParam::Type>(i));
}
}
ImGui::EndCombo();
}
int paramId = 0;
for (auto param : controllerData->Params)
{
ImGui::PushID(paramId++);
if (SHEditorWidgets::InputText
(
"",
[&]() { return param.first; },
[&](const std::string& val)
{
// Remove from previous
const SHAnimationController::AnimParam::Type TYPE = param.second;
controllerData->Params.erase(param.first);
// Put into the new
controllerData->Params[val] = TYPE;
}
))
{
ImGui::PopID();
break; // Map was modified
}
ImGui::SameLine();
if (ImGui::BeginCombo("##Type", typesList[static_cast<int>(param.second)].c_str(), ImGuiComboFlags_None))
{
// All other options
for (int i = 0; i < static_cast<int>(typesList.size()); ++i)
{
const bool IS_SELECTED = static_cast<int>(param.second) == i;
if (ImGui::Selectable(typesList[i].c_str(), IS_SELECTED))
{
SHCommandManager::PerformCommand
(
std::reinterpret_pointer_cast<SHBaseCommand>
(
std::make_shared<SHCommand<SHAnimationController::AnimParam::Type>>
(
param.second,
static_cast<SHAnimationController::AnimParam::Type>(i),
[&](SHAnimationController::AnimParam::Type val) { controllerData->Params[param.first] = val; }
)
),
false
);
}
if (IS_SELECTED)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
ImGui::PopID();
}
}
void SHAnimationControllerEditor::drawNodeEditor() void SHAnimationControllerEditor::drawNodeEditor()
{ {
static constexpr float NODE_WIDTH = 80.0f; static constexpr float NODE_WIDTH = 80.0f;
@ -324,7 +404,6 @@ namespace SHADE
const bool IS_SELECTED = param.first == linkData.ParamName; const bool IS_SELECTED = param.first == linkData.ParamName;
if (ImGui::Selectable(param.first.c_str(), IS_SELECTED)) if (ImGui::Selectable(param.first.c_str(), IS_SELECTED))
{ {
linkData.ParamName = param.first;
SHCommandManager::PerformCommand SHCommandManager::PerformCommand
( (
std::reinterpret_pointer_cast<SHBaseCommand> std::reinterpret_pointer_cast<SHBaseCommand>

View File

@ -114,11 +114,13 @@ namespace SHADE
std::optional<AnimControllerData> controllerData; std::optional<AnimControllerData> controllerData;
// Persistent Cached Data // Persistent Cached Data
std::vector<std::string> conditionsList; std::vector<std::string> conditionsList;
std::vector<std::string> typesList;
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Helper Functions */ /* Helper Functions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
void drawActiveMenuBar(); void drawActiveMenuBar();
void drawParamsPanel();
void drawNodeEditor(); void drawNodeEditor();
void drawPropertiesPanel(); void drawPropertiesPanel();
NodeAttributeIndex getExtraInputAttrib(uint32_t nodeIndex); NodeAttributeIndex getExtraInputAttrib(uint32_t nodeIndex);