-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
380 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using HActLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace CMNEdit | ||
{ | ||
public class UserElementFile | ||
{ | ||
public Game TargetGame; | ||
public UserElementData Data = new UserElementData(); | ||
|
||
public static UserElementFile Read(string path) | ||
{ | ||
if (!File.Exists(path)) | ||
return null; | ||
|
||
string[] buf = File.ReadAllLines(path); | ||
|
||
if(buf.Length <= 0) | ||
return null; | ||
|
||
string[] split = buf[0].Split(' '); | ||
|
||
if (split.Length < 4) | ||
return null; | ||
|
||
object gameVal = null; | ||
|
||
if (!Enum.TryParse(typeof(Game), split[0], out gameVal)) | ||
return null; | ||
|
||
UserElementFile file = new UserElementFile(); | ||
file.TargetGame = (Game)gameVal; | ||
file.Data.DeveloperName = split[1]; | ||
file.Data.NodeName = split[2]; | ||
file.Data.ElementID = uint.Parse(split[3]); | ||
|
||
if (buf.Length <= 1) | ||
return file; | ||
|
||
for (int i = 1; i < buf.Length; i++) | ||
{ | ||
if (string.IsNullOrEmpty(buf[i])) | ||
continue; | ||
|
||
string[] fieldDat = buf[i].Split(new char[] { ' ' }); | ||
|
||
if (fieldDat.Length < 2) | ||
continue; | ||
|
||
string name = fieldDat[1]; | ||
string type = fieldDat[0]; //rest is args | ||
|
||
object typeObject = null; | ||
|
||
if (!Enum.TryParse(typeof(UserElementFieldType), type, true, out typeObject)) | ||
continue; | ||
|
||
UserElementField field = new UserElementField(); | ||
field.FieldType = (UserElementFieldType)typeObject; | ||
field.Name = name; | ||
|
||
if(fieldDat.Length > 2) | ||
for(int k = 2; k < fieldDat.Length; k++) | ||
field.Args.Add(fieldDat[k]); | ||
|
||
file.Data.Fields.Add(field); | ||
} | ||
|
||
return file; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
Projects/CMNEdit/Windows/Common/NodeElementUserWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using CMNEdit.Windows; | ||
using HActLib; | ||
using ParLibrary; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace CMNEdit | ||
{ | ||
internal static class NodeElementUserWindow | ||
{ | ||
private static void DrawField(Form1 form, NodeElementUser element, int idx) | ||
{ | ||
var field = element.Fields[idx]; | ||
|
||
string fieldName = field.Name.ToString().ToTitleCase().Replace("_", " "); | ||
|
||
|
||
switch (field.FieldType) | ||
{ | ||
default: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { }, NumberBox.NumberMode.Text, true); | ||
break; | ||
case UserElementFieldType.Byte: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = byte.Parse(val); }, NumberBox.NumberMode.Byte); | ||
break; | ||
case UserElementFieldType.Short: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = short.Parse(val); }, NumberBox.NumberMode.Ushort); | ||
break; | ||
case UserElementFieldType.Int32: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = int.Parse(val); }, NumberBox.NumberMode.Int); | ||
break; | ||
case UserElementFieldType.Int64: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = long.Parse(val); }, NumberBox.NumberMode.Long); | ||
break; | ||
case UserElementFieldType.UShort: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = ushort.Parse(val); }, NumberBox.NumberMode.Ushort); | ||
break; | ||
case UserElementFieldType.UInt32: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = uint.Parse(val); }, NumberBox.NumberMode.UInt); | ||
break; | ||
case UserElementFieldType.UInt64: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = ulong.Parse(val); }, NumberBox.NumberMode.ULong); | ||
break; | ||
case UserElementFieldType.RGB32: | ||
Panel rgb32Panel = null; | ||
|
||
rgb32Panel = form.CreatePanel(fieldName, (RGB32)field.Value, | ||
delegate (Color col) | ||
{ | ||
field.Value = (RGB32)col; | ||
rgb32Panel.BackColor = col; | ||
}); | ||
break; | ||
|
||
case UserElementFieldType.RGBA32: | ||
Panel rgba32Panel = null; | ||
|
||
rgba32Panel = form.CreatePanel(fieldName, (RGBA32)field.Value, | ||
delegate (Color col) | ||
{ | ||
field.Value = (RGBA32)col; | ||
rgba32Panel.BackColor = col; | ||
}); | ||
break; | ||
|
||
case UserElementFieldType.Float: | ||
form.CreateInput(fieldName, field.Value.ToString(), delegate (string val) { field.Value = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); | ||
break; | ||
|
||
case UserElementFieldType.FAnimationCurve: | ||
form.CreateButton(fieldName, delegate | ||
{ | ||
CurveView myNewForm = new CurveView(); | ||
myNewForm.Visible = true; | ||
myNewForm.Init((float[])field.Value, | ||
delegate (float[] outCurve) | ||
{ | ||
field.Value = outCurve; | ||
}); | ||
}); | ||
break; | ||
|
||
} | ||
} | ||
|
||
public static void Draw(Form1 form, Node node) | ||
{ | ||
var nodeUser = node as NodeElementUser; | ||
|
||
form.CreateHeader(nodeUser.UserData.NodeName.Replace("_", " ")); | ||
|
||
for(int i = 0; i < nodeUser.Fields.Count; i++) | ||
DrawField(form, nodeUser, i); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.