Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit c582d2a

Browse files
committed
Add changing of number of decimal digits
Also: - rename MicroEntry to BaseEntry - move save/load/reset layout to Manager - Manager is making sure that every instance has an up-to-date version of windows and entries - reset layout now also rebuilds entries
1 parent 9e44c39 commit c582d2a

File tree

19 files changed

+321
-156
lines changed

19 files changed

+321
-156
lines changed

MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs renamed to MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Newtonsoft.Json;
2+
using System.Xml;
3+
using UnityEngine;
24

35
namespace MicroMod
46
{
@@ -20,7 +22,14 @@ public class BaseEntry
2022
[JsonProperty]
2123
public string Unit;
2224
[JsonProperty]
23-
public string Formatting;
25+
public byte NumberOfDecimalDigits;
26+
[JsonProperty("Formatting")]
27+
private string _formatting;
28+
public string Formatting
29+
{
30+
get => String.IsNullOrEmpty(_formatting) ? null : $"{{0:{_formatting}{this.NumberOfDecimalDigits}}}";
31+
set => _formatting = value;
32+
}
2433

2534
public virtual object EntryValue { get; set; }
2635

@@ -38,6 +47,8 @@ public virtual string ValueDisplay
3847
}
3948
}
4049

50+
51+
4152
public virtual void RefreshData() { }
4253
}
4354
}

MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public ReferenceBodyConstants_Radius()
3333
Category = MicroEntryCategory.Body;
3434
IsDefault = false;
3535
Unit = "m";
36-
Formatting = "{0:N0}";
36+
NumberOfDecimalDigits = 0;
37+
Formatting = "N";
3738
}
3839

3940
public override void RefreshData()
@@ -53,7 +54,8 @@ public ReferenceBodyConstants_StandardGravitationParameter()
5354
Category = MicroEntryCategory.Body;
5455
IsDefault = false;
5556
Unit = "μ";
56-
Formatting = "{0:e4}";
57+
NumberOfDecimalDigits = 4;
58+
Formatting = "e";
5759
}
5860

5961
public override void RefreshData()

MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public Speed()
1313
Category = MicroEntryCategory.Flight;
1414
IsDefault = true;
1515
Unit = "m/s";
16-
Formatting = "{0:N1}";
16+
NumberOfDecimalDigits = 1;
17+
Formatting = "N";
1718
}
1819

1920
public override void RefreshData()
@@ -33,7 +34,8 @@ public MachNumber()
3334
Category = MicroEntryCategory.Flight;
3435
IsDefault = true;
3536
Unit = null;
36-
Formatting = "{0:N2}";
37+
NumberOfDecimalDigits = 2;
38+
Formatting = "N";
3739
}
3840

3941
public override void RefreshData()
@@ -53,7 +55,8 @@ public GeeForce()
5355
Category = MicroEntryCategory.Flight;
5456
IsDefault = true;
5557
Unit = "g";
56-
Formatting = "{0:N3}";
58+
NumberOfDecimalDigits = 3;
59+
Formatting = "N";
5760
}
5861

5962
public override void RefreshData()
@@ -73,7 +76,8 @@ public AngleOfAttack()
7376
Category = MicroEntryCategory.Flight;
7477
IsDefault = true;
7578
Unit = "°";
76-
Formatting = "{0:N3}";
79+
NumberOfDecimalDigits = 3;
80+
Formatting = "N";
7781
}
7882

7983
public override void RefreshData()
@@ -93,7 +97,8 @@ public SideSlip()
9397
Category = MicroEntryCategory.Flight;
9498
IsDefault = false;
9599
Unit = "°";
96-
Formatting = "{0:N3}";
100+
NumberOfDecimalDigits = 3;
101+
Formatting = "N";
97102
}
98103

99104
public override void RefreshData()
@@ -113,7 +118,8 @@ public Heading()
113118
Category = MicroEntryCategory.Flight;
114119
IsDefault = true;
115120
Unit = "°";
116-
Formatting = "{0:N2}";
121+
NumberOfDecimalDigits = 2;
122+
Formatting = "N";
117123
}
118124

119125
public override void RefreshData()
@@ -133,7 +139,8 @@ public Pitch_HorizonRelative()
133139
Category = MicroEntryCategory.Flight;
134140
IsDefault = true;
135141
Unit = "°";
136-
Formatting = "{0:N2}";
142+
NumberOfDecimalDigits = 2;
143+
Formatting = "N";
137144
}
138145

139146
public override void RefreshData()
@@ -153,7 +160,8 @@ public Roll_HorizonRelative()
153160
Category = MicroEntryCategory.Flight;
154161
IsDefault = true;
155162
Unit = "°";
156-
Formatting = "{0:N2}";
163+
NumberOfDecimalDigits = 2;
164+
Formatting = "N";
157165
}
158166

159167
public override void RefreshData()
@@ -173,7 +181,8 @@ public Yaw_HorizonRelative()
173181
Category = MicroEntryCategory.Flight;
174182
IsDefault = true;
175183
Unit = "°";
176-
Formatting = "{0:N2}";
184+
NumberOfDecimalDigits = 2;
185+
Formatting = "N";
177186
}
178187

179188
public override void RefreshData()
@@ -193,7 +202,8 @@ public Zenith()
193202
Category = MicroEntryCategory.Flight;
194203
IsDefault = false;
195204
Unit = "°";
196-
Formatting = "{0:N2}";
205+
NumberOfDecimalDigits = 2;
206+
Formatting = "N";
197207
}
198208

199209
public override void RefreshData()
@@ -213,7 +223,8 @@ public TotalLift()
213223
Category = MicroEntryCategory.Flight;
214224
IsDefault = true;
215225
Unit = "N";
216-
Formatting = "{0:N0}";
226+
NumberOfDecimalDigits = 0;
227+
Formatting = "N";
217228
}
218229

219230
public override void RefreshData()
@@ -243,7 +254,8 @@ public TotalDrag()
243254
Category = MicroEntryCategory.Flight;
244255
IsDefault = true;
245256
Unit = "N";
246-
Formatting = "{0:N0}";
257+
NumberOfDecimalDigits = 0;
258+
Formatting = "N";
247259
}
248260

249261
public override void RefreshData()
@@ -273,7 +285,8 @@ public LiftDivDrag()
273285
Category = MicroEntryCategory.Flight;
274286
IsDefault = true;
275287
Unit = null;
276-
Formatting = "{0:N2}";
288+
NumberOfDecimalDigits = 2;
289+
Formatting = "N";
277290
}
278291

279292
public override void RefreshData()
@@ -303,7 +316,8 @@ public DragCoefficient()
303316
Category = MicroEntryCategory.Flight;
304317
IsDefault = false;
305318
Unit = null;
306-
Formatting = "{0:N2}";
319+
NumberOfDecimalDigits = 2;
320+
Formatting = "N";
307321
}
308322

309323
public override void RefreshData()
@@ -323,7 +337,8 @@ public ExposedArea()
323337
Category = MicroEntryCategory.Flight;
324338
IsDefault = false;
325339
Unit = null; // TODO
326-
Formatting = "{0:N2}";
340+
NumberOfDecimalDigits = 2;
341+
Formatting = "N";
327342
}
328343

329344
public override void RefreshData()
@@ -343,7 +358,8 @@ public AtmosphericDensity()
343358
Category = MicroEntryCategory.Flight;
344359
IsDefault = true;
345360
Unit = "g/L";
346-
Formatting = "{0:N3}";
361+
NumberOfDecimalDigits = 3;
362+
Formatting = "N";
347363
}
348364

349365
public override void RefreshData()
@@ -363,7 +379,8 @@ public SoundSpeed()
363379
Category = MicroEntryCategory.Flight;
364380
IsDefault = false;
365381
Unit = "m/s";
366-
Formatting = "{0:N1}";
382+
NumberOfDecimalDigits = 1;
383+
Formatting = "N";
367384
}
368385

369386
public override void RefreshData()

0 commit comments

Comments
 (0)