!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / SchematycEditor / LegacyOpenDlgModel.cpp
bloba3c9b1c1fd3e5cdf6fee4d68f841278b1e620d3d
1 // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
4 #include "LegacyOpenDlgModel.h"
6 #include <CrySchematyc2/IFramework.h>
7 #include <CrySchematyc2/Script/IScriptRegistry.h>
9 #include "Util.h"
11 namespace Cry {
12 namespace SchematycEd {
14 uint32 CLegacyOpenDlgEntry::GetType() const
16 return CAbstractDictionaryEntry::Type_Entry;
19 QVariant CLegacyOpenDlgEntry::GetColumnValue(int32 columnIndex) const
21 switch (columnIndex)
23 case CLegacyOpenDlgModel::Column_Name:
24 return QVariant::fromValue(m_name);
25 default:
26 break;
29 return QVariant();
32 QString CLegacyOpenDlgEntry::GetToolTip() const
34 return m_description;
37 QString CLegacyOpenDlgEntry::GetName() const
39 return m_name;
42 QString CLegacyOpenDlgEntry::GetFullName() const
44 return m_fullName;
47 SGUID CLegacyOpenDlgEntry::GetTypeGUID()
49 return m_guid;
53 CLegacyOpenDlgModel::CLegacyOpenDlgModel()
55 Load();
58 CLegacyOpenDlgModel::~CLegacyOpenDlgModel()
62 int32 CLegacyOpenDlgModel::GetNumEntries() const
64 return m_entries.size();
67 const CAbstractDictionaryEntry* CLegacyOpenDlgModel::GetEntry(int32 index) const
69 if (index < m_entries.size())
71 return &m_entries[index];
74 return nullptr;
77 int32 CLegacyOpenDlgModel::GetNumColumns() const
79 return Column_Count;
82 QString CLegacyOpenDlgModel::GetColumnName(int32 index) const
84 switch (index)
86 case Column_Name:
87 return QString("Name");
88 default:
89 break;
92 return QString();
95 int32 CLegacyOpenDlgModel::GetDefaultFilterColumn() const
97 return Column_Name;
100 int32 CLegacyOpenDlgModel::GetDefaultSortColumn() const
102 return Column_Name;
105 void CLegacyOpenDlgModel::Load()
107 m_entries.reserve(100);
109 using VisitClassFunc = std::function<EVisitStatus(const IScriptClass&, const stack_string&)>;
110 VisitClassFunc visitClassFunc = [this](const IScriptClass& scriptClass, const stack_string& filePath)
112 CLegacyOpenDlgEntry entry;
114 entry.m_name = scriptClass.GetName();
115 entry.m_guid = scriptClass.GetGUID();
116 entry.m_fullName = filePath;
117 entry.m_description = scriptClass.GetDescription();
119 m_entries.emplace_back(entry);
121 return EVisitStatus::Continue;
124 using VisitScriptsFunc = std::function<void(const VisitClassFunc& visitClassFunc, const stack_string&)>;
125 static VisitScriptsFunc visitScriptsFunc = [](const VisitClassFunc& visitClassFunc, const stack_string& path)
127 TStringVector subFolderNames;
128 TStringVector fileNames;
130 GetSubFoldersAndFileNames(path.c_str(), "*.*", true, subFolderNames, fileNames);
132 for (auto& fileName : fileNames)
134 stack_string scriptFileName = path;
135 scriptFileName.append("/");
136 scriptFileName.append(fileName.c_str());
138 const IScriptFile* pScriptFile = gEnv->pSchematyc2->GetScriptRegistry().GetFile(scriptFileName.c_str());
139 if (pScriptFile)
141 auto lambda = std::bind(visitClassFunc, std::placeholders::_1, scriptFileName);
143 SGUID scopeGUID;
144 pScriptFile->VisitClasses(ScriptClassConstVisitor::FromLambdaFunction(lambda), scopeGUID, false);
148 for (auto& subFolderName : subFolderNames)
150 stack_string subFolderPath = path;
151 subFolderPath.append("/");
152 subFolderPath.append(subFolderName.c_str());
154 visitScriptsFunc(visitClassFunc, subFolderPath);
158 visitScriptsFunc(visitClassFunc, gEnv->pSchematyc2->GetOldScriptsFolder());
162 } //namespace SchematycEd
163 } //namespace Cry