Skip to content

Commit

Permalink
Ctrl clicking a fairing side will toggle them open/closed (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Sep 3, 2023
1 parent e3bc465 commit 252d3db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 13 additions & 0 deletions Source/ProceduralFairings/FairingSide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ public override void OnStart(StartState state)
else
ApplyShapeOnStart();

if (HighLogic.LoadedSceneIsEditor)
part.AddOnMouseDown(OnPartClick);

SetUICallbacks();
SetUIFieldVisibility();

SetDensityField();
}

public override void OnStartFinished(StartState state)
{
base.OnStartFinished(state);
Expand All @@ -239,6 +243,7 @@ public override void OnStartFinished(StartState state)
SetHingeToggles();

}

private void SetDensityField()
{
var floatRange = Fields[nameof(density)].uiControlEditor as UI_FloatRange;
Expand Down Expand Up @@ -354,6 +359,14 @@ void SetUIFieldVisibility()
Fields[nameof(noseHeightRatio)].guiActiveEditor = !usePreset;
}

private void OnPartClick(Part p)
{
if (Input.GetKey(KeyCode.LeftControl))
{
ToggleOpenClosed();
}
}

private static void LoadPresets(Dictionary<string, FairingSideShapePreset> presets)
{
presets.Clear();
Expand Down
11 changes: 6 additions & 5 deletions Source/ProceduralFairings/ProceduralFairings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@
<Reference Include="System" />
<Reference Include="mscorlib" />
<Reference Include="UnityEngine" />
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.AudioModule" />
<Reference Include="UnityEngine.CoreModule" />
<Reference Include="UnityEngine.IMGUIModule" />
<Reference Include="UnityEngine.InputLegacyModule" />
<Reference Include="UnityEngine.PhysicsModule" />
<Reference Include="UnityEngine.TextRenderingModule" />
<Reference Include="UnityEngine.UI" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit 252d3db

Please sign in to comment.