public override void SetVisible(bool newValue) { base.SetVisible(newValue); WindowTitle = this.part.partInfo.title; if (newValue) { //Set starting page pageID = PipelineViewPages.SelectVessel; //Find Pipelines FindPipeEndpoints(); //Get vessel resources sourceVesselResources.Clear(); getVesselResources(this.part.vessel, sourceVesselResources); if (sourceVesselResources.Keys.Count > 0) { sourceDisplayNames = sourceVesselResources.Keys.ToArray(); } else { sourceDisplayNames = null; } //Get inventory if any if (WBIKISWrapper.IsKISInstalled()) { inventory = WBIKISInventoryWrapper.GetInventory(this.part); } } }
protected void drawSelectResourcesPage() { if (sourceDisplayNames == null) { GUILayout.Label(kNoResources); return; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //Left pane drawLeftPane(); //Right pane drawRightPane(); GUILayout.EndHorizontal(); //Buttons GUILayout.BeginHorizontal(); //Back button if (GUILayout.Button(kBackLabel)) { pageID = PipelineViewPages.SelectVessel; } //Next button if (GUILayout.Button(kNextLabel)) { if (issues.Length == 0) { pageID = PipelineViewPages.ConfirmDelivery; } else { ScreenMessages.PostScreenMessage(kLaunchIssuesMsg, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
protected void drawSelectVesselPage() { if (pipeEndpoints == null) { GUILayout.Label(kNoVesselsInRange); return; } GUILayout.BeginVertical(); //Directions GUILayout.Label(kSelectVessel); //Selection list scrollPos = GUILayout.BeginScrollView(scrollPos); selectedIndex = GUILayout.SelectionGrid(selectedIndex, vesselNames, 1); selectedPipelineNode = pipeEndpoints[selectedIndex]; GUILayout.EndScrollView(); //Next button if (GUILayout.Button(kNextLabel)) { //Get transfer type transferType = getTransferType(); //Make sure that the transfer is allowed if (transferType == WBITransferTypes.OrbitToGround && !allowOrbitToGround) { ScreenMessages.PostScreenMessage(kNoOrbitToGroundMsg, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); } //Set next page else { pageID = PipelineViewPages.ChooseResources; } } GUILayout.EndVertical(); }
protected void drawConfirmPage() { GUILayout.BeginVertical(); //Payload Summary GUILayout.Label("<color=white><b>Payload:</b></color>"); scrollPosResources = GUILayout.BeginScrollView(scrollPosResources, resourcePaneOptions); //Resources int totalResources = sourceDisplayNames.Length; WBIResourceTotals resourceTotals; for (int index = 0; index < totalResources; index++) { resourceTotals = sourceVesselResources[sourceDisplayNames[index]]; if (resourceTotals.transferPercent < 0.0001f) { continue; } GUILayout.BeginScrollView(panelPos, resourcePanelOptions); GUILayout.BeginVertical(); //Resource name GUILayout.Label("<color=white><b>" + resourceTotals.displayName + "</b></color>"); //Amount text field GUILayout.Label("<color=white> Units: " + string.Format("{0:f2}", resourceTotals.amount * resourceTotals.transferPercent) + "</color>"); GUILayout.EndVertical(); GUILayout.EndScrollView(); sourceVesselResources[sourceDisplayNames[index]] = resourceTotals; } //Packing list if (packingList.Count > 0) { WBIPackingItem packingItem; int totalItems = packingList.Count; for (int index = 0; index < totalItems; index++) { //Get the packing item packingItem = packingList[index]; //If selected list out the item if (packingItem.isSelected) { GUILayout.Label("<color=white>" + packingItem.partTitle + "(" + packingItem.quantity + ")</color>"); } } } GUILayout.EndScrollView(); //Buttons GUILayout.BeginHorizontal(); //Back button if (GUILayout.Button(kBackLabel)) { pageID = PipelineViewPages.ChooseResources; } //Launch button //At this time, deduct the required resources and payload resources if (GUILayout.Button(kLaunchLabel)) { //Pay EC cost double amountToTransfer = electricityCostPerTonne * projectileMass; this.part.RequestResource("ElectricCharge", amountToTransfer, ResourceFlowMode.ALL_VESSEL); //Pay LFO units this.part.RequestResource("LiquidFuel", liquidFuelUnits, ResourceFlowMode.ALL_VESSEL); this.part.RequestResource("Oxidizer", oxidizerUnits, ResourceFlowMode.ALL_VESSEL); //Pay guidance data cost if (setGuidanceDataAmount != null) { setGuidanceDataAmount(totalGuidanceData - totalDataCost); } //Create the resource manifest WBIResourceManifest manifest = new WBIResourceManifest(); manifest.destinationID = selectedPipelineNode.moduleValues.GetValue("uniqueIdentifier"); //Deduct payload resources and load them into the transfer request. for (int index = 0; index < totalResources; index++) { //Get the totals, skipping any that has no transfer percent resourceTotals = sourceVesselResources[sourceDisplayNames[index]]; if (resourceTotals.transferPercent < 0.0001f) { continue; } //Deduct the resource amount from the vessel amountToTransfer = resourceTotals.amount * resourceTotals.transferPercent; this.part.RequestResource(resourceTotals.resourceName, amountToTransfer, ResourceFlowMode.ALL_VESSEL); //Add the resource to the transfer manifest. manifest.resourceAmounts.Add(resourceTotals.resourceName, amountToTransfer); } if (manifest.resourceAmounts.Count > 0) { WBIManifestScenario.Instance.AddManifest(manifest); } //Create the Inventory manifest if (packingList.Count > 0) { int totalItems = packingList.Count; WBIKISInventoryManifest inventoryManifest = new WBIKISInventoryManifest(); inventoryManifest.destinationID = selectedPipelineNode.moduleValues.GetValue("uniqueIdentifier"); WBIPackingItem packingItem; WBIInventoryManifestItem manifestItem; for (int index = 0; index < totalItems; index++) { //Get the packing item packingItem = packingList[index]; if (!packingItem.isSelected) { continue; } //Fill out the manifest manifestItem = new WBIInventoryManifestItem(); manifestItem.partName = packingItem.kisItem.availablePart.name; manifestItem.quantity = packingItem.quantity; manifestItem.volume = packingItem.volume; ConfigNode partNode = new ConfigNode(WBIKISInventoryManifest.kPartNode); packingItem.kisItem.availablePart.partConfig.CopyTo(partNode); ConfigNode partConfigNode = new ConfigNode(WBIKISInventoryManifest.kPartConfig); partConfigNode.AddNode(partNode); manifestItem.partConfigNode = partConfigNode; inventoryManifest.inventoryItems.Add(manifestItem); //Remove the item from the inventory inventory.DeleteItem(packingItem.slot); } WBIManifestScenario.Instance.AddManifest(inventoryManifest); packingList.Clear(); } //Play launch effects and inform user. ScreenMessages.PostScreenMessage(kShipmentLaunched + selectedPipelineNode.vesselName, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); //Change page pageID = PipelineViewPages.SelectVessel; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }