Skip to content

Commit

Permalink
Combine latest script features for v1.3 (#892)
Browse files Browse the repository at this point in the history
* Fix in module Script
Add Rendez-vous autopilot module

* Add all Maneuvers except the advanced transfer
Add the possibility to name scripts in slots and add a new configuration system where setting are stored in a "conf" file
Modify the number of slots to 8

* Add an action to open/close the shield of docking ports
When targeting a dock, check if the dock is shielded and open it

* Add flash Messages to show info messages or error messages
Add messages when a script is loaded or deleted

* Add a button to be able to delete scripts

* Fix a bug in the Target Dock action: Add a check for action available when referring to shielded docking port

* Add Activate Engine Function
Add a script transfer in the Undock Function (To be finalized)

* Update PArts selections with new method that is using flightID and not dependant from the iteration. This makes it consistent between load/save

* Add a "Clear" call in actions constructor involving parts list to avoid multiple times the same part in the list.

* Fix Activate Engine action
Modify part selection routines

* Fix NullpointerException when modifying items in the list

* Open the shield when a dock is a shielded one in Undock action

* Update view icons and limit the size of the view button

* Fix a small bug to reset the quicksave point after the script ends to avoid starting the script from the previous save point

* Change the part selection routine in SAS action and ActiveVessel action to be able to select also probes and not only vessels with crew capacity > 0

* Fix a bug in the part selection that repeats the existing part

* Add RCSThrottle and RCS for rotation in RCS action

* Add Zero Rvel action for RCS
Customize error message with yellow color

* Add Control From Action to select the module that will be used as the control reference
Fix a bug where the list was not cleared in TargetDock action

* Add a connection with the Plugin IRSequence from Infernal Robotic to be able to start pause and reset sequences in the sequencer

* Add new action to send commands to kOS processors

* kOS action: add a function to wait for the command to end

* IR Sequencer action: Add a feature to refresh the sequences list
Fix a bug in the IR Sequencer refresh method

* Add refresh icon for IR Robotic module

* Cache reflection Objects for kOS Action

* First shot on the conditions
Refactor the actions list outside the script module

* Add a spacer in the "add" action

* Add If Control Action
Add While Control Action
Add Condition System for Control Actions

* Add Borders on the GUI

* Add GUI to show/hide Add Actions in lists
Add padding in the program actions GUI

* Add a lot of variable in conditions

* Link the Wait For condition to program condition logic

* Add condition verification UI in condition object

* Add parallel execution action

* Fix actions index for Quicksave reference

* Fix breakpoint system with new switch action capabilities
Minor UI Fixes

* UI tweak

* Minor UI Fix

* Fix merge

* Remove useless file ActionInterceptWithHohmann (Replaced with Maneuver action)

* make stable ullage stable (#891)

its probably obvious that this should have been fixed this way.

however, i was considering vessels which had means of ullage and when i
was considering how far MJ should ullage until it tried to light the
engine i was like "why not _very_ stable, that's better right?"

but for something like a sounding rocket where it is as ullaged as its
ever going to get, you want to allow users to throttle with 'stable' as
well.  right now if the prop status falls from 'very stable' to 'stable'
before you hit the throttle it breaks your launch.

really for sounding rockets users should turn this feature off.

should also consider autodetecting sounding rockets (if there's no
other engines or RCS on the craft, it'll never ullage, so this whole
feature is a bit breaking if its checked).

Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>

* MemoryslotsMemoryslots

* Remove beta title
  • Loading branch information
SPD13 authored and sarbian committed Jun 2, 2017
1 parent 9be3000 commit 49ef5a9
Show file tree
Hide file tree
Showing 41 changed files with 2,250 additions and 601 deletions.
583 changes: 155 additions & 428 deletions MechJeb2/MechJebModuleScript.cs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions MechJeb2/ScriptsModule/IMechJebModuleScriptActionContainer.cs
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;

namespace MuMech
{
public interface IMechJebModuleScriptActionContainer
{
int getRecursiveCount();
List<MechJebModuleScriptAction> getRecursiveActionsList();
List<MechJebModuleScriptActionsList> getActionsListsObjects();
}
}

9 changes: 9 additions & 0 deletions MechJeb2/ScriptsModule/IMechJebModuleScriptActionsList.cs
@@ -0,0 +1,9 @@
using System;
namespace MuMech
{
public interface IMechJebModuleScriptActionsListParent
{
void notifyEndActionsList();
}
}

34 changes: 26 additions & 8 deletions MechJeb2/ScriptsModule/MechJebModuleScriptAction.cs
Expand Up @@ -11,20 +11,31 @@ public abstract class MechJebModuleScriptAction
protected MechJebModuleScript scriptModule;
protected MechJebCore core;
protected int actionIndex;
protected MechJebModuleScriptActionsList actionsList;

public MechJebModuleScriptAction (MechJebModuleScript scriptModule, MechJebCore core, String name)
public MechJebModuleScriptAction (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList, String name)
{
this.scriptModule = scriptModule;
this.core = core;
this.name = name;
this.actionsList = actionsList;
}

public virtual void activateAction(int actionIndex)
public void setActionIndex(int actionIndex)
{
this.started = true;
this.actionIndex = actionIndex;
}

public int getActionIndex()
{
return this.actionIndex;
}

public virtual void activateAction()
{
this.started = true;
}

public void markActionDone() //Used when we reload a previously saved script to mark past actions as resolved
{
this.started = false;
Expand All @@ -34,7 +45,7 @@ public virtual void activateAction(int actionIndex)
public virtual void endAction()
{
this.markActionDone();
this.scriptModule.notifyEndAction(actionIndex);
this.actionsList.notifyEndAction();
}

public bool isStarted()
Expand All @@ -49,7 +60,7 @@ public bool isExecuted()

public void deleteAction()
{
this.scriptModule.removeAction(this);
this.actionsList.removeAction(this);
}

public virtual void readModuleConfiguration() { }
Expand Down Expand Up @@ -92,21 +103,28 @@ virtual public void WindowGUI(int windowID)
}
if (!this.scriptModule.isStarted())
{
if (GUILayout.Button(GameDatabase.Instance.GetTexture("MechJeb2/Icons/delete", true), new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(20) }))
if (GUILayout.Button("", new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(20) }))
{
this.deleteAction();
}
if (GUILayout.Button(GameDatabase.Instance.GetTexture("MechJeb2/Icons/up", true), new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(20) }))
if (GUILayout.Button("", new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(20) }))
{
this.scriptModule.moveActionUp(this);
this.actionsList.moveActionUp(this);
}
}
}

public void postWindowGUI(int windowID)
{
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

public void resetStatus()
{
this.started = false;
this.executed = false;
}
}
}

Expand Up @@ -12,7 +12,7 @@ public class MechJebModuleScriptActionActionGroup : MechJebModuleScriptAction
[Persistent(pass = (int)Pass.Type)]
private int selectedActionId;

public MechJebModuleScriptActionActionGroup (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionActionGroup (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
actionGroups.Add("Abord");
actionGroups.Add("Brakes");
Expand All @@ -34,9 +34,9 @@ public MechJebModuleScriptActionActionGroup (MechJebModuleScript scriptModule, M
actionGroups.Add("Stage");
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
KSPActionGroup selectedGroup = KSPActionGroup.Abort;
if (selectedActionId == 0)
{
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class MechJebModuleScriptActionActivateEngine : MechJebModuleScriptAction
private uint selectedPartFlightID = 0;
private bool partHighlighted = false;

public MechJebModuleScriptActionActivateEngine (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionActivateEngine (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
this.enginePartsList.Clear();
this.enginePartsNames.Clear();
Expand All @@ -35,9 +35,9 @@ public MechJebModuleScriptActionActivateEngine (MechJebModuleScript scriptModule
}
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
if (enginePartsList[selectedPartIndex] != null)
{
enginePartsList[selectedPartIndex].force_activate();
Expand Down
Expand Up @@ -18,7 +18,7 @@ public class MechJebModuleScriptActionActiveVessel : MechJebModuleScriptAction
private int initTime = 5; //Add a 5s timer after the action
private float startTime = 0f;

public MechJebModuleScriptActionActiveVessel (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionActiveVessel (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
this.commandParts.Clear();
this.commandPartsNames.Clear();
Expand All @@ -38,9 +38,9 @@ public MechJebModuleScriptActionActiveVessel (MechJebModuleScript scriptModule,
}
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
FlightGlobals.SetActiveVessel(commandParts[selectedPartIndex].vessel);
this.scriptModule.setActiveBreakpoint(actionIndex, commandParts[selectedPartIndex].vessel);
//crewableParts[selectedPartIndex].vessel.MakeActive();
Expand Down
6 changes: 3 additions & 3 deletions MechJeb2/ScriptsModule/MechJebModuleScriptActionAscent.cs
Expand Up @@ -40,7 +40,7 @@ public class MechJebModuleScriptActionAscent : MechJebModuleScriptAction
[Persistent(pass = (int)Pass.Type)]
public Orbit targetOrbit;

public MechJebModuleScriptActionAscent (MechJebModuleScript scriptModule, MechJebCore core) : base(scriptModule, core, NAME)
public MechJebModuleScriptActionAscent (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList) : base(scriptModule, core, actionsList, NAME)
{
this.autopilot = core.GetComputerModule<MechJebModuleAscentAutopilot>();
this.ascentModule = core.GetComputerModule<MechJebModuleAscentGuidance>();
Expand Down Expand Up @@ -128,9 +128,9 @@ override public void afterOnFixedUpdate()
}
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
this.writeModuleConfiguration();
if (this.launchingToRendezvous)
{
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class MechJebModuleScriptActionControlFrom : MechJebModuleScriptAction
private uint selectedPartFlightID = 0;
private bool partHighlighted = false;

public MechJebModuleScriptActionControlFrom (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionControlFrom (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
this.controlPartsList.Clear();
this.controlPartsNames.Clear();
Expand All @@ -35,9 +35,9 @@ public MechJebModuleScriptActionControlFrom (MechJebModuleScript scriptModule, M
}
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
if (selectedPartIndex < controlPartsList.Count)
{
if (controlPartsList[selectedPartIndex].HasModule<ModuleCommand>())
Expand Down
Expand Up @@ -27,7 +27,7 @@ public class MechJebModuleScriptActionCrewTransfer : MechJebModuleScriptAction
private bool partHighlightedS = false;
private bool partHighlightedT = false;

public MechJebModuleScriptActionCrewTransfer (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionCrewTransfer (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
this.crewableParts.Clear();
this.crewablePartsNamesS.Clear();
Expand Down Expand Up @@ -88,9 +88,9 @@ private void RemoveCrew(ProtoCrewMember member, Part part, bool fireVesselUpdate
GameEvents.onVesselChange.Fire(FlightGlobals.ActiveVessel);
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
base.activateAction(actionIndex);
base.activateAction();
if (crewableParts [selectedPartIndexT].protoModuleCrew.Count < crewableParts [selectedPartIndexT].CrewCapacity)
{
MoveKerbal(crewableParts [selectedPartIndexS], crewableParts [selectedPartIndexT], kerbalsList[selectedKerbal]);
Expand Down
Expand Up @@ -30,7 +30,7 @@ public class MechJebModuleScriptActionDockingAutopilot : MechJebModuleScriptActi
[Persistent(pass = (int)Pass.Type)]
private bool drawBoundingBox;

public MechJebModuleScriptActionDockingAutopilot (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionDockingAutopilot (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{

this.autopilot = core.GetComputerModule<MechJebModuleDockingAutopilot>(); ;
Expand All @@ -47,7 +47,7 @@ public MechJebModuleScriptActionDockingAutopilot (MechJebModuleScript scriptModu
this.drawBoundingBox = autopilot.drawBoundingBox;
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
autopilot.users.Add(this.moduleGuidance);
autopilot.speedLimit = speedLimit;
Expand All @@ -63,7 +63,7 @@ override public void activateAction(int actionIndex)
autopilot.enabled = true;
autopilot.users.Add(this.moduleGuidance);
autopilot.dockingStep = MechJebModuleDockingAutopilot.DockingStep.INIT;
base.activateAction(actionIndex);
base.activateAction();
}

override public void endAction()
Expand Down
Expand Up @@ -18,7 +18,7 @@ public class MechJebModuleScriptActionDockingShield : MechJebModuleScriptAction
private bool partHighlighted = false;
private List<String> actionTypes = new List<String>();

public MechJebModuleScriptActionDockingShield (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionDockingShield (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
this.actionTypes.Clear();
this.actionTypes.Add("Open");
Expand All @@ -44,7 +44,7 @@ public MechJebModuleScriptActionDockingShield (MechJebModuleScript scriptModule,
}
}

override public void activateAction(int actionIndex)
override public void activateAction()
{
if (dockingPartsList[selectedPartIndex] != null)
{
Expand All @@ -69,7 +69,7 @@ override public void activateAction(int actionIndex)
}
}
}
base.activateAction(actionIndex);
base.activateAction();
}

override public void endAction()
Expand Down
Expand Up @@ -14,14 +14,14 @@ public class MechJebModuleScriptActionExecuteNode : MechJebModuleScriptAction
private List<String> actionTypes = new List<String>();
private int startNodeCount = 0;

public MechJebModuleScriptActionExecuteNode (MechJebModuleScript scriptModule, MechJebCore core):base(scriptModule, core, NAME)
public MechJebModuleScriptActionExecuteNode (MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList):base(scriptModule, core, actionsList, NAME)
{
actionTypes.Add("Next node");
actionTypes.Add("All nodes");
}

override public void activateAction(int actionIndex) {
base.activateAction(actionIndex);
override public void activateAction() {
base.activateAction();
if (core.node != null)
{
if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count > 0 && !core.node.enabled)
Expand Down

0 comments on commit 49ef5a9

Please sign in to comment.