Skip to content

Commit

Permalink
Version 1.27
Browse files Browse the repository at this point in the history
Fix SPH made craft not saving
  • Loading branch information
SirDiazo committed Dec 28, 2014
1 parent a98ae8d commit b09f47b
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 53 deletions.
52 changes: 39 additions & 13 deletions AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,47 @@
namespace ActionGroupsExtended
{

public class AGXMethods : PartModule



public class ModuleAGX : PartModule
{
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
public string placeHolder = "Hello World"; //Config nodes can behave wierd when empty, a part with no actions on it will have no data besides this line
//config nodes get added/removed via OnLoad/OnSave here
public List<AGXAction> agxActionsThisPart = new List<AGXAction>();

public override void OnStart(StartState state)
{
if(agxActionsThisPart == null)
{
agxActionsThisPart = new List<AGXAction>();
}
}


//public static void SettingsWindow(int WindowID)
//{
// if(GUI.Button(new Rect(10, 25, 130, 40), "Show KeyCodes in\nFlight Window"))
// {
// AGXFlight.FlightWinShowKeycodes = !AGXFlight.FlightWinShowKeycodes;
// }


// GUI.DragWindow();
//}
}//AGXMethods closing bracket
public override void OnSave(ConfigNode node)
{
if(agxActionsThisPart.Count > 0)
{
foreach (AGXAction agAct in agxActionsThisPart)
{
ConfigNode actionNode = new ConfigNode("ACTION");
actionNode = AGextScenario.SaveAGXActionVer2(agAct);
node.AddNode(actionNode);
}
}
}

public override void OnLoad(ConfigNode node)
{
ConfigNode[] actionsNodes = node.GetNodes("ACTION");
foreach(ConfigNode actionNode in actionsNodes)
{
agxActionsThisPart.Add(AGextScenario.LoadAGXActionVer2(actionNode,this.part,false));
}
}

}//ModuleAGX



Expand Down
96 changes: 60 additions & 36 deletions AGExt/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ public void Start()
PartPlus.LoadImage(importPartPlus);
PartPlus.Apply();
//EditorLoadFromFile();
if (HighLogic.LoadedScene == GameScenes.EDITOR)
//if (HighLogic.LoadedScene == GameScenes.EDITOR)
if(EditorDriver.editorFacility == EditorFacility.VAB)
{
inVAB = true;
}
Expand Down Expand Up @@ -621,6 +622,19 @@ public void PartAttaching(GameEvents.HostTargetAction<Part,Part> host_target)
AttachAGXPart(p);
}
DetachedPartReset.Start();

ModuleAGX agxMod = host_target.host.Modules.OfType<ModuleAGX>().First();
foreach(AGXAction agAct in agxMod.agxActionsThisPart)
{
if(!CurrentVesselActions.Contains(agAct))
{
CurrentVesselActions.Add(agAct);
}
}




}

public void PartRemove(GameEvents.HostTargetAction<Part, Part> host_target)
Expand All @@ -634,6 +648,14 @@ public void PartRemove(GameEvents.HostTargetAction<Part, Part> host_target)
}
DetachedPartReset.Stop(); //stop timer so it resets
// //print("Detach");
//start subassembly stuff
ModuleAGX agxMod = host_target.target.Modules.OfType<ModuleAGX>().First();
agxMod.agxActionsThisPart.AddRange(CurrentVesselActions.Where(p3 => p3.ba.listParent.part == host_target.target));
foreach (Part p in host_target.target.FindChildParts<Part>(true)) //action only fires for part clicked on, have to parse all child parts this way
{
agxMod.agxActionsThisPart.AddRange(CurrentVesselActions.Where(p3 => p3.ba.listParent.part == p)); //add parts to list
}

}

public void CheckExistingShips()
Expand Down Expand Up @@ -3033,9 +3055,8 @@ public static void LoadGroupNames(string LoadNames) //v2 done
// }
//}


public void Update()

{

if (checkShipsExist)
Expand All @@ -3053,101 +3074,101 @@ public void Update()
}



EditorLogic ELCur = new EditorLogic();
ELCur = EditorLogic.fetch;//get current editor logic instance



if (AGXDoLock && ELCur.editorScreen != EditorScreen.Actions)
{
ELCur.Unlock("AGXLock");
AGXDoLock = false;
}
else if(AGXDoLock && !TrapMouse)
else if (AGXDoLock && !TrapMouse)
{
ELCur.Unlock("AGXLock");
AGXDoLock = false;
}
else if (!AGXDoLock && TrapMouse && ELCur.editorScreen == EditorScreen.Actions)
{
ELCur.Lock(false,false,false,"AGXLock");
ELCur.Lock(false, false, false, "AGXLock");
AGXDoLock = true;
}


if (ELCur.editorScreen == EditorScreen.Actions) //only show mod if on actions editor screen
{

ShowSelectedWin = true;
}
else
{

ShowSelectedWin = false;




AGEditorSelectedParts.Clear();//mod is hidden, clear list so parts don't get orphaned in it

PartActionsList.Clear();

ActionsListDirty = true;
}

if (ShowSelectedWin)

if (ShowSelectedWin)
{



if (EditorActionGroups.Instance.GetSelectedParts() != null) //on first run, list is null
{

if (ActionsListDirty)
{
UpdateActionsListCheck();

}
if (EditorActionGroups.Instance.GetSelectedParts().Count > 0) //are there parts selected?
{


if (PreviousSelectedPart != EditorActionGroups.Instance.GetSelectedParts().First()) //has selected part changed?
{
if(!AGEditorSelectedParts.Any(p => p.AGPart==EditorActionGroups.Instance.GetSelectedParts().First())) //make sure selected part is not already in AGEdSelParts

if (!AGEditorSelectedParts.Any(p => p.AGPart == EditorActionGroups.Instance.GetSelectedParts().First())) //make sure selected part is not already in AGEdSelParts
{

if (AGEditorSelectedParts.Count == 0) //no items in Selected Parts list, so just add selection
{
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));


}
else if (AGEditorSelectedParts.First().AGPart.name == EditorActionGroups.Instance.GetSelectedParts().First().name) //selected part matches first part already in selected parts list, so just add selected part
{
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));


}
else //part does not match first part in list, clear list before adding part
{

AGEditorSelectedParts.Clear();
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));



}
}
PreviousSelectedPart = EditorActionGroups.Instance.GetSelectedParts().First(); //remember selected part so logic does not run unitl another part selected
}

}
}

}


Expand All @@ -3158,9 +3179,12 @@ public void Update()

if (AGXRoot != EditorLogic.RootPart)
{
// print("Root diff");
// print("Root diff");
EditorLoadFromNode();
}

// print("test " + FindObjectsOfType<EditorSubassemblyItem>().Count());
} //close Update()
//if(needToAddStockButton)
//{
// if (ApplicationLauncher.Ready)
Expand All @@ -3184,7 +3208,7 @@ public void Update()
//PrintSelectedPart();
//print("Keyset " + CurrentKeySet);

}


public void PrintSelectedPart()
{
Expand Down
18 changes: 16 additions & 2 deletions AGExt/External.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,28 @@ public static bool AGXGroupState(int i) //is a group activated?
}
}

public class AGXAction : MonoBehaviour //basic data class for AGX mod, used everywhere
public class AGXAction : MonoBehaviour, IEquatable<AGXAction> //basic data class for AGX mod, used everywhere
{
public Part prt;
public BaseAction ba;
public int group;
public bool activated = false;

public bool Equals(AGXAction obj)
{
if(this.prt == obj.prt && this.ba == obj.ba && this.group == obj.group)
{
return true;
}
else
{
return false;
}
}

}

}


public class AGXDefaultCheck : MonoBehaviour //used in Editor to monitor default action groups
{
Expand Down
2 changes: 1 addition & 1 deletion AGExt/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4525,7 +4525,7 @@ public void Update()

}
//PrintPartActs();
//print("Keyset " + CurrentKeySetFlight);
//print("landed " + FlightGlobals.ActiveVessel.landedAt);
}
catch(Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion AGExt/Instantly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AGXMainMenu :PartModule

public void Start()
{
print("AGExt Ver. 1.26 loaded");
print("AGExt Ver. 1.27 loaded");
//below no longer needed with InputLockManager
//AGXguiKeys = new Dictionary<int, KeyCode>();
//AGExtNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
Expand Down

0 comments on commit b09f47b

Please sign in to comment.