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

Commit 8c0606d

Browse files
committed
Fixed main gui from twitching
1 parent df12d4a commit 8c0606d

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

MicroEngineerProject/MicroEngineer/Managers/Manager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public void Update()
2929
{
3030
Utility.RefreshGameManager();
3131

32+
bool isFlightActive = Windows.OfType<MainGuiWindow>().FirstOrDefault().IsFlightActive;
33+
3234
// Perform flight UI updates only if we're in Flight or Map view
33-
if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView))
35+
if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) && isFlightActive)
3436
{
3537
Utility.RefreshActiveVesselAndCurrentManeuver();
3638

MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using BepInEx.Logging;
2-
using KSP.Game;
1+
using KSP.Game;
32
using KSP.Messages;
3+
using KSP.UI.Binding;
4+
using UnityEngine;
45

56
namespace MicroMod
67
{
@@ -11,8 +12,6 @@ internal class MessageManager
1112
private UI _ui;
1213
internal List<BaseWindow> Windows;
1314

14-
private static readonly ManualLogSource _logger = Logger.CreateLogSource("MicroEngineer.MessageManager");
15-
1615
internal MessageManager(MicroEngineerMod plugin, Manager manager, UI ui)
1716
{
1817
_plugin = plugin;
@@ -71,8 +70,6 @@ private void OnPartManipulationCompletedMessage(MessageCenterMessage obj)
7170

7271
private void GameStateEntered(MessageCenterMessage obj)
7372
{
74-
_logger.LogInfo("Message triggered: GameStateEnteredMessage");
75-
7673
Utility.RefreshGameManager();
7774
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView)
7875
{
@@ -81,11 +78,15 @@ private void GameStateEntered(MessageCenterMessage obj)
8178
_ui.Windows = Windows;
8279

8380
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)
81+
{
8482
_ui.ShowGuiFlight = Windows.OfType<MainGuiWindow>().FirstOrDefault().IsFlightActive;
83+
GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(_ui.ShowGuiFlight);
84+
}
8585

8686
if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder)
8787
{
8888
_ui.ShowGuiOAB = Windows.FindAll(w => w is EntryWindow).Cast<EntryWindow>().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive;
89+
GameObject.Find("BTN - MicroEngineerOAB")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(_ui.ShowGuiOAB);
8990
_ui.CelestialBodies.GetBodies();
9091
_ui.CelestialBodySelectionStageIndex = -1;
9192
Styles.SetActiveTheme(Theme.Gray); // TODO implement other themes in OAB
@@ -95,8 +96,6 @@ private void GameStateEntered(MessageCenterMessage obj)
9596

9697
private void GameStateLeft(MessageCenterMessage obj)
9798
{
98-
_logger.LogInfo("Message triggered: GameStateLeftMessage");
99-
10099
Utility.RefreshGameManager();
101100
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView)
102101
{

MicroEngineerProject/MicroEngineer/Managers/UI.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,6 @@ private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLoc
373373
GUILayout.Space(10);
374374
GUILayout.BeginHorizontal();
375375

376-
// If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow
377-
//isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout;
378-
//isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout;
379-
380376
GUILayout.Label($"{sectionName}", Styles.WindowTitleLabelStyle);
381377
GUILayout.FlexibleSpace();
382378
if(GUILayout.Button(Styles.Settings15Texture, Styles.SettingsBtnStyle))

MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace MicroMod
1010
{
11-
[BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.0.0")]
11+
[BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.0.1")]
1212
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
1313
public class MicroEngineerMod : BaseSpaceWarpPlugin
1414
{

MicroEngineerProject/MicroEngineer/Utilities/Utility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public static Vector2 ClampToScreen(Vector2 position, Vector2 size)
235235
{
236236
float x = Mathf.Clamp(position.x, 0, Screen.width - size.x);
237237
float y = Mathf.Clamp(position.y, 0, Screen.height - size.y);
238-
return new Vector2(x, y);
238+
return new Vector2(x, size.y > Screen.height ? position.y : y);
239239
}
240240

241241
/// <summary>

0 commit comments

Comments
 (0)