Пример #1
0
 private void removeFromVessels(Vessel v, bool warn = true)
 {
     if (currentVessels.ContainsKey(v.id))
     {
         currentVessels.Remove(v.id);
     }
     else if (warn)
     {
         DMC_MBE.LogFormatted("Mission [{0}] Vessel List Does Not Contain A Vessel With ID: [{1}] And Title [{2}]", _missionTitle, v.id, v.vesselName);
     }
 }
Пример #2
0
 private void addToVessels(Vessel v, bool warn = true)
 {
     if (!currentVessels.ContainsKey(v.id))
     {
         currentVessels.Add(v.id, v);
     }
     else if (warn)
     {
         DMC_MBE.LogFormatted("Mission [{0}] Vessel List Already Contains A Vessel With ID: [{1}] And Title [{2}]", _missionTitle, v.id, v.vesselName);
     }
 }
        private IEnumerator replaceStockContractApp()
        {
            while (!ApplicationLauncher.Ready || ContractsApp.Instance == null || ContractsApp.Instance.appLauncherButton == null)
            {
                yield return(null);
            }

            if (toolbarButton == null)
            {
                DMC_MBE.LogFormatted("Contracts Window + App Launcher Button Not Initialized; Starting It Now");
                toolbarButton = ApplicationLauncher.Instance.AddModApplication(open, close, null, null, null, null, (ApplicationLauncher.AppScenes) 63, contractLoader.ToolbarIcon);
            }

            stockAppButton = ContractsApp.Instance.appLauncherButton;

            if (stockAppButton != null)
            {
                stockAppButton.onDisable();

                stockAppButton.onTrue     = toolbarButton.onTrue;
                stockAppButton.onFalse    = toolbarButton.onFalse;
                stockAppButton.onHover    = toolbarButton.onHover;
                stockAppButton.onHoverOut = toolbarButton.onHoverOut;
                stockAppButton.onEnable   = toolbarButton.onEnable;
                stockAppButton.onDisable  = toolbarButton.onDisable;

                ApplicationLauncher.Instance.DisableMutuallyExclusive(stockAppButton);

                DMC_MBE.LogFormatted("Stock Contracts App Replaced With Contracts Window +");

                try
                {
                    removeButton(HighLogic.LoadedScene);
                }
                catch (Exception e)
                {
                    DMC_MBE.LogFormatted("Error In Removing Contracts Window + Toolbar App After Replacing Stock App: {0}", e);
                }
            }
            else
            {
                DMC_MBE.LogFormatted("Something went wrong while replacing the stock contract; attempting to add standard toolbar button");

                if (toolbarButton != null)
                {
                    GameEvents.onGUIApplicationLauncherUnreadifying.Add(removeButton);
                }
                else
                {
                    StartCoroutine(addButton());
                }
            }
        }
Пример #4
0
        private void setupToolbar()
        {
            LogFormatted_DebugOnly("Adding Blizzy Toolbar");
            if (!ToolbarManager.ToolbarAvailable)
            {
                return;
            }

            int sceneInt = contractScenario.currentScene(HighLogic.LoadedScene);

            contractButton = ToolbarManager.Instance.add("ContractsWindow", "ContractWindowPlus");

            if (File.Exists(Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "GameData/Contracts Window/Textures/ContractsIcon.png").Replace("\\", "/")))
            {
                contractButton.TexturePath = "Contracts Window/Textures/ContractsIcon";
            }
            else
            {
                contractButton.TexturePath = "000_Toolbar/resize-cursor";
            }

            contractButton.ToolTip  = "Contract Window";
            contractButton.OnClick += (e) =>
            {
                if (contractScenario.Instance == null)
                {
                    DMC_MBE.LogFormatted("Contract Scenario Not Loaded...");
                }
                else if (contractScenario.Instance.cWin == null)
                {
                    DMC_MBE.LogFormatted("Contract Window Not Loaded...");
                }
                else
                {
                    if (contractScenario.Instance.cWin.Visible)
                    {
                        contractScenario.Instance.cWin.Visible = false;
                        contractScenario.Instance.cWin.StopRepeatingWorker();
                        contractScenario.Instance.windowVisible[sceneInt] = false;
                    }
                    else
                    {
                        contractScenario.Instance.cWin.Visible = true;
                        contractScenario.Instance.cWin.StartRepeatingWorker(5);
                        contractScenario.Instance.windowVisible[sceneInt] = true;
                    }
                }
            };
        }
Пример #5
0
        private void buildMissionList(string s, bool Active)
        {
            if (string.IsNullOrEmpty(s))
            {
                return;
            }
            else
            {
                string[] sA = s.Split(',');
                for (int i = 0; i < sA.Length; i++)
                {
                    contractContainer c   = null;
                    contractUIObject  cUI = null;
                    string[]          sB  = sA[i].Split('|');
                    try
                    {
                        Guid g = new Guid(sB[0]);
                        if (g == null)
                        {
                            continue;
                        }

                        c = contractParser.getActiveContract(g);
                        if (c == null)
                        {
                            continue;
                        }

                        addContract(c, Active, true);
                        cUI = getContract(g);
                        if (cUI == null)
                        {
                            continue;
                        }

                        cUI.SetHidden(!Active);
                        cUI.Order      = stringIntParse(sB[1]);
                        cUI.ShowParams = stringBoolParse(sB[2]);
                    }
                    catch (Exception e)
                    {
                        DMC_MBE.LogFormatted("Guid invalid: {0}", e);
                        continue;
                    }
                }
            }
        }
Пример #6
0
        private void setupToolbar()
        {
            if (!ToolbarManager.ToolbarAvailable)
            {
                return;
            }

            int sceneInt = contractScenario.currentScene(HighLogic.LoadedScene);

            contractButton = ToolbarManager.Instance.add("ContractsWindow", "ContractWindowPlus");

            if (File.Exists(Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "GameData/DMagicUtilities/ContractsWindow/Resources/ContractsIcon.png").Replace("\\", "/")))
            {
                contractButton.TexturePath = "DMagicUtilities/ContractsWindow/Resources/ContractsIcon";
            }
            else
            {
                contractButton.TexturePath = "000_Toolbar/resize-cursor";
            }

            contractButton.ToolTip  = "Contract Window";
            contractButton.OnClick += (e) =>
            {
                if (contractScenario.Instance == null)
                {
                    DMC_MBE.LogFormatted("Contract Scenario Not Loaded...");
                }
                else if (contractWindow.Instance == null)
                {
                    DMC_MBE.LogFormatted("Contract Window Not Loaded...");
                }
                else
                {
                    if (contractWindow.Instance.IsVisible)
                    {
                        contractWindow.Instance.Close();
                        contractScenario.Instance.windowVisible[sceneInt] = false;
                    }
                    else
                    {
                        contractWindow.Instance.Open();
                        contractScenario.Instance.windowVisible[sceneInt] = true;
                    }
                }
            };
        }
Пример #7
0
 internal void addContract(contractContainer c, bool active, bool warn, bool addToUI = false)
 {
     if (!activeMissionList.Contains(c.Root.ContractGuid) && !hiddenMissionList.Contains(c.Root.ContractGuid))
     {
         if (addToMasterList(c, addToUI))
         {
             if (active)
             {
                 activeMissionList.Add(c.Root.ContractGuid);
             }
             else
             {
                 hiddenMissionList.Add(c.Root.ContractGuid);
             }
         }
     }
     else if (warn)
     {
         DMC_MBE.LogFormatted("Mission List Already Contains Contract: {0}", c.Title);
     }
 }
Пример #8
0
        private bool addToMasterList(contractContainer c, bool add = false)
        {
            if (!contractList.ContainsKey(c.Root.ContractGuid))
            {
                contractUIObject cUI = new contractUIObject(c, this);

                contractList.Add(c.Root.ContractGuid, cUI);

                if (add && UIParent != null)
                {
                    UIParent.AddContract(cUI);
                }

                return(true);
            }
            else
            {
                DMC_MBE.LogFormatted("Master Mission List For: [{0}] Already Contains Contract: [{1}]", _missionTitle, c.Title);
            }

            return(false);
        }
Пример #9
0
        private void buildVesselList(string s)
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if (string.IsNullOrEmpty(s))
            {
                return;
            }

            string[] a = s.Split(',');

            for (int i = 0; i < a.Length; i++)
            {
                try
                {
                    Guid   g = new Guid(a[i]);
                    Vessel v = FlightGlobals.Vessels.FirstOrDefault(V => V.id == g);

                    if (v == null)
                    {
                        continue;
                    }

                    addToVessels(v);
                }
                catch (Exception e)
                {
                    DMC_MBE.LogFormatted("Guid invalid: {0} for mission [{1}]", e, _missionTitle);
                }
            }

            List <Vessel> source = currentVessels.Values.ToList();

            vesselIDString = vesselConcat(source);
        }