Skip to content

Commit

Permalink
1.6
Browse files Browse the repository at this point in the history
KSP 1.3
  • Loading branch information
SirDiazo committed Jun 9, 2017
1 parent 09c5d6a commit 6b3d092
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 24 deletions.
Binary file modified .vs/ModActions/v14/.suo
Binary file not shown.
68 changes: 66 additions & 2 deletions ModActions/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ModActionsMainMenu : PartModule
{
public void Start()
{
Debug.Log("ModActions Ver. 1.4b Starting.....");
Debug.Log("ModActions Ver. 1.6 Starting.....");
if (!StaticMethods.ListPopulated) //populate our list if this is first load
{
StaticMethods.AllActionsList = new List<ModActionData>();
Expand Down Expand Up @@ -310,6 +310,68 @@ public void Update()
}

[KSPAddon(KSPAddon.Startup.Flight, false)]
public class EventTest : PartModule
{
public static List<EventTestListClass> testListContainer;
public static Dictionary<Guid, Dictionary<int, bool>> testDict;

public void Start()
{
testListContainer = new List<EventTestListClass>();
}

public static void CallEvent()
{
testDict = new Dictionary<Guid, Dictionary<int, bool>>();
Debug.Log("MA Call event start");
EventData<Action<Dictionary<Guid, Dictionary<int, bool>>>> MA2testEvent = GameEvents.FindEvent<EventData<Action<Dictionary<Guid, Dictionary<int, bool>>>>>("onTestEvent");
List<float> tempList = new List<float>();
MA2testEvent.Fire(linkOverEvent);
//testListContainer.Add(new EventTestListClass(Time.realtimeSinceStartup, tempList));
Debug.Log("MA Call event end " + testDict.Count);
}

public static void linkOverEvent(Dictionary<Guid, Dictionary<int, bool>> toLink)
{
testDict = toLink;
}

public static void PrintContainer()
{
Debug.Log("MA container print start " + Time.realtimeSinceStartup + testListContainer.Count);
for(int i = 0;i< testDict.Count; i++)
{
Debug.Log("MA entry " + i + "|" + testDict.ElementAt(i).Key.ToString() + "|" + testDict.ElementAt(i).Value.ToString());
//foreach (float fl in testListContainer[i].numList)
//{
// Debug.Log("MA entry sub " + testListContainer[i].initTime + "|" + fl);
//}
}
Debug.Log("MA Container print end");

}


}

public class EventTestListClass //use for event testing
{
public List<float> numList;
public float initTime;

public EventTestListClass()
{
numList = new List<float>();
initTime = Time.realtimeSinceStartup;
}
public EventTestListClass(float tmr, List<float> tempList)
{
numList = tempList;
initTime = tmr;
}
}

[KSPAddon(KSPAddon.Startup.Flight, false)]
public class ModActionsFlight : PartModule
{
private bool buttonCreated = false;
Expand All @@ -325,9 +387,11 @@ public class ModActionsFlight : PartModule
public bool showKSPui = true;
bool showBtn = true;



public void Start()
{

settings = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/ModActions/ModActions.settings");
winTop = float.Parse(settings.GetValue("FltWinTop"));
winLeft = float.Parse(settings.GetValue("FltWinLeft"));
Expand Down
2 changes: 2 additions & 0 deletions ModActions/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ public static void ExectueAction(ModActionData action, PartModule pm, KSPActionP
case 9: //stock command RCS on
{
pm.vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, true);
//EventTest.CallEvent();
break;
}
case 10: //stock command RCS off
{
pm.vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, false);
//EventTest.PrintContainer();
break;
}
case 11: //stock command RCS toggle
Expand Down
53 changes: 39 additions & 14 deletions ModActions/GUIWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MainGUIWindow//DO NOT INHERIT ANYTHING, BREAKS THIS CLASS FOR REASONS UNKN
public bool copyMode;
Part copyPart;
public bool showKSPui = true;



public MainGUIWindow(List<Part> prts, float winTop, float winLeft, bool showingKSPui) //effectively our Start() method
Expand Down Expand Up @@ -756,25 +757,49 @@ public void SyncSymmetry(Part p, ModActionData modData, int actID)

class StaticMethodsUnity : PartModule
{
public static void RefreshAGXEditor() //mess of reflection to update AGX if present.
public static void RefreshAGXEditor() //move to using new GameEvents system from KSP 1.2
{
Type linkType = Type.GetType("ActionGroupsExtended.AGXEditor, AGExt");
if (linkType != null)
EventData<string> AGExtRefreshActions = GameEvents.FindEvent<EventData<string>>("AGExtRefreshActionsEvent");
if(AGExtRefreshActions!= null)
{
object[] linkObjs = FindObjectsOfType(linkType);
linkType.InvokeMember("RefreshPartActions", BindingFlags.InvokeMethod | BindingFlags.Public, null, linkObjs.First(), null);
AGExtRefreshActions.Fire(null);
}
}

public static void RefreshAGXFlight() //mess of reflection to update AGX if present.
}//mess of reflection to update AGX if present.
//{
// private EventData<string> AGExtEventRefreshActions;

//AGExtEventRefreshActions = GameEvents.FindEvent<EventData<string>>("AGExtEventRefreshActionsEvent");
//AGExtEventRefreshActions.Fire();

//don't forget to remove them in OnDestroy:
//if (onKerbalFrozenEvent != null) onKerbalFrozenEvent.Remove(onKerbalFrozen);
//Type linkType = Type.GetType("ActionGroupsExtended.AGXEditor, AGExt");
//if (linkType != null)
//{
// object[] linkObjs = FindObjectsOfType(linkType);
// linkType.InvokeMember("RefreshPartActions", BindingFlags.InvokeMethod | BindingFlags.Public, null, linkObjs.First(), null);
//}

//}

public static void RefreshAGXFlight() //mess of reflection to update AGX if present, use new gameEvents system from KSP 1.2 now.
{
Type linkType = Type.GetType("ActionGroupsExtended.AGXFlight, AGExt");
if (linkType != null)
{
object[] linkObjs = FindObjectsOfType(linkType);
Debug.Log("Link " + linkObjs.First().GetType());
linkType.InvokeMember("RefreshPartActions", BindingFlags.InvokeMethod | BindingFlags.Public, null, linkObjs.First(), null);
}

EventData<string> AGExtRefreshActions = GameEvents.FindEvent<EventData<string>>("AGExtRefreshActionsEvent");
if (AGExtRefreshActions != null)
{
AGExtRefreshActions.Fire(null);
}


//Type linkType = Type.GetType("ActionGroupsExtended.AGXFlight, AGExt");
//if (linkType != null)
//{
// object[] linkObjs = FindObjectsOfType(linkType);
// Debug.Log("Link " + linkObjs.First().GetType());
// linkType.InvokeMember("RefreshPartActions", BindingFlags.InvokeMethod | BindingFlags.Public, null, linkObjs.First(), null);
//}
}
}
enum SelectType
Expand Down
12 changes: 4 additions & 8 deletions ModActions/ModActions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\1.2.2 Dev\GameData\Diazo\ModActions\</OutputPath>
<OutputPath>..\..\..\..\1.3 Dev\GameData\Diazo\ModActions\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,11 +31,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\1.2.2 Dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\..\1.2.2 Dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\..\..\1.3 Dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -45,11 +41,11 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\1.2.2 Dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\1.3 Dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\..\1.2.2 Dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\..\..\1.3 Dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
Binary file modified ModActions/obj/Debug/ModActions.dll
Binary file not shown.
Binary file modified ModActions/obj/Debug/ModActions.pdb
Binary file not shown.

0 comments on commit 6b3d092

Please sign in to comment.