Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom class fixes and re-enabling of the flow diagram #40

Merged
merged 8 commits into from
Aug 5, 2023
10 changes: 8 additions & 2 deletions WolvenKit.CR2W/CR2WManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ public static Type GetEnumByName(string typeName)



private const string header = @"
private const string header1 = @"
using System.IO;
using FastMember;
using WolvenKit.CR2W.Reflection;
using static WolvenKit.CR2W.Types.Enums;


namespace WolvenKit.CR2W
{
";
private const string header2 = @"
namespace WolvenKit.CR2W.Types
{
";
Expand Down Expand Up @@ -210,7 +214,7 @@ private static (int, string) InterpretScriptClasses()
using (StringWriter sw = new StringWriter())
{
// usings and namespace
sw.WriteLine(header);
sw.WriteLine(header1);

FileInfo[] projectScriptFiles = m_projectinfo.GetFiles("*.ws", SearchOption.AllDirectories);

Expand Down Expand Up @@ -289,6 +293,8 @@ private static (int, string) InterpretScriptClasses()
}
#endregion
sw.WriteLine("\t}\r\n");
sw.WriteLine("}\r\n");
sw.WriteLine(header2);

// interpret classes
#region Classes
Expand Down
4 changes: 3 additions & 1 deletion WolvenKit.CR2W/Reflection/REDReflection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DotNetHelper.FastMember.Extension.Extension;
using DotNetHelper.FastMember.Extension.Extension;
using FastMember;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -123,6 +123,8 @@ public static string GetWKitBaseTypeFromREDBaseType(string typename)
case "float": return "CFloat";
case "String": return "CString";
case "string": return "CString";
case "Name": return "CName";
case "name": return "CName";
case "Color": return "CColor";
case "Matrix": return "CMatrix";
default:
Expand Down
22 changes: 11 additions & 11 deletions WolvenKit.CR2W/Types/Generic/CPtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public CPtr(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, n
#region Methods
public string GetPtrTargetType()
{
return ReferenceType;
//try
//{
// if (Reference == null)
// return "NULL";
// return Reference.REDType;
//}
//catch (Exception ex)
//{
// throw new InvalidPtrException(ex.Message);
//}
//return ReferenceType;
try
{
if (Reference == null)
return "NULL";
return Reference.REDType;
}
catch (Exception ex)
{
throw new InvalidPtrException(ex.Message);
}
}

/// <summary>
Expand Down
23 changes: 18 additions & 5 deletions WolvenKit/Forms/Dialog/frmAddChunk.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WolvenKit.CR2W;
using WolvenKit.CR2W.Types;
using WolvenKit.CR2W.Reflection;
using System.Windows.Documents;

namespace WolvenKit
{
public partial class frmAddChunk : Form
{
private string[] classTypes = null;
private string[] enumTypes = null;
private List<string> vanillaClasses = null;
private List<string> customClasses = null;
private List<string> vanillaEnums = null;
private List<string> customEnums = null;
public frmAddChunk(List<string> list = null, bool isVariant = false, bool allowEditName = false)
{
InitializeComponent();
Expand All @@ -29,11 +34,19 @@ public frmAddChunk(List<string> list = null, bool isVariant = false, bool allowE
list = AssemblyDictionary.TypeNames;
}
list.Sort();
classTypes = list.ToArray();

list = AssemblyDictionary.EnumNames;
list.Sort();
enumTypes = list.ToArray();
customClasses = CR2WManager.TypeNames;
customClasses.Sort();

classTypes = list.Concat(customClasses).Distinct().ToArray();

vanillaEnums = AssemblyDictionary.EnumNames;
vanillaEnums.Sort();
customEnums = CR2WManager.EnumNames;
customEnums.Sort();

enumTypes = vanillaEnums.Concat(customEnums).Distinct().ToArray();

UpdateTypeChoices();
}

Expand Down
12 changes: 6 additions & 6 deletions WolvenKit/Forms/MVVM/frmCR2WDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,12 @@ public void PostLoadFile(string filename = "", bool openrenderer = false)
case ".w2quest":
case ".w2phase":
{
//this.flowDiagram = new frmChunkFlowDiagram();
//this.flowDiagram.OnOutput += MainController.LogString;
//this.flowDiagram.File = this.File;
//this.flowDiagram.DockAreas = DockAreas.Document;
//this.flowDiagram.OnSelectChunk += this.frmCR2WDocument_OnSelectChunk;
//this.flowDiagram.Show(this.FormPanel, DockState.Document);
this.flowDiagram = new frmChunkFlowDiagram();
this.flowDiagram.OnOutput += MainController.LogString;
this.flowDiagram.File = this.File;
this.flowDiagram.DockAreas = DockAreas.Document;
this.flowDiagram.OnSelectChunk += this.frmCR2WDocument_OnSelectChunk;
this.flowDiagram.Show(this.FormPanel, DockState.Document);
break;
}

Expand Down
7 changes: 3 additions & 4 deletions WolvenKit/Forms/frmChunkFlowDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
Expand Down Expand Up @@ -51,7 +51,6 @@ public partial class frmChunkFlowDiagram : DockContent
public frmChunkFlowDiagram()
{
InitializeComponent();

selectionBackground = new SolidBrush(Color.FromArgb(100, SystemColors.Highlight));
selectionBorder = new Pen(Color.FromArgb(200, SystemColors.Highlight));
selectionItemHighlight = new Pen(Color.Green, 2.0f);
Expand Down Expand Up @@ -292,7 +291,7 @@ private void frmChunkFlowView_Paint(object sender, PaintEventArgs e)
// eat the exception, allready logging the exception when creating the node editor
}

if (conns != null)
if (conns != null && !isMoving)
{
foreach (var conn in conns)
{
Expand Down Expand Up @@ -590,4 +589,4 @@ private void copyDisplayTextToolStripMenuItem_Click(object sender, EventArgs e)
}
}
}
}
}