protected override void DrawWindowContents(int windowId) { GUILayout.BeginVertical(); if (GUILayout.Button("New Transfer", MKSGui.buttonStyle, GUILayout.Width(150))) { _model.makeBodyVesselList(); editGUITransfer = new MKSLGuiTransfer(); System.Random rnd = new System.Random(); editGUITransfer.transferName = rnd.Next(100000, 999999).ToString(); editGUITransfer.initTransferList(_model.ManagedResources); editGUITransfer.initCostList(_model.Mix1CostResources); editGUITransfer.VesselFrom = _model.vessel; editGUITransfer.VesselTo = _model.vessel; editGUITransfer.calcResources(); } GUILayout.Label("Current transfers", MKSGui.labelStyle, GUILayout.Width(150)); scrollPositionGUICurrentTransfers = GUILayout.BeginScrollView(scrollPositionGUICurrentTransfers, false, true, GUILayout.MinWidth(160), GUILayout.MaxHeight(180)); foreach (MKSLtransfer trans in _model.saveCurrentTransfersList) { if (GUILayout.Button(trans.transferName + " (" + Utilities.DeliveryTimeString(trans.arrivaltime, Planetarium.GetUniversalTime()) + ")", MKSGui.buttonStyle, GUILayout.Width(135), GUILayout.Height(22))) { if (_transferView == null) { _transferView = new MKSTransferView(trans, this); } else { _transferView.Transfer = trans; } } } GUILayout.EndScrollView(); GUILayout.Label("Previous tranfers", MKSGui.labelStyle, GUILayout.Width(150)); scrollPositionGUIPreviousTransfers = GUILayout.BeginScrollView(scrollPositionGUIPreviousTransfers, false, true, GUILayout.MinWidth(160), GUILayout.MaxHeight(120)); foreach (MKSLtransfer trans in _model.savePreviousTransfersList) { if (GUILayout.Button(trans.transferName + " " + (trans.delivered ? "succes" : "failure"), MKSGui.buttonStyle, GUILayout.Width(135), GUILayout.Height(22))) { if (_transferView == null) { _transferView = new MKSTransferView(trans, this); } else { _transferView.Transfer = trans; } } } GUILayout.EndScrollView(); GUILayout.Label("", MKSGui.labelStyle, GUILayout.Width(150)); if (GUILayout.Button("Close", MKSGui.buttonStyle, GUILayout.Width(150))) { SetVisible(false); } GUILayout.EndVertical(); }
private void Start() { var listStyle = new GUIStyle(); var fromList = _central.bodyVesselList.Select(x => new GUIContent(x.vesselName)).ToArray(); var toList = _central.bodyVesselList.Select(x => new GUIContent(x.vesselName)).ToArray(); //comboBoxList = new GUIContent[5]; //comboBoxList[0] = new GUIContent("Thing 1"); //comboBoxList[1] = new GUIContent("Thing 2"); //comboBoxList[2] = new GUIContent("Thing 3"); //comboBoxList[3] = new GUIContent("Thing 4"); //comboBoxList[4] = new GUIContent("Thing 5"); listStyle.normal.textColor = Color.white; listStyle.onHover.background = listStyle.hover.background = new Texture2D(2, 2); listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4; this._costPayModes = new Dictionary <TransferCostPaymentModes, bool> { { TransferCostPaymentModes.Source, false }, { TransferCostPaymentModes.Target, false }, { TransferCostPaymentModes.Both, true } }; fromVesselComboBox = new ComboBox(new Rect(20, 30, 100, 20), fromList[0], fromList, "button", "box", listStyle, i => { vesselFrom = i; _model.VesselFrom = _central.bodyVesselList[i]; _model.calcResources(); }); fromVesselComboBox.SelectedItemIndex = _central.bodyVesselList.IndexOf(_model.VesselFrom); toVesselComboBox = new ComboBox(new Rect(20, 30, 100, 20), toList[0], toList, "button", "box", listStyle, i => { vesselTo = i; _model.VesselTo = _central.bodyVesselList[i]; _model.calcResources(); }); toVesselComboBox.SelectedItemIndex = _central.bodyVesselList.IndexOf(_model.VesselTo); }
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]; _model.calcResources(); } GUILayout.Label("From:", MKSGui.labelStyle, GUILayout.Width(60)); GUILayout.Label(_model.VesselFrom.vesselName, MKSGui.labelStyle, GUILayout.Width(160)); if (GUILayout.Button(">>", MKSGui.buttonStyle, GUILayout.Width(40))) { nextBodyVesselList(ref vesselFrom); _model.VesselFrom = _central.bodyVesselList[vesselFrom]; _model.calcResources(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("<<", MKSGui.buttonStyle, GUILayout.Width(40))) { previousBodyVesselList(ref vesselTo); _model.VesselTo = _central.bodyVesselList[vesselTo]; _model.calcResources(); } GUILayout.Label("To:", MKSGui.labelStyle, GUILayout.Width(60)); GUILayout.Label(_model.VesselTo.vesselName, MKSGui.labelStyle, GUILayout.Width(160)); if (GUILayout.Button(">>", MKSGui.buttonStyle, GUILayout.Width(40))) { nextBodyVesselList(ref vesselTo); _model.VesselTo = _central.bodyVesselList[vesselTo]; _model.calcResources(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); scrollPositionEditGUIResources = GUILayout.BeginScrollView(scrollPositionEditGUIResources, GUILayout.Width(300), GUILayout.Height(150)); foreach (MKSLresource res in _model.transferList) { GUILayout.BeginHorizontal(); if (GUILayout.Button(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(number, 2).ToString(); } else { StrAmount = "0"; editGUIResource.amount = 0; } editGUIResource.amount = Convert.ToDouble(StrAmount); 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.Label("Tranfer Mass: " + Math.Round(_model.totalMass(), 2) + " (maximum: " + _central.maxTransferMass + ")", MKSGui.labelStyle, GUILayout.Width(300)); GUILayout.Label(""); GUILayout.BeginHorizontal(); 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(); }