Ejemplo n.º 1
0
        /// <summary>
        /// Called by <see cref="KolonizationMonitor"/> to render the UI.
        /// </summary>
        public void DrawWindow()
        {
            if (!_isVisible)
            {
                return;
            }

            // Declare some temporary variables
            GUIStyle labelStyle;
            OrbitalLogisticsTransferRequest transfer;

            OrbitalLogisticsTransferRequest[] pendingTransfers = _scenario.PendingTransfers.ToArray();
            OrbitalLogisticsTransferRequest[] expiredTransfers = _scenario.ExpiredTransfers.ToArray();

            // Display everything inside a scroll view
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, UIHelper.scrollStyle, GUILayout.Width(680), GUILayout.Height(380));
            GUILayout.BeginVertical();

            // Display pending transfer section header
            GUILayout.BeginHorizontal();
            GUILayout.Label("Pending Transfers", UIHelper.labelStyle, GUILayout.Width(200));
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();

            if (pendingTransfers.Length == 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("None", UIHelper.whiteLabelStyle, GUILayout.Width(160));
                GUILayout.EndHorizontal();
            }
            else
            {
                // Display pending transfer column headers
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(25));
                GUILayout.Label(" Origin", UIHelper.whiteLabelStyle, GUILayout.Width(165));
                GUILayout.Label("Destination", UIHelper.whiteLabelStyle, GUILayout.Width(165));
                GUILayout.Label("Cost", UIHelper.whiteLabelStyle, GUILayout.Width(80));
                GUILayout.Label("Mass", UIHelper.whiteLabelStyle, GUILayout.Width(80));
                GUILayout.Label("Arrival Time", UIHelper.whiteLabelStyle, GUILayout.Width(90));
                GUILayout.EndHorizontal();

                // Display pending transfers
                for (int i = 0; i < pendingTransfers.Length; i++)
                {
                    transfer = pendingTransfers[i];

                    // Determine text color based on transfer status
                    if (transfer.Status == DeliveryStatus.Returning)
                    {
                        labelStyle = UIHelper.redLabelStyle;
                    }
                    else
                    {
                        labelStyle = UIHelper.yellowLabelStyle;
                    }

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(UIHelper.rightArrowSymbol, UIHelper.buttonStyle, GUILayout.Width(25), GUILayout.Height(22)))
                    {
                        _selectedTransfer = transfer;

                        if (ReviewTransferGui == null)
                        {
                            ReviewTransferGui = new OrbitalLogisticsGui_ReviewTransfer(_selectedTransfer, this);
                        }
                        else
                        {
                            ReviewTransferGui.Transfer = _selectedTransfer;
                        }

                        ReviewTransferGui.SetVisible(true);
                    }
                    GUILayout.Label(" " + transfer.OriginVesselName ?? "(Missing)", labelStyle, GUILayout.Width(165));
                    GUILayout.Label(transfer.DestinationVesselName ?? "(Missing)", labelStyle, GUILayout.Width(165));
                    GUILayout.Label(transfer.CalculateFuelUnits().ToString("F2"), labelStyle, GUILayout.Width(80));
                    GUILayout.Label(transfer.TotalMass().ToString("F2"), labelStyle, GUILayout.Width(80));
                    GUILayout.Label(
                        Utilities.FormatTime(transfer.GetArrivalTime() - Planetarium.GetUniversalTime()),
                        labelStyle, GUILayout.Width(90)
                        );
                    if (GUILayout.Button(UIHelper.deleteSymbol, UIHelper.buttonStyle, GUILayout.Width(22), GUILayout.Height(22)))
                    {
                        _selectedTransfer = null;

                        if (ReviewTransferGui != null)
                        {
                            ReviewTransferGui.Transfer = null;
                            ReviewTransferGui.SetVisible(false);
                        }

                        // Cancel transfer
                        AbortTransfer(transfer);
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndVertical();

            // Display a blank section to create some visual separation between sections
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(200));
            GUILayout.EndHorizontal();

            // Display expired transfer section header
            GUILayout.BeginHorizontal();
            GUILayout.Label("Expired Transfers", UIHelper.labelStyle, GUILayout.Width(200));
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();

            if (expiredTransfers.Length == 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("None", UIHelper.whiteLabelStyle, GUILayout.Width(160));
                GUILayout.EndHorizontal();
            }
            else
            {
                // Display expired transfer column headers
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(25));
                GUILayout.Label(" Origin", UIHelper.whiteLabelStyle, GUILayout.Width(165));
                GUILayout.Label("Destination", UIHelper.whiteLabelStyle, GUILayout.Width(165));
                GUILayout.Label("Cost", UIHelper.whiteLabelStyle, GUILayout.Width(80));
                GUILayout.Label("Mass", UIHelper.whiteLabelStyle, GUILayout.Width(80));
                GUILayout.Label("Status", UIHelper.whiteLabelStyle, GUILayout.Width(90));
                GUILayout.EndHorizontal();

                // Diplay expired transfers
                for (int i = 0; i < expiredTransfers.Length; i++)
                {
                    transfer = expiredTransfers[i];

                    // Determine text color based on transfer status
                    if (transfer.Status == DeliveryStatus.Delivered)
                    {
                        labelStyle = UIHelper.yellowLabelStyle;
                    }
                    else
                    {
                        labelStyle = UIHelper.redLabelStyle;
                    }

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(UIHelper.rightArrowSymbol, UIHelper.buttonStyle, GUILayout.Width(25), GUILayout.Height(22)))
                    {
                        _selectedTransfer = transfer;

                        if (ReviewTransferGui == null)
                        {
                            ReviewTransferGui = new OrbitalLogisticsGui_ReviewTransfer(_selectedTransfer, this);
                        }
                        else
                        {
                            ReviewTransferGui.Transfer = _selectedTransfer;
                        }

                        ReviewTransferGui.SetVisible(true);
                    }
                    GUILayout.Label(" " + transfer.OriginVesselName ?? "(Missing)", labelStyle, GUILayout.Width(165));
                    GUILayout.Label(transfer.DestinationVesselName ?? "(Missing)", labelStyle, GUILayout.Width(165));
                    GUILayout.Label(transfer.CalculateFuelUnits().ToString("F2"), labelStyle, GUILayout.Width(80));
                    GUILayout.Label(transfer.TotalMass().ToString("F2"), labelStyle, GUILayout.Width(80));
                    GUILayout.Label(transfer.Status.ToString(), labelStyle, GUILayout.Width(90));
                    if (GUILayout.Button(UIHelper.deleteSymbol, UIHelper.buttonStyle, GUILayout.Width(22), GUILayout.Height(22)))
                    {
                        _selectedTransfer = null;

                        if (ReviewTransferGui != null)
                        {
                            ReviewTransferGui.Transfer = null;
                            ReviewTransferGui.SetVisible(false);
                        }

                        // Remove transfer from expired transfers list
                        _scenario.ExpiredTransfers.Remove(transfer);
                    }
                    GUILayout.EndHorizontal();
                }

                // Display a blank line to create some visual separation
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(200));
                GUILayout.EndHorizontal();

                // Display clear all expired transfers button
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(300));
                if (GUILayout.Button("Clear All", UIHelper.buttonStyle, GUILayout.Width(80), GUILayout.Height(25)))
                {
                    _selectedTransfer = null;

                    if (ReviewTransferGui != null)
                    {
                        ReviewTransferGui.Transfer = null;
                        ReviewTransferGui.SetVisible(false);
                    }

                    // Remove all transfers from expired transfers list
                    _scenario.ExpiredTransfers.Clear();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            // Close main scroll view
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by <see cref="MonoBehaviour"/>.OnGUI to render the UI.
        /// </summary>
        /// <param name="windowId"></param>
        protected override void DrawWindowContents(int windowId)
        {
            // Allocate some variables for later
            GUIStyle labelStyle;
            GUIStyle rAlignLabelStyle;

            GUILayout.BeginVertical();

            // Display pending transfers section header
            GUILayout.Label("Pending Transfers", UIHelper.labelStyle, GUILayout.Width(200));
            _scrollPositionCurrentTransfers = GUILayout.BeginScrollView(_scrollPositionCurrentTransfers);

            // Display pending transfers column headers
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(25));
            GUILayout.Label(" Origin", UIHelper.whiteLabelStyle, GUILayout.Width(155));
            GUILayout.Label("Destination", UIHelper.whiteLabelStyle, GUILayout.Width(155));
            GUILayout.Label("Arrival Time", UIHelper.whiteRightAlignLabelStyle, GUILayout.Width(80));
            GUILayout.EndHorizontal();

            // Display pending transfers
            foreach (OrbitalLogisticsTransferRequest transfer in _scenario.PendingTransfers)
            {
                // Only show transfers in the module's SoI
                if (transfer.Destination == null ||
                    transfer.Origin == null ||
                    (transfer.Destination.mainBody != _module.vessel.mainBody &&
                     transfer.Origin.mainBody != _module.vessel.mainBody))
                {
                    continue;
                }

                // Determine text color based on transfer status
                if (transfer.Status == DeliveryStatus.Returning)
                {
                    labelStyle       = UIHelper.redLabelStyle;
                    rAlignLabelStyle = UIHelper.redRightAlignLabelStyle;
                }
                else
                {
                    labelStyle       = UIHelper.yellowLabelStyle;
                    rAlignLabelStyle = UIHelper.yellowRightAlignLabelStyle;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(UIHelper.rightArrowSymbol, UIHelper.buttonStyle, GUILayout.Width(25), GUILayout.Height(22)))
                {
                    if (ReviewTransferGui == null)
                    {
                        ReviewTransferGui = new OrbitalLogisticsGui_ReviewTransfer(transfer, this);
                    }
                    else
                    {
                        ReviewTransferGui.Transfer = transfer;
                    }

                    ReviewTransferGui.SetVisible(true);
                }
                GUILayout.Label(" " + transfer.OriginVesselName, labelStyle, GUILayout.Width(155));
                GUILayout.Label(transfer.DestinationVesselName, labelStyle, GUILayout.Width(155));
                GUILayout.Label(
                    Utilities.FormatTime(transfer.GetArrivalTime() - Planetarium.GetUniversalTime()),
                    rAlignLabelStyle, GUILayout.Width(80)
                    );
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            // Display expired transfers section header
            GUILayout.Label("Expired Tranfers", UIHelper.labelStyle, GUILayout.Width(200));
            _scrollPositionPreviousTransfers = GUILayout.BeginScrollView(_scrollPositionPreviousTransfers);

            // Display expired transfers column headers
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(25));
            GUILayout.Label(" Origin", UIHelper.whiteLabelStyle, GUILayout.Width(155));
            GUILayout.Label("Destination", UIHelper.whiteLabelStyle, GUILayout.Width(155));
            GUILayout.Label("Status", UIHelper.whiteLabelStyle, GUILayout.Width(80));
            GUILayout.EndHorizontal();

            // Display expired transfers
            foreach (OrbitalLogisticsTransferRequest transfer in _scenario.ExpiredTransfers)
            {
                // Only show transfers in the module's SoI
                if (transfer.Destination == null ||
                    transfer.Origin == null ||
                    (transfer.Destination.mainBody != _module.vessel.mainBody &&
                     transfer.Origin.mainBody != _module.vessel.mainBody))
                {
                    continue;
                }

                // Determine text color based on transfer status
                if (transfer.Status == DeliveryStatus.Delivered)
                {
                    labelStyle = UIHelper.yellowLabelStyle;
                }
                else
                {
                    labelStyle = UIHelper.redLabelStyle;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(UIHelper.rightArrowSymbol, UIHelper.buttonStyle, GUILayout.Width(25), GUILayout.Height(22)))
                {
                    if (ReviewTransferGui == null)
                    {
                        ReviewTransferGui = new OrbitalLogisticsGui_ReviewTransfer(transfer, this);
                    }
                    else
                    {
                        ReviewTransferGui.Transfer = transfer;
                    }

                    ReviewTransferGui.SetVisible(true);
                }
                GUILayout.Label(" " + transfer.OriginVesselName, labelStyle, GUILayout.Width(155));
                GUILayout.Label(transfer.DestinationVesselName, labelStyle, GUILayout.Width(155));
                GUILayout.Label(transfer.Status.ToString(), labelStyle, GUILayout.Width(80));
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Empty, UIHelper.labelStyle, GUILayout.Width(100));
            if (GUILayout.Button("New Transfer", UIHelper.buttonStyle, GUILayout.Width(120)))
            {
                _module.MakeBodyVesselList();

                CreateTransferGui = new OrbitalLogisticsGui_CreateTransfer(_module, _scenario);
            }
            if (GUILayout.Button("Close", UIHelper.buttonStyle, GUILayout.Width(120)))
            {
                SetVisible(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }