Esempio n. 1
0
        public void ManualTracking()
        {
            KopernicusStar[] orderedStars = KopernicusStar.Stars.OrderBy(s => Vector3.Distance(vessel.transform.position, s.sun.position)).ToArray();
            Int32            stars        = orderedStars.Count();

            DialogGUIBase[] options = new DialogGUIBase[stars + 1];
            // Assemble the buttons
            options[0] = new DialogGUIButton(button_Auto, () => { _manualTracking = false; }, true);//Auto
            for (Int32 i = 0; i < stars; i++)
            {
                CelestialBody body = orderedStars[i].sun;
                options[i + 1] = new DialogGUIButton
                                 (
                    body.bodyDisplayName.Replace("^N", ""),
                    () => SetTrackingBody(body),
                    true
                                 );
            }

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                             "SelectTrackingBody",
                                             SelectBody_Msg, //Please select the Body you want to track with this Solar Panel.
                                             SelectBody,     //Select Tracking Body
                                             UISkinManager.GetSkin("MainMenuSkin"),
                                             options), false, UISkinManager.GetSkin("MainMenuSkin"));
        }
        [KSPEvent(active = true, guiActive = false, guiName = "#Kopernicus_UI_SelectBody")]//Select Tracking Body
        public void ManualTracking()
        {
            // Assemble the buttons
            Int32 stars = KopernicusStar.Stars.Count;

            DialogGUIBase[] options = new DialogGUIBase[stars + 1];
            options[0] = new DialogGUIButton(button_Auto, () => { _manualTracking = false; }, true);//Auto
            for (Int32 i = 0; i < stars; i++)
            {
                CelestialBody body = KopernicusStar.Stars[i].sun;
                options[i + 1] = new DialogGUIButton
                                 (
                    body.bodyDisplayName.Replace("^N", ""),
                    () =>
                {
                    for (int n = SPs?.Length ?? 0; n > 0; n--)
                    {
                        ModuleDeployableSolarPanel SP = SPs[n - 1];
                        _manualTracking = true;
                        SP.trackingBody = body;
                        SP.GetTrackingBodyTransforms();
                    }
                },
                    true
                                 );
            }

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                             "SelectTrackingBody",
                                             SelectBody_Msg, //Please select the Body you want to track with this Solar Panel.
                                             SelectBody,     //Select Tracking Body
                                             UISkinManager.GetSkin("MainMenuSkin"),
                                             options), false, UISkinManager.GetSkin("MainMenuSkin"));
        }
Esempio n. 3
0
        private void OnTrue()
        {
            if (!FlightGlobals.ready || FlightGlobals.ActiveVessel == null)
            {
                return;
            }

            DialogGUIBase guiBase = new DialogGUIVerticalLayout();

            bool Filter(VesselType t) => VesselType.Lander == t || VesselType.Probe == t || VesselType.Rover == t ||
            VesselType.Ship == t || VesselType.Station == t;

            foreach (var vessel in FlightGlobals.Vessels.Where(v =>
                                                               v.id != FlightGlobals.ActiveVessel.id && Filter(v.vesselType)))
            {
                bool IsSelected() => FlightGlobals.ActiveVessel.targetObject != null;

                guiBase
                .WithHorizontal()
                .WithLabel(vessel.DiscoveryInfo.displayName.Value)
                .WithFlexible()
                .WithButton <ITargetable>("Set Target", target
                                          => FlightGlobals.fetch.SetVesselTarget(target, true), vessel, () => !IsSelected())
                .WithButton <ITargetable>("Clear Target", target
                                          => FlightGlobals.fetch.SetVesselTarget(target, true), null, IsSelected);
            }

            var optionDialog = new MultiOptionDialog("Target Selector", string.Empty, "Select target", HighLogic.UISkin,
                                                     guiBase);

            _dialog = PopupDialog.SpawnPopupDialog(Vector2.one * .5f, Vector2.one * .5f, optionDialog, false,
                                                   UISkinManager.GetSkin("MainMenuSkin"), false);
        }
Esempio n. 4
0
 // Displays a warning if Kopernicus failed to load for some reason
 public static void DisplayWarning()
 {
     PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "KopernicusFail", "Warning",
                                  "Kopernicus was not able to load the custom planetary system due to an exception in the loading process.\n" +
                                  "Loading your saved game is NOT recommended, because the missing planets could corrupt it and delete your progress.\n\n" +
                                  "Please contact the planet pack author or the Kopernicus team about the issue and send them a valid bug report, including your KSP.log, your ModuleManager.ConfigCache file and the folder Logs/Kopernicus/ from your KSP root directory.\n\n",
                                  "OK", true, UISkinManager.GetSkin("MainMenuSkin"));
 }
        public void Awake()
        {
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("GPPTEXTURES"))
            {
                data = node;
            }

            if (data == null)
            {
                installed = false;
            }

            if (!File.Exists(settingsPath))
            {
                installedCorrectly = false;
            }

            if (!installed)
            {
                PopupDialog popup =
                    PopupDialog.SpawnPopupDialog
                    (
                        new Vector2(0.5f, 0.5f),
                        new Vector2(0.5f, 0.5f),
                        "GPP Texture Checker",
                        "No GPP_Textures Folder Detected",
                        "\n<color=#FF9231><b>The GPP_Textures folder is missing.\n" +
                        "GPP will not load without it.</b>\n\n" +
                        "Go to GitHub and download the latest texture release.</color>",
                        "Open in browser",
                        false,
                        UISkinManager.GetSkin("MainMenuSkin")
                    );

                popup.gameObject.AddComponent <Downloader>();

                Debug.LogError("No GPP_Textures Folder Detected");
            }

            if (installed && !installedCorrectly)
            {
                PopupDialog.SpawnPopupDialog
                (
                    new Vector2(0.5f, 0.5f),
                    new Vector2(0.5f, 0.5f),
                    "GPP Texture Checker",
                    "GPP_Textures Folder Installed Incorrectly",
                    "\n<color=#FF9231><b>The GPP_Textures folder should be installed to " +
                    "<color=#FFFFFF>~/GameData/GPP/GPP_Textures.</color>\n\n" +
                    "GPP will not work until the texture folder is installed properly.</color>",
                    "I Understand",
                    false,
                    UISkinManager.GetSkin("MainMenuSkin")
                );

                Debug.LogError("GPP_Textures Folder Installed Incorrectly");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a new config dialog window.
        /// </summary>
        public static ConfigDialog Create(GameObject gameObject, Callback onClose)
        {
            ConfigDialog configDialog = gameObject.AddComponent <ConfigDialog>();

            configDialog.guiSkin    = UISkinManager.GetSkin("MiniSettingsSkin");
            configDialog.screenRect = new Rect(0.5f, 0.5f, 400f, 150f);
            configDialog.tempConfig = Config.Clone();
            configDialog.onClose    = onClose;

            return(configDialog);
        }
Esempio n. 7
0
 public void DoDependencyCheck()
 {
     if (ContractConfigurator.Util.Version.VerifyAssemblyVersion("CustomBarnKit", "1.0.0") == null)
     {
         var             ainfoV       = Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
         string          title        = "Strategia " + ainfoV.InformationalVersion + " Message";
         string          message      = "Strategia requires Custom Barn Kit to function properly.  Strategia is currently disabled, and will automatically re-enable itself when Custom Barn Kit is installed.";
         DialogGUIButton dialogOption = new DialogGUIButton("Okay", new Callback(DoNothing), true);
         PopupDialog.SpawnPopupDialog(new MultiOptionDialog(message, title, UISkinManager.GetSkin("default"), dialogOption), false, UISkinManager.GetSkin("default"));
     }
 }
        public static QuickLaunchMissionDialog Create(Callback onDismissCallback, QuickLaunchVessel quickLaunchVessel, Vessel vessel)
        {
            GameObject gameObject = new GameObject("BeenThereDoneThat mission start menu");
            QuickLaunchMissionDialog quickLaunchMissionDialog = gameObject.AddComponent <QuickLaunchMissionDialog>();

            quickLaunchMissionDialog.onDismissCallback = onDismissCallback;
            quickLaunchMissionDialog.skin = UISkinManager.GetSkin("MainMenuSkin");
            quickLaunchMissionDialog.quickLaunchVessel    = quickLaunchVessel;
            quickLaunchMissionDialog.vessel               = vessel;
            quickLaunchMissionDialog.selectedMissionIndex = -1;

            return(quickLaunchMissionDialog);
        }
Esempio n. 9
0
            public void ManualTracking()
            {
                // Assemble the buttons
                DialogGUIBase[] options = new DialogGUIBase[KopernicusStar.Stars.Count + 1];
                options[0] = new DialogGUIButton("Auto", () => { manualTracking = false; }, true);
                for (Int32 i = 0; i < KopernicusStar.Stars.Count; i++)
                {
                    CelestialBody body = KopernicusStar.Stars[i].sun;
                    options[i + 1] = new DialogGUIButton(body.bodyDisplayName.Replace("^N", ""), () => { manualTracking = true; trackingBody = body; GetTrackingBodyTransforms(); }, true);
                }

                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                                 "SelectTrackingBody",
                                                 "Please select the Body you want to track with this Solar Panel.",
                                                 "Select Tracking Body",
                                                 UISkinManager.GetSkin("MainMenuSkin"),
                                                 options), false, UISkinManager.GetSkin("MainMenuSkin"));
            }
Esempio n. 10
0
 void Start()
 {
     if (Debug.debug)
     {
         PopupDialog.SpawnPopupDialog
         (
             new Vector2(0.5f, 0.5f),
             new Vector2(0.5f, 0.5f),
             UserSettings.nodeName,
             UserSettings.nodeName + " Warning",
             "\n<color=#FF9231><b>Debug Spam is activated.</b>\n\n" +
             "This feature will greatly affect performance:\n" +
             "use it only for debugging purposes.</color>",
             "OK",
             true,
             UISkinManager.GetSkin("MainMenuSkin")
         );
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Loads the contract group details from the given config node.
        /// </summary>
        /// <param name="configNode">The config node to load from</param>
        /// <returns>Whether we were successful.</returns>
        public bool Load(ConfigNode configNode)
        {
            try
            {
                dataNode = new DataNode(configNode.GetValue("name"), this);

                LoggingUtil.CaptureLog = true;
                ConfigNodeUtil.SetCurrentDataNode(dataNode);
                bool valid = true;

                valid &= ConfigNodeUtil.ParseValue <string>(configNode, "name", x => name = x, this);
                valid &= ConfigNodeUtil.ParseValue <string>(configNode, "displayName", x => displayName = x, this, name);
                valid &= ConfigNodeUtil.ParseValue <string>(configNode, "minVersion", x => minVersionStr = x, this, "");
                valid &= ConfigNodeUtil.ParseValue <int>(configNode, "maxCompletions", x => maxCompletions = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue <int>(configNode, "maxSimultaneous", x => maxSimultaneous = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue <List <string> >(configNode, "disabledContractType", x => disabledContractType = x, this, new List <string>());
                valid &= ConfigNodeUtil.ParseValue <Agent>(configNode, "agent", x => agent = x, this, (Agent)null);
                valid &= ConfigNodeUtil.ParseValue <string>(configNode, "sortKey", x => sortKey = x, this, displayName);
                valid &= ConfigNodeUtil.ParseValue <string>(configNode, "tip", x => {}, this, "");

                if (configNode.HasValue("sortKey") && parent == null)
                {
                    sortKey = displayName;
                    LoggingUtil.LogWarning(this, ErrorPrefix() + ": Using the sortKey field is only applicable on child CONTRACT_GROUP elements");
                }

                if (!string.IsNullOrEmpty(minVersionStr))
                {
                    if (Util.Version.VerifyAssemblyVersion("ContractConfigurator", minVersionStr) == null)
                    {
                        valid = false;

                        var    ainfoV  = Attribute.GetCustomAttribute(typeof(ExceptionLogWindow).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
                        string title   = "Contract Configurator " + ainfoV.InformationalVersion + " Message";
                        string message = "The contract group '" + name + "' requires at least Contract Configurator " + minVersionStr +
                                         " to work, and you are running version " + ainfoV.InformationalVersion +
                                         ".  Please upgrade Contract Configurator to use the contracts in this group.";
                        DialogGUIButton dialogOption = new DialogGUIButton("Okay", new Callback(DoNothing), true);
                        PopupDialog.SpawnPopupDialog(new MultiOptionDialog(message, title, UISkinManager.GetSkin("default"), dialogOption), false, UISkinManager.GetSkin("default"));
                    }
                }

                // Load DATA nodes
                valid &= dataNode.ParseDataNodes(configNode, this, dataValues, uniquenessChecks);

                // Do the deferred loads
                valid &= ConfigNodeUtil.ExecuteDeferredLoads();

                // Do post-deferred load warnings
                if (agent == null)
                {
                    LoggingUtil.LogWarning(this, ErrorPrefix() + ": Providing the agent field for all CONTRACT_GROUP nodes is highly recommended, as the agent is used to group contracts in Mission Control.");
                }
                if (string.IsNullOrEmpty(minVersionStr) || minVersion < ContractConfigurator.ENHANCED_UI_VERSION)
                {
                    LoggingUtil.LogWarning(this, ErrorPrefix() + ": No minVersion or older minVersion provided.  It is recommended that the minVersion is set to at least 1.15.0 to turn important warnings for deprecated functionality into errors.");
                }
                if (!configNode.HasValue("displayName"))
                {
                    LoggingUtil.LogWarning(this, ErrorPrefix() + ": No display name provided.  A display name is recommended, as it is used in the Mission Control UI.");
                }

                config = configNode.ToString();
                log   += LoggingUtil.capturedLog;
                LoggingUtil.CaptureLog = false;

                // Load child groups
                foreach (ConfigNode childNode in ConfigNodeUtil.GetChildNodes(configNode, "CONTRACT_GROUP"))
                {
                    ContractGroup child     = null;
                    string        childName = childNode.GetValue("name");
                    try
                    {
                        child = new ContractGroup(childName);
                    }
                    catch (ArgumentException)
                    {
                        LoggingUtil.LogError(this, "Couldn't load CONTRACT_GROUP '" + childName + "' due to a duplicate name.");
                        valid = false;
                        continue;
                    }

                    child.parent          = this;
                    valid                &= child.Load(childNode);
                    child.dataNode.Parent = dataNode;
                    if (child.hasWarnings)
                    {
                        hasWarnings = true;
                    }
                }

                // Check for unexpected values - always do this last
                valid &= ConfigNodeUtil.ValidateUnexpectedValues(configNode, this);

                // Invalidate children
                if (!valid)
                {
                    Invalidate();
                }

                enabled = valid;
                return(valid);
            }
            catch
            {
                enabled = false;
                throw;
            }
        }
Esempio n. 12
0
        public void ConfirmDialog()
        {
            if (QuickLaunchHangar.Instance.ContainsMissionVehicle(launchVehicleName, missionName))
            {
                saveDialog.gameObject.SetActive(false);
                confirmDialog = PopupDialog.SpawnPopupDialog(anchorMin, anchorMax, new MultiOptionDialog("SavegameConfirmation", "Overwrite " + missionName, "Overwrite", UISkinManager.GetSkin("MainMenuSkin"), new DialogGUIButton("Overwrite", delegate
                {
                    OnSaveConfirmed();
                    DismissConfirmDialog();
                    DismissSaveDialog();
                }, true), new DialogGUIButton("Cancel", delegate
                {
                    DismissConfirmDialog();
                }, true)), false, null, true, string.Empty);
                return;
            }
            if (!CheckFilename(missionName))
            {
                saveDialog.gameObject.SetActive(false);
                confirmDialog = PopupDialog.SpawnPopupDialog(anchorMin, anchorMax, new MultiOptionDialog("SavegameInvalidName", "Oh crap", "Invalid Filename!", UISkinManager.GetSkin("MainMenuSkin"), new DialogGUIButton("Oh crap", delegate
                {
                    DismissConfirmDialog();
                }, true)), false, null, true, string.Empty);
                return;
            }

            OnSaveConfirmed();
            DismissSaveDialog();
        }
Esempio n. 13
0
        public void ShowSaveDialog()
        {
            MultiOptionDialog dialog = new MultiOptionDialog("Save mission", "Save mission", "Save mission", UISkinManager.GetSkin("MainMenuSkin"),
                                                             new DialogGUITextInput(missionName, string.Empty, false, 64, delegate(string name)
            {
                missionName = name;
                return(missionName);
            }, 24f), new DialogGUIButton("Save", delegate
            {
                ConfirmDialog();
            }, false), new DialogGUIButton("Cancel", delegate
            {
                DismissSaveDialog();
            }, true));

            saveDialog = PopupDialog.SpawnPopupDialog(anchorMin, anchorMax, dialog, false, null, true, string.Empty);
        }
Esempio n. 14
0
        public PopupDialog KctError()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("It looks like you have Kerbal Construction Time installed. You should not use KCT's Facility Upgrade and Bureaucracy's Facility Upgrade at the same time. Bad things will happen."));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("KCTError", "", "KCT Detected!", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 400, 100), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 15
0
        public PopupDialog NoLaunchesWindow()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("Due to reduced funding levels, we were unable to afford any fuel"));
            dialogElements.Add(new DialogGUISpace(20));
            dialogElements.Add(new DialogGUILabel("No fuel will be available until the end of the month."));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("NoFuel", "", "No Fuel Available!", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 200, 160), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
        private void OnVesselRecovered(ProtoVessel recoveredVessel, bool quick)
        {
            if (HighLogic.CurrentGame.Parameters.CustomParams <XenoIndustryCoreGameParameters>().enabled)
            {
                Dictionary <string, int> recoveredResources = new Dictionary <string, int>();

                CalculateLaunchCosts(ref recoveredResources, recoveredVessel);

                if (recoveredResources.Count > 0)
                {
                    string message = "Following resources have been recovered: \n";

                    string bodyName = "Kerbin"; // Recovery is only possible on Kerbin for now

                    foreach (KeyValuePair <string, int> kvPair in recoveredResources)
                    {
                        message += String.Format("\n {0} {1}", kvPair.Value, kvPair.Key);

                        StartCoroutine(XenoIndustrySignpost.AddItemsToClusterio(bodyName, kvPair.Key, kvPair.Value));
                    }

                    message += "\n";

                    if (!quick)
                    {
                        MultiOptionDialog dialog = new MultiOptionDialog("ClusterioResourceRecovery", message, "Recovery successful", UISkinManager.GetSkin("KSP window 7"),
                                                                         new DialogGUIBase[]
                        {
                            new DialogGUIButton("Continue", null)
                        });

                        PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, null);
                    }
                }
            }
        }
Esempio n. 17
0
        private PopupDialog DrawUI()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUIImage(new Vector2(300, 147), new Vector2(0, 0), Color.gray, GameDatabase.Instance.GetTexture("Bureaucracy/Mortimer", false)));
            innerElements.Add(new DialogGUILabel(() => "Bank Balance: " + Math.Round(balance, 0)));
            innerElements.Add(new DialogGUITextInput(playerInput.ToString(), false, 30, s => SetPlayerInput(s), 300.0f, 30.0f));
            DialogGUIBase[] horizontal = new DialogGUIBase[3];
            horizontal[0] = new DialogGUIButton("Deposit", () => DepositFunds(playerInput), false);
            horizontal[1] = new DialogGUIButton("Withdraw", () => WithdrawFunds(playerInput), false);
            horizontal[2] = new DialogGUIButton("Close", null, true);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontal));
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(vertical);
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("Bureaucracy", "", "Bank of " + FlightGlobals.GetHomeBody().bodyName, UISkinManager.GetSkin("MainMenuSkin"),
                                                                      new Rect(0.5f, 0.5f, 350, 265), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
Esempio n. 18
0
        private PopupDialog AllocationErrorWindow()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("Allocations do not add up to 100%"));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("AllocationError", "", "Bureaucracy: Error", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 200, 90), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 19
0
        private PopupDialog DrawWarningDialog(BureaucracyFacility facility)
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("Upgrade of " + facility.Name + " will be cancelled. " + (facility.Upgrade.OriginalCost - facility.Upgrade.RemainingInvestment + " will be lost. Are you sure?")));
            dialogElements.Add(new DialogGUIButton("Yes", facility.CancelUpgrade, true));
            dialogElements.Add(new DialogGUIButton("No", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("CancelUpgradeDialog", "", "Bureaucracy: Cancel Upgrade", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 210, 100), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 20
0
        private PopupDialog GenerateKctWarning(int facilityLevel)
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("Facility level doesn't match requested upgrade!"));
            dialogElements.Add(new DialogGUILabel("Expected a level " + levelRequested + " " + parentFacility.Name + " - Got level " + (facilityLevel + 1)));
            dialogElements.Add(new DialogGUILabel("If KCT is installed, make sure you have the right launchpad selected"));
            dialogElements.Add(new DialogGUILabel("When you are ready, right click the launchpad and click \"Upgrade\" to proceed"));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("ResearchDialog", "", "Bureaucracy: Research", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 200, 200), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 21
0
        private PopupDialog DrawMainUi()
        {
            padding = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                innerElements.Add(new DialogGUILabel("Bureaucracy is only available in Career Games"));
            }
            else
            {
                innerElements.Add(new DialogGUISpace(10));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Next Budget: " + Utilities.Instance.ConvertUtToKspTimeStamp(BudgetManager.Instance.NextBudget.CompletionTime), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Gross Budget: $" + Utilities.Instance.GetGrossBudget(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Wage Costs: $" + Costs.Instance.GetWageCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Facility Maintenance Costs: $" + Costs.Instance.GetFacilityMaintenanceCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Launch Costs: $" + Costs.Instance.GetLaunchCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Mission Bonuses: $" + GetBonusesToPay(), false)));
                for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++)
                {
                    Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i);
                    if (m.Name == "Budget")
                    {
                        continue;
                    }
                    double departmentFunding = Math.Round(Utilities.Instance.GetNetBudget(m.Name), 0);
                    if (departmentFunding < 0.0f)
                    {
                        continue;
                    }
                    innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(m.Name + " Department Funding: $" + departmentFunding, false)));
                }
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Net Budget: $" + Utilities.Instance.GetNetBudget("Budget"), false)));
                DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());
                vertical.AddChild(new DialogGUIContentSizer(widthMode: ContentSizeFitter.FitMode.Unconstrained, heightMode: ContentSizeFitter.FitMode.MinSize));
                dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical));
                DialogGUIBase[] horizontal = new DialogGUIBase[6];
                horizontal[0] = new DialogGUILabel("Allocations: ");
                horizontal[1] = new DialogGUILabel("Funds: " + fundingAllocation + "%");
                horizontal[2] = new DialogGUILabel("|");
                horizontal[3] = new DialogGUILabel("Construction: " + constructionAllocation + "%");
                horizontal[4] = new DialogGUILabel("|");
                horizontal[5] = new DialogGUILabel("Research: " + researchAllocation + "%");
                dialogElements.Add(new DialogGUIHorizontalLayout(horizontal));
                dialogElements.Add(GetBoxes("main"));
            }
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("BureaucracyMain", "", "Bureaucracy: Budget", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
Esempio n. 22
0
        private PopupDialog DrawBudgetAllocationUi()
        {
            padding = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            DialogGUIBase[] horizontalArray = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Budget", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(70);
            horizontalArray[3] = new DialogGUITextInput(fundingAllocation.ToString(), false, 3, s => SetAllocation("Budget", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            horizontalArray    = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Construction", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(10);
            horizontalArray[3] = new DialogGUITextInput(constructionAllocation.ToString(), false, 3, s => SetAllocation("Construction", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            horizontalArray    = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Research", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(45);
            horizontalArray[3] = new DialogGUITextInput(researchAllocation.ToString(), false, 3, s => SetAllocation("Research", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++)
            {
                Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i);
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (Utilities.Instance.GetNetBudget(m.Name) == -1.0f)
                {
                    continue;
                }
                horizontalArray    = new DialogGUIBase[3];
                horizontalArray[0] = new DialogGUISpace(10);
                horizontalArray[1] = new DialogGUILabel(m.Name + ": ");
                horizontalArray[2] = new DialogGUILabel(() => ShowFunding(m));
                innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            }
            horizontalArray    = new DialogGUIBase[2];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUIButton("Load Settings", () => SettingsClass.Instance.InGameLoad(), false);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(-Vector2.one, false, false, vertical));
            dialogElements.Add(GetBoxes("allocation"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("Bureaucracy", "", "Bureaucracy: Budget Allocation", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
Esempio n. 23
0
        private PopupDialog DrawCrewUI()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));
            DialogGUIBase[] horizontal;
            for (int i = 0; i < CrewManager.Instance.Kerbals.Count; i++)
            {
                KeyValuePair <string, CrewMember> crew = CrewManager.Instance.Kerbals.ElementAt(i);
                if (crew.Value.CrewReference().rosterStatus != ProtoCrewMember.RosterStatus.Available)
                {
                    continue;
                }
                if (crew.Value.CrewReference().inactive)
                {
                    continue;
                }
                if (crew.Value.CrewReference().experienceLevel >= 5)
                {
                    continue;
                }
                horizontal    = new DialogGUIBase[3];
                horizontal[0] = new DialogGUISpace(10);
                horizontal[1] = new DialogGUILabel(crew.Key, MessageStyle(true));
                horizontal[2] = new DialogGUIButton("Train", () => TrainKerbal(crew.Value), false);
                innerElements.Add(new DialogGUIHorizontalLayout(horizontal));
            }
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical));
            dialogElements.Add(GetBoxes("crew"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("Bureaucracy", "", "Bureaucracy: Crew Manager", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      new Rect(0.5f, 0.5f, 350, 265), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
Esempio n. 24
0
        public PopupDialog NoHireWindow()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel("Due to reduced staffing levels we are unable to take on any new kerbals at this time"));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("NoHire", "", "Can't Hire!", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 100, 200), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 25
0
        public void OnEventFire()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUISpace(10));
            innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(Body)));
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(-Vector2.one, false, false, vertical));
            dialogElements.Add(new DialogGUIButton(AcceptString, OnEventAccepted));
            if (CanBeDeclined)
            {
                dialogElements.Add(new DialogGUIButton(declineString, OnEventDeclined));
            }
            eventDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("EventDialog", "", Title, UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 300, 200), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"));
        }
Esempio n. 26
0
        public PopupDialog GeneralError(string error)
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();

            dialogElements.Add(new DialogGUILabel(error));
            dialogElements.Add(new DialogGUIButton("OK", () => { }, true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("GeneralErrorDialog", "", "Bureaucracy: Error", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 200, 200), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 27
0
        private PopupDialog DrawFacilityUi()
        {
            padding = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();
            int upgradeCount = 0;

            innerElements.Add(new DialogGUISpace(10));
            float investmentNeeded = 0;

            innerElements.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));
            innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("This Month's Budget: $" + Math.Round(FacilityManager.Instance.ThisMonthsBudget, 0), false)));
            for (int i = 0; i < FacilityManager.Instance.Facilities.Count; i++)
            {
                BureaucracyFacility bf = FacilityManager.Instance.Facilities.ElementAt(i);
                if (!bf.Upgrading)
                {
                    continue;
                }
                upgradeCount++;
                investmentNeeded += bf.Upgrade.RemainingInvestment;
                float percentage = bf.Upgrade.OriginalCost - bf.Upgrade.RemainingInvestment;
                percentage = (float)Math.Round(percentage / bf.Upgrade.OriginalCost * 100, 0);
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(bf.Name + " " + percentage + "% ($" + bf.Upgrade.RemainingInvestment + " needed)", false)));
            }
            if (upgradeCount == 0)
            {
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("No Facility Upgrades in progress", false)));
            }
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical));
            DialogGUIBase[] horizontal = new DialogGUIBase[3];
            horizontal[0] = new DialogGUILabel("Total Investment Needed: $" + investmentNeeded);
            horizontal[1] = new DialogGUILabel("|");
            horizontal[2] = new DialogGUILabel("Chance of Fire: " + Math.Round(FacilityManager.Instance.FireChance * 100, 0) + "%");
            dialogElements.Add(new DialogGUIHorizontalLayout(horizontal));
            dialogElements.Add(GetBoxes("facility"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("FacilitiesDialog", "", "Bureaucracy: Facilities", UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 320, 350), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
        IEnumerator ClusterioPreflightResourceCheck()
        {
            Debug.Log("XenoIndustryLaunchCosts: PreflightResourceCheck");

            string bodyName = "Kerbin"; // Launching only works on Kerbin for now

            yield return(StartCoroutine(XenoIndustrySignpost.GetClusterioInventory(bodyName, clusterioInventory)));

            CalculateLaunchCosts(ref latestLaunchCosts);

            bool pass = true;

            foreach (KeyValuePair <string, int> kvPair in latestLaunchCosts)
            {
                if (!clusterioInventory.ContainsKey(kvPair.Key) || clusterioInventory[kvPair.Key] < kvPair.Value)
                {
                    pass = false;
                    break;
                }
            }

            if (!pass)
            { // Insufficient resources to launch
                string message = "You do not have enough resources to launch this vessel! This vessel needs: \n";

                foreach (KeyValuePair <string, int> kvPair in latestLaunchCosts)
                {
                    message += String.Format("\n {0} {1} (you have {2})", kvPair.Value, kvPair.Key, (clusterioInventory.ContainsKey(kvPair.Key)) ? clusterioInventory[kvPair.Key] : 0);
                }

                message += "\n";

                MultiOptionDialog dialog = new MultiOptionDialog("InsufficientClusterioResources", message, "Insufficient resources!", UISkinManager.GetSkin("KSP window 7"),
                                                                 new DialogGUIBase[]
                {
                    new DialogGUIButton("Unable to Launch", null)
                });

                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, null);
            }
            else
            { // Launch can proceed
                string message = "Launching this vessel will require: \n";

                foreach (KeyValuePair <string, int> kvPair in latestLaunchCosts)
                {
                    message += String.Format("\n {0} {1} (you have {2})", kvPair.Value, kvPair.Key, (clusterioInventory.ContainsKey(kvPair.Key)) ? clusterioInventory[kvPair.Key] : 0);
                }

                message += "\n";

                MultiOptionDialog dialog = new MultiOptionDialog("ClusterioLaunchConfirmation", message, "Launch Possible", UISkinManager.GetSkin("KSP window 7"),
                                                                 new DialogGUIBase[]
                {
                    new DialogGUIButton("Launch", new Callback(ProceedToLaunch)),
                    new DialogGUIButton("Cancel", null)
                });

                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, null);
            }
        }
Esempio n. 29
0
        private PopupDialog DrawResearchUi()
        {
            padding = 0;
            float scienceCount = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));
            innerElements.Add(new DialogGUISpace(10));
            if (ResearchManager.Instance.ProcessingScience.Count == 0)
            {
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("No research in progress", false)));
            }
            for (int i = 0; i < ResearchManager.Instance.ProcessingScience.Count; i++)
            {
                ScienceEvent se = ResearchManager.Instance.ProcessingScience.ElementAt(i).Value;
                if (se.IsComplete)
                {
                    continue;
                }
                scienceCount += se.RemainingScience;
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(se.UiName + ": " + Math.Round(se.OriginalScience - se.RemainingScience, 1) + "/" + Math.Round(se.OriginalScience, 1), false)));
            }

            dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, innerElements.ToArray())));
            DialogGUIBase[] horizontal = new DialogGUIBase[3];
            horizontal[0] = new DialogGUILabel("Processing Science: " + Math.Round(scienceCount, 1));
            horizontal[1] = new DialogGUILabel("|");
            double scienceOutput = ResearchManager.Instance.ThisMonthsBudget / SettingsClass.Instance.ScienceMultiplier * ResearchManager.Instance.ScienceMultiplier;

            horizontal[2] = new DialogGUILabel("Research Output: " + Math.Round(scienceOutput, 1));
            dialogElements.Add(new DialogGUIHorizontalLayout(horizontal));
            dialogElements.Add(GetBoxes("research"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("ResearchDialog", "", "Bureaucracy: Research", UISkinManager.GetSkin("MainMenuSkin"), GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
Esempio n. 30
0
        /// <summary>
        /// Displays the scream if the condition evals to true
        /// </summary>
        public void Process(Boolean force = false)
        {
            // Is the execution forced?
            if (!force)
            {
                // Was the scream already shown?
                if (once && _shown)
                {
                    return;
                }

                // Build the evaluator variables
                Boolean canExecute = true;
                foreach (String s in condition.Value)
                {
                    canExecute &= ScreamBehaviour.Conditions[s]();
                }

                // Should we continue?
                if (!canExecute)
                {
                    return;
                }
            }

            // Assemble the message
            String _message = message.Replace("\\n", "\n");
            String _title   = title;

            foreach (KeyValuePair <String, Func <String> > kVP in ScreamBehaviour.Variables)
            {
                _message = _message.Replace("@" + kVP.Key, kVP.Value());
                _title   = _title.Replace("@" + kVP.Key, kVP.Value());
            }

            HighLogic.fetch.StartCoroutine(DelayExecution(delay, () =>
            {
                // Display it
                if (type == ScreamMessageType.ScreenMessage)
                {
                    ScreenMessages.PostScreenMessage(_message, duration, style);
                }

                if (type == ScreamMessageType.PopupDialog)
                {
                    // Calculate the position on screen
                    Single x = position.Value.x / Screen.width;
                    Single y = (Screen.height - position.Value.y) / Screen.height;

                    // Create the action buttons
                    List <DialogGUIBase> elements = new List <DialogGUIBase>();
                    foreach (ActionLoader element in actions)
                    {
                        elements.Add(new DialogGUIButton(element.name, () =>
                        {
                            // Process all actions
                            foreach (String action in element.actions.Value)
                            {
                                // Is the element another scream?
                                if (ScreamBehaviour.Instance.screams.Any(s => s.name == action))
                                {
                                    Scream sc = ScreamBehaviour.Instance.screams.FirstOrDefault(s => s.name == action);
                                    sc.Process(true);
                                }

                                // Is the element a ScreamAction?
                                if (ScreamBehaviour.Actions.ContainsKey(action))
                                {
                                    ScreamBehaviour.Actions[action]();
                                }

                                // Is the element a link?
                                if (action.StartsWith("url:"))
                                {
                                    Application.OpenURL("http://" + action.Substring(4));
                                }
                                if (action.StartsWith("urls:"))
                                {
                                    Application.OpenURL("https://" + action.Substring(5));
                                }
                            }
                        }, element.actions.Value.Contains("Dismiss")));
                    }
                    MultiOptionDialog dialog = new MultiOptionDialog(Guid.NewGuid().ToString(), _message,
                                                                     _title, UISkinManager.GetSkin("MainMenuSkin"), new Rect(x, y, 300f, 100f),
                                                                     elements.ToArray());
                    PopupDialog.SpawnPopupDialog(new Vector2(0f, 1f), new Vector2(0f, 1f), dialog, false,
                                                 UISkinManager.GetSkin("MainMenuSkin"));
                }

                if (type == ScreamMessageType.Debug)
                {
                    Debug.Log("[" + _title + "] " + _message);
                }
                _shown = true;
                Debug.Log("[Screamer] Displayed scream \"" + name + "\"");
            }));
        }