Script: Auto-detect available script targets (GetAvailableTargets)
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.IO;
|
||||
using Il2CppInspector.Reflection;
|
||||
using Il2CppInspector.Model;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Il2CppInspector.Outputs
|
||||
{
|
||||
@@ -16,6 +17,14 @@ namespace Il2CppInspector.Outputs
|
||||
|
||||
public IDAPythonScript(AppModel model) => this.model = model;
|
||||
|
||||
// Get list of available script targets
|
||||
public static IEnumerable<string> GetAvailableTargets() {
|
||||
var ns = typeof(IDAPythonScript).Namespace + ".ScriptResources.Targets";
|
||||
var res = ResourceHelper.GetNamesForNamespace(ns);
|
||||
return res.Select(s => Path.GetFileNameWithoutExtension(s.Substring(ns.Length + 1))).OrderBy(s => s);
|
||||
}
|
||||
|
||||
// Output script file
|
||||
public void WriteScriptToFile(string outputFile, string existingTypeHeaderFIle = null, string existingJsonMetadataFile = null) {
|
||||
|
||||
// Write types file first if it hasn't been specified
|
||||
@@ -42,10 +51,9 @@ namespace Il2CppInspector.Outputs
|
||||
var targetApi = "IDA";
|
||||
|
||||
var ns = typeof(IDAPythonScript).Namespace + ".ScriptResources";
|
||||
var scripts = ResourceHelper.GetNamesForNamespace(ns);
|
||||
var preamble = ResourceHelper.GetText(scripts.First(s => s == ns + ".shared-preamble.py"));
|
||||
var main = ResourceHelper.GetText(scripts.First(s => s == ns + ".shared-main.py"));
|
||||
var api = ResourceHelper.GetText(scripts.First(s => s == $"{ns}.{targetApi.ToLower()}-api.py"));
|
||||
var preamble = ResourceHelper.GetText(ns + ".shared-preamble.py");
|
||||
var main = ResourceHelper.GetText(ns + ".shared-main.py");
|
||||
var api = ResourceHelper.GetText($"{ns}.Targets.{targetApi}.py");
|
||||
|
||||
var script = string.Join("\n", new [] { preamble, api, main })
|
||||
.Replace("%SCRIPTFILENAME%", Path.GetFileName(outputFile))
|
||||
|
||||
Reference in New Issue
Block a user