Beispiel #1
0
        public void Start()
        {
            string errLine = "1";
            try
            {

                useRT = true;
                AGXguiMod1Groups = new Dictionary<int, bool>();
                AGXguiMod2Groups = new Dictionary<int, bool>();
                for (int i = 1; i <= 250; i++)
                {
                    AGXguiMod1Groups[i] = false;
                    AGXguiMod2Groups[i] = false;
                }
                errLine = "2";
                defaultActionsListThisType = new List<BaseAction>(); //initialize list
                defaultActionsListAll = new List<BaseAction>(); //initialize list
                ThisGroupActions = new List<AGXAction>();
                //Save10Keys = new Dictionary<int, KeyCode>();
                //foreach (Part p in
                ActiveKeys = new List<KeyCode>();
                ActiveKeysDirect = new Dictionary<int, KeyCode>();
                DefaultTen = new Dictionary<int, KeyCode>();
                DirectKeysState = new Dictionary<int, bool>();
                for (int i = 1; i <= 250; i++)
                {
                    DirectKeysState[i] = false;

                }

                TestWin = new Rect(600, 300, 100, 100);
                RenderingManager.AddToPostDrawQueue(33, AGXOnDraw); //was 0, 33 random number to fix FAR issue
                AGEditorSelectedParts = new List<AGXPart>();
                PartActionsList = new List<BaseAction>();
                ScrollPosSelParts = Vector2.zero;
                ScrollPosSelPartsActs = Vector2.zero;
                ScrollGroups = Vector2.zero;
                CurGroupsWin = Vector2.zero;
                errLine = "3";
                //AGXVsl = new AGXVessel();

                //AGXWinStyle = new GUIStyle(HighLogic.Skin.window);

                BtnTexRed.SetPixel(0, 0, new Color(1, 0, 0, .5f));
                BtnTexRed.Apply();
                BtnTexGrn.SetPixel(0, 0, new Color(0, 1, 0, .5f));
                BtnTexGrn.Apply();

                AGXguiNames = new Dictionary<int, string>();

                AGXguiKeys = new Dictionary<int, KeyCode>();

                groupActivatedState = new Dictionary<int, bool>();
                errLine = "4";
                for (int i = 1; i <= 250; i = i + 1)
                {
                    AGXguiNames[i] = "";
                    AGXguiKeys[i] = KeyCode.None;
                    groupActivatedState[i] = false;
                }

                KeyCodeNames = new List<String>();
                KeyCodeNames.AddRange(Enum.GetNames(typeof(KeyCode)));
                KeyCodeNames.Remove("None");
                JoyStickCodes.AddRange(KeyCodeNames.Where(JoySticks));
                KeyCodeNames.RemoveAll(JoySticks);
                errLine = "5";
                try
                {
                    //AGExtNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
                    AGExtNode = AGXStaticData.LoadBaseConfigNode();
                }
                catch
                {
                    print("AGX Flight Start CRITICAL FAIL: AGExt.cfg not found. Check install path.");
                }
                if (AGExtNode == null)
                {
                    print("AGX Flight Start CRITICAL FAIL: AGExt.cfg not loaded. Check install path.");
                }
                errLine = "6";
                CurrentKeySetFlight = 1;
                CurrentKeySetNameFlight = (string)AGExtNode.GetValue("KeySetName1");
                KeySetNamesFlight[0] = (string)AGExtNode.GetValue("KeySetName1");
                KeySetNamesFlight[1] = (string)AGExtNode.GetValue("KeySetName2");
                KeySetNamesFlight[2] = (string)AGExtNode.GetValue("KeySetName3");
                KeySetNamesFlight[3] = (string)AGExtNode.GetValue("KeySetName4");
                KeySetNamesFlight[4] = (string)AGExtNode.GetValue("KeySetName5");
                //CurrentVesselActions = new List<AGXAction>();
                AGXRoot = null;
                errLine = "7";
                StartLoadWindowPositions();
                ActiveGroups = new Dictionary<int, bool>();
                errLine = "8";
                if (AGExtNode.GetValue("FlightWinShowKeys") == "1")
                {
                    FlightWinShowKeycodes = true;
                }
                else
                {
                    FlightWinShowKeycodes = false;
                }
                errLine = "9";

                // UnbindDefaultKeys();  //obsolete with INputLockManager
                //print("input lock");
                try
                {
                    if ((string)AGExtNode.GetValue("LockOutKSPManager") == "0")
                    {

                        AGXLockSet = false;
                        //print("zero found");

                    }
                    else
                    {
                        InputLockManager.SetControlLock(ControlTypes.CUSTOM_ACTION_GROUPS, "AGExtControlLock");
                        AGXLockSet = true;
                        //print("one found");
                    }
                    errLine = "10";

                }
                catch
                {
                    errLine = "11";
                    InputLockManager.SetControlLock(ControlTypes.CUSTOM_ACTION_GROUPS, "AGExtControlLock");
                    AGXLockSet = true;
                    //print("Catch");
                }
                errLine = "12";
                groupCooldowns = new List<AGXCooldown>(); //setup values for group cooldowns logic
                try
                {
                    activationCoolDown = Convert.ToInt32(AGExtNode.GetValue("ActivationCooldown"));
                }
                catch
                {
                    print("AGX Default cooldown not found, using 5 Update frames");
                }
                errLine = "13";
                if (ToolbarManager.ToolbarAvailable) //check if toolbar available, load if it is
                {
                    errLine = "14";

                    AGXBtn = ToolbarManager.Instance.add("AGX", "AGXBtn");
                    AGXBtn.TexturePath = "Diazo/AGExt/icon_button";
                    AGXBtn.ToolTip = "Action Groups Extended";
                    AGXBtn.OnClick += (e) =>
                        {
                            if (e.MouseButton == 0)
                            {
                                onLeftButtonClick();
                            }
                            if (e.MouseButton == 1)
                            {
                                //ShowSettingsWin = !ShowSettingsWin;
                                if (ShowSettingsWin)
                                {
                                    AGXBtn.Drawable = null;
                                    ShowSettingsWin = false;
                                }
                                else
                                {
                                    SettingsWindow Settings = new SettingsWindow();
                                    AGXBtn.Drawable = Settings;
                                    ShowSettingsWin = true;
                                }

                            }
                        };
                    //{
                    //    ShowAGXMod = !ShowAGXMod;
                    //};
                }
                else
                {
                    errLine = "15";
                    AGXAppFlightButton = ApplicationLauncher.Instance.AddModApplication(onStockToolbarClick, onStockToolbarClick, DummyVoid, DummyVoid, DummyVoid, DummyVoid, ApplicationLauncher.AppScenes.FLIGHT, (Texture)GameDatabase.Instance.GetTexture("Diazo/AGExt/icon_button", false));
                }
                errLine = "16";
                if (AGExtNode.GetValue("FltShow") == "0")
                {
                    ShowAGXMod = false;
                }
                errLine = "17";
                float facilityLevel = Mathf.Max(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding));
                //print("AGX Career check: " + facilityLevel);
                if (AGExtNode.HasValue("OverrideCareer")) //are action groups unlocked?
                {
                    //print("b");
                    errLine = "18";
                    if ((string)AGExtNode.GetValue("OverrideCareer") == "1")
                    {
                        //print("c");
                        showCareerCustomAGs = true;
                        showCareerStockAGs = true;
                    }
                    else
                    {
                        //print("d");

                        if (GameVariables.Instance.UnlockedActionGroupsCustom(facilityLevel))
                        {
                            // print("g");
                            showCareerStockAGs = true;
                            showCareerCustomAGs = true;
                        }
                        else if (GameVariables.Instance.UnlockedActionGroupsStock(facilityLevel))
                        {
                            // print("h");
                            showCareerStockAGs = true;
                            showCareerCustomAGs = false;
                        }
                        else
                        {
                            //print("i");
                            showCareerStockAGs = false;
                            showCareerCustomAGs = false;
                        }
                    }
                }
                else
                {
                    //print("j");
                    errLine = "19";

                    if (GameVariables.Instance.UnlockedActionGroupsCustom(facilityLevel))
                    {
                        // print("m");
                        showCareerStockAGs = true;
                        showCareerCustomAGs = true;
                    }
                    else if (GameVariables.Instance.UnlockedActionGroupsStock(facilityLevel))
                    {
                        // print("n");
                        showCareerStockAGs = true;
                        showCareerCustomAGs = false;
                    }
                    else
                    {
                        // print("o");
                        showCareerStockAGs = false;
                        showCareerCustomAGs = false;
                    }
                }
                // print("startd " + showCareerCustomAGs);
                errLine = "20";
                IsGroupToggle = new Dictionary<int, bool>();
                ShowGroupInFlight = new bool[6, 251];
                ShowGroupInFlightNames = new string[6];
                ShowGroupInFlightNames[1] = "Group 1";
                ShowGroupInFlightNames[2] = "Group 2";
                ShowGroupInFlightNames[3] = "Group 3";
                ShowGroupInFlightNames[4] = "Group 4";
                ShowGroupInFlightNames[5] = "Group 5";
                //foreach (ModuleAGExtData agData in FlightGlobals.ActiveVessel.rootPart.Modules.OfType<ModuleAGExtData>())
                //{
                //    ShowGroupInFlightNames = agData.LoadShowGroupNames();

                errLine = "21";
                for (int i = 1; i <= 250; i++)
                {
                    IsGroupToggle[i] = false;
                    for (int i2 = 1; i2 <= 5; i2++)
                    {
                        ShowGroupInFlight[i2, i] = true;
                    }
                }
                ShowGroupInFlightCurrent = 1;
                // print("AGXStart " + Planetarium.GetUniversalTime());
                errLine = "22";
                //AGXSkin = (GUISkin)MonoBehaviour.Instantiate(HighLogic.Skin);
                AGXSkin = (GUISkin)MonoBehaviour.Instantiate(HighLogic.Skin);
                AGXWinStyle = new GUIStyle(AGXSkin.window);
                AGXLblStyle = new GUIStyle(AGXSkin.label);
                AGXFldStyle = new GUIStyle(AGXSkin.textField);
                AGXFldStyle.fontStyle = FontStyle.Normal;
                //AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1);
                AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
                AGXLblStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
                AGXLblStyle.wordWrap = false;
                errLine = "23";
                AGXBtnStyle = new GUIStyle(AGXSkin.button);
                //AGXScrollStyle = new GUIStyle(HighLogic.skin.scrollView);
                AGXBtnStyle.fontStyle = FontStyle.Normal;
                AGXBtnStyle.alignment = TextAnchor.MiddleCenter;
                AGXBtnStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
                //AGXScrollStyle.normal.background = null;
                //print("AGX " + AGXBtnStyle.normal.background);
                byte[] importTxt = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTexture.png");
                byte[] importTxtRed = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureRed.png");
                byte[] importTxtGreen = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureGreen.png");
                byte[] importPartCenter = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/PartLocationCross.png");
                byte[] importPartCross = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/PartLocCross.png");
                byte[] importPartPlus = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/PartLocPlus.png");
                //byte[] testXport = AGXBtnStyle.normal.background.EncodeToPNG();
                //File.WriteAllBytes(Application.dataPath + "/SavedScreen.png", testXport);
                errLine = "24";
                ButtonTexture.LoadImage(importTxt);
                ButtonTexture.Apply();
                ButtonTextureRed.LoadImage(importTxtRed);
                ButtonTextureRed.Apply();
                ButtonTextureGreen.LoadImage(importTxtGreen);
                ButtonTextureGreen.Apply();
                AGXBtnStyle.normal.background = ButtonTexture;
                AGXBtnStyle.onNormal.background = ButtonTexture;
                AGXBtnStyle.onActive.background = ButtonTexture;
                AGXBtnStyle.onFocused.background = ButtonTexture;
                AGXBtnStyle.onHover.background = ButtonTexture;
                AGXBtnStyle.active.background = ButtonTexture;
                AGXBtnStyle.focused.background = ButtonTexture;
                AGXBtnStyle.hover.background = ButtonTexture;

                //foreach(Font fnt in fonts)
                //{
                //    Debug.Log("fnt " + fnt.name);
                //}
                AGXBtnStyle.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
                AGXLblStyle.font = AGXBtnStyle.font;
                AGXFldStyle.font = AGXBtnStyle.font;
                //Debug.Log(AGXBtnStyle.font.name);

                //AGXScrollStyle = new GUIStyle(AGXSkin.verticalScrollbar);

                //AGXScrollStyle.normal.background = null;
                //AGXBtnStyle.font = Font.
                PartCenter.LoadImage(importPartCenter);
                PartCenter.Apply();
                PartCross.LoadImage(importPartCross);
                PartCross.Apply();
                PartPlus.LoadImage(importPartPlus);
                PartPlus.Apply();
                SettingsWinRect = new Rect(500, 500, 150, 75);
                partOldVessel = new List<AGXPartVesselCheck>();
                errLine = "25";
                //GameEvents.onVesselGoOffRails.Add(VesselOffRails); //triggers when vessel loads at flight scene start also
                //GameEvents.onVesselGoOnRails.Add(VesselOnRails);
                //GameEvents.onPartDestroyed.Add(partDead);
                GameEvents.onPartDie.Add(partDead); //remove part from RootParts if possible
                //GameEvents.onPartExplode.Add(partDead2);
                //GameEvents.onPartAttach.Add(DockingEvent);

                //AGXBaseNode = AGextScenario.LoadBaseNode();
                AGXFlightNode = new ConfigNode();
                errLine = "26";
                if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
                {
                    errLine = "27";
                    AGXEditorNodeFlight = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                }
                else
                {
                    errLine = "28";
                    AGXEditorNodeFlight = new ConfigNode("EDITOR");
                    AGXEditorNodeFlight.AddValue("name", "editor");
                }
                //AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                //AllVesselsActions = new List<AGXAction>();
                loadedVessels = new List<Vessel>();
                errLine = "29";
                LoadCurrentKeyBindings();
                errLine = "30";
                oldShipParts = new List<Part>();
                //KeySetNamesFlight[0] = AGExtNode.GetValue("KeySetName1");
                // /print("3a");
                //KeySetNamesFlight[1] = AGExtNode.GetValue("KeySetName2");
                //print("4a");
                //KeySetNamesFlight[2] = AGExtNode.GetValue("KeySetName3");
                // //print("5a");
                //KeySetNamesFlight[3] = AGExtNode.GetValue("KeySetName4");
                //print("6a");
                //KeySetNamesFlight[4] = AGExtNode.GetValue("KeySetName5");
                //print("7a");
                //KeySetNamesFlight[CurrentKeySetFlight - 1] = CurrentKeySetNameFlight;
                AGXRemoteTechQueue = new List<AGXRemoteTechQueueItem>();
                RTFound = false;
                foreach (AssemblyLoader.LoadedAssembly Asm in AssemblyLoader.loadedAssemblies)
                {
                    if (Asm.dllName == "RemoteTech")
                    {
                        //Debug.Log("RemoteTech found");
                        //AGXRemoteTechQueue.Add(new AGXRemoteTechQueueItem(group, FlightGlobals.ActiveVessel.rootPart.flightID, Planetarium.GetUniversalTime() + 10, force, forceDir));
                        RTFound = true;
                    }
                }
                //print("RT FOUND " + RTFound);
                errLine = "31";
                if (RTFound && bool.Parse(AGExtNode.GetValue("RTWinShow")))
                {
                    RTWinShow = true;
                }
                else
                {
                    RTWinShow = false;
                }
                //Debug.Log("RemoteTech " + RTWinShow);
                isDirectAction = new Dictionary<int, bool>();
                for (int i = 1; i <= 250; i++)
                {
                    isDirectAction[i] = false;
                }

               // Debug.Log("AGX Flight Started Okay"); //temporary
            }
            catch (Exception e)
            {
                print("AGX Flight Start FAIL " + errLine + " " + e);
                print("AGX AGExt node dump: " + AGExtNode);
            }
        }
Beispiel #2
0
        public void Start()
        {
            defaultActionsListThisType = new List<BaseAction>(); //initialize list
            defaultActionsListAll = new List<BaseAction>(); //initialize list
            
            //Save10Keys = new Dictionary<int, KeyCode>();
            //foreach (Part p in 
            ActiveKeys = new List<KeyCode>();

            TestWin = new Rect(600, 300, 100, 100);
            RenderingManager.AddToPostDrawQueue(33, AGXOnDraw); //was 0, 33 random number to fix FAR issue
            AGEditorSelectedParts = new List<AGXPart>();
            PartActionsList = new List<BaseAction>();
            ScrollPosSelParts = Vector2.zero;
            ScrollPosSelPartsActs = Vector2.zero;
            ScrollGroups = Vector2.zero;
            CurGroupsWin = Vector2.zero;

            //AGXVsl = new AGXVessel();

            //AGXWinStyle = new GUIStyle(HighLogic.Skin.window);

            BtnTexRed.SetPixel(0, 0, new Color(1, 0, 0, .5f));
            BtnTexRed.Apply();
            BtnTexGrn.SetPixel(0, 0, new Color(0, 1, 0, .5f));
            BtnTexGrn.Apply();

            AGXguiNames = new Dictionary<int, string>();


            AGXguiKeys = new Dictionary<int, KeyCode>();



            for (int i = 1; i <= 250; i = i + 1)
            {
                AGXguiNames[i] = "";
                AGXguiKeys[i] = KeyCode.None;
            }


            KeyCodeNames = new List<String>();
            KeyCodeNames.AddRange(Enum.GetNames(typeof(KeyCode)));
            KeyCodeNames.Remove("None");
            JoyStickCodes.AddRange(KeyCodeNames.Where(JoySticks));
            KeyCodeNames.RemoveAll(JoySticks);
            AGExtNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
            CurrentKeySet = Convert.ToInt32(AGExtNode.GetValue("ActiveKeySet"));
            CurrentKeySetName = AGExtNode.GetValue("KeySetName" + CurrentKeySet);
            CurrentVesselActions = new List<AGXAction>();
            AGXRoot = null;
            GroupsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltGroupsX")), Convert.ToInt32(AGExtNode.GetValue("FltGroupsY")), 250, 530);
            SelPartsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltSelPartsX")), Convert.ToInt32(AGExtNode.GetValue("FltSelPartsY")), 365, 270);
            KeyCodeWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltKeyCodeX")), Convert.ToInt32(AGExtNode.GetValue("FltKeyCodeY")), 410, 730);
            KeySetWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltKeySetX")), Convert.ToInt32(AGExtNode.GetValue("FltKeySetY")), 185, 335);
            CurActsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltCurActsX")), Convert.ToInt32(AGExtNode.GetValue("FltCurActsY")), 345, 140);
            FlightWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltMainX")), Convert.ToInt32(AGExtNode.GetValue("FltMainY")), 235, 100);
            GroupsInFlightWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltMainX")), Convert.ToInt32(AGExtNode.GetValue("FltMainY")), 80, 110);
            ActiveGroups = new Dictionary<int, bool>();
            if(AGExtNode.GetValue("FlightWinShowKeys") == "1")
            {
                FlightWinShowKeycodes = true;
            }
            else
            {
                FlightWinShowKeycodes = false;
            }
            
            UnbindDefaultKeys();

            if (ToolbarManager.ToolbarAvailable) //check if toolbar available, load if it is
            {


                AGXBtn = ToolbarManager.Instance.add("AGX", "AGXBtn");
                AGXBtn.TexturePath = "Diazo/AGExt/icon_button";
                AGXBtn.ToolTip = "Action Groups Extended";
                AGXBtn.OnClick += (e) =>
                    {
                        if (e.MouseButton == 0)
                        {
                            ShowAGXMod = !ShowAGXMod;
                        }
                        if (e.MouseButton == 1)
                        {
                            //ShowSettingsWin = !ShowSettingsWin;
                            if (ShowSettingsWin)
                            {
                                AGXBtn.Drawable = null;
                                ShowSettingsWin = false;
                            }
                            else
                            {
                                SettingsWindow Settings = new SettingsWindow();
                                AGXBtn.Drawable = Settings;
                                ShowSettingsWin = true;
                            }
                            
                        }
                    };
                //{
                //    ShowAGXMod = !ShowAGXMod;
                //};
            }

            if (AGExtNode.GetValue("FltShow") == "0")
            {
                ShowAGXMod = false;
            }

            IsGroupToggle = new Dictionary<int, bool>();
            ShowGroupInFlight = new bool[6,251];
            ShowGroupInFlightNames = new string[6];
            ShowGroupInFlightNames[1] = "Group 1";
            ShowGroupInFlightNames[2] = "Group 2";
            ShowGroupInFlightNames[3] = "Group 3";
            ShowGroupInFlightNames[4] = "Group 4";
            ShowGroupInFlightNames[5] = "Group 5";
            //foreach (ModuleAGExtData agData in FlightGlobals.ActiveVessel.rootPart.Modules.OfType<ModuleAGExtData>())
            //{
            //    ShowGroupInFlightNames = agData.LoadShowGroupNames();
            //}
            for (int i = 1; i <= 250; i++)
            {
                IsGroupToggle[i] = false;
                for (int i2 = 1; i2 <= 5;i2++)
                {
                    ShowGroupInFlight[i2, i] = true;
                }
            }
            ShowGroupInFlightCurrent = 1;
           // print("AGXStart " + Planetarium.GetUniversalTime());

            AGXSkin = (GUISkin)MonoBehaviour.Instantiate(HighLogic.Skin);
            AGXWinStyle = new GUIStyle(AGXSkin.window); 
            AGXLblStyle = new GUIStyle(AGXSkin.label);
            AGXFldStyle = new GUIStyle(AGXSkin.textField);
            AGXFldStyle.fontStyle = FontStyle.Normal;
            //AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1);
            AGXFldStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            AGXLblStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            AGXLblStyle.wordWrap = false;

            AGXBtnStyle = new GUIStyle(AGXSkin.button);
            AGXBtnStyle.fontStyle = FontStyle.Normal;
            AGXBtnStyle.alignment = TextAnchor.MiddleCenter;
            AGXBtnStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            //AGXScrollStyle.normal.background = null;
            //print("AGX " + AGXBtnStyle.normal.background);
            byte[] importTxt = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTexture.png");
            byte[] importTxtRed = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureRed.png");
            byte[] importTxtGreen = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/ButtonTextureGreen.png");
            byte[] importPartCenter = File.ReadAllBytes(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/PartLocationCross.png");
            //byte[] testXport = AGXBtnStyle.normal.background.EncodeToPNG();
            //File.WriteAllBytes(Application.dataPath + "/SavedScreen.png", testXport);
            ButtonTexture.LoadImage(importTxt);
            ButtonTexture.Apply();
            ButtonTextureRed.LoadImage(importTxtRed);
            ButtonTextureRed.Apply();
            ButtonTextureGreen.LoadImage(importTxtGreen);
            ButtonTextureGreen.Apply();
            AGXBtnStyle.normal.background = ButtonTexture;
            AGXBtnStyle.onNormal.background = ButtonTexture;
            AGXBtnStyle.onActive.background = ButtonTexture;
            AGXBtnStyle.onFocused.background = ButtonTexture;
            AGXBtnStyle.onHover.background = ButtonTexture;
            AGXBtnStyle.active.background = ButtonTexture;
            AGXBtnStyle.focused.background = ButtonTexture;
            AGXBtnStyle.hover.background = ButtonTexture;
            PartCenter.LoadImage(importPartCenter);
            PartCenter.Apply();
            SettingsWinRect = new Rect(500, 500, 150, 75);
            partOldVessel = new List<AGXPartVesselCheck>();
            GameEvents.onVesselGoOffRails.Add(VesselOffRails); //triggers when vessel loads at flight scene start also
            GameEvents.onVesselGoOnRails.Add(VesselOnRails);
            //GameEvents.onPartDestroyed.Add(partDead);
            GameEvents.onPartDie.Add(partDead);
            //GameEvents.onPartExplode.Add(partDead2);
            
            //AGXBaseNode = AGextScenario.LoadBaseNode();
            AGXFlightNode = new ConfigNode();
            if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
            {
                AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
            }
            else
            {
                AGXEditorNode = new ConfigNode("EDITOR");
                AGXEditorNode.AddValue("name", "editor");
            }
            //AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"); 
            AllVesselsActions = new List<AGXAction>();
            loadedVessels = new List<Vessel>();
            LoadCurrentKeyBindings();
            
           
        }