Skip to content

Commit

Permalink
0.6a
Browse files Browse the repository at this point in the history
- 0.6a Editing character file (anim name & properties)
- 0.6a CRC32 Macro
- 0.6a char prop in behavior file can edit type now
  • Loading branch information
Pentalimbed committed May 13, 2022
1 parent 6455cb4 commit 7e8da1d
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 232 deletions.
9 changes: 7 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
- 0.5.1a Blending transition hotfix
- 0.5.1a Transition array hotfix

- 0.6a Editing character file (anim name & properties)
- 0.6a CRC32 Macro
- 0.6a char prop in behavior file can edit type now

Delete all children
Behaviour diagnosis
Display names within the var/state/ref/evt edit when not editing (using combobox?)
Editing character file (anim name & properties)
Scrolling names for var/state/ref/evt edit
Nested state id picker
Maybe cleanup replicate varedit code?
1 change: 0 additions & 1 deletion cmake/headerlist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ set(headers
src/ui/propedit.h
src/ui/columnview.h
src/ui/macros.h
src/ui/charedit.h
)
1 change: 0 additions & 1 deletion cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ set(sources
src/ui/propedit.cpp
src/ui/columnview.cpp
src/ui/macros.cpp
src/ui/charedit.cpp
)
15 changes: 15 additions & 0 deletions src/hkx/hkclass.inl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,23 @@ inline VariableTypeEnum getVarTypeEnum(std::string_view enumstr)
return VARIABLE_TYPE_INVALID;
}


#define DEFENUM(name) constexpr auto name = std::to_array<EnumWrapper>

DEFENUM(e_variableTypeEnum) // for prop edit
({
{"VARIABLE_TYPE_INVALID"},
{"VARIABLE_TYPE_BOOL"},
{"VARIABLE_TYPE_INT8"},
{"VARIABLE_TYPE_INT16"},
{"VARIABLE_TYPE_INT32"},
{"VARIABLE_TYPE_REAL"},
{"VARIABLE_TYPE_POINTER"},
{"VARIABLE_TYPE_VECTOR3"},
{"VARIABLE_TYPE_VECTOR4"},
{"VARIABLE_TYPE_QUATERNION"},
});

// hkbVariableInfo -> hkbRoleAttribute
DEFENUM(e_hkbRoleAttribute_Role)
({
Expand Down
3 changes: 1 addition & 2 deletions src/hkx/linkedmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ class CharacterPropertyManager : public LinkedPropertyManager<CharacterProperty>
{
auto retval = LinkedPropertyManager<CharacterProperty>::addEntry();

retval.get<PropVarInfo>().getByName("type").text() = "VARIABLE_TYPE_POINTER";
retval.get<PropVarInfo>().getByName("role").first_child().getByName("flags").text() = "FLAG_OUTPUT|FLAG_HIDDEN|FLAG_NOT_VARIABLE|FLAG_NONE";
retval.get<PropVarInfo>().getByName("role").first_child().getByName("flags").text() = "FLAG_NOT_VARIABLE|FLAG_NONE";

return retval;
}
Expand Down
121 changes: 0 additions & 121 deletions src/ui/charedit.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions src/ui/charedit.h

This file was deleted.

44 changes: 43 additions & 1 deletion src/ui/macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "hkx/hkutils.h"
#include "hkx/hkclass.inl"

#include <filesystem>

#include <imgui.h>
#include <extern/imgui_stdlib.h>

Expand All @@ -19,7 +21,7 @@ void MacroModal::open(pugi::xml_node working_obj, Hkx::HkxFile* file)
}
void MacroModal::show()
{
if (!m_working_obj || !m_file)
if (getClass() && (!m_working_obj || !m_file))
{
m_open = false;
return;
Expand Down Expand Up @@ -126,6 +128,44 @@ void TriggerMacro::parse()
}
}

//////////////////// CRC32

void Crc32Macro::open(pugi::xml_node working_obj, Hkx::HkxFile* file)
{
MacroModal::open(working_obj, file);
m_path = {};
}

void Crc32Macro::drawUi()
{
ImGui::TextUnformatted(getHint());
ImGui::Separator();
if (ImGui::InputTextWithHint("Path", R"(meshes\actors\character\animations\1hm_attackright.hkx)", &m_path, ImGuiInputTextFlags_EnterReturnsTrue))
{
auto temp_path = m_path;

for (auto& ch : temp_path)
if (ch == '/') ch = '\\';
transform(temp_path.begin(), temp_path.end(), temp_path.begin(), ::tolower);

std::filesystem::path path(temp_path);
if (path.has_stem() && path.has_parent_path())
{
auto parent = path.parent_path().string();
auto stem = path.stem().string();

m_out_crc = fmt::format("{}\n{}\n{}",
Crc32::update(parent.data(), parent.length()),
Crc32::update(stem.data(), stem.length()),
7891816);
}
}
addTooltip("Press Enter to convert");
ImGui::InputTextMultiline("Output", &m_out_crc, {}, ImGuiInputTextFlags_ReadOnly);
}

//////////////////// Macro manager

MacroManager* MacroManager::getSingleton()
{
static MacroManager manager;
Expand All @@ -135,6 +175,8 @@ MacroManager* MacroManager::getSingleton()
MacroManager::MacroManager()
{
m_macros.emplace_back(std::make_unique<TriggerMacro>());
m_macros.emplace_back(std::make_unique<Crc32Macro>());

m_file_listener = Hkx::HkxFileManager::getSingleton()->appendListener(Hkx::kEventFileChanged, [=]() {
for (auto& macro : m_macros)
{
Expand Down
23 changes: 22 additions & 1 deletion src/ui/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MacroModal
friend class MacroManager;

virtual constexpr const char* getName() = 0;
virtual constexpr const char* getClass() = 0;
virtual constexpr const char* getClass() = 0; // nullptr = no objects / files, empty string = any objects
virtual constexpr const char* getHint() = 0;
virtual void open(pugi::xml_node working_obj, Hkx::HkxFile* file);
virtual void show();
Expand Down Expand Up @@ -57,6 +57,27 @@ class TriggerMacro : public MacroModal
void parse();
};

class Crc32Macro : public MacroModal
{
public:
virtual void open(pugi::xml_node working_obj, Hkx::HkxFile* file) override;
virtual constexpr const char* getName() override { return "CRC32"; }
virtual constexpr const char* getClass() override { return nullptr; }
virtual constexpr const char* getHint() override
{
return "This macro will generate crc32 checksum for an animation path.\n"
"All capital letters with be converted to lower case, and all / to \\\n"
"Extension doesn't matter because this is only for hkx files.";
}
virtual void drawUi() override;

private:
std::string m_path;
std::string m_out_crc;

void parse();
};

/////////////////////////// MACRO MANAGER

class MacroManager
Expand Down
14 changes: 14 additions & 0 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ void showMenuBar()
file_manager->getCurrentFile()->buildRefList();
if (ImGui::MenuItem("Reindex Objects", nullptr, false, file_manager->isCurrentFileReady()))
file_manager->getCurrentFile()->reindexObj();

ImGui::Separator();

for (auto& macro : MacroManager::getSingleton()->getMacros())
if (!macro->getClass())
{
if (ImGui::MenuItem(macro->getName()))
{
ImGui::CloseCurrentPopup();
macro->open({}, nullptr);
}
addTooltip(macro->getHint());
}

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Window"))
Expand Down
4 changes: 1 addition & 3 deletions src/ui/propedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,13 @@ void PropEdit::show()
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_SCROLL))
{
ImGui::OpenPopup("Macro Select");
}
addTooltip("Macros");
if (ImGui::BeginPopup("Macro Select"))
{
bool has_something = false;
for (auto& macro : MacroManager::getSingleton()->getMacros())
if (!strcmp(macro->getClass(), class_str))
if (macro->getClass() && !strcmp(macro->getClass(), class_str))
{
has_something = true;
if (ImGui::Selectable(macro->getName()))
Expand Down
Loading

0 comments on commit 7e8da1d

Please sign in to comment.