static void ShareBlueprintRequest(ref ShareBlueprintMsg msg, MyNetworkClient sender)
 {
     if (Sync.IsServer && msg.SendToId != Sync.MyId)
     {
         Sync.Layer.SendMessage(ref msg, msg.SendToId);
     }
     else
     {
         var itemId = msg.WorkshopId;
         var name   = msg.Name;
         var info   = new MyBlueprintItemInfo(MyBlueprintTypeEnum.SHARED, id: itemId);
         var item   = new MyGuiControlListbox.Item(new StringBuilder(name.ToString()), userData: info, icon: MyGuiConstants.TEXTURE_BLUEPRINTS_ARROW.Normal);
         item.ColorMask = new Vector4(0.7f);
         if (!m_recievedBlueprints.Any(item2 => (item2.UserData as MyBlueprintItemInfo).PublishedItemId == (item.UserData as MyBlueprintItemInfo).PublishedItemId))
         {
             m_recievedBlueprints.Add(item);
             m_blueprintList.Add(item);
             if (sender != null)
             {
                 var notification = new MyHudNotificationDebug(sender.DisplayName + " just shared a blueprint with you.", 2500);
                 MyHud.Notifications.Add(notification);
             }
         }
     }
 }
Beispiel #2
0
 private void FillCurrentList(ICollection <MyGuiControlListbox.Item> content, ICollection <MyGuiControlListbox.Item> selectedItems)
 {
     foreach (MyObjectBuilderType type in this.m_inventoryConstraint.ConstrainedTypes)
     {
         byte num;
         Tuple <MyObjectBuilderType, StringBuilder> tuple;
         if (!CandidateTypesToId.TryGetValue(type, out num))
         {
             continue;
         }
         if (CandidateTypes.TryGetValue(num, out tuple))
         {
             MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(tuple.Item2, null, null, num, null);
             content.Add(item);
         }
     }
     foreach (MyDefinitionId id in this.m_inventoryConstraint.ConstrainedIds)
     {
         MyPhysicalItemDefinition definition;
         if (MyDefinitionManager.Static.TryGetPhysicalItemDefinition(id, out definition))
         {
             m_helperSB.Clear().Append(definition.DisplayNameText);
         }
         else
         {
             m_helperSB.Clear().Append(id.ToString());
         }
         MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(m_helperSB, null, null, id, null);
         content.Add(item);
     }
 }
        public void OnDelete(MyGuiControlButton button)
        {
            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       messageCaption : MyTexts.Get(MySpaceTexts.LoadScreenButtonDelete),
                                       messageText : MyTexts.Get(MySpaceTexts.ProgrammableBlock_DeleteScriptDialogText),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
            {
                if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    Debug.Assert(m_selectedItem != null, "Selected item shouldnt be null");
                    if (m_selectedItem != null)
                    {
                        if (DeleteScript(m_selectedItem.Text.ToString()))
                        {
                            m_renameButton.Enabled  = false;
                            m_deleteButton.Enabled  = false;
                            m_detailsButton.Enabled = false;
                            m_selectedItem          = null;
                        }

                        RefreshBlueprintList();
                    }
                }
            },
                                       canHideOthers: false
                                       ));
        }
Beispiel #4
0
        void OnItemDoubleClick(MyGuiControlListbox list)
        {
            m_selectedItem = list.SelectedItems[0];
            var itemInfo = m_selectedItem.UserData as MyBlueprintItemInfo;

            if (itemInfo.Type == MyBlueprintTypeEnum.SHARED)
            {
                OpenSharedBlueprint(itemInfo);
            }
            else
            {
                if (MySession.Static.SurvivalMode && m_clipboard == Sandbox.Game.Entities.MyCubeBuilder.Static.Clipboard)
                {
                    CloseScreen();
                }
                else
                {
                    var close = CopySelectedItemToClipboard();
                    if (close)
                    {
                        CloseScreen();
                    }
                }
            }
        }
Beispiel #5
0
        public MyGuiDetailScreenLocal(Action <MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreenBase parent, string thumbnailTexture, float textScale) :
            base(false, parent, thumbnailTexture, selectedItem, textScale)
        {
            var prefabPath = Path.Combine(m_localBlueprintFolder, m_blueprintName, "bp.sbc");

            this.callBack = callBack;

            if (File.Exists(prefabPath))
            {
                m_loadedPrefab = LoadPrefab(prefabPath);

                if (m_loadedPrefab == null)
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               buttonType: MyMessageBoxButtonsType.OK,
                                               styleEnum: MyMessageBoxStyleEnum.Error,
                                               messageCaption: new StringBuilder("Error"),
                                               messageText: new StringBuilder("Failed to load the blueprint file.")
                                               ));
                    m_killScreen = true;
                }
                else
                {
                    RecreateControls(true);
                }
            }
            else
            {
                m_killScreen = true;
            }
        }
 private void FillCurrentList(ICollection <MyGuiControlListbox.Item> content, ICollection <MyGuiControlListbox.Item> selectedItems)
 {
     foreach (var type in m_inventoryConstraint.ConstrainedTypes)
     {
         byte b;
         if (!CandidateTypesToId.TryGetValue(type, out b))
         {
             Debug.Assert(false, "type not in reverse dictionary");
             continue;
         }
         Tuple <MyObjectBuilderType, StringBuilder> tuple;
         if (!CandidateTypes.TryGetValue(b, out tuple))
         {
             Debug.Assert(false, "type not in dictionary");
             continue;
         }
         var item = new MyGuiControlListbox.Item(text: tuple.Item2, userData: b);
         content.Add(item);
     }
     foreach (var id in m_inventoryConstraint.ConstrainedIds)
     {
         MyPhysicalItemDefinition physDef;
         if (MyDefinitionManager.Static.TryGetPhysicalItemDefinition(id, out physDef))
         {
             m_helperSB.Clear().Append(physDef.DisplayNameText);
         }
         else
         {
             Debug.Assert(false, "no physical definition for item in list");
             m_helperSB.Clear().Append(id.ToString());
         }
         var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: id);
         content.Add(item);
     }
 }
Beispiel #7
0
 private void UpdateItemAppearance(MyTerminalBlock block, MyGuiControlListbox.Item item)
 {
     item.Text.Clear().Append(block.CustomName);
     if (!block.IsFunctional)
     {
         item.ColorMask = Vector4.One;
         item.Text.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete));
         item.FontOverride = MyFontEnum.Red;
     }
     else if (!block.HasPlayerAccess(m_controller.Identity.IdentityId))
     {
         item.ColorMask = Vector4.One;
         item.Text.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockAccessDenied));
         item.FontOverride = MyFontEnum.Red;
     }
     else if (block.ShowInTerminal == false)
     {
         item.ColorMask    = 0.6f * m_colorHelper.GetGridColor(block.CubeGrid).ToVector4();
         item.FontOverride = null;
     }
     else
     {
         item.ColorMask    = m_colorHelper.GetGridColor(block.CubeGrid).ToVector4();
         item.FontOverride = null;
     }
 }
Beispiel #8
0
        public MyGuiDetailScreenSteam(Action <MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreen parent, string thumbnailTexture, float textScale) :
            base(false, parent, thumbnailTexture, selectedItem, textScale)
        {
            this.callBack = callBack;

            m_publishedItemId = (selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId;

            var prefabPath = Path.Combine(m_workshopBlueprintFolder, m_publishedItemId.ToString() + m_workshopBlueprintSuffix);

            if (File.Exists(prefabPath))
            {
                m_loadedPrefab = LoadWorkshopPrefab(prefabPath, m_publishedItemId);

                Debug.Assert(m_loadedPrefab != null);
                if (m_loadedPrefab == null)
                {
                    m_killScreen = true;
                }
                else
                {
                    var name = m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].DisplayName;
                    if (name.Length > 40)
                    {
                        var newName = name.Substring(0, 40);
                        m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].DisplayName = newName;
                    }
                    RecreateControls(true);
                }
            }
            else
            {
                m_killScreen = true;
            }
        }
 private void FillCandidatesList(ICollection <MyGuiControlListbox.Item> content, ICollection <MyGuiControlListbox.Item> selectedItems)
 {
     //MyObjectBuilderType:
     foreach (var type in CandidateTypes)
     {
         var item = new MyGuiControlListbox.Item(text: (StringBuilder)type.Value.Item2, userData: type.Key);
         content.Add(item);
     }
     //MyDefinitionId
     foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions().OrderBy(x => sorter(x)))
     {
         if (!definition.Public)
         {
             continue;
         }
         var physicalItemDef = definition as MyPhysicalItemDefinition;
         if (physicalItemDef == null || definition.Public == false || physicalItemDef.CanSpawnFromScreen == false)
         {
             continue;
         }
         m_helperSB.Clear().Append(definition.DisplayNameText);
         var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: physicalItemDef.Id);
         content.Add(item);
     }
 }
        void OnItemDoubleClick(MyGuiControlListbox list)
        {
            m_selectedItem = list.SelectedItems[0];
            var itemInfo = m_selectedItem.UserData as MyBlueprintItemInfo;

            OpenSelectedSript();
        }
        void GetBlueprints(string directory, MyBlueprintTypeEnum type)
        {
            if (!Directory.Exists(directory))
            {
                return;
            }
            string[]      folders        = Directory.GetDirectories(directory);
            List <string> fileNames      = new List <string>();
            List <string> blueprintNames = new List <string>();

            foreach (var f in folders)
            {
                fileNames.Add(f + "\\bp.sbc");
                var tokens = f.Split('\\');
                blueprintNames.Add(tokens[tokens.Length - 1]);
            }

            for (int i = 0; i < blueprintNames.Count; i++)
            {
                String name = blueprintNames[i];
                var    info = new MyBlueprintItemInfo(type);
                var    item = new MyGuiControlListbox.Item(text: new StringBuilder(name), toolTip: name, userData: info, icon: MyGuiConstants.TEXTURE_ICON_BLUEPRINTS_LOCAL.Normal);
                m_blueprintList.Add(item);
            }
        }
        void OnSelectItem(MyGuiControlListbox list)
        {
            if (list.SelectedItems.Count == 0)
            {
                return;
            }

            m_selectedItem          = list.SelectedItems[0];
            m_detailsButton.Enabled = true;
            m_renameButton.Enabled  = false;

            var type = (m_selectedItem.UserData as MyBlueprintItemInfo).Type;
            var id   = (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId;

            if (type == MyBlueprintTypeEnum.LOCAL)
            {
                m_deleteButton.Enabled  = true;
                m_replaceButton.Enabled = true;
                m_renameButton.Enabled  = true;
            }
            else if (type == MyBlueprintTypeEnum.STEAM)
            {
                m_deleteButton.Enabled  = false;
                m_replaceButton.Enabled = false;
            }
            else if (type == MyBlueprintTypeEnum.SHARED)
            {
                m_renameButton.Enabled  = false;
                m_detailsButton.Enabled = false;
                m_deleteButton.Enabled  = false;
            }
        }
        void GetLocalScriptNames(bool reload = false)
        {
            if (!Directory.Exists(m_localBlueprintFolder))
            {
                return;
            }
            string[] scriptNames = Directory.GetDirectories(m_localBlueprintFolder);

            foreach (var scriptName in scriptNames)
            {
                string directoryName = Path.GetFileName(scriptName);
                var    info          = new MyScriptItemInfo(MyBlueprintTypeEnum.LOCAL, directoryName);
                var    item          = new MyGuiControlListbox.Item(text: new StringBuilder(directoryName), toolTip: directoryName, userData: info, icon: MyGuiConstants.TEXTURE_ICON_BLUEPRINTS_LOCAL.Normal);
                m_scriptList.Add(item);
            }

            if (m_task.IsComplete && reload)
            {
                GetWorkshopScripts();
            }
            else
            {
                AddWorkshopItemsToList();
            }
        }
Beispiel #14
0
        void OnDelete(MyGuiControlButton button)
        {
            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       messageCaption : new StringBuilder("Delete"),
                                       messageText : new StringBuilder("Are you sure you want to delete this blueprint?"),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
            {
                if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    Debug.Assert(m_selectedItem != null, "Selected item shouldnt be null");
                    if (m_selectedItem != null)
                    {
                        if (DeleteBlueprint(m_selectedItem.Text.ToString()))
                        {
                            m_deleteButton.Enabled     = false;
                            m_detailsButton.Enabled    = false;
                            m_screenshotButton.Enabled = false;
                            m_replaceButton.Enabled    = false;
                            m_selectedItem             = null;
                        }

                        RefreshBlueprintList();
                    }
                }
            }));
        }
Beispiel #15
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 include in entity", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));


            m_replicableEntityCheckBox             = new MyGuiControlCheckbox();
            m_replicableEntityCheckBox.Position    = new Vector2(0f, -0.42f);
            m_replicableEntityCheckBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            this.Controls.Add(m_replicableEntityCheckBox);

            // ENTITY TYPE LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.39f), text: "MyEntityReplicable / MyEntity", font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));


            // ADD COMPONENTS LABEL
            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -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";

            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.0f, 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;
        }
Beispiel #16
0
        void OnReload(MyGuiControlButton button)
        {
            m_selectedItem             = null;
            m_detailsButton.Enabled    = false;
            m_screenshotButton.Enabled = false;

            RefreshAndReloadBlueprintList();
        }
        void OnReload(MyGuiControlButton button)
        {
            m_selectedItem          = null;
            m_renameButton.Enabled  = false;
            m_detailsButton.Enabled = false;

            RefreshAndReloadScriptsList(true);
        }
Beispiel #18
0
 public void FillSelectedListContent(ICollection <MyGuiControlListbox.Item> listBoxContent, ICollection <MyGuiControlListbox.Item> listBoxSelectedItems)
 {
     foreach (var texture in m_selectedTexturesToDraw)
     {
         m_helperSB.Clear().Append(texture.Id.SubtypeName);
         var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: texture.TexturePath);
         listBoxContent.Add(item);
     }
 }
 private static void AddWorkshopItemsToList()
 {
     foreach (var steamItem in m_subscribedItemsList)
     {
         var info = new MyScriptItemInfo(MyBlueprintTypeEnum.STEAM, steamItem.Title, steamItem.SteamIDOwner, steamItem.Description, steamItem);
         var item = new MyGuiControlListbox.Item(text: new StringBuilder(steamItem.Title), toolTip: steamItem.Title, userData: info, icon: MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.Normal);
         m_scriptList.Add(item);
     }
 }
        /// <summary>
        /// Puts all loaded planet definitions into the given listbox.
        /// </summary>
        /// <param name="listBox">Listbox</param>
        private void LoadPlanetDefs(MyGuiControlListbox listBox)
        {
            listBox.Clear();
            var definitions = MyDefinitionManager.Static.GetPlanetsGeneratorsDefinitions();

            foreach (var planet in definitions)
            {
                MyGuiControlListbox.Item i = new MyGuiControlListbox.Item(new StringBuilder(planet.Id.SubtypeId.ToString()), userData: planet);
                listBox.Items.Add(i);
            }
        }
        void OnSelectItem(MyGuiControlListbox list)
        {
            if (list.SelectedItems.Count == 0)
            {
                return;
            }

            m_selectedItem             = list.SelectedItems[0];
            m_detailsButton.Enabled    = true;
            m_screenshotButton.Enabled = true;
            m_replaceButton.Enabled    = m_clipboard.HasCopiedGrids();

            var type = (m_selectedItem.UserData as MyBlueprintItemInfo).Type;
            var id   = (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId;
            var path = "";

            if (type == MyBlueprintTypeEnum.LOCAL)
            {
                path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "thumb.png");
                m_deleteButton.Enabled = true;
            }
            else if (type == MyBlueprintTypeEnum.STEAM)
            {
                path = Path.Combine(m_workshopBlueprintFolder, "temp", id.ToString(), "thumb.png");
                m_screenshotButton.Enabled = false;
                m_replaceButton.Enabled    = false;
                m_deleteButton.Enabled     = false;
            }
            else if (type == MyBlueprintTypeEnum.SHARED)
            {
                m_replaceButton.Enabled    = false;
                m_screenshotButton.Enabled = false;
                m_detailsButton.Enabled    = false;
                m_deleteButton.Enabled     = false;
            }
            else if (type == MyBlueprintTypeEnum.DEFAULT)
            {
                path = Path.Combine(m_defaultBlueprintFolder, m_selectedItem.Text.ToString(), "thumb.png");
                m_replaceButton.Enabled    = false;
                m_screenshotButton.Enabled = false;
                m_deleteButton.Enabled     = false;
            }

            if (File.Exists(path))
            {
                m_selectedImage.SetTexture(path);
            }

            else
            {
                m_selectedImage.BackgroundTexture = null;
            }
        }
Beispiel #22
0
        private MyGuiControlListbox.Item AddBlockToList(MyTerminalBlock block)
        {
            var item = new MyGuiControlListbox.Item(userData: block);

            UpdateItemAppearance(block, item);
            block.CustomNameChanged     += block_CustomNameChanged;
            block.PropertiesChanged     += block_CustomNameChanged;
            block.ShowInTerminalChanged += block_ShowInTerminalChanged;

            m_blockListbox.Add(item);
            return(item);
        }
Beispiel #23
0
        public RotorPicker(IMyTerminalBlock cockpit, string rotorName, ControlRotorParams rotorParams, SetControlRotors onComplete)
        {
            m_block      = cockpit;
            m_onComplete = onComplete;

            IEnumerable <IMyMotorStator> selected;

            rotorParams(out selected, out m_sensitivity, out m_trim);
            m_trim = MathHelper.ToDegrees(m_trim);

            m_listbox              = new MyTerminalControlListbox <MyCockpit>("Arms_RotorPicker", MyStringId.GetOrCompute(rotorName + " Rotors"), MyStringId.NullOrEmpty, true, 14);
            m_listbox.ListContent  = ListContent;
            m_listbox.ItemSelected = ItemSelected;

            m_sensitivitySlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerSensitivity", MyStringId.GetOrCompute("Control Sensitivity"), MyStringId.GetOrCompute("How sensitive the ship will be to input"));
            m_sensitivitySlider.DefaultValue = 1f;
            m_sensitivitySlider.Getter       = b => m_sensitivity;
            m_sensitivitySlider.Setter       = (b, value) => m_sensitivity = value;
            m_sensitivitySlider.SetLogLimits(0.01f, 100f);
            m_sensitivitySlider.Writer = (b, sb) => sb.Append(m_sensitivity);

            m_trimSlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerTrim", MyStringId.GetOrCompute("Trim"), MyStringId.GetOrCompute("Default angle of rotors"));
            m_trimSlider.DefaultValue = 0f;
            m_trimSlider.Getter       = b => m_trim;
            m_trimSlider.Setter       = (b, value) => m_trim = value;
            m_trimSlider.SetLimits(-45f, 45f);
            m_trimSlider.Writer = (b, sb) => {
                sb.Append(m_trim);
                sb.Append('°');
            };

            m_save = new MyTerminalControlButton <MyCockpit>("Arms_RotorPickerSave", MyStringId.GetOrCompute("Save & Exit"), MyStringId.NullOrEmpty, SaveAndExit);

            CubeGridCache cache = CubeGridCache.GetFor(m_block.CubeGrid);

            if (cache == null)
            {
                return;
            }

            foreach (IMyMotorStator stator in cache.BlocksOfType(typeof(MyObjectBuilder_MotorStator)))
            {
                MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(new StringBuilder(stator.DisplayNameText), userData: stator);
                m_allItems.Add(item);
                if (selected.Contains(stator))
                {
                    m_selected.Add(item);
                }
            }

            MyTerminalControls.Static.CustomControlGetter += CustomControlGetter;
            cockpit.RebuildControls();
        }
        private void RefreshFactionList()
        {
            var localFaction = MySession.Static.Factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId);

            if (localFaction != null)
            {
                //Add local player faction first
                m_tempStringBuilder.Clear();
                m_tempStringBuilder.Append(localFaction.Name);

                var chatHistory = MyChatSystem.GetFactionChatHistory(MySession.Static.LocalPlayerId, localFaction.FactionId);
                if (chatHistory != null && chatHistory.UnreadMessageCount > 0)
                {
                    m_tempStringBuilder.Append(" (");
                    m_tempStringBuilder.Append(chatHistory.UnreadMessageCount);
                    m_tempStringBuilder.Append(")");
                }

                var item = new MyGuiControlListbox.Item(text: m_tempStringBuilder, userData: localFaction);
                m_factionList.Add(item);

                m_factionList.SetToolTip(string.Empty);
                foreach (var faction in MySession.Static.Factions)
                {
                    //Don't add local player faction twice
                    if (faction.Value != localFaction && faction.Value.AcceptHumans)
                    {
                        m_tempStringBuilder.Clear();
                        m_tempStringBuilder.Append(faction.Value.Name);

                        chatHistory = MyChatSystem.GetFactionChatHistory(MySession.Static.LocalPlayerId, faction.Value.FactionId);
                        if (chatHistory != null && chatHistory.UnreadMessageCount > 0)
                        {
                            m_tempStringBuilder.Append(" (");
                            m_tempStringBuilder.Append(chatHistory.UnreadMessageCount);
                            m_tempStringBuilder.Append(")");
                        }

                        item = new MyGuiControlListbox.Item(text: m_tempStringBuilder, userData: faction.Value);
                        m_factionList.Add(item);
                    }
                }
            }
            else
            {
                m_factionList.SelectedItems.Clear();
                m_factionList.Items.Clear();

                m_factionList.SetToolTip(MyTexts.GetString(MySpaceTexts.TerminalTab_Chat_NoFaction));
            }
        }
Beispiel #25
0
        private void AddGroupToList(MyBlockGroup group, int?position = null)
        {
            foreach (var it in m_blockListbox.Items)
            {
                if (it.UserData == group)
                {
                    return;
                }
            }
            var item = new MyGuiControlListbox.Item(userData: group);

            item.Text.Clear().Append("*").AppendStringBuilder(group.Name).Append("*");
            m_blockListbox.Add(item, position);
        }
Beispiel #26
0
        public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, string thumbnailTexture, MyGuiControlListbox.Item selectedItem, float textScale)
            : base(new Vector2(0.37f, 0.325f), new Vector2(0.725f, 0.4f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen)
        {
            m_thumbnailImage = new MyGuiControlImage()
            {
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
            };
            m_thumbnailImage.SetPadding(new MyGuiBorderThickness(3f, 2f, 3f, 2f));
            m_thumbnailImage.SetTexture(thumbnailTexture);

            m_selectedItem  = selectedItem;
            m_blueprintName = selectedItem.Text.ToString();
            m_textScale     = textScale;
            m_parent        = parent;
        }
        private void FillGpsList(ICollection <MyGuiControlListbox.Item> gpsItemList, ICollection <MyGuiControlListbox.Item> selectedGpsItemList)
        {
            List <IMyGps> gpsList = new List <IMyGps>();

            MySession.Static.Gpss.GetGpsList(MySession.Static.LocalPlayerId, gpsList);
            foreach (var gps in gpsList)
            {
                var item = new MyGuiControlListbox.Item(text: new StringBuilder(gps.Name), userData: gps);
                gpsItemList.Add(item);

                if (m_selectedGps == gps)
                {
                    selectedGpsItemList.Add(item);
                }
            }
        }
Beispiel #28
0
        public void FillListContent(ICollection <MyGuiControlListbox.Item> listBoxContent, ICollection <MyGuiControlListbox.Item> listBoxSelectedItems)
        {
            string button = MyTexts.GetString(MySpaceTexts.BlockPropertyText_Button);

            for (int i = 0; i < m_buttonsUseObjects.Count; ++i)
            {
                m_helperSB.Clear().Append(button + " " + (i + 1).ToString());
                var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: i);
                listBoxContent.Add(item);

                if (i == m_selectedButton)
                {
                    listBoxSelectedItems.Add(item);
                }
            }
        }
Beispiel #29
0
        private void FillWaypointList(IMyTerminalBlock dontCare, ICollection <MyGuiControlListbox.Item> allItems, ICollection <MyGuiControlListbox.Item> selected)
        {
            List <IMyGps> gpsList = MyAPIGateway.Session.GPS.GetGpsList(MyAPIGateway.Session.Player.IdentityId);
            bool          select  = destination.IsValid();

            foreach (IMyGps gps in gpsList)
            {
                MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(new System.Text.StringBuilder(gps.Name), gps.Description, userData: gps);
                allItems.Add(item);

                if (select && selected.Count == 0 && gps.Coords == destination)
                {
                    selected.Add(item);
                }
            }
        }
 public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, MyGuiCompositeTexture thumbnailTexture, MyGuiControlListbox.Item selectedItem, float textScale)
     : base(new Vector2(0.37f, 0.325f), new Vector2(0.725f, 0.4f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen)
 {
     m_thumbnailImage = new MyGuiControlImageButton(true);
     if (thumbnailTexture == null)
     {
         m_thumbnailImage.Visible = false;
     }
     else
     {
         m_thumbnailImage.BackgroundTexture = thumbnailTexture;
     }
     m_selectedItem  = selectedItem;
     m_blueprintName = selectedItem.Text.ToString();
     m_textScale     = textScale;
     m_parent        = parent;
 }