forked from MapStudioProject/MapStudio.UI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectFile.cs
More file actions
171 lines (138 loc) · 5.78 KB
/
Copy pathProjectFile.cs
File metadata and controls
171 lines (138 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.IO;
using System.Collections.Generic;
using OpenTK;
using Newtonsoft.Json;
using GLFrameworkEngine;
using System.Globalization;
namespace MapStudio.UI
{
public class ProjectFile
{
//Folder of the loaded files
public string WorkingDirectory { get; set; }
private string saveData = "";
//Save date of project document
public string SaveDate
{
get { return saveData; }
set
{
saveData = value;
DateTime = DateTime.ParseExact(value, "dd/MMM/yyyy-(hh:mm:ss)", CultureInfo.InvariantCulture);
}
}
public DateTime DateTime;
/// <summary>
/// Gets or sets the original GUI scroll value of the outliner on the Y axis.
/// </summary>
public float OutlierScroll { get; set; }
/// <summary>
/// A list of files used by the project to load/save
/// </summary>
public List<string> FileAssets = new List<string>();
//Editor properties
public string SelectedWorkspace = "Default";
public List<string> ActiveWorkspaces = new List<string>();
public string ActiveEditor { get; set; }
public string ModelDisplay { get; set; }
public bool UseCollisionDetection { get; set; } = true;
//Path point size
public float PointSize { get; set; } = 1.0f;
//Global model rendering brightness
public float Brightness { get; set; } = 1.0f;
//Camera settings
public CameraSettings Camera = new CameraSettings();
//Debug viewport shading
public string ShadingMode { get; set; } = "Default";
//Nodes with an ID linked.
public Dictionary<int, NodeSettings> Nodes = new Dictionary<int, NodeSettings>();
public static ProjectFile Load(string filePath)
{
string json = File.ReadAllText(filePath);
return JsonConvert.DeserializeObject<ProjectFile>(json);
}
public void Save(string filePath)
{
saveData = DateTime.Now.ToString("dd/MMM/yyyy-(hh:mm:ss)");
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(filePath, json);
}
public void ApplySettings(GLContext context, Workspace workspace)
{
// SelectedWorkspace = workspace.ActiveEditor.SubEditor;
ShadingMode = DebugShaderRender.DebugRendering.ToString();
var camera = context.Camera;
this.UseCollisionDetection = context.EnableDropToCollision;
this.Camera.RotationX = camera.RotationX;
this.Camera.RotationY = camera.RotationY;
this.Camera.Distance = camera.TargetDistance;
this.Camera.PositionX = camera.TargetPosition.X;
this.Camera.PositionY = camera.TargetPosition.Y;
this.Camera.PositionZ = camera.TargetPosition.Z;
this.Camera.FovDegrees = camera.FovDegrees;
this.Camera.ZFar = camera.ZFar;
this.Camera.ZNear = camera.ZNear;
}
public void LoadSettings(GLContext context, Workspace workspace)
{
// workspace.ActiveEditor.SubEditor = SelectedWorkspace;
DebugShaderRender.DebugRendering = Enum.Parse<DebugShaderRender.DebugRender>(ShadingMode);
var camera = context.Camera;
context.EnableDropToCollision = UseCollisionDetection;
camera.RotationX = this.Camera.RotationX;
camera.RotationY = this.Camera.RotationY;
camera.TargetDistance = this.Camera.Distance;
camera.TargetPosition = new Vector3(this.Camera.PositionX, this.Camera.PositionY, this.Camera.PositionZ);
camera.FovDegrees = this.Camera.FovDegrees;
camera.ZFar = this.Camera.ZFar;
camera.ZNear = this.Camera.ZNear;
}
public class NodeSettings
{
public bool IsExpaned = false;
public bool IsSelected = false;
}
public class CameraSettings
{
public float PositionX { get; set; }
public float PositionY { get; set; }
public float PositionZ { get; set; }
public float Distance { get; set; }
public float RotationX { get; set; }
public float RotationY { get; set; }
/// <summary>
/// Gets or sets the camera controller mode to determine how the camera moves.
/// </summary>
public Camera.CameraMode Mode { get; set; } = GLFrameworkEngine.Camera.CameraMode.Inspect;
/// <summary>
/// Toggles orthographic projection.
/// </summary>
public bool IsOrthographic { get; set; } = false;
/// <summary>
/// Gets or sets the field of view in degrees.
/// </summary>
public float FovDegrees { get; set; } = 45;
/// <summary>
/// Gets or sets the camera move speed using key inputs.
/// </summary>
public float KeyMoveSpeed { get; set; } = 10.0f;
/// <summary>
/// Gets or sets the camera move speed during panning.
/// </summary>
public float PanSpeed { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the camera move speed during zooming.
/// </summary>
public float ZoomSpeed { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the z near projection.
/// </summary>
public float ZNear { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the z far projection.
/// </summary>
public float ZFar { get; set; } = 100000.0f;
}
}
}