using System;
using KSP;
using KSP.UI;
using KSP.UI.Screens;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AlphabeticalKerbals
{
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
public class AlphabetVAB : MonoBehaviour
{
public bool HasBeenSorted;
public EditorScreen CurrentEditorScreen;
private int sortAttempts;
///
/// Module initialization
///
public void Start()
{
print("AlphabeticalKerbals: AlphabetVAB started!");
}
///
/// Module startup
///
public void Awake()
{
print("AlphabeticalKerbals: Registering VAB events");
GameEvents.onEditorLoad.Add(OnShipLoaded);
GameEvents.onEditorScreenChange.Add(OnEditorScreenChange);
}
///
/// Module shutdown
///
public void OnDestroy()
{
print("AlphabeticalKerbals: Unregistering VAB events");
GameEvents.onEditorLoad.Remove(OnShipLoaded);
GameEvents.onEditorScreenChange.Remove(OnEditorScreenChange);
}
///
/// Here when a ship is loaded in the editor.
///
///
///
private void OnShipLoaded(ShipConstruct construct, CraftBrowserDialog.LoadType loadType)
{
try
{
CurrentEditorScreen = EditorScreen.Parts;
HasBeenSorted = false;
sortAttempts = 0;
}
catch (Exception e)
{
print("AlphabeticalKerbals: There was an error in OnShipLoaded");
}
}
///
/// Here when Editor Panel is changed
///
///
private void OnEditorScreenChange(EditorScreen screen)
{
try
{
CurrentEditorScreen = screen;
HasBeenSorted = false;
sortAttempts = 0;
if (screen == EditorScreen.Crew)
{
OnEditorCrewOpened();
}
}
catch (Exception e)
{
print("AlphabeticalKerbals: There was an error in OnEditorScreenChange");
}
}
///
/// Here when Editor Crew Panel is opened
///
///
///
private void OnEditorCrewOpened()
{
try
{
if (KerbalSorter.Sort_Kerbals())
{
print("AlphabeticalKerbals: CrewPanel Sorting successful!");
HasBeenSorted = true;
}
}
catch (Exception e)
{
print("AlphabeticalKerbals: There was an error in OnEditorCrewOpened");
}
}
}
[KSPAddon(KSPAddon.Startup.SpaceCentre, false)]
public class AlphabetSC : MonoBehaviour
{
public void Start()
{
print("AlphabeticalKerbals: AlphabetSC started!");
}
}
}