Skip to content

Commit a7c15d9

Browse files
committed
1.32a
-External Interface Tweaks-previous commit -Fix MERGE option in editor -Add config for KIS so parts can staick
1 parent e676d72 commit a7c15d9

File tree

4 files changed

+65
-15
lines changed

4 files changed

+65
-15
lines changed

AGExt/CommonMethods.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,19 @@ public override void OnSave(ConfigNode node)
359359
node.RemoveNodes("TOGGLE");
360360
node.RemoveNodes("HOLD");
361361
ErrLine = "2";
362-
if (agxActionsThisPart.Count > 0)
362+
List<AGXAction> actsToSave = new List<AGXAction>();
363+
actsToSave.AddRange(agxActionsThisPart);
364+
if(HighLogic.LoadedSceneIsEditor)
363365
{
366+
actsToSave.AddRange(AGXEditor.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part));
367+
}
368+
else if(HighLogic.LoadedSceneIsFlight)
369+
{
370+
actsToSave.AddRange(AGXFlight.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part));
371+
}
372+
364373
ErrLine = "3";
365-
foreach (AGXAction agAct in agxActionsThisPart)
374+
foreach (AGXAction agAct in actsToSave)
366375
{
367376
ErrLine = "4";
368377
ConfigNode actionNode = new ConfigNode("ACTION");
@@ -376,7 +385,7 @@ public override void OnSave(ConfigNode node)
376385
node.AddNode(actionNode);
377386
ErrLine = "7";
378387
}
379-
}
388+
380389
if (HighLogic.LoadedSceneIsEditor)
381390
{
382391
ConfigNode toggleStates = new ConfigNode("TOGGLE");
@@ -404,6 +413,7 @@ public override void OnSave(ConfigNode node)
404413

405414
public override void OnLoad(ConfigNode node)
406415
{
416+
//Debug.Log("Part Load " + this.part.partName);
407417
string errLine = "1";
408418
try
409419
{

AGExt/Editor.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,22 @@ public void OnShipLoad(ShipConstruct ship ,CraftBrowser.LoadType loadType)
576576
}
577577
else
578578
{
579-
Debug.Log("AGX Ship Load of type MERGE detected");
579+
//Debug.Log("AGX Ship Load of type MERGE detected");
580+
//foreach (Part p in ship.parts)
581+
//{
582+
// ModuleAGX agxPM = p.Modules.OfType<ModuleAGX>().First();
583+
// foreach (AGXAction agAct in agxPM.agxActionsThisPart)
584+
// {
585+
// if (!CurrentVesselActions.Contains(agAct))
586+
// {
587+
// CurrentVesselActions.Add(agAct);
588+
// if (AGXguiNames[agAct.group].Length == 0)
589+
// {
590+
// AGXguiNames[agAct.group] = agAct.grpName;
591+
// }
592+
// }
593+
// }
594+
//}
580595
}
581596
}
582597

@@ -709,6 +724,7 @@ public void onLeftButtonClick()
709724

710725
public void PartAttaching(GameEvents.HostTargetAction<Part, Part> host_target)
711726
{
727+
//Debug.Log("Part attache fire!");
712728
string ErrLine = "1";
713729
try
714730
{

AGExt/Flight.cs

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6193,19 +6193,39 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
61936193
agAct.activated = true;
61946194
}
61956195
}
6196-
if (agAct.ba.name == "ActivateSpoiler")
6196+
6197+
6198+
if (agAct.ba.name == "ActivateSpoiler") //THIS CODE WORKS, just need to wait for brake to become public on the next version of FAR
61976199
{
6198-
if (FlightGlobals.ActiveVessel.ActionGroups[KSPActionGroup.Brakes])
6200+
6201+
6202+
Assembly FarAsm = null;
6203+
foreach (AssemblyLoader.LoadedAssembly Asm in AssemblyLoader.loadedAssemblies)
61996204
{
6200-
agAct.activated = false;
6205+
if (Asm.dllName == "FerramAerospaceResearch")
6206+
{
6207+
//Debug.Log("far found");
6208+
FarAsm = Asm.assembly;
6209+
}
62016210
}
6202-
else
6211+
//Debug.Log("far found2");
6212+
if (FarAsm != null)
62036213
{
6204-
agAct.activated = true;
6214+
Type FarCtrlSurf = FarAsm.GetType("FARControllableSurface");
6215+
//Debug.Log("far found3");
6216+
if((bool)agAct.ba.listParent.module.GetType().GetField("brake").GetValue(agAct.ba.listParent.module))//.GetValue(FarCtrlSurf));
6217+
{
6218+
agAct.activated = true;
6219+
}
6220+
else
6221+
{
6222+
agAct.activated = false;
6223+
}
62056224
}
6225+
62066226
}
62076227
}
6208-
if (agAct.ba.listParent.module.moduleName == "FSrotorTrim")
6228+
if (agAct.ba.listParent.module.moduleName == "FSrotorTrim")
62096229
{
62106230

62116231

@@ -6585,17 +6605,21 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
65856605
}
65866606
if (agAct.ba.listParent.module.moduleName == "ModuleControlSurfaceActions") //other acts not needed, bool check
65876607
{
6608+
//Debug.Log("surface found");
65886609
agAct.activated = true;
65896610
foreach (PartModule pm in agAct.ba.listParent.part.Modules)
65906611
//foreach (ModuleControlSurface pm in agAct.ba.listParent.part.Modules.OfType<ModuleControlSurface>())
65916612
{
6592-
if (pm.moduleName == "ModuleControlSurface")
6613+
if (pm is ModuleControlSurface)
65936614
{
6615+
//Debug.Log("surface found2");
65946616
ModuleControlSurface CS = (ModuleControlSurface)pm;
65956617
if (agAct.ba.name == "TogglePitchAction" || agAct.ba.name == "EnablePitchAction" || agAct.ba.name == "DisablePitchAction")
65966618
{
6619+
//Debug.Log("surface found3");
65976620
if (CS.ignorePitch == true)
65986621
{
6622+
//Debug.Log("surface found4");
65996623
agAct.activated = false;
66006624
}
66016625
}
@@ -6614,7 +6638,7 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
66146638
}
66156639
}
66166640
}
6617-
else if (pm.moduleName == "FARControllableSurface")
6641+
else if (pm.moduleName == "FARControllableSurface") //FAR adds this after stock ModuleControlSurface always, so this runs second
66186642
{
66196643
//Debug.Log("Start FAR Module");
66206644
int i;
@@ -6736,9 +6760,9 @@ public static List<AGXAction> CheckActionsActiveActualCode(List<AGXAction> actsL
67366760
//Debug.Log("End calc active action!");
67376761
}
67386762

6739-
catch
6763+
catch(Exception e)
67406764
{
6741-
print("AGX Action State Check Fail " + agAct.ba.name + " " + agAct.ba.listParent.module.moduleName);
6765+
print("AGX Action State Check Fail " + agAct.ba.name + " " + agAct.ba.listParent.module.moduleName + " " + e);
67426766
}
67436767

67446768

AGExt/Instantly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AGXMainMenu :PartModule
1313
//abandoned module, no longer needed for key rebinding
1414
public void Start()
1515
{
16-
print("AGExt Ver. 1.32 loaded");
16+
print("AGExt Ver. 1.32a loaded");
1717

1818

1919
}

0 commit comments

Comments
 (0)