コード例 #1
0
        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);
        }
コード例 #2
0
        private void updateVesselGUIRow(Vessel updatedVessel)
        {
            if (this.currentContentType != ContentType.VESSELS)
            {
                return;
            }

            CNCCommNetVessel     thisVessel = (CNCCommNetVessel)updatedVessel.Connection;
            List <DialogGUIBase> rows       = contentLayout.children;

            for (int i = 0; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(updatedVessel.id.ToString()))
                {
                    DialogGUILabel freqLabel = thisRow.children[2] as DialogGUILabel;
                    freqLabel.SetOptionText(getFreqString(thisVessel.getFrequencyList(), thisVessel.getStrongestFrequency()));
                    return;
                }
            }
        }
コード例 #3
0
        private void refreshFrequencyRows()
        {
            deregisterLayoutComponents(frequencyRowLayout);

            CNCCommNetVessel cncVessel           = (CNCCommNetVessel)this.hostVessel.Connection;
            List <short>     vesselFrequencyList = cncVessel.getFrequencyList();

            vesselFrequencyList.Sort();

            for (int i = 0; i < vesselFrequencyList.Count; i++)
            {
                frequencyRowLayout.AddChild(createFrequencyRow(vesselFrequencyList[i]));
            }

            if (vesselFrequencyList.Count == 0)
            {
                frequencyRowLayout.AddChild(new DialogGUILabel(nofreqMessage, nofreqMessageStyle, true, false));
            }

            registerLayoutComponents(frequencyRowLayout);
            scrollArea.Resize();
        }
コード例 #4
0
        protected override List <DialogGUIBase> drawContentComponents()
        {
            List <DialogGUIBase> listComponments = new List <DialogGUIBase>();

            CNCCommNetVessel cncVessel           = (CNCCommNetVessel)this.hostVessel.Connection;
            List <short>     vesselFrequencyList = cncVessel.getFrequencyList();

            vesselFrequencyList.Sort();

            listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) }));

            //frequency list
            listComponments.Add(new DialogGUILabel("<b>Active frequencies</b>", false, false));
            DialogGUIBase[] frequencyRows;
            if (vesselFrequencyList.Count == 0)
            {
                frequencyRows    = new DialogGUIBase[2];
                frequencyRows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
                frequencyRows[1] = new DialogGUILabel(nofreqMessage, nofreqMessageStyle, true, false);
            }
            else
            {
                frequencyRows    = new DialogGUIBase[vesselFrequencyList.Count + 1];
                frequencyRows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
                for (int i = 0; i < vesselFrequencyList.Count; i++)
                {
                    frequencyRows[i + 1] = createFrequencyRow(vesselFrequencyList[i]);
                }
            }
            frequencyRowLayout = new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, frequencyRows);
            scrollArea         = new CustomDialogGUIScrollList(new Vector2(450, 100), false, true, frequencyRowLayout);
            listComponments.Add(scrollArea);

            //tools
            listComponments.AddRange(this.toolMgt.getLayoutContents());

            return(listComponments);
        }