1
0
mirror of synced 2024-12-02 11:07:26 +01:00
Switch-Toolbox/Switch_FileFormatsMain/GUI/Byaml/CourseMuunt/Paths/Paths.cs

112 lines
3.2 KiB
C#
Raw Normal View History

2019-04-08 03:14:39 +02:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using GL_EditorFramework.EditorDrawables;
using GL_EditorFramework.GL_Core;
using GL_EditorFramework.Interfaces;
using OpenTK.Graphics.OpenGL;
using OpenTK;
using System.Drawing;
namespace FirstPlugin.Turbo.CourseMuuntStructs
{
public class PathGroup : BasePathGroup, IObject
{
public const string N_UnitIdNum = "UnitIdNum";
public PathGroup(dynamic bymlNode)
{
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
else throw new Exception("Not a dictionary");
foreach (var point in this["PathPt"])
{
PathPoints.Add(new PathPoint(point));
}
}
[Browsable(false)]
public Dictionary<string, dynamic> Prop { get; set; } = new Dictionary<string, dynamic>();
public bool Delete
{
get { return this["Delete"] != null ? this["Delete"] : false; }
set { this["Delete"] = value; }
}
public bool IsClosed
{
get { return this["Delete"] != null ? this["Delete"] : false; }
set { this["Delete"] = value; }
}
public int RailType
{
get { return this["RailType"] != null ? this["RailType"] : -1; }
set { if (value != -1) this["RailType"] = value; }
}
public int UnitIdNum
{
get { return this[N_UnitIdNum] != null ? this[N_UnitIdNum] : -1; }
set { this[N_UnitIdNum] = value; }
}
public dynamic this[string name]
{
get
{
if (Prop.ContainsKey(name)) return Prop[name];
else return null;
}
set
{
if (Prop.ContainsKey(name)) Prop[name] = value;
else Prop.Add(name, value);
}
}
}
public class PathPoint : BasePathPoint
{
private RenderablePathPoint renderablePoint;
[Browsable(false)]
public override RenderablePathPoint RenderablePoint
{
get
{
if (renderablePoint == null)
renderablePoint = new RenderablePathPoint(new Vector4(0.2f, 0.2f, 0.2f, 1f), Translate, Rotate, new OpenTK.Vector3(30), this);
return renderablePoint;
}
}
[Category("Properties")]
public int prm1
{
get { return this["prm1"] != null ? this["prm1"] : -1; }
set { if (value != -1) this["prm1"] = value; }
}
[Category("Properties")]
public int prm2
{
get { return this["prm2"] != null ? this["prm2"] : -1; }
set { if (value != -1) this["prm2"] = value; }
}
public PathPoint(dynamic bymlNode)
{
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
else throw new Exception("Not a dictionary");
foreach (var point in this["ControlPoints"])
{
ControlPoints.Add(new BaseControlPoint(point));
}
}
}
}