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

Commit d888592

Browse files
authored
UITK rewrite
2 parents 6c2689f + 3757123 commit d888592

File tree

130 files changed

+7624
-2317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+7624
-2317
lines changed
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6-
<LangVersion>latest</LangVersion>
7-
<ImplicitUsings>true</ImplicitUsings>
8-
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
9-
</PropertyGroup>
10-
<ItemGroup>
11-
<PackageReference Include="BepInEx.BaseLib" Version="5.4.21" Publicize="true" />
12-
<Reference Include="external_dlls\SpaceWarp.dll" />
13-
<Reference Include="external_dlls\UnityEngine.dll" />
14-
<Reference Include="external_dlls\UnityEngine.CoreModule.dll" />
15-
<Reference Include="external_dlls\Assembly-CSharp.dll" />
16-
<Reference Include="external_dlls\NewtonSoft.Json.dll" />
17-
<Reference Include="external_dlls\NewtonSoft.Json.dll" />
18-
<Reference Include="UnityEngine.IMGUIModule">
19-
<HintPath>external_dlls\UnityEngine.IMGUIModule.dll</HintPath>
20-
</Reference>
21-
<Reference Include="UnityEngine.TextRenderingModule">
22-
<HintPath>external_dlls\UnityEngine.TextRenderingModule.dll</HintPath>
23-
</Reference>
24-
</ItemGroup>
25-
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
26-
<Exec Command="echo Killing task KSP2_x64.exe&#xD;&#xA;taskkill /f /fi &quot;pid gt 0&quot; /im KSP2_x64.exe&#xD;&#xA;&#xD;&#xA;echo Copying output .dll to &quot;..Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;xcopy /y &quot;$(TargetDir)$(ProjectName).dll&quot; &quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;&#xD;&#xA;echo Copying output .pdb to &quot;..Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;xcopy /y &quot;$(TargetDir)$(ProjectName).pdb&quot; &quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;&#xD;&#xA;echo Starting KSP2_x64.exe&#xD;&#xA;powershell &quot;start-process &quot;&quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\KSP2_x64.exe&quot;&quot;&quot;" />
27-
</Target>
28-
</Project>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6+
<LangVersion>latest</LangVersion>
7+
<ImplicitUsings>true</ImplicitUsings>
8+
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="BepInEx.BaseLib" Version="5.4.21" Publicize="true" />
12+
<Reference Include="external_dlls\SpaceWarp.dll" />
13+
<Reference Include="external_dlls\UnityEngine.dll" />
14+
<Reference Include="external_dlls\UnityEngine.CoreModule.dll" />
15+
<Reference Include="external_dlls\Assembly-CSharp.dll" />
16+
<Reference Include="external_dlls\NewtonSoft.Json.dll" />
17+
<Reference Include="UitkForKsp2">
18+
<HintPath>external_dlls\UitkForKsp2.dll</HintPath>
19+
</Reference>
20+
<Reference Include="UitkForKsp2.Controls">
21+
<HintPath>external_dlls\UitkForKsp2.Controls.dll</HintPath>
22+
</Reference>
23+
<Reference Include="UnityEngine.IMGUIModule">
24+
<HintPath>external_dlls\UnityEngine.IMGUIModule.dll</HintPath>
25+
</Reference>
26+
<Reference Include="UnityEngine.InputLegacyModule">
27+
<HintPath>external_dlls\UnityEngine.InputLegacyModule.dll</HintPath>
28+
</Reference>
29+
<Reference Include="UnityEngine.TextRenderingModule">
30+
<HintPath>external_dlls\UnityEngine.TextRenderingModule.dll</HintPath>
31+
</Reference>
32+
<Reference Include="UnityEngine.UIElementsModule">
33+
<HintPath>external_dlls\UnityEngine.UIElementsModule.dll</HintPath>
34+
</Reference>
35+
</ItemGroup>
36+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
37+
<Exec Command="echo Killing task KSP2_x64.exe&#xD;&#xA;taskkill /f /fi &quot;pid gt 0&quot; /im KSP2_x64.exe&#xD;&#xA;&#xD;&#xA;echo Copying output .dll to &quot;..Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;xcopy /y &quot;$(TargetDir)$(ProjectName).dll&quot; &quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;&#xD;&#xA;echo Copying output .pdb to &quot;..Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;xcopy /y &quot;$(TargetDir)$(ProjectName).pdb&quot; &quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\BepInEx\plugins\micro_engineer\&quot;&#xD;&#xA;&#xD;&#xA;echo Starting KSP2_x64.exe&#xD;&#xA;powershell &quot;start-process &quot;&quot;D:\Steam\steamapps\common\Kerbal Space Program 2 0.1.3.0 DEV\KSP2_x64.exe&quot;&quot;&quot;" />
38+
</Target>
39+
</Project>

MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using BepInEx.Logging;
2+
using Newtonsoft.Json;
23

34
namespace MicroMod
45
{
@@ -15,6 +16,7 @@ public class BaseEntry
1516
public string Description;
1617
[JsonProperty]
1718
public MicroEntryCategory Category;
19+
public EntryType EntryType;
1820
public bool IsDefault;
1921
[JsonProperty]
2022
public bool HideWhenNoData;
@@ -38,10 +40,53 @@ public string Formatting
3840
set => _formatting = value;
3941
}
4042

41-
public virtual object EntryValue { get; set; }
43+
private object entryValue;
44+
public virtual object EntryValue
45+
{
46+
get => entryValue;
47+
48+
set
49+
{
50+
if (value != entryValue)
51+
{
52+
entryValue = value;
53+
54+
switch (EntryType)
55+
{
56+
case EntryType.BasicText:
57+
OnEntryValueChanged?.Invoke(ValueDisplay, UnitDisplay);
58+
break;
59+
case EntryType.Time:
60+
var time = Utility.ParseSecondsToTimeFormat((double?)value ?? 0);
61+
OnEntryTimeValueChanged?.Invoke(time.Days, time.Hours, time.Minutes, time.Seconds);
62+
break;
63+
case EntryType.LatitudeLongitude:
64+
var latLon = Utility.ParseDegreesToDMSFormat((double?)value ?? 0);
65+
OnEntryLatLonChanged?.Invoke(latLon.Degrees, latLon.Minutes, latLon.Seconds, BaseUnit);
66+
break;
67+
case EntryType.StageInfo:
68+
OnStageInfoChanged?.Invoke((List<Stage>)entryValue);
69+
break;
70+
case EntryType.Separator:
71+
break;
72+
default:
73+
break;
74+
}
75+
}
76+
}
77+
}
78+
79+
public delegate void EntryValueChanged(string value, string unit);
80+
public delegate void EntryTimeValueChanged(int days, int hours, int minutes, int seconds);
81+
public delegate void EntryLatLonChanged(int degrees, int minutes, int seconds, string direction);
82+
public delegate void StageInfoChanged(List<Stage> stages);
83+
public event EntryValueChanged OnEntryValueChanged;
84+
public event EntryTimeValueChanged OnEntryTimeValueChanged;
85+
public event EntryLatLonChanged OnEntryLatLonChanged;
86+
public event StageInfoChanged OnStageInfoChanged;
4287

4388
/// <summary>
44-
/// Controls how the value should be displayed. Should be overriden in a inheritet class for a concrete implementation.
89+
/// Controls how the value should be displayed. Can be overriden in a inheritet class for a more specialized implementation.
4590
/// </summary>
4691
public virtual string ValueDisplay
4792
{

MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
namespace MicroMod
1+
namespace MicroMod
32
{
43
public class BodyEntry : BaseEntry
54
{ }
@@ -68,5 +67,5 @@ public override void RefreshData()
6867
}
6968

7069
public override string ValueDisplay => base.ValueDisplay;
71-
}
70+
}
7271
}

MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
namespace MicroMod
1+
namespace MicroMod
32
{
43
public class FlightEntry : BaseEntry
54
{ }
@@ -317,7 +316,7 @@ public override string ValueDisplay
317316
return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue);
318317
}
319318
}
320-
}
319+
}
321320

322321
public class DragCoefficient : FlightEntry
323322
{

0 commit comments

Comments
 (0)