Skip to content

Commit

Permalink
1.34d
Browse files Browse the repository at this point in the history
New external interface methods
  • Loading branch information
SirDiazo committed Dec 24, 2015
1 parent 2b5ef94 commit e9954de
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 15 deletions.
2 changes: 1 addition & 1 deletion AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public override void OnLoad(ConfigNode node)
{
private uint flightID; //
private bool vesselInstanceOK = false; //is this vessel loadable? if this is false, run nothing
private List<AGXAction> actionsList;
public List<AGXAction> actionsList;
private Vessel thisVsl;
private Dictionary<int, string> guiNames;

Expand Down
104 changes: 91 additions & 13 deletions AGExt/External.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static List<AGXAction> AGX2VslGroupActions(uint FlightID, int group) //wo
}
else if (HighLogic.LoadedSceneIsEditor)
{
return StaticData.CurrentVesselActions.FindAll(ag => ag.group == group);
return StaticData.CurrentVesselActions.FindAll(ag => ag.group == group);
}
else
{
Expand Down Expand Up @@ -161,9 +161,9 @@ public static string AGX2VslGroupNameSingle(uint FlightID, int group) //return n
}
}

public static Dictionary<int,string> AGXGroupNamesAll() //return dictionary of group names, returns dictionary of 250 items, only groups with defined names will have strings
public static Dictionary<int, string> AGXGroupNamesAll() //return dictionary of group names, returns dictionary of 250 items, only groups with defined names will have strings
{
if(HighLogic.LoadedSceneIsFlight)
if (HighLogic.LoadedSceneIsFlight)
{
return AGXFlight.AGXguiNames;
}
Expand All @@ -175,13 +175,13 @@ public static Dictionary<int,string> AGXGroupNamesAll() //return dictionary of g
{
return new Dictionary<int, string>();
}
}
public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //return dictionary of group names
}

public static Dictionary<int, string> AGX2VslGroupNamesAll(uint FlightID) //return dictionary of group names
{
if(HighLogic.LoadedSceneIsFlight)
if (HighLogic.LoadedSceneIsFlight)
{
if(FlightID == FlightGlobals.ActiveVessel.rootPart.flightID)
if (FlightID == FlightGlobals.ActiveVessel.rootPart.flightID)
{
return AGXFlight.AGXguiNames;
}
Expand All @@ -191,9 +191,9 @@ public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //retur
return otherVsl.GetGroupNamesAll();
}
}
else if(HighLogic.LoadedSceneIsEditor)
else if (HighLogic.LoadedSceneIsEditor)
{
if(FlightID == EditorLogic.RootPart.flightID)
if (FlightID == EditorLogic.RootPart.flightID)
{
return AGXEditor.AGXguiNames;
}
Expand All @@ -207,7 +207,7 @@ public static Dictionary<int,string> AGX2VslGroupNamesAll(uint FlightID) //retur
return new Dictionary<int, string>();
}
}

public static bool AGX2VslToggleGroup(uint FlightID, int group) //other vessel direct toggle activate
{
print("AGX Call: toggle action " + group + " for vessel " + FlightID);
Expand Down Expand Up @@ -801,6 +801,84 @@ public static List<Part> AGXListOfPartsInGroup(int i)
}
}

public static Dictionary<int,string> AGXListOfAssignedGroups()
{
print("AGX Call: list of groups with assigned actions");
if (HighLogic.LoadedSceneIsFlight)
{
Dictionary<int,string> grpList = new Dictionary<int,string>();
foreach (AGXAction agAct in StaticData.CurrentVesselActions)
{
if(!grpList.ContainsKey(agAct.group))
//if (!grpList.Concat(agAct.group))
{
grpList.Add(agAct.group,AGXFlight.AGXguiNames[agAct.group]);
}
}
//dictionary isn't sortable, you sort the results when you access it which has to happen in the other mod.
return grpList;
}
else if (HighLogic.LoadedSceneIsEditor)
{
Dictionary<int, string> grpList = new Dictionary<int, string>();
foreach (AGXAction agAct in StaticData.CurrentVesselActions)
{
if (!grpList.ContainsKey(agAct.group))
{
grpList.Add(agAct.group, AGXEditor.AGXguiNames[agAct.group]);
}
}
return grpList;
}
else
{
return new Dictionary<int, string>();
}
}

public static Dictionary<int,string> AGX2VslListOfAssignedGroups(uint flightID)
{
print("AGX Call: list of groups with assigned actions on vessel " + flightID);
try
{

if (HighLogic.LoadedSceneIsFlight) //only workes in flight
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == flightID)
{
return AGXListOfAssignedGroups();
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(flightID);
Dictionary<int, string> grpList = new Dictionary<int, string>();
foreach (AGXAction agAct in otherVsl.actionsList)
{
if (!grpList.ContainsKey(agAct.group))
{
grpList.Add(agAct.group, AGXEditor.AGXguiNames[agAct.group]);
}
}
return grpList;

}
}
else if (HighLogic.LoadedSceneIsEditor)
{
return AGXListOfAssignedGroups();
}

else
{
return new Dictionary<int, string>();
}
}
catch
{
return new Dictionary<int, string>();
}
}



}
Expand Down Expand Up @@ -895,7 +973,7 @@ public int GetHashCode(AGXAction obj)
public override string ToString()
{
string str = "";
if(prt == null)
if (prt == null)
{
str = str + "PartNull";
}
Expand All @@ -917,7 +995,7 @@ public override string ToString()
//}
//else
//{
str = str + ":" + group.ToString();
str = str + ":" + group.ToString();
//}
return str;
}
Expand Down
26 changes: 26 additions & 0 deletions AGExt/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,32 @@ public void DrawSettingsWin(int WindowID)
if (GUI.Button(new Rect(10, 150, 130, 25), "Bypass RemoteTech", AGXBtnStyle))
{
useRT = !useRT;
//mechject test stuff start

//Type VSType = Type.GetType("MuMech.VesselState, MechJeb2"); //this is good, finds our VesselState type.
//Type MCType = Type.GetType("MuMech.MechJebCore, MechJeb2"); //this is goo, finds our MechJebCore type.
//foreach (Part p in FlightGlobals.ActiveVessel.Parts) //cycle all parts on our vessel, MechJeb attaches to parts with ModuleCommand
//{
// if (p.Modules.Contains("MechJebCore"))
// {
// PartModule pm2 = p.Modules["MechJebCore"]; //Find our MechJeb module
// if (pm2 != null) //if part does not have a mechjeb module, pm2 is null at this point
// {
// Debug.Log("vslstatea found");
// object vslState = MCType.GetField("vesselState").GetValue(pm2); //get our reference to the vessel state object
// Debug.Log("vslstate found");
// foreach (PropertyInfo pinfo in VSType.GetProperties())
// {
// Debug.Log("ping" + pinfo.Name + " " + pinfo.PropertyType);
// }
// var maxThrustAvail = VSType.GetProperty("thrustAvailable").GetValue(vslState,null);
// Debug.Log("found " + maxThrustAvail);
// break; //pull max thrust from the vessel state object.
// }
// }
//}

//mechjeb test stuff end
}
AGXBtnStyle.normal.background = ButtonTexture;
AGXBtnStyle.hover.background = ButtonTexture;
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.34c loaded");
print("AGExt Ver. 1.34d loaded");


}
Expand Down

0 comments on commit e9954de

Please sign in to comment.