Skip to content

Commit

Permalink
gh-5-export-post-scripts complex post scripts now supported
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNCatz committed Apr 22, 2021
1 parent eeb6a71 commit 654c2e3
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 72 deletions.
35 changes: 17 additions & 18 deletions Code/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using Godot;
using MetaMakerLib;
using LibT;
using LibT.Serialization;
using LibT.Services;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class App
private bool _hasUnbackedChanges;
private GenericDataArray _model;
private readonly List<GenericDataArray> _topModels = new List<GenericDataArray>();
private ExportRules _exportRules;
private ExportRulesAbstract _exportRules;
private string _loadingPath;

public string Version => _version;
Expand Down Expand Up @@ -518,13 +519,6 @@ public void ExportSet(string exportName)
{
if(string.IsNullOrEmpty(SaveFilePath)) throw new Exception("Relative export requires the graph to have been saved first.");

List<string> keys = new List<string>
{
NODE_NAME_KEY,
NODE_POSITION_KEY,
NODE_SIZE_KEY
};

_exportRules.graphVersionKey = GRAPH_VERSION_KEY;
_exportRules.metaMakerVersion = Version;

Expand All @@ -537,11 +531,6 @@ public void ExportSet(string exportName)

data = data.DataCopy();

if(keys != null)
{
data.RecursivelyRemoveKeys(keys);
}

string path = exportSet.relativeSavePath.Replace("$name",GetFileName(SaveFilePath));
path = path.Replace("$export",exportName);
path = GetContainingPath(SaveFilePath) + "/" + path;
Expand All @@ -557,7 +546,6 @@ public void ExportSet(string exportName)
{
itemCount = data.values.Count;
}
Log.Error($"c{exportSet.childCount} f{fileCount} i{itemCount}");

List<GenericDataArray> items = new List<GenericDataArray>();
var graph = new GenericDataArray(){type = data.type};
Expand All @@ -571,7 +559,6 @@ public void ExportSet(string exportName)
current = 0;
}
graph.AddValue(pair.Key, pair.Value);
Log.Error($"{pair.Key}:{pair.Value} c{current} I{items.Count}");
current++;
}
items.Add(graph);
Expand All @@ -581,8 +568,20 @@ public void ExportSet(string exportName)
string myPath = path.Replace("$index",$"{i+1}");
myPath = System.IO.Path.GetFullPath(myPath);

_exportRules.PreprocessExportGDA(items[i], exportName, myPath, i+1);
List<string> keys = new List<string>
{
NODE_NAME_KEY,
NODE_POSITION_KEY,
NODE_SIZE_KEY
};

_exportRules.PreprocessExportGDA(items[i], keys, exportName, myPath, i+1);

if(keys != null)
{
data.RecursivelyRemoveKeys(keys);
}

string json = items[i].ToJson();

json = _exportRules.PostprocessExportJSON(json, exportName, myPath, i+1);
Expand Down Expand Up @@ -915,7 +914,7 @@ private void LoadAssembly(string exportScript, bool reuseDll)
args.exportPath = dllPath;
}
args.references.Add(SharpMods.GetPortableReferenceToType(typeof(Dictionary<,>)));
args.references.Add(SharpMods.GetPortableReferenceToType(typeof(ExportRules)));
args.references.Add(SharpMods.GetPortableReferenceToType(typeof(ExportRulesAbstract)));
args.references.Add(SharpMods.GetPortableReferenceToType(typeof(GenericDataArray)));
args.code = exportScript;
assembly = SharpMods.RoslynRuntimeCompile(args);
Expand All @@ -931,7 +930,7 @@ private void LoadAssembly(string exportScript, bool reuseDll)
var type = assembly.GetType("Rules.ExportRules");

var obj = Activator.CreateInstance(type, null);
_exportRules = obj as ExportRules;
_exportRules = obj as ExportRulesAbstract;
}
}
#endregion
Expand Down
Binary file added Code/DLLs/LibT.Debugging.dll
Binary file not shown.
Binary file added Code/DLLs/LibT.Serialization.dll
Binary file not shown.
Binary file modified Code/DLLs/LibT.dll
Binary file not shown.
Binary file modified Code/DLLs/LibTGodot.dll
Binary file not shown.
Binary file added Code/DLLs/MetaMakerLib.dll
Binary file not shown.
Binary file modified Code/DLLs/RSG.Promises.dll
Binary file not shown.
51 changes: 0 additions & 51 deletions Code/ExportRules.cs

This file was deleted.

1 change: 1 addition & 0 deletions Code/NodeCode/MainView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Godot;
using MetaMakerLib;
using LibT;
using LibT.Maths;
using LibT.Serialization;
Expand Down
9 changes: 9 additions & 0 deletions MetaMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="MetaMakerLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>Code\DLLs\MetaMakerLib.dll</HintPath>
</Reference>
<Reference Include="LibT.Debugging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>Code\DLLs\LibT.Debugging.dll</HintPath>
</Reference>
<Reference Include="LibT.Serialization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>Code\DLLs\LibT.Serialization.dll</HintPath>
</Reference>
<Reference Include="LibT, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>Code\DLLs\LibT.dll</HintPath>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion Templates-and-Graphs/MissionsTemplate.ngmap
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
"metaMakerVersion": "0.6.0",
"defaultListing": "nodeList",
"explicitNode": "Graph",
"reuseDll": false,
"reuseDll": true,
"exportScript": {},
"nestingColors": [
{
Expand Down
4 changes: 2 additions & 2 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon="res://icon.ico"
application/file_version="0.4.1"
application/product_version="0.4.1"
application/file_version="0.6.0"
application/product_version="0.6.0"
application/company_name="Blade End"
application/product_name="MetaMaker"
application/file_description=""
Expand Down

0 comments on commit 654c2e3

Please sign in to comment.