Ejemplo n.º 1
0
        public void initTransferList(string resourceString)
        {
            transferList.Clear();

            string[] SplitArray = resourceString.Split(',');

            foreach (String resName in SplitArray)
            {
                MKSLresource res = new MKSLresource();
                res.resourceName = resName.Trim();
                transferList.Add(res);
            }
        }
Ejemplo n.º 2
0
        private List <MKSLresource> loadlist(string load)
        {
            var resourceList = new List <MKSLresource>();

            string[] SplitArray = load.Split(',');

            foreach (String st in SplitArray)
            {
                MKSLresource res = new MKSLresource();
                res.loadstring(st);
                resourceList.Add(res);
            }
            return(resourceList);
        }
Ejemplo n.º 3
0
        public void initCostList(string costString)
        {
            costList.Clear();

            string[] SplitArray = costString.Split(',');

            foreach (String resource in SplitArray)
            {
                string[] component = resource.Split(':');

                MKSLresource res = new MKSLresource();
                res.resourceName = component[0].Trim();
                res.costPerMass  = Convert.ToDouble(component[1].Trim());
                costList.Add(res);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// GUI Edit
        /// </summary>
        private void WindowGUIEdit(int windowID)
        {
            GUI.DragWindow(new Rect(0, 0, 400, 30));
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselFrom);
                editGUITransfer.vesselFrom = bodyVesselList[vesselFrom];
            }
            GUILayout.Label("From:", labelStyle, GUILayout.Width(60));
            GUILayout.Label(editGUITransfer.vesselFrom.vesselName, labelStyle, GUILayout.Width(160));
            if (GUILayout.Button(">>", buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselFrom);
                editGUITransfer.vesselFrom = bodyVesselList[vesselFrom];
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselTo);
                editGUITransfer.vesselTo = bodyVesselList[vesselTo];
            }
            GUILayout.Label("To:", labelStyle, GUILayout.Width(60));
            GUILayout.Label(editGUITransfer.vesselTo.vesselName, labelStyle, GUILayout.Width(160));
            if (GUILayout.Button(">>", buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselTo);
                editGUITransfer.vesselTo = bodyVesselList[vesselTo];
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            scrollPositionEditGUIResources = GUILayout.BeginScrollView(scrollPositionEditGUIResources, GUILayout.Width(200), GUILayout.Height(150));
            foreach (MKSLresource res in editGUITransfer.transferList)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(res.resourceName + ": " + Math.Round(res.amount, 2).ToString()))
                {
                    editGUIResource = res;
                    StrAmount = Math.Round(res.amount, 2).ToString();
                    currentAvailable = readResource(editGUITransfer.vesselFrom, editGUIResource.resourceName);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            if (editGUIResource != null)
            {
                   GUILayout.BeginHorizontal();
                   GUILayout.Label("Resource:", labelStyle, GUILayout.Width(80));
                   GUILayout.Label(editGUIResource.resourceName, labelStyle, GUILayout.Width(100));
                   GUILayout.EndHorizontal();

                   GUILayout.BeginHorizontal();
                   GUILayout.Label("Amount:", labelStyle, GUILayout.Width(80));
                   StrAmount = GUILayout.TextField(StrAmount, 10, textFieldStyle, GUILayout.Width(60));
                   if (GUILayout.Button("Set", buttonStyle, GUILayout.Width(30)))
                   {
                       double number = 0;
                       if (Double.TryParse(StrAmount, out number))
                       {
                           if (number < currentAvailable)
                               editGUIResource.amount = number;
                           else
                               editGUIResource.amount = currentAvailable;
                           StrAmount = Math.Round(number, 2).ToString();
                       }
                       else
                       {
                           StrAmount = "0";
                           editGUIResource.amount = 0;
                       }
                       editGUIResource.amount = Convert.ToDouble(StrAmount);
                       updateCostList(editGUITransfer);
                       validateTransfer(editGUITransfer,ref StrValidationMessage);
                   }
                   GUILayout.EndHorizontal();

                   GUILayout.BeginHorizontal();
                   GUILayout.Label("Mass:", labelStyle, GUILayout.Width(80));
                   GUILayout.Label(Math.Round(editGUIResource.mass(), 2).ToString(), labelStyle, GUILayout.Width(100));
                   GUILayout.EndHorizontal();

                   GUILayout.BeginHorizontal();
                   GUILayout.Label("Available:", labelStyle, GUILayout.Width(80));
                   GUILayout.Label(Math.Round(currentAvailable, 2).ToString(), labelStyle, GUILayout.Width(100));
                   GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Label("Tranfer Mass: " + Math.Round(editGUITransfer.totalMass(),2).ToString() + " (maximum: " + maxTransferMass.ToString() + ")", labelStyle, GUILayout.Width(300));

            GUILayout.Label("");
            GUILayout.BeginHorizontal();
            if (Mix1CostName != "")
            {
                if (GUILayout.Button(Mix1CostName, buttonStyle, GUILayout.Width(170)))
                {
                    editGUITransfer.initCostList(Mix1CostResources);
                    updateCostList(editGUITransfer);
                }
            }
            if (Mix2CostName != "")
            {
                if (GUILayout.Button(Mix2CostName, buttonStyle, GUILayout.Width(170)))
                {
                    editGUITransfer.initCostList(Mix2CostResources);
                    updateCostList(editGUITransfer);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (Mix3CostName != "")
            {
                if (GUILayout.Button(Mix3CostName, buttonStyle, GUILayout.Width(170)))
                {
                    editGUITransfer.initCostList(Mix3CostResources);
                    updateCostList(editGUITransfer);
                }
            }
            if (Mix4CostName != "")
            {
                if (GUILayout.Button(Mix4CostName, buttonStyle, GUILayout.Width(170)))
                {
                    editGUITransfer.initCostList(Mix4CostResources);
                    updateCostList(editGUITransfer);
                }
            }
            GUILayout.EndHorizontal();

            foreach (MKSLresource resCost in editGUITransfer.costList)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(resCost.resourceName + ":", labelStyle, GUILayout.Width(100));
                GUILayout.Label(Math.Round(resCost.amount, 2).ToString(), labelStyle, GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }

            GUILayout.Label(StrValidationMessage, redlabelStyle);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Initiate Transfer", buttonStyle, GUILayout.Width(200)))
            {
                updateCostList(editGUITransfer);
                if (validateTransfer(editGUITransfer, ref StrValidationMessage))
                {
                    createTransfer(editGUITransfer);
                }
            }
            if (GUILayout.Button("Cancel", buttonStyle, GUILayout.Width(100)))
            {
                closeGUIEdit();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Ejemplo n.º 5
0
        private void WindowGUIMain(int windowID)
        {
            GUI.DragWindow(new Rect(0, 0, 150, 30));
            GUILayout.BeginVertical();

            if (GUILayout.Button("New Transfer", buttonStyle, GUILayout.Width(150)))
            {
                //newedit = true;
                makeBodyVesselList();

                editGUITransfer = new MKSLtransfer();
                System.Random rnd = new System.Random();
                editGUITransfer.transferName = rnd.Next(100000, 999999).ToString();
                editGUITransfer.initTransferList(ManagedResources);
                editGUITransfer.initCostList(Mix1CostResources);
                editGUITransfer.vesselFrom = vessel;
                editGUITransfer.vesselTo = vessel;

                editGUIResource = editGUITransfer.transferList[0];
                StrAmount = "0";
                currentAvailable = readResource(editGUITransfer.vesselFrom, editGUIResource.resourceName);

                openGUIEdit();
            }

            GUILayout.Label("Current transfers", labelStyle, GUILayout.Width(150));
            scrollPositionGUICurrentTransfers = GUILayout.BeginScrollView(scrollPositionGUICurrentTransfers, false,true, GUILayout.Width(160), GUILayout.Height(180));
            foreach (MKSLtransfer trans in currentTransfers)
            {
                if (GUILayout.Button(trans.transferName + " (" + deliveryTimeString(trans.arrivaltime, Planetarium.GetUniversalTime()) + ")", buttonStyle, GUILayout.Width(135), GUILayout.Height(22)))
                {
                    viewCurrent = true;
                    viewGUITransfer = trans;
                    openGUIView();
                }
            }
            GUILayout.EndScrollView();

            GUILayout.Label("Previous tranfers", labelStyle, GUILayout.Width(150));
            scrollPositionGUIPreviousTransfers = GUILayout.BeginScrollView(scrollPositionGUIPreviousTransfers, false, true, GUILayout.Width(160), GUILayout.Height(80));
            foreach (MKSLtransfer trans in previousTransfers)
            {
                if (GUILayout.Button(trans.transferName + " " + (trans.delivered == true ? "succes" : "failure"), buttonStyle, GUILayout.Width(135), GUILayout.Height(22)))
                {
                    viewCurrent = false;
                    viewGUITransfer = trans;
                    openGUIView();
                }
            }
            GUILayout.EndScrollView();

            GUILayout.Label("", labelStyle, GUILayout.Width(150));
            if (GUILayout.Button("Close", buttonStyle, GUILayout.Width(150)))
            {
                closeGUIMain();
            }
            GUILayout.EndVertical();
        }
Ejemplo n.º 6
0
        private void loadlist(ref List<MKSLresource> resourceList, string load)
        {
            string[] SplitArray = load.Split(',');

            foreach (String st in SplitArray)
            {
                MKSLresource res = new MKSLresource();
                res.loadstring(st);
                resourceList.Add(res);
            }
        }
Ejemplo n.º 7
0
        public void initTransferList(string resourceString)
        {
            transferList.Clear();

            string[] SplitArray = resourceString.Split(',');

            foreach (String resName in SplitArray)
            {
                MKSLresource res = new MKSLresource();
                res.resourceName = resName.Trim();
                transferList.Add(res);
            }
        }
Ejemplo n.º 8
0
        public void initCostList(string costString)
        {
            costList.Clear();

            string[] SplitArray = costString.Split(',');

            foreach (String resource in SplitArray)
            {
                string[] component = resource.Split(':');

                MKSLresource res = new MKSLresource();
                res.resourceName = component[0].Trim();
                res.costPerMass = Convert.ToDouble(component[1].Trim());
                costList.Add(res);
            }
        }
Ejemplo n.º 9
0
        protected override void DrawWindowContents(int windowId)
        {
            Func <TransferCostPaymentModes> getSelectedMode = () =>
            {
                return((this._costPayModes.First(kv => kv.Value)).Key);
            };

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselFrom);
                _model.VesselFrom = _central.bodyVesselList[vesselFrom];
                fromVesselComboBox.SelectedItemIndex = vesselFrom;
                _model.calcResources();
            }
            GUILayout.Label("From:", MKSGui.labelStyle, GUILayout.Width(60));
            fromVesselComboBox.Show();
            //GUILayout.Label(_model.VesselFrom.vesselName, MKSGui.labelStyle, GUILayout.Width(160));
            if (GUIButton.LayoutButton(new GUIContent(">>"), MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselFrom);
                _model.VesselFrom = _central.bodyVesselList[vesselFrom];
                fromVesselComboBox.SelectedItemIndex = vesselFrom;
                _model.calcResources();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselTo);
                _model.VesselTo = _central.bodyVesselList[vesselTo];
                toVesselComboBox.SelectedItemIndex = vesselTo;
                _model.calcResources();
            }
            GUILayout.Label("To:", MKSGui.labelStyle, GUILayout.Width(60));
            toVesselComboBox.Show();
            //GUILayout.Label(_model.VesselTo.vesselName, MKSGui.labelStyle, GUILayout.Width(160));
            if (GUIButton.LayoutButton(new GUIContent(">>"), MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselTo);
                _model.VesselTo = _central.bodyVesselList[vesselTo];
                toVesselComboBox.SelectedItemIndex = vesselTo;
                _model.calcResources();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            scrollPositionEditGUIResources = GUILayout.BeginScrollView(scrollPositionEditGUIResources, GUILayout.Width(300), GUILayout.Height(150));
            foreach (MKSLresource res in _model.transferList)
            {
                GUILayout.BeginHorizontal();
                if (GUIButton.LayoutButton(new GUIContent(res.resourceName + ": " + Math.Round(res.amount, 2) + " of " +
                                                          Math.Round(_model.resourceAmount.Find(x => x.resourceName == res.resourceName).amount))))
                {
                    editGUIResource      = res;
                    StrAmount            = Math.Round(res.amount, 2).ToString();
                    currentAvailable     = readResource(_model.VesselFrom, editGUIResource.resourceName)[0];
                    currentTargetAmounts = this.readResource(_model.VesselTo, editGUIResource.resourceName);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            if (editGUIResource != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Resource:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(editGUIResource.resourceName, MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Amount:", MKSGui.labelStyle, GUILayout.Width(80));
                StrAmount = GUILayout.TextField(StrAmount, 10, MKSGui.textFieldStyle, GUILayout.Width(60));
                Action <double> setAmount = (a) =>
                {
                    if (a < currentAvailable)
                    {
                        editGUIResource.amount = a;
                    }
                    else
                    {
                        editGUIResource.amount = currentAvailable;
                        StrAmount = editGUIResource.amount.ToString("F2");
                    }
                };
                if (GUILayout.Button("Set", MKSGui.buttonStyle, GUILayout.Width(30)))
                {
                    double number;
                    if (Double.TryParse(StrAmount, out number))
                    {
                        setAmount(number);
                    }
                    else
                    {
                        StrAmount = "0";
                        editGUIResource.amount = 0;
                    }
                    updateCostList(_model);
                    validateTransfer(_model, getSelectedMode(), ref StrValidationMessage);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Mass:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(Math.Round(editGUIResource.mass(), 2).ToString(), MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Available:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(Math.Round(currentAvailable, 2).ToString(), MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Target:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(string.Format("{0:F2}/{1:F2}", currentTargetAmounts[0], currentTargetAmounts[1]), MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Fill Up", MKSGui.buttonStyle, GUILayout.Width(100)))
                {
                    var diff = Math.Round(currentTargetAmounts[1] - currentTargetAmounts[0], 2);
                    if (diff >= 0)
                    {
                        setAmount(diff);
                        StrAmount = diff.ToString("F2");
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Tranfer Mass: " + Math.Round(_model.totalMass(), 2) + " (maximum: " + _central.maxTransferMass + ")", MKSGui.labelStyle, GUILayout.Width(300));


            GUILayout.BeginHorizontal();
            GUILayout.Label("");
            if (_central.Mix1CostName != "")
            {
                if (GUILayout.Button(_central.Mix1CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix1CostResources);
                    updateCostList(_model);
                }
            }
            if (_central.Mix2CostName != "")
            {
                if (GUILayout.Button(_central.Mix2CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix2CostResources);
                    updateCostList(_model);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (_central.Mix3CostName != "")
            {
                if (GUILayout.Button(_central.Mix3CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix3CostResources);
                    updateCostList(_model);
                }
            }
            if (_central.Mix4CostName != "")
            {
                if (GUILayout.Button(_central.Mix4CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix4CostResources);
                    updateCostList(_model);
                }
            }
            GUILayout.EndHorizontal();

            foreach (MKSLresource resCost in _model.costList)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(resCost.resourceName + ":", MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.Label(Math.Round(resCost.amount, 2).ToString(), MKSGui.labelStyle, GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Transfer cost paid by: ", MKSGui.labelStyle, GUILayout.Width(170));
            if (this._checkTransferAmounts(this._model, TransferCostPaymentModes.Both).EnoughRes)
            {
                var oldVal = this._costPayModes[TransferCostPaymentModes.Both];
                this._costPayModes[TransferCostPaymentModes.Both] = GUILayout.Toggle(this._costPayModes[TransferCostPaymentModes.Both], "Both", MKSGui.buttonStyle);
                if (oldVal != this._costPayModes[TransferCostPaymentModes.Both])
                {
                    this._costPayModes[TransferCostPaymentModes.Source] = this._costPayModes[TransferCostPaymentModes.Target] = false;
                }
            }
            if (this._checkTransferAmounts(this._model, TransferCostPaymentModes.Source).EnoughRes)
            {
                var oldVal = this._costPayModes[TransferCostPaymentModes.Source];
                this._costPayModes[TransferCostPaymentModes.Source] = GUILayout.Toggle(this._costPayModes[TransferCostPaymentModes.Source], "Source", MKSGui.buttonStyle);
                if (oldVal != this._costPayModes[TransferCostPaymentModes.Source])
                {
                    this._costPayModes[TransferCostPaymentModes.Both] = this._costPayModes[TransferCostPaymentModes.Target] = false;
                }
            }
            if (this._checkTransferAmounts(this._model, TransferCostPaymentModes.Target).EnoughRes)
            {
                var oldVal = this._costPayModes[TransferCostPaymentModes.Target];
                this._costPayModes[TransferCostPaymentModes.Target] = GUILayout.Toggle(this._costPayModes[TransferCostPaymentModes.Target], "Target", MKSGui.buttonStyle);
                if (oldVal != this._costPayModes[TransferCostPaymentModes.Target])
                {
                    this._costPayModes[TransferCostPaymentModes.Both] = this._costPayModes[TransferCostPaymentModes.Source] = false;
                }
            }
            if (!(this._costPayModes[TransferCostPaymentModes.Both] || this._costPayModes[TransferCostPaymentModes.Source] || this._costPayModes[TransferCostPaymentModes.Target]))
            {
                this._costPayModes[TransferCostPaymentModes.Both] = true;
            }
            GUILayout.EndHorizontal();

            updateArrivalTime(_model);
            GUILayout.Label("Transfer time: " + Utilities.DeliveryTimeString(_model.arrivaltime, Planetarium.GetUniversalTime()));

            GUILayout.Label(StrValidationMessage, MKSGui.redlabelStyle);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Initiate Transfer", MKSGui.buttonStyle, GUILayout.Width(200)))
            {
                updateCostList(_model);
                var selMode = getSelectedMode();
                if (validateTransfer(_model, selMode, ref StrValidationMessage))
                {
                    createTransfer(_model, selMode);
                }
            }
            if (GUILayout.Button("Cancel", MKSGui.buttonStyle, GUILayout.Width(100)))
            {
                SetVisible(false);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            fromVesselComboBox.ShowRest();
            toVesselComboBox.ShowRest();
        }
Ejemplo n.º 10
0
        protected override void DrawWindowContents(int windowId)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselFrom);
                _model.VesselFrom = _central.bodyVesselList[vesselFrom];
                fromVesselComboBox.SelectedItemIndex = vesselFrom;
                _model.calcResources();
            }
            GUILayout.Label("From:", MKSGui.labelStyle, GUILayout.Width(60));
            fromVesselComboBox.Show();
            //GUILayout.Label(_model.VesselFrom.vesselName, MKSGui.labelStyle, GUILayout.Width(160));
            if (GUIButton.LayoutButton(new GUIContent(">>"), MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselFrom);
                _model.VesselFrom = _central.bodyVesselList[vesselFrom];
                fromVesselComboBox.SelectedItemIndex = vesselFrom;
                _model.calcResources();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                previousBodyVesselList(ref vesselTo);
                _model.VesselTo = _central.bodyVesselList[vesselTo];
                toVesselComboBox.SelectedItemIndex = vesselTo;
                _model.calcResources();
            }
            GUILayout.Label("To:", MKSGui.labelStyle, GUILayout.Width(60));
            toVesselComboBox.Show();
            //GUILayout.Label(_model.VesselTo.vesselName, MKSGui.labelStyle, GUILayout.Width(160));
            if (GUIButton.LayoutButton(new GUIContent(">>"), MKSGui.buttonStyle, GUILayout.Width(40)))
            {
                nextBodyVesselList(ref vesselTo);
                _model.VesselTo = _central.bodyVesselList[vesselTo];
                toVesselComboBox.SelectedItemIndex = vesselTo;
                _model.calcResources();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            scrollPositionEditGUIResources = GUILayout.BeginScrollView(scrollPositionEditGUIResources, GUILayout.Width(300), GUILayout.Height(150));
            foreach (MKSLresource res in _model.transferList)
            {
                GUILayout.BeginHorizontal();
                if (GUIButton.LayoutButton(new GUIContent(res.resourceName + ": " + Math.Round(res.amount, 2) + " of " +
                                                          Math.Round(_model.resourceAmount.Find(x => x.resourceName == res.resourceName).amount))))
                {
                    editGUIResource  = res;
                    StrAmount        = Math.Round(res.amount, 2).ToString();
                    currentAvailable = readResource(_model.VesselFrom, editGUIResource.resourceName);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            if (editGUIResource != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Resource:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(editGUIResource.resourceName, MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Amount:", MKSGui.labelStyle, GUILayout.Width(80));
                StrAmount = GUILayout.TextField(StrAmount, 10, MKSGui.textFieldStyle, GUILayout.Width(60));
                if (GUILayout.Button("Set", MKSGui.buttonStyle, GUILayout.Width(30)))
                {
                    double number;
                    if (Double.TryParse(StrAmount, out number))
                    {
                        if (number < currentAvailable)
                        {
                            editGUIResource.amount = number;
                        }
                        else
                        {
                            editGUIResource.amount = currentAvailable;
                        }
                        StrAmount = Math.Round(editGUIResource.amount, 2).ToString();
                    }
                    else
                    {
                        StrAmount = "0";
                        editGUIResource.amount = 0;
                    }
                    updateCostList(_model);
                    validateTransfer(_model, ref StrValidationMessage);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Mass:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(Math.Round(editGUIResource.mass(), 2).ToString(), MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Available:", MKSGui.labelStyle, GUILayout.Width(80));
                GUILayout.Label(Math.Round(currentAvailable, 2).ToString(), MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Tranfer Mass: " + Math.Round(_model.totalMass(), 2) + " (maximum: " + _central.maxTransferMass + ")", MKSGui.labelStyle, GUILayout.Width(300));


            GUILayout.BeginHorizontal();
            GUILayout.Label("");
            if (_central.Mix1CostName != "")
            {
                if (GUILayout.Button(_central.Mix1CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix1CostResources);
                    updateCostList(_model);
                }
            }
            if (_central.Mix2CostName != "")
            {
                if (GUILayout.Button(_central.Mix2CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix2CostResources);
                    updateCostList(_model);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (_central.Mix3CostName != "")
            {
                if (GUILayout.Button(_central.Mix3CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix3CostResources);
                    updateCostList(_model);
                }
            }
            if (_central.Mix4CostName != "")
            {
                if (GUILayout.Button(_central.Mix4CostName, MKSGui.buttonStyle, GUILayout.Width(170)))
                {
                    _model.initCostList(_central.Mix4CostResources);
                    updateCostList(_model);
                }
            }
            GUILayout.EndHorizontal();

            foreach (MKSLresource resCost in _model.costList)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(resCost.resourceName + ":", MKSGui.labelStyle, GUILayout.Width(100));
                GUILayout.Label(Math.Round(resCost.amount, 2).ToString(), MKSGui.labelStyle, GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }


            GUILayout.Label(StrValidationMessage, MKSGui.redlabelStyle);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Initiate Transfer", MKSGui.buttonStyle, GUILayout.Width(200)))
            {
                updateCostList(_model);
                if (validateTransfer(_model, ref StrValidationMessage))
                {
                    createTransfer(_model);
                }
            }
            if (GUILayout.Button("Cancel", MKSGui.buttonStyle, GUILayout.Width(100)))
            {
                SetVisible(false);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            fromVesselComboBox.ShowRest();
            toVesselComboBox.ShowRest();
        }