Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7d31a95
Initial commit
Falki-git Apr 15, 2023
634b874
Add ManeuverWindow
Falki-git Apr 15, 2023
1cb14cd
Update maneuver window
Falki-git Apr 16, 2023
815373f
Make maneuver fields private
Falki-git Apr 16, 2023
799d767
More maneuver updates
Falki-git Apr 16, 2023
5d1df8e
New Target entries
Falki-git Apr 16, 2023
4f96184
3 new target entries
Falki-git Apr 16, 2023
32596c4
Add new vessel entries
Falki-git Apr 16, 2023
debef85
Simplify maneuver entry refresh
Falki-git Apr 17, 2023
024b6d2
Add new maneuver entries
Falki-git Apr 17, 2023
a6da38a
Fix index out of range if maneuver node is manually deleted
Falki-git Apr 17, 2023
dd93fcb
Mark Maneuver entries as accepted
Falki-git Apr 18, 2023
c4510c8
Flight entries update
Falki-git Apr 18, 2023
4f843f4
Simplify Target ValueDisplay calls
Falki-git Apr 18, 2023
e8570f1
Add phase angle
Falki-git Apr 19, 2023
831b177
Add TransferAngle
Falki-git Apr 19, 2023
28d27b3
Add Throttle
Falki-git Apr 19, 2023
bc21a0b
Refactor
Falki-git Apr 19, 2023
145ef8d
Add Body entries
Falki-git Apr 19, 2023
91b3940
Further refinement
Falki-git Apr 20, 2023
987f5db
Add description to all new entries
Falki-git Apr 20, 2023
dc6ff29
Rename MicroUtility to Utility
Falki-git Apr 21, 2023
1a849a7
Add layout version control
Falki-git Apr 21, 2023
067ea78
Refactor
Falki-git Apr 21, 2023
1ee150a
Reorder entries to have a logical order
Falki-git Apr 21, 2023
5592c16
Move torque OAB updates to PartManipulationCompletedMessage
Falki-git Apr 21, 2023
d530cd8
Remove backward compatibility as we now have layout versioning
Falki-git Apr 21, 2023
c85d07e
Major refactor - move logic to manager classes, GUI to UI class
Falki-git Apr 21, 2023
1cfbeb4
Add Themes, refactor windows
Falki-git Apr 23, 2023
e775e7b
Move flight StageInfo to StageWindow, add theme support
Falki-git Apr 23, 2023
43d1a93
Add changing of number of decimal digits
Falki-git Apr 23, 2023
6e2d65d
Add Settings button on each window
Falki-git Apr 24, 2023
d2f4ecf
Add automatic scaling of Units used for bigger numbers
Falki-git Apr 24, 2023
a2c336d
Add themes to edit window, OAB stage info hardcode gray theme
Falki-git Apr 24, 2023
78957e9
Final tweaks
Falki-git Apr 25, 2023
53da7bc
Update icon.png
Falki-git Apr 25, 2023
23edf00
Lectoring
Falki-git Apr 26, 2023
4c5de68
Nothing important
Falki-git Apr 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions MicroEngineerProject/MicroEngineer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31605.320
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroEngineer", "MicroEngineer.csproj", "{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}"
EndProject
Expand All @@ -11,8 +11,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.Build.0 = Release|Any CPU
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
130 changes: 130 additions & 0 deletions MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Newtonsoft.Json;

namespace MicroMod
{
/// <summary>
/// Base class for all Entries (values that can be attached to windows)
/// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class BaseEntry
{
[JsonProperty]
public string Name;
[JsonProperty]
public string Description;
[JsonProperty]
public MicroEntryCategory Category;
public bool IsDefault;
[JsonProperty]
public bool HideWhenNoData;
[JsonProperty]
public string MiliUnit;
[JsonProperty]
public string BaseUnit;
[JsonProperty]
public string KiloUnit;
[JsonProperty]
public string MegaUnit;
[JsonProperty]
public string GigaUnit;
[JsonProperty]
public byte NumberOfDecimalDigits;
[JsonProperty("Formatting")]
private string _formatting;
public string Formatting
{
get => String.IsNullOrEmpty(_formatting) ? null : $"{{0:{_formatting}{this.NumberOfDecimalDigits}}}";
set => _formatting = value;
}

public virtual object EntryValue { get; set; }

/// <summary>
/// Controls how the value should be displayed. Should be overriden in a inheritet class for a concrete implementation.
/// </summary>
public virtual string ValueDisplay
{
get
{
if (EntryValue == null)
return "-";

if (String.IsNullOrEmpty(this.Formatting))
return EntryValue.ToString();

if (!double.TryParse(EntryValue.ToString(), out double d))
return EntryValue.ToString(); // This case shouldn't exist, but just to be sure

if (Math.Abs(d) < 1) // mili
{
return !String.IsNullOrEmpty(this.MiliUnit) ? String.Format(Formatting, d * 1000) :
String.Format(Formatting, d);
}
else if (Math.Abs(d) < 1000000) // base
{
return String.Format(Formatting, d);
}
else if (Math.Abs(d) < 1000000000) // kilo
{
return !String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) :
String.Format(Formatting, d);

}
else if (Math.Abs(d) < 1000000000000) // mega
{
return !String.IsNullOrEmpty(this.MegaUnit) ? String.Format(Formatting, d / 1000000) :
!String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) :
String.Format(Formatting, d);

}
else // giga
{
return !String.IsNullOrEmpty(this.GigaUnit) ? String.Format(Formatting, d / 1000000000) :
!String.IsNullOrEmpty(this.MegaUnit) ? String.Format(Formatting, d / 1000000) :
!String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) :
String.Format(Formatting, d);
}
}
}

public virtual string UnitDisplay
{
get
{
if (EntryValue == null)
return "";

if (String.IsNullOrEmpty(this.Formatting))
return this.BaseUnit ?? "";

if (!double.TryParse(EntryValue.ToString(), out double d))
return this.BaseUnit ?? ""; // This case shouldn't exist, but just to be sure

if (d > 0.001 && d < 1) // mili
{
return this.MiliUnit ?? this.BaseUnit ?? "";
}
else if (Math.Abs(d) < 1000000) // base
{
return this.BaseUnit ?? "";
}
else if (Math.Abs(d) < 1000000000) // kilo
{
return this.KiloUnit ?? this.BaseUnit ?? "";

}
else if (Math.Abs(d) < 1000000000000) // mega
{
return this.MegaUnit ?? this.KiloUnit ?? this.BaseUnit ?? "";

}
else // giga
{
return this.GigaUnit ?? this.MegaUnit ?? this.KiloUnit ?? this.BaseUnit ?? "";
}
}
}

public virtual void RefreshData() { }
}
}
72 changes: 72 additions & 0 deletions MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

namespace MicroMod
{
public class BodyEntry : BaseEntry
{ }

public class Body : BodyEntry
{
public Body()
{
Name = "Body";
Description = "Shows the body that vessel is currently at.";
Category = MicroEntryCategory.Body;
IsDefault = false;
BaseUnit = null;
Formatting = null;
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.mainBody.bodyName;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class ReferenceBodyConstants_Radius : BodyEntry
{
public ReferenceBodyConstants_Radius()
{
Name = "Body radius";
Description = "Body's radius.";
Category = MicroEntryCategory.Body;
IsDefault = false;
MiliUnit = "mm";
BaseUnit = "m";
KiloUnit = "km";
MegaUnit = "Mm";
GigaUnit = "Gm";
NumberOfDecimalDigits = 2;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class ReferenceBodyConstants_StandardGravitationParameter : BodyEntry
{
public ReferenceBodyConstants_StandardGravitationParameter()
{
Name = "Std. grav. param.";
Description = "Product of the gravitational constant G and the mass M of the body.";
Category = MicroEntryCategory.Body;
IsDefault = false;
BaseUnit = "μ";
NumberOfDecimalDigits = 4;
Formatting = "e";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter;
}

public override string ValueDisplay => base.ValueDisplay;
}
}
Loading