Skip to content

Commit

Permalink
0.5a
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentalimbed committed May 12, 2022
1 parent 4f5520b commit 825dd9a
Show file tree
Hide file tree
Showing 18 changed files with 911 additions and 805 deletions.
7 changes: 5 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
- 0.4a Macros
- 0.4a Parse trigger macro

- 0.5a Refactor the shit out of the bloody widgets
- 0.5a ListView/PropEdit edit all kinds of hkx file (which they're supposed to but were not due to my stupidity)
- 0.5a Scalar/Reference edit's width set to fixed

Behaviour diagnosis
Display names within the var/state/ref/evt edit when not editing (using combobox?)
Editing character file
Refactor the shit out of the bloody widgets!
Editing character file (anim name & properties)
Nested state id picker
4 changes: 2 additions & 2 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ int initApp()

Hkx::HkxFileManager::getSingleton()->appendListener(Hkx::kEventFileChanged, [=]() {
auto file_manager = Hkx::HkxFileManager::getSingleton();
if (file_manager->isFileSelected())
glfwSetWindowTitle(g_window, fmt::format("{} [{}]", g_window_title, file_manager->getCurrentFile().getPath()).c_str());
if (auto file = file_manager->getCurrentFile(); file)
glfwSetWindowTitle(g_window, fmt::format("{} [{}]", g_window_title, file->getPath()).c_str());
else
glfwSetWindowTitle(g_window, g_window_title);
});
Expand Down
18 changes: 18 additions & 0 deletions src/hkx/hkclass.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,24 @@ constexpr auto g_class_modifiers = std::to_array<std::string_view>(
"BSTweenerModifier",
"BSSpeedSamplerModifier"});

constexpr auto g_class_payload = std::to_array<std::string_view>({"hkbStringEventPayload"});
constexpr auto g_class_transition = std::to_array<std::string_view>({"hkbBlendingTransitionEffect"});
constexpr auto g_class_expression = std::to_array<std::string_view>({"hkbExpressionCondition"});
constexpr auto g_class_expr_array = std::to_array<std::string_view>({"hkbExpressionDataArray"});
constexpr auto g_class_binding = std::to_array<std::string_view>({"hkbVariableBindingSet"});
constexpr auto g_class_graph_data = std::to_array<std::string_view>({"hkbBehaviorGraphData"});
constexpr auto g_class_state_chooser = std::to_array<std::string_view>({"hkbStateChooser"});
constexpr auto g_class_transition_array = std::to_array<std::string_view>({"hkbBlendingTrahkbStateMachineTransitionInfoArraynsitionEffect"});
constexpr auto g_class_events_array = std::to_array<std::string_view>({"hkbStateMachineEventPropertyArray"});
constexpr auto g_class_bone_weights = std::to_array<std::string_view>({"hkbBoneWeightArray"});
constexpr auto g_class_bone_indices = std::to_array<std::string_view>({"hkbBoneIndexArray"});
constexpr auto g_class_boneswitch_data = std::to_array<std::string_view>({"BSBoneSwitchGeneratorBoneData"});
constexpr auto g_class_triggers = std::to_array<std::string_view>({"hkbClipTriggerArray"});
constexpr auto g_class_clip = std::to_array<std::string_view>({"hkbClipGenerator"});
constexpr auto g_class_blender_gens = std::to_array<std::string_view>({"hkbBlenderGenerator", "hkbPoseMatchingGenerator"});
constexpr auto g_class_event_ranges = std::to_array<std::string_view>({"hkbEventRangeDataArray"});
constexpr auto g_class_key_bones = std::to_array<std::string_view>({"keyframedBonesList"});

////////////////////////// CLASS INFO

inline const std::map<std::string_view, std::string_view>& getClassInfo()
Expand Down
6 changes: 3 additions & 3 deletions src/hkx/hkutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Haviour
{
inline pugi::xml_node getParentStateMachine(pugi::xml_node hkparam, Hkx::BehaviourFile& file)
inline pugi::xml_node getParentStateMachine(pugi::xml_node hkparam, Hkx::HkxFile& file)
{
auto state_machine = getParentObj(hkparam);
while (strcmp(state_machine.attribute("class").as_string(), "hkbStateMachine"))
Expand All @@ -25,7 +25,7 @@ inline pugi::xml_node getParentStateMachine(pugi::xml_node hkparam, Hkx::Behavio
return {};
}

inline pugi::xml_node getStateById(pugi::xml_node state_machine, int32_t state_id, Hkx::BehaviourFile& file)
inline pugi::xml_node getStateById(pugi::xml_node state_machine, int32_t state_id, Hkx::HkxFile& file)
{
if (strcmp(state_machine.attribute("class").as_string(), "hkbStateMachine"))
return {};
Expand All @@ -48,7 +48,7 @@ inline pugi::xml_node getStateById(pugi::xml_node state_machine, int32_t state_i
return {};
}

inline int getBiggestStateId(pugi::xml_node state_machine, Hkx::BehaviourFile& file)
inline int getBiggestStateId(pugi::xml_node state_machine, Hkx::HkxFile& file)
{
if (strcmp(state_machine.attribute("class").as_string(), "hkbStateMachine"))
return -1;
Expand Down
6 changes: 3 additions & 3 deletions src/hkx/hkxfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ void HkxFileManager::loadFile(std::string_view path)
file.loadFile(path);
if (file.isFileLoaded())
{
m_current_file = m_files.size() - 1;
m_current_file = &m_files[m_files.size() - 1];
dispatch(kEventFileChanged);
}
else
Expand All @@ -678,10 +678,10 @@ void HkxFileManager::loadFile(std::string_view path)

void HkxFileManager::saveFile(std::string_view path)
{
if (m_current_file < 0)
if (!m_current_file)
return;

m_files[m_current_file].saveFile(path);
m_current_file->saveFile(path);
}
} // namespace Hkx
} // namespace Haviour
53 changes: 44 additions & 9 deletions src/hkx/hkxfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ enum HkxFileEventEnum
class HkxFile
{
public:
enum HkxFileType
{
kUnknown,
kBehaviour,
kCharacter,
kSkeleton
};
virtual constexpr HkxFileType getType() { return kUnknown; }

void loadFile(std::string_view path);
void saveFile(std::string_view path = {});
inline bool isFileLoaded() { return m_loaded; }
Expand Down Expand Up @@ -97,6 +106,8 @@ class HkxFile
class BehaviourFile : public HkxFile
{
public:
virtual constexpr HkxFileType getType() override { return kBehaviour; }

void loadFile(std::string_view path);
void saveFile(std::string_view path = {});

Expand Down Expand Up @@ -136,6 +147,8 @@ class BehaviourFile : public HkxFile
class SkeletonFile : public HkxFile
{
public:
virtual constexpr HkxFileType getType() override { return kSkeleton; }

void loadFile(std::string_view path);

inline pugi::xml_node getBoneNode(bool ragdoll = false) { return (ragdoll ? m_skel_rag_obj : m_skel_obj).getByName("bones"); }
Expand All @@ -155,6 +168,8 @@ class SkeletonFile : public HkxFile
class CharacterFile : public HkxFile
{
public:
virtual constexpr HkxFileType getType() override { return kCharacter; }

void loadFile(std::string_view path);

inline virtual bool isObjEssential(std::string_view id) override
Expand All @@ -179,13 +194,32 @@ class HkxFileManager : public eventpp::EventDispatcher<HkxFileEventEnum, void()>

inline void setCurrentFile(int idx)
{
m_current_file = idx;
m_current_file = &m_files[idx];
dispatch(kEventFileChanged);
}
inline size_t getCurrentFileIdx() { return m_current_file; }
inline BehaviourFile& getCurrentFile() { return m_files[m_current_file]; }
inline void setCurrentFile(HkxFile::HkxFileType type)
{
switch (type)
{
case HkxFile::kBehaviour:
if (m_files.empty())
m_current_file = nullptr;
else
setCurrentFile(0);
break;
case HkxFile::kSkeleton:
m_current_file = &m_skel_file;
break;
case HkxFile::kCharacter:
m_current_file = &m_char_file;
break;
default: break;
}
if (type != HkxFile::kUnknown)
dispatch(kEventFileChanged);
}
inline HkxFile* getCurrentFile() { return m_current_file; }

inline bool isFileSelected() { return m_current_file >= 0; }
inline std::vector<std::string_view> getPathList()
{
std::vector<std::string_view> retval;
Expand All @@ -198,16 +232,17 @@ class HkxFileManager : public eventpp::EventDispatcher<HkxFileEventEnum, void()>
void saveFile(std::string_view path = {});
inline void closeCurrentFile()
{
if (m_current_file >= 0)
if (m_current_file->getType() == HkxFile::kBehaviour)
{
m_files.erase(m_files.begin() + m_current_file);
m_current_file = m_files.empty() ? -1 : std::clamp(m_current_file, 0, (int)m_files.size() - 1);
auto idx = std::ranges::find_if(m_files, [=](auto& item) { return &item == m_current_file; }) - m_files.begin();
m_files.erase(m_files.begin() + idx);
m_current_file = m_files.empty() ? nullptr : &m_files[std::clamp(idx, (int64_t)0, (int64_t)m_files.size() - 1)];
dispatch(kEventFileChanged);
}
}
inline void closeAllFiles()
{
m_current_file = -1;
m_current_file = nullptr;
m_files.clear();
dispatch(kEventFileChanged);
}
Expand All @@ -216,7 +251,7 @@ class HkxFileManager : public eventpp::EventDispatcher<HkxFileEventEnum, void()>
CharacterFile m_char_file;

private:
int m_current_file = -1;
HkxFile* m_current_file = nullptr;
std::vector<BehaviourFile> m_files;
};

Expand Down
Loading

0 comments on commit 825dd9a

Please sign in to comment.