protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); DialogGUILabel newColorLabel = new DialogGUILabel("<b> " + Localizer.Format("#CNC_ColorPicker_newColorLabel") + "</b>", 40, 12);//New newColorImage = new DialogGUIImage(new Vector2(30, 24), Vector2.zero, chosenColor, UIUtils.createAndColorize(30, 24, Color.white)); DialogGUILabel currentColorLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_ColorPicker_CurrentColorLabel") + " </b>", 45, 12);//Current DialogGUIImage currentColorImage = new DialogGUIImage(new Vector2(30, 24), Vector2.zero, currentColor, UIUtils.createAndColorize(30, 24, Color.white)); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUISpace(40), newColorImage, newColorLabel, new DialogGUISpace(dialogWidth - 80 - 145), currentColorLabel, currentColorImage, new DialogGUISpace(40) })); colorPickerImage = new DialogGUIImage(new Vector2(displayTextureWidth, displayTextureHeight), Vector2.zero, Color.white, colorPickerTexture); DialogGUIImage hueSliderImage = new DialogGUIImage(new Vector2(displayTextureWidth, sliderHeight * 2), Vector2.zero, Color.white, renderHueSliderTexture()); DialogGUISlider hueSlider = new DialogGUISlider(() => hueValue, 0f, 1f, false, displayTextureWidth, sliderHeight, setHueValue); listComponments.Add(new DialogGUIVerticalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { colorPickerImage, new DialogGUISpace(5f), hueSliderImage, hueSlider })); DialogGUILabel hexColorLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_ColorPicker_HexColorLabel") + " <size=15>#</size></b>", true, false);//Or hex color colorHexInput = new DialogGUITextInput("", false, 6, setColorHexString, 75, 24); DialogGUIButton hexGoButton = new DialogGUIButton(Localizer.Format("#CNC_ColorPicker_HexGoButton"), delegate { this.readColorHexString(); }, 40, 24, false);//"Parse" listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(0, 0, 0, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUISpace(5), hexColorLabel, colorHexInput, new DialogGUISpace(3), hexGoButton, new DialogGUISpace(5) })); return(listComponments); }
public override List <DialogGUIBase> getContentComponents() { List <DialogGUIBase> layout = new List <DialogGUIBase>(); DialogGUILabel msgLbl = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_msgLabel4"), 100, 32);//"Set up the master frequency in one go. All antennas will be assigned to this frequency, and Comm powers of those deployed antennas will be combined." layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl })); DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_FrequencyLabel") + "</b>", 52, 12);//Frequency frequencyInput = new DialogGUITextInput(CNCSettings.Instance.PublicRadioFrequency + "", false, CNCSettings.MaxDigits, setConstellFreq, 45, 25); DialogGUIToggle membershipToggle = new DialogGUIToggle(false, "", membershipFlagToggle); DialogGUILabel membershipLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_getContentCompon_membershipLabel") + "</b>", 200, 12);//Talk to constellation members only DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(20), membershipToggle, membershipLabel }); layout.Add(constellationGroup); constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, Color.white, colorTexture); DialogGUILabel constNameLabel = new DialogGUILabel(getConstellationName, 200, 12); layout.Add(new DialogGUIHorizontalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { constNameLabel, constellationColorImage })); DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateClick, false); //"Update" DialogGUIButton publicButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_PublicButton"), defaultClick, false); //"Revert to public" DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, publicButton, new DialogGUIFlexibleSpace() }); layout.Add(actionGroup); return(layout); }
private DialogGUIHorizontalLayout createConstellationRow(Constellation thisConstellation) { Color color = Constellation.getColor(thisConstellation.frequency); DialogGUIImage colorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.zero, thisConstellation.color, colorTexture); DialogGUILabel constNameLabel = new DialogGUILabel(thisConstellation.name, 170, 12); DialogGUILabel freqLabel = new DialogGUILabel(Localizer.Format("#CNC_Generic_FrequencyLabel") + string.Format(": <color={0}>{1}</color>", UIUtils.colorToHex(color), thisConstellation.frequency), 100, 12); //Frequency DialogGUILabel numSatsLabel = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_numSatsLabel", Constellation.countVessels(thisConstellation)), 75, 12); //string.Format("{0} vessels", ) DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Editbutton"), delegate { editConstellationClick(thisConstellation); }, 50, 32, false); //"Edit" DialogGUIToggleButton toggleButton = new DialogGUIToggleButton(thisConstellation.visibility, Localizer.Format("#CNC_Generic_Mapbutton"), delegate { toggleConstellationVisibility(thisConstellation); }, 45, 32); //"Map" DialogGUIBase[] rowGUIBase = new DialogGUIBase[] { colorImage, constNameLabel, freqLabel, numSatsLabel, toggleButton, updateButton, null }; if (thisConstellation.frequency == CNCSettings.Instance.PublicRadioFrequency) { rowGUIBase[rowGUIBase.Length - 1] = new DialogGUIButton(Localizer.Format("#CNC_Generic_Resetbutton"), resetPublicConstClick, 60, 32, false);//"Reset" } else { rowGUIBase[rowGUIBase.Length - 1] = new DialogGUIButton(Localizer.Format("#CNC_Generic_DeleteButton"), delegate { deleteConstellationClick(thisConstellation); }, 60, 32, false);//"Delete" } DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, rowGUIBase); constellationGroup.SetOptionText(thisConstellation.frequency.ToString()); //for quick identification return(constellationGroup); }
private void updateConstellationGUIRow(short updatedfrequency, short previousFrequency) { if (this.currentContentType != ContentType.CONSTELLATIONS) { return; } List <DialogGUIBase> rows = contentLayout.children; for (int i = 2; i < rows.Count; i++) { DialogGUIBase thisRow = rows[i]; if (thisRow.OptionText.Equals(updatedfrequency.ToString()) || thisRow.OptionText.Equals(previousFrequency.ToString())) { DialogGUIImage colorImage = thisRow.children[0] as DialogGUIImage; DialogGUILabel nameLabel = thisRow.children[1] as DialogGUILabel; DialogGUILabel freqLabel = thisRow.children[2] as DialogGUILabel; DialogGUILabel vesselLabel = thisRow.children[3] as DialogGUILabel; Constellation updatedConstellation = CNCCommNetScenario.Instance.constellations.Find(x => x.frequency == updatedfrequency); colorImage.uiItem.GetComponent <RawImage>().color = updatedConstellation.color; nameLabel.SetOptionText(updatedConstellation.name); freqLabel.SetOptionText(Localizer.Format("#CNC_Generic_FrequencyLabel") + string.Format(": <color={0}>{1}</color>", UIUtils.colorToHex(updatedConstellation.color), updatedConstellation.frequency)); //Frequency vesselLabel.SetOptionText(Localizer.Format("#CNC_ConstellationControl_numSatsLabel", Constellation.countVessels(updatedConstellation))); // + " vessels" thisRow.SetOptionText(updatedConstellation.frequency.ToString()); break; } } }
private void updateGroundStationGUIRow(string stationID) { if (this.currentContentType != ContentType.GROUNDSTATIONS) { return; } List <DialogGUIBase> rows = contentLayout.children; for (int i = 1; i < rows.Count; i++) { DialogGUIBase thisRow = rows[i]; if (thisRow.OptionText.Equals(stationID)) { DialogGUIImage colorImage = thisRow.children[0] as DialogGUIImage; DialogGUILabel nameLabel = thisRow.children[1] as DialogGUILabel; DialogGUILabel freqsLabel = thisRow.children[3] as DialogGUILabel; CNCCommNetHome station = CNCCommNetScenario.Instance.groundStations.Find(x => x.ID.Equals(stationID)); colorImage.uiItem.GetComponent <RawImage>().color = station.Color; nameLabel.SetOptionText(station.stationName); freqsLabel.SetOptionText(getFreqString(station.getFrequencyList())); break; } } }
private DialogGUIHorizontalLayout createConstellationRow(short freq) { Color color = Constellation.getColor(freq); string name = Constellation.getName(freq); DialogGUIImage colorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, color, colorTexture); DialogGUILabel nameLabel = new DialogGUILabel(name, 140, 12); DialogGUILabel eachFreqLabel = new DialogGUILabel(string.Format("(<color={0}>{1}</color>)", UIUtils.colorToHex(color), freq), 40, 12); DialogGUIButton removeButton = new DialogGUIButton("Drop", delegate { deleteFreqClick(freq); }, 40, 25, false); return new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { colorImage, nameLabel, eachFreqLabel, removeButton }); }
public static DialogGUIImage GUIImage(Vector2 s, Vector2 p, Color t, Texture i, Modifier <DialogGUIImage> modifier = null) { DialogGUIImage element = new DialogGUIImage(s, p, t, i); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
public static DialogGUIImage GUIImage(Texture i, Single x, Single y, Color t, Modifier <DialogGUIImage> modifier = null) { DialogGUIImage element = new DialogGUIImage(new Vector2(x, y), Vector2.zero, t, i); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
private DialogGUIHorizontalLayout createFrequencyRow(short freq) { CNCCommNetVessel cncVessel = (CNCCommNetVessel)this.hostVessel.Connection; Color color = Constellation.getColor(freq); string name = Constellation.getName(freq); DialogGUIImage colorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, color, colorTexture); DialogGUILabel nameLabel = new DialogGUILabel(name, 170, 12); DialogGUILabel eachFreqLabel = new DialogGUILabel(string.Format("(<color={0}>{1}</color>)", UIUtils.colorToHex(color), freq), 70, 12); DialogGUILabel freqPowerLabel = new DialogGUILabel(string.Format("Combined Comm Power: {0}", UIUtils.RoundToNearestMetricFactor(cncVessel.getMaxComPower(freq), 2)), 220, 12); return(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { colorImage, new DialogGUISpace(20), nameLabel, eachFreqLabel, freqPowerLabel })); }
private DialogGUIHorizontalLayout createGroundStationRow(CNCCommNetHome thisStation) { DialogGUIImage colorImage = new DialogGUIImage(new Vector2(16, 16), Vector2.one, thisStation.Color, groundstationTexture); DialogGUILabel stationNameLabel = new DialogGUILabel(thisStation.stationName, 170, 12); DialogGUILabel locationLabel = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_LatitudeAndLongitude", string.Format("{0:0.0}", thisStation.latitude), string.Format("{0:0.0}", thisStation.longitude)), 100, 24); //string.Format("LAT: \nLON: ", , ) DialogGUILabel freqsLabel = new DialogGUILabel(getFreqString(thisStation.getFrequencyList()), 210, 12); DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Editbutton"), delegate { groundstationEditClick(thisStation); }, 50, 32, false); //"Edit" DialogGUIBase[] rowGUIBase = new DialogGUIBase[] { colorImage, stationNameLabel, locationLabel, freqsLabel, updateButton }; DialogGUIHorizontalLayout groundStationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, rowGUIBase); groundStationGroup.SetOptionText(thisStation.ID); //for quick identification return(groundStationGroup); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); //Current group DialogGUILabel currentLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_currentLevelLabel") + "</b>");//Current tech level currentTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture(this.hostStation.TechLevel)); DialogGUILabel currentPower = new DialogGUILabel(currentPowerFunc); DialogGUIVerticalLayout currentLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { currentLevelLabel, currentTexture, currentPower }); //Upgrade arrow DialogGUIImage arrowTexture = new DialogGUIImage(new Vector2(40, 40), Vector2.zero, Color.white, upgradeArrowTexture); //Next group DialogGUILabel nextLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_nextLevelLabel") + "</b>");//Next tech level nextTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture((short)(this.hostStation.TechLevel + 1))); DialogGUILabel nextPower = new DialogGUILabel(nextPowerFunc); DialogGUIVerticalLayout nextLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nextLevelLabel, nextTexture, nextPower }); listComponments.Add(new CustomDialogGUIScrollList(new Vector2(300 - 10, 150), false, false, new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { currentLevelGroup, arrowTexture, nextLevelGroup }))); //Requirements if (Funding.Instance != null) //only available in Career mode { DialogGUILabel costLabel = new DialogGUILabel(costFunc); DialogGUILabel availableLabel = new DialogGUILabel(availableFunc); listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { costLabel })); listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { availableLabel })); } listComponments.Add(new DialogGUISpace(10)); DialogGUIButton upgradeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Upgradebutton"), onClickUpgrade, false);//Upgrade upgradeButton.OptionInteractableCondition = () => this.hostStation.TechLevel < 3 ? true : false; DialogGUIButton closeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Close"), delegate { this.dismiss(); }, false);//Close DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), upgradeButton, closeButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); DialogGUILabel nameLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_nameLabel") + "</b>", 30, 12);//Name nameInput = new DialogGUITextInput(this.hostStation.stationName, false, CNCSettings.MaxLengthName, setNameInput, 145, 25); DialogGUIButton defaultButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Resetbutton"), defaultNameClick, 40, 25, false);//"Reset" DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nameLabel, nameInput, new DialogGUIFlexibleSpace(), defaultButton }); listComponments.Add(nameGroup); DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationEdit_freqLabel") + "</b>", 85, 12);//New frequency frequencyInput = new DialogGUITextInput("", false, CNCSettings.MaxDigits, setFreqInput, 60, 25); DialogGUIButton addButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Addbutton"), addClick, 40, 25, false);//"Add" stationColorImage = new DialogGUIImage(new Vector2(16f, 16f), Vector2.zero, this.hostStation.Color, CNCCommNetHome.getGroundStationTexture(this.hostStation.TechLevel)); DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(5, 5, 5, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { stationColorImage }); DialogGUIButton colorButton = new DialogGUIButton("", colorEditClick, 26, 26, false, new DialogGUIBase[] { imageBtnLayout }); DialogGUIHorizontalLayout freqGRoup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, addButton, new DialogGUISpace(50), colorButton }); listComponments.Add(freqGRoup); //Prepare a list container for the GUILayout rows DialogGUIBase[] rows = new DialogGUIBase[this.hostStation.getFrequencyList().Count + 1]; rows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < this.freqListShown.Count; i++) { rows[i + 1] = createConstellationRow(this.freqListShown[i]); } frequencyRowLayout = new DialogGUIVerticalLayout(10, 100, 0, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, rows); listComponments.Add(new CustomDialogGUIScrollList(new Vector2(240, 100), false, true, frequencyRowLayout)); DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateAction, false); //"Update" DialogGUIButton cancelButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_CancelButton"), delegate { this.dismiss(); }, false); //"Cancel" DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, cancelButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
private DialogGUIHorizontalLayout createVesselRow(CNCCommNetVessel thisVessel) { //answer is from FlagBrowserGUIButton DialogGUIImage focusImage = new DialogGUIImage(new Vector2(32f, 32f), Vector2.zero, Color.white, focusTexture); DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(1, 1, 1, 1), TextAnchor.MiddleCenter, new DialogGUIBase[] { focusImage }); DialogGUIButton focusButton = new DialogGUIButton("", delegate { vesselFocusClick(thisVessel.Vessel); }, 34, 34, false, new DialogGUIBase[] { imageBtnLayout }); DialogGUILabel vesselLabel = new DialogGUILabel(thisVessel.Vessel.GetDisplayName(), 160, 12); DialogGUILabel freqLabel = new DialogGUILabel(getFreqString(thisVessel.getFrequencyList(), thisVessel.getStrongestFrequency()), 160, 12); DialogGUILabel locationLabel = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_locationLabel", thisVessel.Vessel.mainBody.GetDisplayName()), 100, 12); //Orbiting: <<1>> DialogGUIButton setupButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Setupbutton"), delegate { vesselSetupClick(thisVessel.Vessel); }, 70, 32, false); //"Setup" DialogGUIHorizontalLayout vesselGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { focusButton, vesselLabel, freqLabel, locationLabel, setupButton }); vesselGroup.SetOptionText(thisVessel.Vessel.id.ToString()); return(vesselGroup); }
protected override List <DialogGUIBase> drawContentComponents() { string constellName = ""; short constellFreq = 0; if (this.existingConstellation != null) { constellName = this.existingConstellation.name; constellFreq = this.existingConstellation.frequency; } List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); DialogGUILabel nameLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_nameLabel") + "</b>", 60, 12);//Name nameInput = new DialogGUITextInput(constellName, false, CNCSettings.MaxLengthName, setConstellName, 170, 25); DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { nameLabel, nameInput }); listComponments.Add(nameGroup); DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_FrequencyLabel") + "</b>", 60, 12);//Frequency frequencyInput = new DialogGUITextInput(constellFreq.ToString(), false, CNCSettings.MaxDigits, setConstellFreq, 55, 25); constellationColorImage = new DialogGUIImage(new Vector2(32f, 32f), Vector2.zero, this.constellColor, colorTexture); DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(1, 1, 1, 1), TextAnchor.MiddleCenter, new DialogGUIBase[] { constellationColorImage }); DialogGUIButton colorButton = new DialogGUIButton("", colorEditClick, 34, 34, false, new DialogGUIBase[] { imageBtnLayout }); DialogGUIHorizontalLayout freqColorGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(30), colorButton, new DialogGUISpace(30) }); listComponments.Add(freqColorGroup); DialogGUIButton updateButton = new DialogGUIButton(this.actionButtonText, actionClick, false); DialogGUIButton cancelButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_CancelButton"), delegate { this.dismiss(); }, false);//"Cancel" DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, cancelButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); DialogGUILabel nameLabel = new DialogGUILabel("<b>Name</b>", 40, 12); nameInput = new DialogGUITextInput(antennaModule.Name, false, CNCSettings.MaxLengthName, setNameInput, 145, 25); DialogGUIButton defaultButton = new DialogGUIButton("Reset", defaultNameClick, 45, 25, false); DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nameLabel, nameInput, defaultButton }); listComponments.Add(nameGroup); DialogGUILabel freqLabel = new DialogGUILabel("<b>Frequency</b>", 52, 12); frequencyInput = new DialogGUITextInput(antennaModule.Frequency.ToString(), false, CNCSettings.MaxDigits, setConstellFreq, 45, 25); DialogGUIButton publicButton = new DialogGUIButton("Revert to public", defaultFreqClick, 100, 25, false); DialogGUIHorizontalLayout freqGRoup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, publicButton }); listComponments.Add(freqGRoup); constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, Color.white, colorTexture); DialogGUILabel constNameLabel = new DialogGUILabel(getConstellationName, 200, 12); DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(5, 25, 5, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { constellationColorImage, constNameLabel }); listComponments.Add(new DialogGUIScrollList(new Vector2(200, 40), false, false, constellationGroup)); DialogGUIButton updateButton = new DialogGUIButton("Update", updateAction, false); DialogGUIButton cancelButton = new DialogGUIButton("Cancel", delegate { this.dismiss(); }, false); DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, cancelButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
/// <summary> /// Construct a settings view object. /// </summary> /// <param name="close">Callback to execute when user closes the view</param> public SettingsView(UnityAction close) : base( windowWidth, -1, 2, winPadding, TextAnchor.UpperLeft ) { getPlanetList(); getTextureList(); AddChild(new DialogGUIHorizontalLayout( windowWidth, -1, new DialogGUIBox( "", boxWidth, boxHeight, null, new DialogGUIVerticalLayout( boxWidth, boxHeight, boxSpacing, boxPadding, TextAnchor.UpperLeft, new DialogGUILabel("smartTank_SettingsAutoBoxTitle"), DeferTooltip(new DialogGUIToggle( () => Settings.Instance.AutoScale, "smartTank_AutoScaleSettingPrompt", (bool b) => { Settings.Instance.AutoScale = b; } ) { tooltipText = "smartTank_AutoScaleSettingTooltip" }), DeferTooltip(new DialogGUIToggle( () => Settings.Instance.DiameterMatching, "smartTank_DiameterMatchingSettingPrompt", (bool b) => { Settings.Instance.DiameterMatching = b; } ) { tooltipText = "smartTank_DiameterMatchingSettingTooltip" }) ) ), new DialogGUIBox( "", boxWidth, boxHeight, null, new DialogGUIVerticalLayout( boxWidth, boxHeight, boxSpacing, boxPadding, TextAnchor.UpperLeft, new DialogGUILabel("smartTank_SettingsTWRBoxTitle"), new DialogGUIVerticalLayout( bigPadding, 1.8f * textFieldHeight, 0, noPadding, TextAnchor.MiddleCenter, DeferTooltip(new DialogGUISlider( () => (float)Math.Log10(Settings.Instance.TargetTWR), -1f, 1f, false, -1, -1, (float f) => { Settings.Instance.TargetTWR = (float)Math.Pow(10f, f); } ) { tooltipText = "smartTank_SettingsTWRBoxTooltip" }), new DialogGUILabel(() => $"{Settings.Instance.TargetTWR:G3}") ), new DialogGUIHorizontalLayout( TextAnchor.MiddleLeft, new DialogGUILabel("smartTank_TWRAtSettingPrompt"), DeferTooltip(new DialogGUIChooseOption( planetList, () => Settings.Instance.BodyForTWR, (string s) => { Settings.Instance.BodyForTWR = s; } ) { tooltipText = "smartTank_TWRAtSettingTooltip" }), DeferTooltip(new DialogGUIToggle( () => Settings.Instance.Atmospheric, "smartTank_AtmosphericSettingPrompt", (bool b) => { Settings.Instance.Atmospheric = b; } ) { tooltipText = "smartTank_AtmosphericSettingTooltip" }) ) ) ) )); AddChild(new DialogGUIHorizontalLayout( true, true, boxSpacing, boxPadding, TextAnchor.MiddleLeft, DeferTooltip(new DialogGUIToggle( () => Settings.Instance.FuelMatching, "smartTank_FuelMatchingPrompt", (bool b) => { Settings.Instance.FuelMatching = b; } ) { tooltipText = "smartTank_FuelMatchingTooltip" }), DeferTooltip(new DialogGUIToggle( () => Settings.Instance.HideNonProceduralParts, "smartTank_HideNonProceduralFuelTanksPrompt", (bool b) => { Settings.Instance.HideNonProceduralParts = b; Settings.Instance.HideNonProceduralPartsChanged(); } ) { tooltipText = "smartTank_HideNonProceduralFuelTanksTooltip" }) )); visibleTexture = new DialogGUIImage( new Vector2(textureWidth, textureHeight), new Vector2(0, 0), Color.white, nameToTexture(Settings.Instance.DefaultTexture) ); AddChild(new DialogGUIBox( "", windowWidth - 2 * bigPadding, textureHeight + 2 * bigPadding, null, new DialogGUIHorizontalLayout( true, false, 4, boxPadding, TextAnchor.MiddleLeft, new DialogGUIVerticalLayout( true, false, bigPadding, noPadding, TextAnchor.UpperLeft, new DialogGUILabel("smartTank_DefaultTexturePrompt", leftColWidth), DeferTooltip(new DialogGUIChooseOption( textureList, () => Settings.Instance.DefaultTexture, (string s) => { Settings.Instance.DefaultTexture = s; visibleTexture.uiItem.GetComponent <RawImage>().texture = nameToTexture(s); } ) { tooltipText = "smartTank_DefaultTextureTooltip" }), new DialogGUIFlexibleSpace() ), visibleTexture ) )); AddChild(new DialogGUISpace(bigPadding)); AddChild(new DialogGUIHorizontalLayout( new DialogGUIFlexibleSpace(), new DialogGUIButton( "smartTank_CloseButtonText", () => { close(); }, 200, -1, false ), new DialogGUIFlexibleSpace() )); }
private static DialogGUIImage makePictureOfAKerbal(int width, int height, bool isGoodNews) { if (instructor == null) { GameObject genesPrefab = AssetBase.GetPrefab("Instructor_Gene"); var instantiatedGene = UnityEngine.Object.Instantiate(genesPrefab); instructor = instantiatedGene.GetComponent <KerbalInstructor>(); // Remove the lights for Gene/Wernher Light mainlight = instructor.GetComponentsInChildren <Light>(true).Where(l => l.name == "mainlight").FirstOrDefault(); if (mainlight != null) { UnityEngine.Object.Destroy(mainlight); } Light backlight = instructor.GetComponentsInChildren <Light>(true).Where(l => l.name == "backlight").FirstOrDefault(); if (backlight != null) { UnityEngine.Object.Destroy(backlight); } instructor.gameObject.transform.Translate(25f, 0.0f, 0.0f); // Add a light GameObject lightGameObject = new GameObject("Dialog Box Light"); Light lightComp = lightGameObject.AddComponent <Light>(); lightComp.color = new Color(0.4f, 0.4f, 0.4f); lightGameObject.transform.position = instructor.instructorCamera.transform.position; instructor.SetupAnimations(); } var instructorTexture = new RenderTexture(width, height, 8); instructor.instructorCamera.targetTexture = instructorTexture; instructor.instructorCamera.ResetAspect(); var initialHappyAnimations = new List <CharacterAnimationState>() { instructor.anim_true_thumbsUp, instructor.anim_true_thumbUp, instructor.anim_true_nodA, instructor.anim_true_nodB, instructor.anim_true_smileA, instructor.anim_true_smileB, }; var initialGrumpyAnimations = new List <CharacterAnimationState>() { instructor.anim_false_disagreeA, instructor.anim_false_disagreeB, instructor.anim_false_disagreeC, }; var vampingAnimations = new List <CharacterAnimationState>() { instructor.anim_idle_lookAround, instructor.anim_idle_sigh, instructor.anim_idle_wonder, instructor.anim_true_nodA, instructor.anim_true_nodB, instructor.anim_true_smileA, instructor.anim_true_smileB, }; // Give a short delay before playing the animation float nextAnimTime = Time.fixedTime + 0.3f; bool doneFirstYet = false; var random = new System.Random(); var guiImage = new DialogGUIImage(new Vector2(width, height), new Vector2(0, 0), Color.gray, instructorTexture); guiImage.OnUpdate = () => { // Play the animation if (nextAnimTime <= Time.fixedTime) { CharacterAnimationState nowPlaying; if (!doneFirstYet) { List <CharacterAnimationState> animationSet = isGoodNews ? initialHappyAnimations : initialGrumpyAnimations; nowPlaying = animationSet[random.Next(animationSet.Count)]; instructor.PlayEmote(nowPlaying); doneFirstYet = true; } else { nowPlaying = vampingAnimations[random.Next(vampingAnimations.Count)]; instructor.PlayEmote(nowPlaying, instructor.anim_idle, playSound: false); } nextAnimTime = Time.fixedTime + nowPlaying.clip.length + 1.0f; } }; return(guiImage); }