Skip to content

Commit

Permalink
1.32a
Browse files Browse the repository at this point in the history
-External Interface Tweaks-previous commit
-Fix MERGE option in editor
-Add config for KIS so parts can staick
  • Loading branch information
SirDiazo committed May 14, 2015
1 parent e676d72 commit a7c15d9
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 15 deletions.
16 changes: 13 additions & 3 deletions AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,19 @@ public override void OnSave(ConfigNode node)
node.RemoveNodes("TOGGLE");
node.RemoveNodes("HOLD");
ErrLine = "2";
if (agxActionsThisPart.Count > 0)
List<AGXAction> actsToSave = new List<AGXAction>();
actsToSave.AddRange(agxActionsThisPart);
if(HighLogic.LoadedSceneIsEditor)
{
actsToSave.AddRange(AGXEditor.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part));
}
else if(HighLogic.LoadedSceneIsFlight)
{
actsToSave.AddRange(AGXFlight.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part));
}

ErrLine = "3";
foreach (AGXAction agAct in agxActionsThisPart)
foreach (AGXAction agAct in actsToSave)
{
ErrLine = "4";
ConfigNode actionNode = new ConfigNode("ACTION");
Expand All @@ -376,7 +385,7 @@ public override void OnSave(ConfigNode node)
node.AddNode(actionNode);
ErrLine = "7";
}
}

if (HighLogic.LoadedSceneIsEditor)
{
ConfigNode toggleStates = new ConfigNode("TOGGLE");
Expand Down Expand Up @@ -404,6 +413,7 @@ public override void OnSave(ConfigNode node)

public override void OnLoad(ConfigNode node)
{
//Debug.Log("Part Load " + this.part.partName);
string errLine = "1";
try
{
Expand Down
18 changes: 17 additions & 1 deletion AGExt/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,22 @@ public void OnShipLoad(ShipConstruct ship ,CraftBrowser.LoadType loadType)
}
else
{
Debug.Log("AGX Ship Load of type MERGE detected");
//Debug.Log("AGX Ship Load of type MERGE detected");
//foreach (Part p in ship.parts)
//{
// ModuleAGX agxPM = p.Modules.OfType<ModuleAGX>().First();
// foreach (AGXAction agAct in agxPM.agxActionsThisPart)
// {
// if (!CurrentVesselActions.Contains(agAct))
// {
// CurrentVesselActions.Add(agAct);
// if (AGXguiNames[agAct.group].Length == 0)
// {
// AGXguiNames[agAct.group] = agAct.grpName;
// }
// }
// }
//}
}
}

Expand Down Expand Up @@ -709,6 +724,7 @@ public void onLeftButtonClick()

public void PartAttaching(GameEvents.HostTargetAction<Part, Part> host_target)
{
//Debug.Log("Part attache fire!");
string ErrLine = "1";
try
{
Expand Down
44 changes: 34 additions & 10 deletions AGExt/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6193,19 +6193,39 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
agAct.activated = true;
}
}
if (agAct.ba.name == "ActivateSpoiler")


if (agAct.ba.name == "ActivateSpoiler") //THIS CODE WORKS, just need to wait for brake to become public on the next version of FAR
{
if (FlightGlobals.ActiveVessel.ActionGroups[KSPActionGroup.Brakes])


Assembly FarAsm = null;
foreach (AssemblyLoader.LoadedAssembly Asm in AssemblyLoader.loadedAssemblies)
{
agAct.activated = false;
if (Asm.dllName == "FerramAerospaceResearch")
{
//Debug.Log("far found");
FarAsm = Asm.assembly;
}
}
else
//Debug.Log("far found2");
if (FarAsm != null)
{
agAct.activated = true;
Type FarCtrlSurf = FarAsm.GetType("FARControllableSurface");
//Debug.Log("far found3");
if((bool)agAct.ba.listParent.module.GetType().GetField("brake").GetValue(agAct.ba.listParent.module))//.GetValue(FarCtrlSurf));
{
agAct.activated = true;
}
else
{
agAct.activated = false;
}
}

}
}
if (agAct.ba.listParent.module.moduleName == "FSrotorTrim")
if (agAct.ba.listParent.module.moduleName == "FSrotorTrim")
{


Expand Down Expand Up @@ -6585,17 +6605,21 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
}
if (agAct.ba.listParent.module.moduleName == "ModuleControlSurfaceActions") //other acts not needed, bool check
{
//Debug.Log("surface found");
agAct.activated = true;
foreach (PartModule pm in agAct.ba.listParent.part.Modules)
//foreach (ModuleControlSurface pm in agAct.ba.listParent.part.Modules.OfType<ModuleControlSurface>())
{
if (pm.moduleName == "ModuleControlSurface")
if (pm is ModuleControlSurface)
{
//Debug.Log("surface found2");
ModuleControlSurface CS = (ModuleControlSurface)pm;
if (agAct.ba.name == "TogglePitchAction" || agAct.ba.name == "EnablePitchAction" || agAct.ba.name == "DisablePitchAction")
{
//Debug.Log("surface found3");
if (CS.ignorePitch == true)
{
//Debug.Log("surface found4");
agAct.activated = false;
}
}
Expand All @@ -6614,7 +6638,7 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
}
}
}
else if (pm.moduleName == "FARControllableSurface")
else if (pm.moduleName == "FARControllableSurface") //FAR adds this after stock ModuleControlSurface always, so this runs second
{
//Debug.Log("Start FAR Module");
int i;
Expand Down Expand Up @@ -6736,9 +6760,9 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
//Debug.Log("End calc active action!");
}

catch
catch(Exception e)
{
print("AGX Action State Check Fail " + agAct.ba.name + " " + agAct.ba.listParent.module.moduleName);
print("AGX Action State Check Fail " + agAct.ba.name + " " + agAct.ba.listParent.module.moduleName + " " + e);
}


Expand Down
2 changes: 1 addition & 1 deletion AGExt/Instantly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AGXMainMenu :PartModule
//abandoned module, no longer needed for key rebinding
public void Start()
{
print("AGExt Ver. 1.32 loaded");
print("AGExt Ver. 1.32a loaded");


}
Expand Down

0 comments on commit a7c15d9

Please sign in to comment.