Skip to content

Commit

Permalink
Fixed menu Show Tweakables, for when Advanced tweakables is enabled, …
Browse files Browse the repository at this point in the history
…to show at the right height

Fixed resizing of menu
  • Loading branch information
linuxgurugamer committed Nov 2, 2016
1 parent 8ad5441 commit 0f44ab0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 38 deletions.
88 changes: 52 additions & 36 deletions EditorExtensionsRedux/EditorExtensionsRedux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public class EditorExtensions : MonoBehaviour
public ConfigData cfg;
string _pluginDirectory;
string _configFilePath;
int _symmetryMode = 0;
//int _symmetryMode = 0;

SettingsWindow _settingsWindow = null;
PartInfoWindow _partInfoWindow = null;
Expand Down Expand Up @@ -884,8 +884,8 @@ void Update()
OSDMessage(string.Format("Change will take effect after deselecting current part"));
// GameEvents.onEditorPartPlaced.Fire(p);
EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour.Instance.OnDestroy();
// if (p != null)
// GameEvents.onEditorPartPicked.Fire(p);
// if (p != null)
// GameEvents.onEditorPartPicked.Fire(p);
}
}
}
Expand Down Expand Up @@ -935,7 +935,7 @@ void Update()
{
DisableMasterSnap();
}
}
}
else
{
DisableMasterSnap();
Expand Down Expand Up @@ -1197,7 +1197,7 @@ bool IsPartNodeAttached(Part p)
return false;
}

#region Alignments
#region Alignments

void AlignToTopOfParent(Part p)
{
Expand Down Expand Up @@ -1269,7 +1269,7 @@ class PartMovement
}

List<PartMovement> partMovement = new List<PartMovement>();

bool partMovementContains(Part p)
{
foreach (var pm in partMovement)
Expand All @@ -1281,9 +1281,9 @@ bool partMovementContains(Part p)
void MoveParts()
{
List<PartMovement> pmToDel = null;

foreach (PartMovement pm in partMovement)
{
{
if (pm.local)
{
Vector3 v = Vector3.Lerp(pm.startPos, pm.endPos, (float)((Time.fixedTime - pm.startTime) / pm.time));
Expand All @@ -1299,7 +1299,7 @@ void MoveParts()
if (Time.fixedTime > pm.endtime)
{
if (pmToDel == null)
pmToDel = new List<PartMovement>();
pmToDel = new List<PartMovement>();
pmToDel.Add(pm);
}
}
Expand Down Expand Up @@ -1445,7 +1445,7 @@ void CenterHorizontallyOnParent(Part p, bool otherHorizontal = false)
PartMovement pm = new PartMovement();
pm.p = p;
pm.local = true;
pm.startPos = p.transform.localPosition;
pm.startPos = p.transform.localPosition;
pm.time = timeToMovePM;
pm.startTime = Time.fixedTime;
pm.endtime = Time.fixedTime + pm.time;
Expand Down Expand Up @@ -1595,9 +1595,9 @@ void AlignCompoundPart(CompoundPart part, bool snapHeights)
}
}

#endregion
#endregion

#region Editor Actions
#region Editor Actions

void AddUndo()
{
Expand Down Expand Up @@ -1876,9 +1876,9 @@ bool GizmoActive()
}
}

#endregion
#endregion

#region GUI
#region GUI

//private Rect _settingsWindowRect;
GUIStyle osdLabelStyle, symmetryLabelStyle;
Expand Down Expand Up @@ -1962,34 +1962,49 @@ public void SettingsWindowClosed()
const float _menuHeightLarge = 380.0f;
const int _toolbarHeight = 42;
//37

public void ShowMenu()
bool oldAllowTweakingWithoutTweakables = GameSettings.ADVANCED_TWEAKABLES;
public void ShowMenu(bool firstTime = true)
{
if (!validVersion)
return;
oldAllowTweakingWithoutTweakables = allowTweakingWithoutTweakables;
Vector3 position = Input.mousePosition;
int toolbarHeight = (int)(_toolbarHeight * GameSettings.UI_SCALE);
float menuHeight;
if (allowTweakingWithoutTweakables)
if (allowTweakingWithoutTweakables || GameSettings.ADVANCED_TWEAKABLES)
menuHeight = _menuHeightLarge;
else
menuHeight = _menuHeightSmall;

_menuRect = new Rect()
if (firstTime)
{
xMin = position.x - _menuWidth / 2,
xMax = position.x + _menuWidth / 2,
yMin = Screen.height - toolbarHeight - menuHeight,
yMax = Screen.height - toolbarHeight
};
_showMenu = true;
_menuRect = new Rect()
{
xMin = position.x - _menuWidth / 2,
xMax = position.x + _menuWidth / 2,
yMin = Screen.height - toolbarHeight - menuHeight,
yMax = Screen.height - toolbarHeight
};
_showMenu = true;
}
else
{
_menuRect.Set(
_menuRect.x,
Screen.height - toolbarHeight - menuHeight,
_menuRect.width,
menuHeight
);
lastTimeShown = Time.fixedTime;
}

}

public void HideMenu()
{
_showMenu = false;
}


//Unity GUI loop
void OnGUI()
{
Expand All @@ -2009,7 +2024,8 @@ void OnGUI()
_menuRect = GUILayout.Window(this.GetInstanceID(), _menuRect, ShowWarning, "EEX Menu");
return;
}

if (oldAllowTweakingWithoutTweakables != allowTweakingWithoutTweakables)
ShowMenu(false);

//show and update the angle snap and symmetry mode labels
ShowSnapLabels();
Expand Down Expand Up @@ -2077,9 +2093,9 @@ void MenuContent(int WindowID)
if (!GameSettings.ADVANCED_TWEAKABLES)
{
GUILayout.Space(10f);
allowTweakingWithoutTweakables = GUILayout.Toggle(allowTweakingWithoutTweakables, "Allow Mass Tweakables");

allowTweakingWithoutTweakables = GUILayout.Toggle(allowTweakingWithoutTweakables, "Allow Mass Tweakables");

}

if (GameSettings.ADVANCED_TWEAKABLES || allowTweakingWithoutTweakables)
Expand Down Expand Up @@ -2162,13 +2178,13 @@ void MenuContent(int WindowID)
{
if (!doNotMessWithAutoStrutModes.Contains(p.autoStrutMode))
{
// p.autoStrutMode = Part.AutoStrutMode.Heaviest;;
// p.autoStrutMode = Part.AutoStrutMode.Heaviest;;

// p.UpdateAutoStrut();
p.autoStrutMode = Part.AutoStrutMode.Off ;
p.autoStrutMode = Part.AutoStrutMode.Off;
// The ToggleAutoStrut will set the mode to Heaviest
p.ToggleAutoStrut();

}
}
OSDMessage("Autostruts set to 'Heaviest' for all current Parts in Vessel (except forced).");
Expand Down Expand Up @@ -2256,7 +2272,7 @@ void OSDMessage(string message)
ScreenMessages.PostScreenMessage(message, cfg.OnScreenMessageTime, ScreenMessageStyle.LOWER_CENTER);
}

#region Snap labels
#region Snap labels

const int FONTSIZE = 14;

Expand Down Expand Up @@ -2357,7 +2373,7 @@ void ShowAutoStruts()
RefreshParts();
foreach (Part p in parts)
{
if (p.autoStrutMode != Part.AutoStrutMode.Off && !doNotMessWithAutoStrutModes.Contains(p.autoStrutMode))
if (p.autoStrutMode != Part.AutoStrutMode.Off && !doNotMessWithAutoStrutModes.Contains(p.autoStrutMode))
{
Part.AutoStrutMode asm = p.autoStrutMode;
p.autoStrutMode = Part.AutoStrutMode.Off;
Expand Down Expand Up @@ -2440,8 +2456,8 @@ private void ShowSnapLabels()
}
}

#endregion
#endregion

#endregion
#endregion
}
}
4 changes: 2 additions & 2 deletions EditorExtensionsRedux/EditorExtensionsRedux.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
{
"MAJOR":3,
"MINOR":3,
"PATCH":5,
"BUILD":1
"PATCH":6,
"BUILD":0
},
"KSP_VERSION":
{
Expand Down

0 comments on commit 0f44ab0

Please sign in to comment.