Skip to content

Commit

Permalink
More texture tool fixes and allow the tool to be opened without behav…
Browse files Browse the repository at this point in the history
…ior workspace
  • Loading branch information
aerisarn committed Sep 1, 2022
1 parent 6e554f5 commit 7d0e9e1
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 209 deletions.
237 changes: 122 additions & 115 deletions gui/src/hkx/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,125 +47,127 @@ ResourceManager::ResourceManager(WorkspaceConfig& workspace) :
scanWorkspace();
}

_charactersNames = _workspace.getCharacterProjects();
for (auto& character : _charactersNames)
if (!_workspace.empty())
{
_characters.push_back(_workspace.getFolder() / character.toUtf8().constData());
}
_charactersNames = _workspace.getCharacterProjects();
for (auto& character : _charactersNames)
{
_characters.push_back(_workspace.getFolder() / character.toUtf8().constData());
}

_miscellaneousNames = _workspace.getMiscellaneousProjects();
for (auto& misc : _miscellaneousNames)
{
_miscellaneous.push_back(_workspace.getFolder() / misc.toUtf8().constData());
}
_miscellaneousNames = _workspace.getMiscellaneousProjects();
for (auto& misc : _miscellaneousNames)
{
_miscellaneous.push_back(_workspace.getFolder() / misc.toUtf8().constData());
}

_esp = new Collection((char* const)_workspace.getFolder().string().c_str(), 3);
_esp = new Collection((char* const)_workspace.getFolder().string().c_str(), 3);

ModFlags masterFlags = ModFlags(0xA);
ModFile* skyrimMod = _esp->AddMod("creatures.esp", masterFlags);
ModFlags masterFlags = ModFlags(0xA);
ModFile* skyrimMod = _esp->AddMod("creatures.esp", masterFlags);

char* argvv[4];
argvv[0] = new char();
argvv[1] = new char();
argvv[2] = new char();
argvv[3] = new char();
logger.init(4, argvv);
char* argvv[4];
argvv[0] = new char();
argvv[1] = new char();
argvv[2] = new char();
argvv[3] = new char();
logger.init(4, argvv);

_esp->Load();
_esp->Load();

//find children classes;
hkDefaultClassNameRegistry& defaultRegistry = hkDefaultClassNameRegistry::getInstance();
hkArray<const hkClass*> classes;
defaultRegistry.getClasses(classes);
for (int i = 0; i < classes.getSize(); ++i)
{
//bool isParent = false;
//for (int j = 0; j < classes.getSize(); ++j)
//find children classes;
hkDefaultClassNameRegistry& defaultRegistry = hkDefaultClassNameRegistry::getInstance();
hkArray<const hkClass*> classes;
defaultRegistry.getClasses(classes);
for (int i = 0; i < classes.getSize(); ++i)
{
//bool isParent = false;
//for (int j = 0; j < classes.getSize(); ++j)
//{
// if (classes[j]->getParent() == classes[i])
// {
// isParent = true;
// break;
// }
//}
bool not_serializable = classes[i]->getFlags().allAreSet(hkClass::FLAGS_NOT_SERIALIZABLE);
if (!not_serializable)
_concreate_classes.push_back(classes[i]);
}

//used to generate the Special members map
//std::set<std::array<std::string, 3>> interesting_members;
//std::set<std::string> interesting_classes;
//for (int c = 0; c < _concreate_classes.size(); ++c)
//{
// if (classes[j]->getParent() == classes[i])
// for (size_t i = 0; i < _concreate_classes[c]->getNumMembers(); ++i) {
// const auto& member_declaration = _concreate_classes[c]->getMember(i);
// if (member_declaration.getFlags().get() & hkClassMember::SERIALIZE_IGNORED)
// continue;
// switch (member_declaration.getType()) {
// case hkClassMember::TYPE_INT8:
// case hkClassMember::TYPE_UINT8:
// case hkClassMember::TYPE_INT16:
// case hkClassMember::TYPE_UINT16:
// case hkClassMember::TYPE_INT32:
// case hkClassMember::TYPE_UINT32:
// case hkClassMember::TYPE_INT64:
// case hkClassMember::TYPE_UINT64:
// interesting_classes.insert(std::string(_concreate_classes[c]->getName()) + "Class");
// interesting_members.insert(
// {
// "&" + std::string(_concreate_classes[c]->getName()) + "Class",
// std::to_string(i),
// member_declaration.getName()
// }
// );
// default:
// break;
// }
// }
//}
//ofstream myfile;
//myfile.open("int_class_members.txt");
//for (auto& entry : interesting_classes)
//{
// myfile << "extern const hkClass " << entry << ";" << std::endl;
//}
//myfile << std::endl;
//for (auto& entry : interesting_members)
//{
// std::string guessed_type = "MemberIndexType::Invalid";
// if (
// entry[0].find("ragdoll") != string::npos || entry[0].find("Ragdoll") != string::npos ||
// entry[2].find("ragdoll") != string::npos || entry[2].find("Ragdoll") != string::npos
// )
// {
// guessed_type = "MemberIndexType::ragdollBoneIndex";
// }
// else if (
// entry[0].find("bone") != string::npos || entry[0].find("Bone") != string::npos ||
// entry[2].find("bone") != string::npos || entry[2].find("Bone") != string::npos
// )
// {
// guessed_type = "MemberIndexType::boneIndex";
// }
// else if (
// entry[0].find("event") != string::npos || entry[0].find("Event") != string::npos ||
// entry[2].find("event") != string::npos || entry[2].find("Event") != string::npos
// )
// {
// isParent = true;
// break;
// guessed_type = "MemberIndexType::eventIndex";
// }
// else if (
// entry[0].find("variable") != string::npos || entry[0].find("Variable") != string::npos ||
// entry[2].find("variable") != string::npos || entry[2].find("Variable") != string::npos
// )
// {
// guessed_type = "MemberIndexType::variableIndex";
// }
// myfile << "\t{{" << entry[0] << "," << entry[1] << "}, " << guessed_type <<"}, //" << entry[2] << std::endl;
//}
bool not_serializable = classes[i]->getFlags().allAreSet(hkClass::FLAGS_NOT_SERIALIZABLE);
if (!not_serializable)
_concreate_classes.push_back(classes[i]);
}

//used to generate the Special members map
//std::set<std::array<std::string, 3>> interesting_members;
//std::set<std::string> interesting_classes;
//for (int c = 0; c < _concreate_classes.size(); ++c)
//{
// for (size_t i = 0; i < _concreate_classes[c]->getNumMembers(); ++i) {
// const auto& member_declaration = _concreate_classes[c]->getMember(i);
// if (member_declaration.getFlags().get() & hkClassMember::SERIALIZE_IGNORED)
// continue;
// switch (member_declaration.getType()) {
// case hkClassMember::TYPE_INT8:
// case hkClassMember::TYPE_UINT8:
// case hkClassMember::TYPE_INT16:
// case hkClassMember::TYPE_UINT16:
// case hkClassMember::TYPE_INT32:
// case hkClassMember::TYPE_UINT32:
// case hkClassMember::TYPE_INT64:
// case hkClassMember::TYPE_UINT64:
// interesting_classes.insert(std::string(_concreate_classes[c]->getName()) + "Class");
// interesting_members.insert(
// {
// "&" + std::string(_concreate_classes[c]->getName()) + "Class",
// std::to_string(i),
// member_declaration.getName()
// }
// );
// default:
// break;
// }
// }
//}
//ofstream myfile;
//myfile.open("int_class_members.txt");
//for (auto& entry : interesting_classes)
//{
// myfile << "extern const hkClass " << entry << ";" << std::endl;
//}
//myfile << std::endl;
//for (auto& entry : interesting_members)
//{
// std::string guessed_type = "MemberIndexType::Invalid";
// if (
// entry[0].find("ragdoll") != string::npos || entry[0].find("Ragdoll") != string::npos ||
// entry[2].find("ragdoll") != string::npos || entry[2].find("Ragdoll") != string::npos
// )
// {
// guessed_type = "MemberIndexType::ragdollBoneIndex";
// }
// else if (
// entry[0].find("bone") != string::npos || entry[0].find("Bone") != string::npos ||
// entry[2].find("bone") != string::npos || entry[2].find("Bone") != string::npos
// )
// {
// guessed_type = "MemberIndexType::boneIndex";
// }
// else if (
// entry[0].find("event") != string::npos || entry[0].find("Event") != string::npos ||
// entry[2].find("event") != string::npos || entry[2].find("Event") != string::npos
// )
// {
// guessed_type = "MemberIndexType::eventIndex";
// }
// else if (
// entry[0].find("variable") != string::npos || entry[0].find("Variable") != string::npos ||
// entry[2].find("variable") != string::npos || entry[2].find("Variable") != string::npos
// )
// {
// guessed_type = "MemberIndexType::variableIndex";
// }
// myfile << "\t{{" << entry[0] << "," << entry[1] << "}, " << guessed_type <<"}, //" << entry[2] << std::endl;
//}
//myfile.close();

//myfile.close();
}
}

ResourceManager::~ResourceManager()
Expand Down Expand Up @@ -1263,7 +1265,7 @@ QStringList ResourceManager::clipAnimationsList(int project_index)
return out.toList();
}

QStringList ResourceManager::attackEventList(int project_index)
QStringList ResourceManager::eventList(int project_index, bool attacksOnly)
{
HKXWrapper wrap;
QSet<QString> out;
Expand All @@ -1287,13 +1289,18 @@ QStringList ResourceManager::attackEventList(int project_index)
for (int e = 0; e < string_data->m_eventNames.getSize(); ++e)
{
QString eventName = string_data->m_eventNames[e].cString();
if (
eventName.startsWith("attackStart") ||
eventName.startsWith("attackPowerStart") ||
eventName.startsWith("bashStart") ||
eventName.startsWith("bashPowerStart")
)
if (attacksOnly)
{
if (eventName.startsWith("attackStart") ||
eventName.startsWith("attackPowerStart") ||
eventName.startsWith("bashStart") ||
eventName.startsWith("bashPowerStart")
)
{
out << eventName;
}
}
else {
out << eventName;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/src/hkx/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ namespace ckcmd {
QStringList assetsList(int project_index, AssetType type);
QStringList clipList(int project_index);
QStringList clipAnimationsList(int project_index);
QStringList attackEventList(int project_index);
QStringList eventList(int project_index, bool attacksOnly);
QStringList wordVariableList(int project_index);

/* CACHE SETS */
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ int main(int argc, char *argv[])
return 1; // Error, for example
}
Settings.set("/general/workspace_folder", launcher._workspace_folder);
workspace_path = launcher._workspace_folder.toStdString();
workspace_path = launcher._workspace_folder.toUtf8().constData();
}

//Check if the workspace is empty
Expand Down
25 changes: 13 additions & 12 deletions gui/src/models/ProjectModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,23 +575,24 @@ QAbstractItemModel* ProjectModel::editModel(const QModelIndex& index, AssetType
}
else if (AssetType::events == type)
{
auto top_behavior_index = getChildAssetProxy(index, NodeType::BehaviorHkxNode);
if (top_behavior_index.isValid())
{
if (AssetType::events == type)
{
auto events_node = getChildAssetProxy(top_behavior_index, NodeType::behaviorEventNames);
if (events_node.isValid())
return new SelectionProxyModel(this, events_node);
}
}
return nullptr;
//auto top_behavior_index = getChildAssetProxy(index, NodeType::BehaviorHkxNode);
//if (top_behavior_index.isValid())
//{
// if (AssetType::events == type)
// {
// auto events_node = getChildAssetProxy(top_behavior_index, NodeType::behaviorEventNames);
// if (events_node.isValid())
// return new SelectionProxyModel(this, events_node);
// }
//}
//return nullptr;
return new StringListModel(_resourceManager.eventList(edge._project, false));
}
else if (AssetType::variable_words == type) {
return new StringListModel(_resourceManager.wordVariableList(edge._project));
}
else if (AssetType::attack_events == type) {
return new StringListModel(_resourceManager.attackEventList(edge._project));
return new StringListModel(_resourceManager.eventList(edge._project, true));
}
else if (AssetType::clips == type) {
return new StringListModel(_resourceManager.clipList(edge._project));
Expand Down
3 changes: 2 additions & 1 deletion gui/src/widgets/TextureTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ void TextureTool::on_folderLineEdit_textChanged(const QString& text)
{
_proxyModel->setFilterFixedString(pattern);
nifView->expandAll();
nifView->resizeColumnToContents(0);
}
);

nifView->setModel(_proxyModel.get());
nifView->setVisible(false);
nifView->resizeColumnToContents(0);
nifView->expandAll();
nifView->resizeColumnToContents(0);
nifView->setVisible(true);

connect(nifView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TextureTool::on_nifView_selectionChanged);
Expand Down
Loading

0 comments on commit 7d0e9e1

Please sign in to comment.