Skip to content

Commit e9954de

Browse files
committed
1.34d
New external interface methods
1 parent 2b5ef94 commit e9954de

4 files changed

Lines changed: 119 additions & 15 deletions

File tree

‎AGExt/CommonMethods.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public override void OnLoad(ConfigNode node)
559559
{
560560
private uint flightID; //
561561
private bool vesselInstanceOK = false; //is this vessel loadable? if this is false, run nothing
562-
private List<AGXAction> actionsList;
562+
public List<AGXAction> actionsList;
563563
private Vessel thisVsl;
564564
private Dictionary<int, string> guiNames;
565565

‎AGExt/External.cs‎

Lines changed: 91 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static List<AGXAction> AGX2VslGroupActions(uint FlightID, int group) //wo
9090
}
9191
else if (HighLogic.LoadedSceneIsEditor)
9292
{
93-
return StaticData.CurrentVesselActions.FindAll(ag => ag.group == group);
93+
return StaticData.CurrentVesselActions.FindAll(ag => ag.group == group);
9494
}
9595
else
9696
{
@@ -161,9 +161,9 @@ public static string AGX2VslGroupNameSingle(uint FlightID, int group) //return n
161161
}
162162
}
163163

164-
public static Dictionary<int,string> AGXGroupNamesAll() //return dictionary of group names, returns dictionary of 250 items, only groups with defined names will have strings
164+
public static Dictionary<int, string> AGXGroupNamesAll() //return dictionary of group names, returns dictionary of 250 items, only groups with defined names will have strings
165165
{
166-
if(HighLogic.LoadedSceneIsFlight)
166+
if (HighLogic.LoadedSceneIsFlight)
167167
{
168168
return AGXFlight.AGXguiNames;
169169
}
@@ -175,13 +175,13 @@ public static Dictionary<int,string> AGXGroupNamesAll() //return dictionary of g
175175
{
176176
return new Dictionary<int, string>();
177177
}
178-
}
179-
180-
public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //return dictionary of group names
178+
}
179+
180+
public static Dictionary<int, string> AGX2VslGroupNamesAll(uint FlightID) //return dictionary of group names
181181
{
182-
if(HighLogic.LoadedSceneIsFlight)
182+
if (HighLogic.LoadedSceneIsFlight)
183183
{
184-
if(FlightID == FlightGlobals.ActiveVessel.rootPart.flightID)
184+
if (FlightID == FlightGlobals.ActiveVessel.rootPart.flightID)
185185
{
186186
return AGXFlight.AGXguiNames;
187187
}
@@ -191,9 +191,9 @@ public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //retur
191191
return otherVsl.GetGroupNamesAll();
192192
}
193193
}
194-
else if(HighLogic.LoadedSceneIsEditor)
194+
else if (HighLogic.LoadedSceneIsEditor)
195195
{
196-
if(FlightID == EditorLogic.RootPart.flightID)
196+
if (FlightID == EditorLogic.RootPart.flightID)
197197
{
198198
return AGXEditor.AGXguiNames;
199199
}
@@ -207,7 +207,7 @@ public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //retur
207207
return new Dictionary<int, string>();
208208
}
209209
}
210-
210+
211211
public static bool AGX2VslToggleGroup(uint FlightID, int group) //other vessel direct toggle activate
212212
{
213213
print("AGX Call: toggle action " + group + " for vessel " + FlightID);
@@ -801,6 +801,84 @@ public static List<Part> AGXListOfPartsInGroup(int i)
801801
}
802802
}
803803

804+
public static Dictionary<int,string> AGXListOfAssignedGroups()
805+
{
806+
print("AGX Call: list of groups with assigned actions");
807+
if (HighLogic.LoadedSceneIsFlight)
808+
{
809+
Dictionary<int,string> grpList = new Dictionary<int,string>();
810+
foreach (AGXAction agAct in StaticData.CurrentVesselActions)
811+
{
812+
if(!grpList.ContainsKey(agAct.group))
813+
//if (!grpList.Concat(agAct.group))
814+
{
815+
grpList.Add(agAct.group,AGXFlight.AGXguiNames[agAct.group]);
816+
}
817+
}
818+
//dictionary isn't sortable, you sort the results when you access it which has to happen in the other mod.
819+
return grpList;
820+
}
821+
else if (HighLogic.LoadedSceneIsEditor)
822+
{
823+
Dictionary<int, string> grpList = new Dictionary<int, string>();
824+
foreach (AGXAction agAct in StaticData.CurrentVesselActions)
825+
{
826+
if (!grpList.ContainsKey(agAct.group))
827+
{
828+
grpList.Add(agAct.group, AGXEditor.AGXguiNames[agAct.group]);
829+
}
830+
}
831+
return grpList;
832+
}
833+
else
834+
{
835+
return new Dictionary<int, string>();
836+
}
837+
}
838+
839+
public static Dictionary<int,string> AGX2VslListOfAssignedGroups(uint flightID)
840+
{
841+
print("AGX Call: list of groups with assigned actions on vessel " + flightID);
842+
try
843+
{
844+
845+
if (HighLogic.LoadedSceneIsFlight) //only workes in flight
846+
{
847+
if (FlightGlobals.ActiveVessel.rootPart.flightID == flightID)
848+
{
849+
return AGXListOfAssignedGroups();
850+
}
851+
else
852+
{
853+
AGXOtherVessel otherVsl = new AGXOtherVessel(flightID);
854+
Dictionary<int, string> grpList = new Dictionary<int, string>();
855+
foreach (AGXAction agAct in otherVsl.actionsList)
856+
{
857+
if (!grpList.ContainsKey(agAct.group))
858+
{
859+
grpList.Add(agAct.group, AGXEditor.AGXguiNames[agAct.group]);
860+
}
861+
}
862+
return grpList;
863+
864+
}
865+
}
866+
else if (HighLogic.LoadedSceneIsEditor)
867+
{
868+
return AGXListOfAssignedGroups();
869+
}
870+
871+
else
872+
{
873+
return new Dictionary<int, string>();
874+
}
875+
}
876+
catch
877+
{
878+
return new Dictionary<int, string>();
879+
}
880+
}
881+
804882

805883

806884
}
@@ -895,7 +973,7 @@ public int GetHashCode(AGXAction obj)
895973
public override string ToString()
896974
{
897975
string str = "";
898-
if(prt == null)
976+
if (prt == null)
899977
{
900978
str = str + "PartNull";
901979
}
@@ -917,7 +995,7 @@ public override string ToString()
917995
//}
918996
//else
919997
//{
920-
str = str + ":" + group.ToString();
998+
str = str + ":" + group.ToString();
921999
//}
9221000
return str;
9231001
}

‎AGExt/Flight.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,32 @@ public void DrawSettingsWin(int WindowID)
13871387
if (GUI.Button(new Rect(10, 150, 130, 25), "Bypass RemoteTech", AGXBtnStyle))
13881388
{
13891389
useRT = !useRT;
1390+
//mechject test stuff start
1391+
1392+
//Type VSType = Type.GetType("MuMech.VesselState, MechJeb2"); //this is good, finds our VesselState type.
1393+
//Type MCType = Type.GetType("MuMech.MechJebCore, MechJeb2"); //this is goo, finds our MechJebCore type.
1394+
//foreach (Part p in FlightGlobals.ActiveVessel.Parts) //cycle all parts on our vessel, MechJeb attaches to parts with ModuleCommand
1395+
//{
1396+
// if (p.Modules.Contains("MechJebCore"))
1397+
// {
1398+
// PartModule pm2 = p.Modules["MechJebCore"]; //Find our MechJeb module
1399+
// if (pm2 != null) //if part does not have a mechjeb module, pm2 is null at this point
1400+
// {
1401+
// Debug.Log("vslstatea found");
1402+
// object vslState = MCType.GetField("vesselState").GetValue(pm2); //get our reference to the vessel state object
1403+
// Debug.Log("vslstate found");
1404+
// foreach (PropertyInfo pinfo in VSType.GetProperties())
1405+
// {
1406+
// Debug.Log("ping" + pinfo.Name + " " + pinfo.PropertyType);
1407+
// }
1408+
// var maxThrustAvail = VSType.GetProperty("thrustAvailable").GetValue(vslState,null);
1409+
// Debug.Log("found " + maxThrustAvail);
1410+
// break; //pull max thrust from the vessel state object.
1411+
// }
1412+
// }
1413+
//}
1414+
1415+
//mechjeb test stuff end
13901416
}
13911417
AGXBtnStyle.normal.background = ButtonTexture;
13921418
AGXBtnStyle.hover.background = ButtonTexture;

‎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.34c loaded");
16+
print("AGExt Ver. 1.34d loaded");
1717

1818

1919
}

0 commit comments

Comments
 (0)