Exemple #1
0
        private void PopulateMutuallyConnectedCubeGrids(HashSet <MyAntennaSystem.BroadcasterInfo> playerMutualConnection)
        {
            m_shipsInRange.ClearItems();
            bool isCubeGrid = m_openInventoryInteractedEntityRepresentative is MyCubeGrid;

            //You should always be selectable
            m_shipsInRange.AddItem(m_openInventoryInteractedEntityRepresentative.EntityId, new StringBuilder(m_openInventoryInteractedEntityRepresentative.DisplayName));

            foreach (var connection in playerMutualConnection)
            {
                if (m_shipsInRange.TryGetItemByKey(connection.EntityId) == null)
                {
                    m_shipsInRange.AddItem(connection.EntityId, new StringBuilder(connection.Name));
                }
            }

            m_shipsInRange.Visible = true;
            m_button.Visible       = true;
            m_shipsInRange.SortItemsByValueText();

            //if the interacted entity is not in the combobox, it means we're watching a disconnected ship so it should be red (somehow)
            if (m_shipsInRange.TryGetItemByKey(m_interactedEntityRepresentative.EntityId) == null)
            {
                if (m_interactedEntityRepresentative is MyCubeGrid)
                {
                    m_shipsInRange.AddItem(m_interactedEntityRepresentative.EntityId, new StringBuilder((m_interactedEntityRepresentative as MyCubeGrid).DisplayName));
                }
            }
            m_shipsInRange.SelectItemByKey(m_interactedEntityRepresentative.EntityId);
        }
Exemple #2
0
        private void ComboResolution_ItemSelected()
        {
            int  adapterIndex        = (int)m_comboVideoAdapter.GetSelectedKey();
            var  selectedResolution  = m_resolutions[(int)m_comboResolution.GetSelectedKey()];
            bool fullscreenSupported = false;

            foreach (var displayMode in MyVideoSettingsManager.Adapters[adapterIndex].SupportedDisplayModes)
            {
                if (displayMode.Width == selectedResolution.X &&
                    displayMode.Height == selectedResolution.Y)
                {
                    fullscreenSupported = true;
                    break;
                }
            }

            var selectedWindowMode = (MyWindowModeEnum)m_comboWindowMode.GetSelectedKey();

            m_comboWindowMode.ClearItems();
            m_comboWindowMode.AddItem((int)MyWindowModeEnum.Window, MySpaceTexts.ScreenOptionsVideo_WindowMode_Window);
            m_comboWindowMode.AddItem((int)MyWindowModeEnum.FullscreenWindow, MySpaceTexts.ScreenOptionsVideo_WindowMode_FullscreenWindow);
            if (fullscreenSupported)
            {
                m_comboWindowMode.AddItem((int)MyWindowModeEnum.Fullscreen, MySpaceTexts.ScreenOptionsVideo_WindowMode_Fullscreen);
            }

            if (!fullscreenSupported && selectedWindowMode == MyWindowModeEnum.Fullscreen)
            {
                m_comboWindowMode.SelectItemByKey((long)MyWindowModeEnum.FullscreenWindow);
            }
            else
            {
                m_comboWindowMode.SelectItemByKey((long)selectedWindowMode);
            }
        }
Exemple #3
0
        protected override void OnUpdateVisual()
        {
            base.OnUpdateVisual();

            var first = FirstBlock;

            if (first != null)
            {
                // clear current listed items
                m_comboBox.ClearItems();
                m_handlerItems.Clear();
                // add items
                if (ComboBoxContent != null)
                {
                    ComboBoxContent(m_handlerItems);
                    foreach (var item in m_handlerItems)
                    {
                        m_comboBox.AddItem(item.Key, item.Value);
                    }

                    var value = GetValue(first);
                    if (m_comboBox.GetSelectedKey() != value)
                    {
                        m_comboBox.SelectItemByKey(value);
                    }
                }
            }
        }
Exemple #4
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_scale = 0.7f;

            AddCaption("Cutscenes", Color.Yellow.ToVector4());
            AddShareFocusHint();

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f);


            m_comboCutscenes       = AddCombo();
            m_playButton           = AddButton(new StringBuilder("Play"), onClick_PlayButton);
            m_addCutsceneButton    = AddButton(new StringBuilder("Add cutscene"), onClick_AddCutsceneButton);
            m_deleteCutsceneButton = AddButton(new StringBuilder("Delete cutscene"), onClick_DeleteCutsceneButton);


            m_currentPosition.Y += 0.01f;

            AddLabel("Nodes", Color.Yellow.ToVector4(), 1);
            m_comboNodes = AddCombo();
            m_comboNodes.ItemSelected += m_comboNodes_ItemSelected;


            m_addNodeButton    = AddButton(new StringBuilder("Add node"), onClick_AddNodeButton);
            m_deleteNodeButton = AddButton(new StringBuilder("Delete node"), onClick_DeleteNodeButton);

            m_nodeTimeSlider = AddSlider("Node time", 0, 0, 100, OnNodeTimeChanged);

            var cutscenes = MySession.Static.GetComponent <MySessionComponentCutscenes>();

            m_comboCutscenes.ClearItems();
            foreach (var key in cutscenes.GetCutscenes().Keys)
            {
                m_comboCutscenes.AddItem(key.GetHashCode(), key);
            }

            m_comboCutscenes.SortItemsByValueText();
            m_comboCutscenes.ItemSelected += m_comboCutscenes_ItemSelected;

            AddLabel("Waypoints", Color.Yellow.ToVector4(), 1);
            m_comboWaypoints = AddCombo();
            m_comboWaypoints.ItemSelected += m_comboWaypoints_ItemSelected;



            m_currentPosition.Y += 0.01f;

            m_spawnButton     = AddButton(new StringBuilder("Spawn entity"), onSpawnButton);
            m_removeAllButton = AddButton(new StringBuilder("Remove all"), onRemoveAllButton);


            if (m_comboCutscenes.GetItemsCount() > 0)
            {
                m_comboCutscenes.SelectItemByIndex(0);
            }
        }
        void AddDisplayModesToComboBox(int adapterIndex)
        {
            m_videoModeCombobox.ClearItems();

            int counter = 0;

            foreach (MyVideoModeEx videoMode in MyVideoModeManager.GetAllSupportedVideoModes(adapterIndex))
            {
                m_videoModeCombobox.AddItem(counter++, new StringBuilder(
                                                videoMode.Width + " × " + videoMode.Height + string.Format(videoMode.IsRecommended ? " – {0} ***" : " – {0}", MyTextsWrapper.Get(MyAspectRatioExList.Get(videoMode.AspectRatioEnum).TextShort))
                                                ));
            }
        }
Exemple #6
0
        void onClick_AddCutsceneButton(MyGuiControlButton sender)
        {
            var    cutscenes = MySession.Static.GetComponent <MySessionComponentCutscenes>();
            string name      = "Cutscene" + cutscenes.GetCutscenes().Count;

            cutscenes.GetCutscenes().Add(name, new Cutscene());

            m_comboCutscenes.ClearItems();
            foreach (var key in cutscenes.GetCutscenes().Keys)
            {
                m_comboCutscenes.AddItem(key.GetHashCode(), key);
            }

            m_comboCutscenes.SelectItemByKey(name.GetHashCode());
        }
Exemple #7
0
        void m_comboNodes_ItemSelected()
        {
            m_selectedCutsceneNode = m_selectedCutscene.SequenceNodes[m_comboNodes.GetSelectedKey()];
            m_nodeTimeSlider.Value = m_selectedCutsceneNode.Time;

            m_comboWaypoints.ClearItems();

            if (m_selectedCutsceneNode.Waypoints != null)
            {
                foreach (var waypoint in m_selectedCutsceneNode.Waypoints)
                {
                    m_comboWaypoints.AddItem(waypoint.Name.GetHashCode(), waypoint.Name);
                }

                if (m_comboWaypoints.GetItemsCount() > 0)
                {
                    m_comboWaypoints.SelectItemByIndex(0);
                }
            }
        }
Exemple #8
0
        void UdpateCuesCombo(MyGuiControlCombobox box)
        {
            box.ClearItems();
            long key = 0;

            foreach (var cue in MyAudio.Static.CueDefinitions)
            {
                if ((m_currentCategorySelectedItem == ALL_CATEGORIES) || (m_currentCategorySelectedItem == cue.Category.ToString()))
                {
                    box.AddItem(key, new StringBuilder(cue.SubtypeId.ToString()));
                    key++;
                }
            }

            box.SortItemsByValueText();
            if (box.GetItemsCount() > 0)
            {
                box.SelectItemByIndex(0);
            }
        }
        private void ComboVideoAdapter_ItemSelected()
        {
            int adapterIndex = (int)m_comboVideoAdapter.GetSelectedKey();
            { // AddDisplayModesToComboBox
                LoadResolutions(MyVideoSettingsManager.Adapters[adapterIndex]);

                m_comboResolution.ClearItems();

                var displayAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                int resolutionToSelect = 0;
                int counter            = 0;
                for (int i = 0; i < m_resolutions.Count; ++i)
                {
                    var   resolution      = m_resolutions[i];
                    float aspectRatio     = (float)resolution.X / (float)resolution.Y;
                    var   aspectId        = MyVideoSettingsManager.GetClosestAspectRatio(aspectRatio);
                    var   aspectDetails   = MyVideoSettingsManager.GetAspectRatio(aspectId);
                    var   aspectRatioText = aspectDetails.TextShort;
                    var   starsMark       = aspectDetails.IsSupported ? (aspectId == displayAspectRatio.AspectRatioEnum) ? " ***" // recommended
                                                                                                                 : ""             // normal
                                                              : " *";                                                             // unsupported by UI
                    if (resolution.X == m_settingsOld.BackBufferWidth &&
                        resolution.Y == m_settingsOld.BackBufferHeight)
                    {
                        resolutionToSelect = counter;
                    }

                    m_comboResolution.AddItem(counter++, new StringBuilder(
                                                  string.Format("{0} x {1} - {2}{3}", resolution.X, resolution.Y, aspectRatioText, starsMark)));
                }

                m_comboResolution.SelectItemByKey(resolutionToSelect);
            }

            { // UpdateRecommendecAspectRatioLabel
                MyAspectRatio recommendedAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MyCommonTexts.RecommendedAspectRatio), recommendedAspectRatio.TextShort);
                m_labelRecommendAspectRatio.Text = string.Format("*** {0}", sb);
            }
        }
Exemple #10
0
        void m_comboCutscenes_ItemSelected()
        {
            m_selectedCutscene = MySession.Static.GetComponent <MySessionComponentCutscenes>().GetCutscene(m_comboCutscenes.GetSelectedValue().ToString());

            m_comboNodes.ClearItems();

            if (m_selectedCutscene.SequenceNodes != null)
            {
                int i = 0;
                foreach (var node in m_selectedCutscene.SequenceNodes)
                {
                    m_comboNodes.AddItem(i, node.Time.ToString());
                    i++;
                }
            }


            if (m_comboNodes.GetItemsCount() > 0)
            {
                m_comboNodes.SelectItemByIndex(0);
            }
        }
Exemple #11
0
        void OnVideoAdapterSelected()
        {
            int adapterIndex = (int)m_videoAdapterCombobox.GetSelectedKey();
            { // AddDisplayModesToComboBox
                m_resolutionCombobox.ClearItems();

                var duplicateFilter = new HashSet <Vector2I>(Vector2I.Comparer);
                foreach (var displayMode in MyVideoSettingsManager.Adapters[adapterIndex].SupportedDisplayModes)
                {
                    duplicateFilter.Add(new Vector2I(displayMode.Width, displayMode.Height));
                }

                m_resolutionsForAdapter.Clear();
                m_resolutionsForAdapter.AddHashset(duplicateFilter);
                m_resolutionsForAdapter.Sort((a, b) =>
                { // Sort by width, then height.
                    if (a.X != b.X)
                    {
                        return(a.X.CompareTo(b.X));
                    }
                    return(a.Y.CompareTo(b.Y));
                });

                // Also show any extra display modes we have (there shouldn't be any on official builds).
                foreach (var mode in MyVideoSettingsManager.DebugDisplayModes)
                {
                    m_resolutionsForAdapter.Add(new Vector2I(mode.Width, mode.Height));
                }

                var displayAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                int resolutionToSelect = 0;
                int counter            = 0;
                for (int i = 0; i < m_resolutionsForAdapter.Count; ++i)
                {
                    var   resolution      = m_resolutionsForAdapter[i];
                    float aspectRatio     = (float)resolution.X / (float)resolution.Y;
                    var   aspectId        = MyVideoSettingsManager.GetClosestAspectRatio(aspectRatio);
                    var   aspectDetails   = MyVideoSettingsManager.GetAspectRatio(aspectId);
                    var   aspectRatioText = aspectDetails.TextShort;
                    var   starsMark       = aspectDetails.IsSupported ? (aspectId == displayAspectRatio.AspectRatioEnum) ? " ***" // recommended
                                                                                                                 : ""             // normal
                                                              : " *";                                                             // unsupported
                    if (resolution.X == m_deviceSettingsOld.BackBufferWidth &&
                        resolution.Y == m_deviceSettingsOld.BackBufferHeight)
                    {
                        resolutionToSelect = counter;
                    }

                    m_resolutionCombobox.AddItem(counter++, new StringBuilder(
                                                     string.Format("{0} x {1} - {2}{3}", resolution.X, resolution.Y, aspectRatioText, starsMark)));
                }

                m_resolutionCombobox.SelectItemByKey(resolutionToSelect);
            }

            { // UpdateRecommendecAspectRatioLabel
                MyAspectRatio recommendedAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MySpaceTexts.RecommendedAspectRatio), recommendedAspectRatio.TextShort);
                m_recommendAspectRatioLabel.Text = string.Format("*** {0}", sb);
            }
        }
Exemple #12
0
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            // LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.46f), text: "Select components to remove and components to add", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            // ENTITY SELECTION
            if (m_entitiesSelection == null)
            {
                m_entitiesSelection = new MyGuiControlCombobox();
                m_entitiesSelection.ItemSelected += EntitySelected;
            }

            m_entitiesSelection.Position    = new Vector2(0f, -0.42f);
            m_entitiesSelection.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;

            m_entitiesSelection.ClearItems();
            foreach (var ent in m_entities)
            {
                m_entitiesSelection.AddItem(ent.EntityId, ent.ToString());
            }
            m_entitiesSelection.SelectItemByKey(m_entityId, false);

            this.Controls.Add(m_entitiesSelection);

            // ENTITY ID LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.39f), text: String.Format("EntityID = {0}", m_entityId), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            // ENTITY NAME LABEL AND COMPONENTS
            MyEntity entity;

            if (MyEntities.TryGetEntityById(m_entityId, out entity))
            {
                this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.36f), text: String.Format("Name: {1}, Type: {0}", entity.GetType().Name, entity.DisplayNameText), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));
            }

            // REMOVE COMPONENTS LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(-0.21f, -0.32f), text: "Select components to remove", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            // COMPONENTS REMOVE SELECTION BOX
            if (m_removeComponentsListBox == null)
            {
                m_removeComponentsListBox = new MyGuiControlListbox();
            }
            m_removeComponentsListBox.ClearItems();
            m_removeComponentsListBox.MultiSelect = true;
            m_removeComponentsListBox.Name        = "RemoveComponents";
            List <Type> components;

            if (MyComponentContainerExtension.TryGetEntityComponentTypes(m_entityId, out components))
            {
                foreach (var component in components)
                {
                    MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(text: new StringBuilder(component.Name), userData: component);
                    m_removeComponentsListBox.Add(item);
                }
                m_removeComponentsListBox.VisibleRowsCount = components.Count + 1;
            }
            m_removeComponentsListBox.Position    = new Vector2(-0.21f, 0f);
            m_removeComponentsListBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            m_removeComponentsListBox.ItemSize    = new Vector2(0.38f, 0.036f);
            m_removeComponentsListBox.Size        = new Vector2(0.4f, 0.6f);
            this.Controls.Add(m_removeComponentsListBox);

            // ADD COMPONENTS LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.21f, -0.32f), text: "Select components to add", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            // COMPONENTS ADD SELECTION BOX
            if (m_addComponentsListBox == null)
            {
                m_addComponentsListBox = new MyGuiControlListbox();
            }
            m_addComponentsListBox.ClearItems();
            m_addComponentsListBox.MultiSelect = true;
            m_addComponentsListBox.Name        = "AddComponents";
            components.Clear();

            List <MyDefinitionId> definitions = new List <MyDefinitionId>();

            MyDefinitionManager.Static.GetDefinedEntityComponents(ref definitions);

            foreach (var id in definitions)
            {
                var text = id.ToString();
                if (text.StartsWith("MyObjectBuilder_"))
                {
                    text = text.Remove(0, "MyObectBuilder_".Length + 1);
                }
                MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(text: new StringBuilder(text), userData: id);
                m_addComponentsListBox.Add(item);
            }
            m_addComponentsListBox.VisibleRowsCount = definitions.Count + 1;
            m_addComponentsListBox.Position         = new Vector2(0.21f, 0f);
            m_addComponentsListBox.OriginAlign      = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            m_addComponentsListBox.ItemSize         = new Vector2(0.36f, 0.036f);
            m_addComponentsListBox.Size             = new Vector2(0.4f, 0.6f);
            this.Controls.Add(m_addComponentsListBox);

            m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.35f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm"));
            m_cancelButton  = new MyGuiControlButton(new Vector2(-0.21f, 0.35f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel"));

            this.Controls.Add(m_confirmButton);
            this.Controls.Add(m_cancelButton);

            m_confirmButton.ButtonClicked += confirmButton_OnButtonClick;
            m_cancelButton.ButtonClicked  += cancelButton_OnButtonClick;
        }