2enum SCR_ESearchXOBPluginSearchType
11enum SCR_ESearchXOBPluginLayerFilter
19class SCR_SearchXOBFunctor
21 protected ref array<ResourceName> m_aFiles;
22 protected int m_iCounter;
23 protected bool m_bPrintFiles;
24 protected bool m_bIgnoreNoColliders;
25 protected ResourceName m_sSearchedDirectory;
26 protected int m_iAddon;
32 WBProgressDialog progress =
new WBProgressDialog(
"Searching...", null);
36 string addon = SCR_AddonTool.ToFileSystem(SCR_AddonTool.GetAddonID(m_iAddon));
38 m_aFiles = SCR_WorkbenchHelper.SearchWorkbenchResources({
"xob" }, null, addon + m_sSearchedDirectory.GetPath());
39 int count = m_aFiles.Count();
40 int updateMask = SCR_Math.IntegerMask(count * 0.1);
42 foreach (
int i, ResourceName file : m_aFiles)
46 if ((i & updateMask) == updateMask)
47 progress.SetProgress(i / count);
55 protected void PrintHeader();
56 protected void ProcessFile(ResourceName file);
57 protected void PrintResults();
65 void SCR_SearchXOBFunctor(
bool printFiles,
bool ignoreNoColliders, ResourceName searchedDir,
int searchedAddon)
68 m_bPrintFiles = printFiles;
69 m_bIgnoreNoColliders = ignoreNoColliders;
70 m_sSearchedDirectory = searchedDir;
71 m_iAddon = searchedAddon;
75class SCR_SearchXOBListAllFunctor : SCR_SearchXOBFunctor
78 override void PrintHeader()
80 Print(
"--- List All XOBs --------------------------------------------------------------",
LogLevel.NORMAL);
84 override void ProcessFile(ResourceName file)
91 override void PrintResults()
97class SCR_SearchXOBLoadAllFunctor : SCR_SearchXOBFunctor
100 override void PrintHeader()
102 Print(
"--- Load All XOBs --------------------------------------------------------------",
LogLevel.NORMAL);
106 override void ProcessFile(ResourceName file)
108 Resource res = Resource.Load(file);
109 MeshObject mesh = res.GetResource().ToMeshObject();
115 override void PrintResults()
122class SCR_SearchXOBInvalidMaskFunctor : SCR_SearchXOBFunctor
125 override void PrintHeader()
127 Print(
"--- Find Invalid Mask ----------------------------------------------------------",
LogLevel.NORMAL);
131 override void ProcessFile(ResourceName file)
133 Resource res = Resource.Load(file);
134 MeshObject mesh = res.GetResource().ToMeshObject();
135 if (m_bIgnoreNoColliders && mesh.GetNumGeoms() == 0)
138 if (mesh.HasValidMask())
143 Print(
string.Format(
"@\"%1\"", file.GetPath()),
LogLevel.NORMAL);
147 override void PrintResults()
154class SCR_SearchXOBLayerMaskFunctor : SCR_SearchXOBFunctor
156 protected int m_iLayerMask;
157 protected SCR_ESearchXOBPluginLayerFilter m_eLayerFilter = SCR_ESearchXOBPluginLayerFilter.ANY;
160 override void PrintHeader()
162 Print(
"--- Find Layer Mask ------------------------------------------------------------",
LogLevel.NORMAL);
166 override void ProcessFile(ResourceName file)
168 Resource res = Resource.Load(file);
169 MeshObject mesh = res.GetResource().ToMeshObject();
170 if (m_bIgnoreNoColliders && mesh.GetNumGeoms() == 0)
173 if (!mesh.HasLayerMask(m_iLayerMask, m_eLayerFilter))
178 Print(
string.Format(
"@\"%1\"", file.GetPath()),
LogLevel.NORMAL);
182 override void PrintResults()
190 void SCR_SearchXOBLayerMaskFunctor(
bool printFiles,
bool ignoreNoColliders, ResourceName searchedDir,
int searchedAddon,
int layerMask, SCR_ESearchXOBPluginLayerFilter layerFilter)
192 m_iLayerMask = layerMask;
193 m_eLayerFilter = layerFilter;
197[
WorkbenchPluginAttribute(name:
"Search Tool (XOBs)", description:
"Searches XOB files", wbModules: {
"ResourceManager" }, awesomeFontCode: 0xF002)]
198class SearchXOBPlugin : WorkbenchPlugin
200 [
Attribute(
"0",
UIWidgets.ComboBox,
"Type of search",
"", enumType: SCR_ESearchXOBPluginSearchType)]
201 protected SCR_ESearchXOBPluginSearchType m_eSearchType;
204 protected int m_iAddon;
206 [
Attribute(defvalue:
"",
desc:
"Folder where to perform search. If empty, search is performed everywhere",
params:
"unregFolders")]
212 [
Attribute(
"0",
UIWidgets.ComboBox,
"LayerMask search parameter",
"", enumType: EPhysicsLayerDefs)]
213 protected ref array<EPhysicsLayerDefs> m_aLayerDefinitions;
215 [
Attribute(
"0",
UIWidgets.ComboBox,
"Filter applied to layer mask",
"", enumType: SCR_ESearchXOBPluginLayerFilter)]
216 protected SCR_ESearchXOBPluginLayerFilter m_eLayerFilter;
219 protected bool m_bPrintFiles;
221 [
Attribute(defvalue:
"0",
desc:
"Ignore files with no physics geometry")]
222 protected bool m_bIgnoreNoColliders;
227 if (!Workbench.ScriptDialog(
"Search XOBs",
"Choose search type, set search parameters ...",
this))
230 SCR_SearchXOBFunctor functor = CreateFunctor();
240 Print(
"Command-line functionality not implemented",
LogLevel.WARNING);
257 protected bool Cancel()
263 protected int GetLayerMask()
266 foreach (
int layer : m_aLayerDefinitions)
274 protected SCR_SearchXOBFunctor CreateFunctor()
276 switch (m_eSearchType)
278 case SCR_ESearchXOBPluginSearchType.ListAllXOBs:
return new SCR_SearchXOBListAllFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon);
279 case SCR_ESearchXOBPluginSearchType.LoadAllXOBs:
return new SCR_SearchXOBLoadAllFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon);
280 case SCR_ESearchXOBPluginSearchType.InvalidMask:
return new SCR_SearchXOBInvalidMaskFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon);
281 case SCR_ESearchXOBPluginSearchType.LayerPreset:
return new SCR_SearchXOBLayerMaskFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon, m_eLayerPreset, m_eLayerFilter);
282 case SCR_ESearchXOBPluginSearchType.LayerMask:
return new SCR_SearchXOBLayerMaskFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon, GetLayerMask(), m_eLayerFilter);
285 return new SCR_SearchXOBFunctor(m_bPrintFiles, m_bIgnoreNoColliders, m_sSearchedDirectory, m_iAddon);
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_RespawnComponentClass OK
Result code for request/assign response.
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
static ParamEnumArray FromAddons(int titleFormat=2, int hideCoreModules=0)
EPhysicsLayerPresets
Enum is filled by C++ by data in project config PhysicsSettings.LayerPresets.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
@ NONE
When Shape is created and not initialized yet.
SCR_FieldOfViewSettings Attribute
@ ANY
Will list all servers regardless platform compatibility.
@ ALL
Everything except general switch.