Skip to content

Commit

Permalink
Merge pull request #80 from ZiwKerman/v2.0-overhaul
Browse files Browse the repository at this point in the history
V2.0 Overhaul PR
  • Loading branch information
ZiwKerman committed Apr 15, 2016
2 parents a7ecc76 + 1ef3002 commit 8361422
Show file tree
Hide file tree
Showing 30 changed files with 3,077 additions and 3,114 deletions.
93 changes: 67 additions & 26 deletions InfernalRobotics/InfernalRobotics.sln
Original file line number Diff line number Diff line change
@@ -1,26 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfernalRobotics", "InfernalRobotics\InfernalRobotics.csproj", "{0EB66193-D77E-4A51-BAA2-67F641217963}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|x86.ActiveCfg = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|Any CPU.Build.0 = Release|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfernalRobotics", "InfernalRobotics\InfernalRobotics.csproj", "{0EB66193-D77E-4A51-BAA2-67F641217963}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Debug|x86.ActiveCfg = Debug|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|Any CPU.Build.0 = Release|Any CPU
{0EB66193-D77E-4A51-BAA2-67F641217963}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.TextStylePolicy = $1
$1.inheritsSet = VisualStudio
$1.inheritsScope = text/plain
$1.scope = text/x-csharp
$0.CSharpFormattingPolicy = $2
$2.IndentSwitchBody = True
$2.IndentBlocksInsideExpressions = True
$2.AnonymousMethodBraceStyle = NextLine
$2.PropertyBraceStyle = NextLine
$2.PropertyGetBraceStyle = NextLine
$2.PropertySetBraceStyle = NextLine
$2.EventBraceStyle = NextLine
$2.EventAddBraceStyle = NextLine
$2.EventRemoveBraceStyle = NextLine
$2.StatementBraceStyle = NextLine
$2.ElseNewLinePlacement = NewLine
$2.CatchNewLinePlacement = NewLine
$2.FinallyNewLinePlacement = NewLine
$2.WhileNewLinePlacement = DoNotCare
$2.ArrayInitializerWrapping = DoNotChange
$2.ArrayInitializerBraceStyle = NextLine
$2.BeforeMethodDeclarationParentheses = False
$2.BeforeMethodCallParentheses = False
$2.BeforeConstructorDeclarationParentheses = False
$2.NewLineBeforeConstructorInitializerColon = NewLine
$2.NewLineAfterConstructorInitializerColon = SameLine
$2.BeforeDelegateDeclarationParentheses = False
$2.NewParentheses = False
$2.SpacesBeforeBrackets = False
$2.inheritsSet = Mono
$2.inheritsScope = text/x-csharp
$2.scope = text/x-csharp
$0.TextStylePolicy = $3
$3.FileWidth = 120
$3.EolMarker = Windows
$3.inheritsSet = VisualStudio
$3.inheritsScope = text/plain
$3.scope = text/plain
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
39 changes: 25 additions & 14 deletions InfernalRobotics/InfernalRobotics/Command/ServoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public static void AddServo(IServo servo)
if (Instance.ServoGroups == null)
Instance.ServoGroups = new List<ControlGroup>();

if (Gui.ControlsGUI.IRGUI)
{
Gui.ControlsGUI.IRGUI.enabled = true;
}

ControlGroup controlGroup = null;

if (!string.IsNullOrEmpty(servo.Group.Name))
Expand Down Expand Up @@ -110,10 +105,10 @@ public static void RemoveServo(IServo servo)
num += group.Servos.Count;
}

if (Gui.ControlsGUI.IRGUI)
if (Gui.WindowManager.Instance)
{
//disable GUI when last servo removed
Gui.ControlsGUI.IRGUI.enabled = num > 0;
Gui.WindowManager.Instance.GUIEnabled &= num > 0;
}
Logger.Log("[ServoController] AddServo finished successfully", Logger.Level.Debug);
}
Expand Down Expand Up @@ -145,6 +140,7 @@ private void OnPartAttach(GameEvents.HostTargetAction<Part, Part> hostTarget)
partCounter = EditorLogic.fetch.ship.parts.Count;
}
}

Logger.Log("[ServoController] OnPartAttach finished successfully", Logger.Level.Debug);
}

Expand Down Expand Up @@ -173,8 +169,10 @@ private void OnPartRemove(GameEvents.HostTargetAction<Part, Part> hostTarget)
Logger.Log("[ServoController] OnPartRemove finished successfully", Logger.Level.Debug);
}

private void OnEditorShipModified(ShipConstruct ship)
private void RebuildServoGroupsEditor()
{
ShipConstruct ship = EditorLogic.fetch.ship;

ServoGroups = null;

var groups = new List<ControlGroup>();
Expand All @@ -199,6 +197,14 @@ private void OnEditorShipModified(ShipConstruct ship)

if (groups.Count > 0)
ServoGroups = groups;
}

private void OnEditorShipModified(ShipConstruct ship)
{
RebuildServoGroupsEditor();

Gui.WindowManager.guiRebuildPending = true; //this should force an UI rebuild on first update
Gui.IRBuildAid.IRBuildAidManager.Reset();

partCounter = EditorLogic.fetch.ship.parts.Count == 1 ? 0 : EditorLogic.fetch.ship.parts.Count;
Logger.Log("[ServoController] OnEditorShipModified finished successfully", Logger.Level.Debug);
Expand All @@ -213,12 +219,13 @@ private void OnEditorRestart()
private void OnEditorLoad(ShipConstruct s, KSP.UI.Screens.CraftBrowserDialog.LoadType t)
{
OnEditorShipModified (s);

Logger.Log ("OnEditorLoad called", Logger.Level.Debug);
}
/// <summary>
/// Rebuilds the servo groups. Only works in flight.
/// </summary>
private void RebuildServoGroups()
private void RebuildServoGroupsFlight()
{
ServoGroups = new List<ControlGroup>();

Expand Down Expand Up @@ -251,36 +258,40 @@ private void RebuildServoGroups()

if (ServoGroups.Count == 0)
ServoGroups = null;

Gui.WindowManager.guiRebuildPending = true; //this should force an UI rebuild on the next update

}

private void OnVesselChange(Vessel v)
{
Logger.Log(string.Format("[ServoController] vessel {0}", v.name));

RebuildServoGroups ();
RebuildServoGroupsFlight ();

foreach (var servo in v.ToServos())
{
servo.RawServo.SetupJoints();
}

Logger.Log("[ServoController] OnVesselChange finished successfully", Logger.Level.Debug);
}

private void OnVesselWasModified(Vessel v)
{
RebuildServoGroups ();
RebuildServoGroupsFlight ();
}

private void OnVesselLoaded (Vessel v)
{
Logger.Log("[ServoController] OnVesselLoaded, v=" + v.GetName());
RebuildServoGroups ();
RebuildServoGroupsFlight ();
}

private void OnVesselUnloaded (Vessel v)
{
Logger.Log("[ServoController] OnVesselUnloaded, v=" + v.GetName());
RebuildServoGroups ();
RebuildServoGroupsFlight ();
}

private void Awake()
Expand Down Expand Up @@ -322,7 +333,7 @@ private void FixedUpdate()
{
if(FlightGlobals.Vessels.Count(v => v.loaded) != loadedVesselCounter)
{
RebuildServoGroups ();
RebuildServoGroupsFlight ();
loadedVesselCounter = FlightGlobals.Vessels.Count(v => v.loaded);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ public void Save(bool symmetry = false)

if (symmetry && rawServo.part.symmetryCounterparts.Count >= 1)
{
Logger.Log ("Applying presets to symmetryCounterparts", Logger.Level.Debug);

foreach (Part part in rawServo.part.symmetryCounterparts)
{
var module = ((ModuleIRServo)part.Modules ["ModuleIRServo"]);
if(module == null)
module = ((ModuleIRServo)part.Modules ["MuMechToggle"]);
if(module== null)
{
Logger.Log ("Could not find ModuleIRServo on a sibling " + part.name, Logger.Level.Warning);
continue;
}
module.presetPositionsSerialized = rawServo.presetPositionsSerialized;
module.ParsePresetPositions();
}
Expand Down
35 changes: 0 additions & 35 deletions InfernalRobotics/InfernalRobotics/Extension/ConfigNodeExtension.cs

This file was deleted.

64 changes: 0 additions & 64 deletions InfernalRobotics/InfernalRobotics/Extension/RectExtensions.cs

This file was deleted.

Loading

0 comments on commit 8361422

Please sign in to comment.