Пример #1
0
        void list_ItemClicked(MyGuiControlListbox sender)
        {
            if (!Visible)
            {
                return;
            }

            int    selectedIndex = -1;
            object userData      = null;

            foreach (var item in sender.SelectedItems)
            {
                selectedIndex = sender.Items.IndexOf(item);
                userData      = item.UserData;
                break;
            }

            if (ItemClicked != null)
            {
                ItemClicked(this, new EventArgs {
                    ItemIndex = selectedIndex, UserData = userData
                });
            }

            //A context menu always disappears when clicked
            Deactivate();
        }
Пример #2
0
        void list_ItemClicked(MyGuiControlListbox sender)
        {
            if (!Visible)
            {
                return;
            }

            int    selectedIndex = -1;
            object userData      = null;

            foreach (var item in sender.SelectedItems)
            {
                selectedIndex = sender.Items.IndexOf(item);
                userData      = item.UserData;
                break;
            }

            if (ItemClicked != null)
            {
                ItemClicked(this, new EventArgs {
                    ItemIndex = selectedIndex, UserData = userData
                });
            }

            //GK: If the item list have scrollbar and we are over the caret then let scrollbar hanlde input. In any other case disappear when clicked
            if (!m_itemsList.IsOverScrollBar())
            {
                Deactivate();
            }
        }
Пример #3
0
        private void CreateContextMenu()
        {
            m_itemsList = new MyGuiControlListbox(visualStyle: MyGuiControlListboxStyleEnum.ContextMenu);

            //Todo: automatically decide how to draw it given the position
            m_itemsList.HighlightType = MyGuiControlHighlightType.WHEN_CURSOR_OVER;
            m_itemsList.Enabled       = true;
            m_itemsList.ItemClicked  += list_ItemClicked;
            m_itemsList.MultiSelect   = false;
        }
Пример #4
0
        public MyGuiControlContextMenu()
        {
            m_itemsList                  = new MyGuiControlListbox();
            m_itemsList.Name             = "ContextMenuListbox";
            m_itemsList.VisibleRowsCount = NUM_VISIBLE_ITEMS;
            Enabled = false;

            m_keys = new MyContextMenuKeyTimerController[3];
            m_keys[(int)MyContextMenuKeys.UP]    = new MyContextMenuKeyTimerController(MyKeys.Up);
            m_keys[(int)MyContextMenuKeys.DOWN]  = new MyContextMenuKeyTimerController(MyKeys.Down);
            m_keys[(int)MyContextMenuKeys.ENTER] = new MyContextMenuKeyTimerController(MyKeys.Enter);

            Name = "ContextMenu";
            Elements.Add(m_itemsList);
        }
Пример #5
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;
 }
        public MyGuiControlContextMenu()
        {
            m_itemsList = new MyGuiControlListbox();
            m_itemsList.Name = "ContextMenuListbox";
            m_itemsList.VisibleRowsCount = NUM_VISIBLE_ITEMS;
            Enabled = false;

            m_keys = new MyContextMenuKeyTimerController[3];
            m_keys[(int)MyContextMenuKeys.UP] = new MyContextMenuKeyTimerController(MyKeys.Up);
            m_keys[(int)MyContextMenuKeys.DOWN] = new MyContextMenuKeyTimerController(MyKeys.Down);
            m_keys[(int)MyContextMenuKeys.ENTER] = new MyContextMenuKeyTimerController(MyKeys.Enter);

            Name = "ContextMenu";
            Elements.Add(m_itemsList);
        }
Пример #7
0
 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;
 }
        public void Init(IMyGuiControlsParent controlsParent)
        {
            m_playerList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("PlayerListbox");
            m_factionList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("FactionListbox");

            m_chatHistory = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("ChatHistory");
            m_chatbox = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("Chatbox");

            m_playerList.ItemsSelected += m_playerList_ItemsSelected;
            m_playerList.MultiSelect = false;

            m_factionList.ItemsSelected += m_factionList_ItemsSelected;
            m_factionList.MultiSelect = false;

            m_sendButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("SendButton");
            m_sendButton.ButtonClicked += m_sendButton_ButtonClicked;

            m_chatbox.TextChanged += m_chatbox_TextChanged;
            m_chatbox.EnterPressed += m_chatbox_EnterPressed;

            if (MySession.Static.LocalCharacter != null)
            {
                MySession.Static.ChatSystem.PlayerMessageReceived += MyChatSystem_PlayerMessageReceived;
                MySession.Static.ChatSystem.FactionMessageReceived += MyChatSystem_FactionMessageReceived;
                MySession.Static.ChatSystem.GlobalMessageReceived += MyChatSystem_GlobalMessageReceived;

                MySession.Static.ChatSystem.FactionHistoryDeleted += ChatSystem_FactionHistoryDeleted;
                MySession.Static.ChatSystem.PlayerHistoryDeleted += ChatSystem_PlayerHistoryDeleted;
            }

            MySession.Static.Players.PlayersChanged += Players_PlayersChanged;
            
            RefreshLists();

            m_chatbox.SetText(m_emptyText);
            m_sendButton.Enabled = false;

            if (MyMultiplayer.Static != null)
            {
                MyMultiplayer.Static.ChatMessageReceived += Multiplayer_ChatMessageReceived;
            }


            m_closed = false;
        }
Пример #9
0
        void OnMouseOverItem(MyGuiControlListbox listBox)
        {
            var item = listBox.MouseOverItem;
            var path = "";
            if (item != null)
            {
                if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
                {
                    path = Path.Combine(m_localBlueprintFolder, item.Text.ToString(), "thumb.png");
                    
                }
                else if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
                {
                    var id = (item.UserData as MyBlueprintItemInfo).PublishedItemId;
                    if (id != null)
                    {
                        path = Path.Combine(m_workshopBlueprintFolder, "temp", id.ToString(), "thumb.png");
                    }
                }
                else if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.DEFAULT)
                {
                    path = Path.Combine(m_defaultBlueprintFolder, item.Text.ToString(), "thumb.png");
                }

                if (File.Exists(path))
                {
                    m_thumbnailImage.SetTexture(path);
                    if (!m_activeDetail)
                    {
                        if (m_thumbnailImage.BackgroundTexture != null)
                        {
                            m_thumbnailImage.Visible = true;
                        }
                    }
                }
                else
                {
                    m_thumbnailImage.Visible = false;
                    m_thumbnailImage.BackgroundTexture = null;
                }
            }
            else
            {
                m_thumbnailImage.Visible = false;
            }
        }
        void list_ItemClicked(MyGuiControlListbox sender)
        {
            if (!Visible)
                return;

            int selectedIndex = -1;
            object userData = null;
            foreach (var item in sender.SelectedItems)
            {
                selectedIndex = sender.Items.IndexOf(item);
                userData = item.UserData;
                break;
            }

            if (ItemClicked != null)
                ItemClicked(this, new EventArgs { ItemIndex = selectedIndex, UserData = userData });

            //GK: If the item list have scrollbar and we are over the caret then let scrollbar hanlde input. In any other case disappear when clicked
            if(!m_itemsList.IsOverScrollBar())
                Deactivate();
        }
        void list_ItemClicked(MyGuiControlListbox sender)
        {
            if (!Visible)
                return;

            int selectedIndex = -1;
            object userData = null;
            foreach (var item in sender.SelectedItems)
            {
                selectedIndex = sender.Items.IndexOf(item);
                userData = item.UserData;
                break;
            }

            if (ItemClicked != null)
                ItemClicked(this, new EventArgs { ItemIndex = selectedIndex, UserData = userData });

            //A context menu always disappears when clicked
            Deactivate();
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f;
            Vector2 controlPadding = new Vector2(0.02f, 0);

            // Position the Caption
            var caption = AddCaption("Scripting Tools", Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop));
            m_currentPosition.Y = caption.PositionY + caption.Size.Y + ITEM_VERTICAL_PADDING;

            // Position all the controls under the caption
            // Debug draw checkbox
            PositionControls(new MyGuiControlBase[]
            {
                CreateLabel("Debug Draw"), 
                CreateCheckbox(DebugDrawCheckedChanged, MyDebugDrawSettings.ENABLE_DEBUG_DRAW)
            });
            // Selected entity controls
            m_selectedEntityNameBox = CreateTextbox("");
            PositionControls(new MyGuiControlBase[]
            {
                CreateLabel("Selected Entity: "), 
                m_selectedEntityNameBox, 
                CreateButton("Rename", RenameSelectedEntityOnClick)
            });
            m_selectedFunctionalBlockNameBox = CreateTextbox("");
            PositionControls(new MyGuiControlBase[]
            {
                CreateLabel("Selected Block: "), 
                m_selectedFunctionalBlockNameBox, 
                CreateButton("Rename", RenameFunctionalBlockOnClick)
            });
            // Spawn entity button
            PositionControls(new MyGuiControlBase[]
            {
                CreateButton("Spawn Entity", SpawnEntityClicked), 
                CreateButton("Delete Entity", DeleteEntityOnClicked)
            });

            // Trigger section
            PositionControl(CreateLabel("Triggers"));

            // Attach new trigger
            PositionControl(CreateButton("Attach to selected entity", AttachTriggerOnClick));

            m_enlargeTriggerButton = CreateButton("+", EnlargeTriggerOnClick);
            m_shrinkTriggerButton = CreateButton("-", ShrinkTriggerOnClick);
            m_setTriggerSizeButton = CreateButton("Size", SetSizeOnClick);

            // Enlarge, Set size, Shrink
            PositionControls(new MyGuiControlBase[]
            {
                m_enlargeTriggerButton, 
                m_setTriggerSizeButton, 
                m_shrinkTriggerButton
            });

            // Snap, Select, Delete
            PositionControls(new MyGuiControlBase[]
                {
                    CreateButton("Snap", SnapTriggerToCameraOrEntityOnClick),
                    CreateButton("Select", SelectTriggerOnClick),
                    CreateButton("Delete", DeleteTriggerOnClick)
                }
            );

            // Selected trigger section
            m_selectedTriggerNameBox = CreateTextbox("Trigger not selected");
            PositionControls(new MyGuiControlBase[] {CreateLabel("Selected Trigger:"), m_selectedTriggerNameBox});

            // Listbox for queried triggers
            m_triggersListBox = CreateListBox();
            m_triggersListBox.Size = new Vector2(0f, 0.06f);
            m_triggersListBox.ItemDoubleClicked += TriggersListBoxOnItemDoubleClicked;
            PositionControl(m_triggersListBox);
            // Because something is reseting the value
            m_triggersListBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);

            // Running Level Scripts
            PositionControl(CreateLabel("Running Level Scripts"));
            m_levelScriptListBox = CreateListBox();
            m_levelScriptListBox.Size = new Vector2(0f, 0.06f);
            PositionControl(m_levelScriptListBox);
            // Because something is reseting the value
            m_triggersListBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);

            // Fill with levelscripts -- they wont change during the process
            if (m_scriptManager.RunningLevelScriptNames != null)
            {
                foreach (var runningLevelScriptName in m_scriptManager.RunningLevelScriptNames)
                {
                    // user data are there to tell if the script already failed or not
                    m_levelScriptListBox.Add(new MyGuiControlListbox.Item(new StringBuilder(runningLevelScriptName),
                        userData: false));
                }
            }

            // Running State machines
            PositionControl(CreateLabel("Running state machines"));
            m_smListBox = CreateListBox();
            m_smListBox.Size = new Vector2(0f, 0.06f);
            PositionControl(m_smListBox);
            // Because something is reseting the value
            m_smListBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);

            // Activate transfomation system
            m_transformSys.Active = true;
        }
        void m_playerList_ItemsSelected(MyGuiControlListbox obj)
        {
            if (m_playerList.SelectedItems.Count > 0)
            {
                var selectedItem = m_playerList.SelectedItems[0];

                if ( selectedItem == m_globalItem )
                {
                    RefreshGlobalChatHistory();
                }
                else if(selectedItem==m_broadcastItem)
                {
                    RefreshBroadcastChatHistory();

                    MyChatHistory chatHistory;
                    if (MySession.Static.ChatHistory.TryGetValue(MySession.Static.LocalPlayerId, out chatHistory) && chatHistory.GlobalChatHistory.UnreadMessageCount > 0)
                    {
                        chatHistory.GlobalChatHistory.UnreadMessageCount = 0;
                        UpdatePlayerList();
                    }
                }
                else
                {
                    var playerIdentity = (MyIdentity)selectedItem.UserData;
                    RefreshPlayerChatHistory(playerIdentity);

                    var playerChatHistory = MyChatSystem.GetPlayerChatHistory(MySession.Static.LocalPlayerId, playerIdentity.IdentityId);
                    if (playerChatHistory != null && playerChatHistory.UnreadMessageCount > 0)
                    {
                        playerChatHistory.UnreadMessageCount = 0;
                        UpdatePlayerList();
                    }
                }
                m_chatbox.SetText(m_emptyText);
            }
        }
 void OnItemDoubleClick(MyGuiControlListbox list)
 {
     m_selectedItem = list.SelectedItems[0];
     Ok();        
 }
        void OnMouseOverItem(MyGuiControlListbox listBox)
        {
            var item = listBox.MouseOverItem;
            var path = "";
            if (item != null)
            {
                MyBlueprintItemInfo blueprintInfo = (item.UserData as MyBlueprintItemInfo);
                if (blueprintInfo.Type == MyBlueprintTypeEnum.LOCAL)
                {
                    path = Path.Combine(m_localBlueprintFolder, item.Text.ToString(), "thumb.png");               
                }
                else if (blueprintInfo.Type == MyBlueprintTypeEnum.STEAM)
                {
                    var id = blueprintInfo.PublishedItemId;
                    if (id != null)
                    {
                        path = Path.Combine(TEMP_PATH, id.ToString(), "thumb.png");
                        if (blueprintInfo.Item != null)
                        {
                            bool isQueued = m_downloadQueued.Contains(blueprintInfo.Item.PublishedFileId);
                            bool isDownloaded = m_downloadFinished.Contains(blueprintInfo.Item.PublishedFileId);
                            MySteamWorkshop.SubscribedItem worshopData = blueprintInfo.Item;
                            if (isDownloaded && IsExtracted(worshopData) == false)
                            {
                                m_blueprintList.Enabled = false;
                                m_okButton.Enabled = false;
                                ExtractWorkshopItem(worshopData);
                                m_blueprintList.Enabled = true;
                                m_okButton.Enabled = true;
                            }
                            if (isQueued == false && isDownloaded == false)
                            {
                                m_blueprintList.Enabled = false;
                                m_okButton.Enabled = false;
                                m_downloadQueued.Add(blueprintInfo.Item.PublishedFileId);

                                Task = Parallel.Start(() =>
                                {
                                    DownloadBlueprintFromSteam(worshopData);
                                }, () => { OnBlueprintDownloadedThumbnail(worshopData); });
                            }
                        }
                    }
                }
                else if (blueprintInfo.Type == MyBlueprintTypeEnum.DEFAULT)
                {
                    path = Path.Combine(m_defaultBlueprintFolder, item.Text.ToString(), "thumb.png");
                }

                if (File.Exists(path))
                {
                    m_thumbnailImage.SetTexture(path);
                    if (!m_activeDetail)
                    {
                        if (m_thumbnailImage.BackgroundTexture != null)
                        {
                            m_thumbnailImage.Visible = true;
                        }
                    }
                }
                else
                {
                    m_thumbnailImage.Visible = false;
                    m_thumbnailImage.BackgroundTexture = null;
                }
            }
            else
            {
                m_thumbnailImage.Visible = false;
            }
        }
 void OnItemDoubleClick(MyGuiControlListbox list)
 {
     m_selectedItem = list.SelectedItems[0];
     var itemInfo = m_selectedItem.UserData as MyBlueprintItemInfo;
     OpenSelectedSript();
 }
        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;
            }
        }
        private void CreateContextMenu()
        {
            m_itemsList = new MyGuiControlListbox(visualStyle: MyGuiControlListboxStyleEnum.ContextMenu);

            //Todo: automatically decide how to draw it given the position
            m_itemsList.HighlightType = MyGuiControlHighlightType.WHEN_CURSOR_OVER;
            m_itemsList.Enabled = true;
            m_itemsList.ItemClicked += list_ItemClicked;
            m_itemsList.MultiSelect = false;

        }
Пример #19
0
        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;
            }
        }
Пример #20
0
        private void CreateControlPanelPageControls(MyGuiControlTabPage page)
        {
            page.Name      = "PageControlPanel";
            page.TextEnum  = MySpaceTexts.ControlPanel;
            page.TextScale = 0.9f;

            var functionalBlockSearch = new MyGuiControlTextbox()
            {
                Position = new Vector2(-0.4625f, -0.325f),
                Size = new Vector2(0.255f, 0.052f),
                Name = "FunctionalBlockSearch",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
            };

            var functionalBlockSearchClear = new MyGuiControlButton()
            {
                Position = new Vector2(-0.232f, -0.325f),
                Size = new Vector2(0.045f, 0.05666667f),
                Name = "FunctionalBlockSearchClear",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisualStyle = MyGuiControlButtonStyleEnum.Close,
                ActivateOnMouseRelease = true
            };

            var functionalBlockListbox = new MyGuiControlListbox()
            {
                Position = new Vector2(-0.4625f, 0.0225f),
                Size = new Vector2(0.29f, 0.5f),
                Name = "FunctionalBlockListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisibleRowsCount = 16
            };

            var control = new MyGuiControlCompositePanel()
            {
                Position = new Vector2(-0.1525f, 0f),
                Size = new Vector2(0.615f, 0.7125f),
                Name = "Control",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                InnerHeight = 0.685f
            };

            var selectedBlockNamePanel = new MyGuiControlPanel()
            {
                Position = new Vector2(-0.1425f, -0.32f),
                Size = new Vector2(0.595f, 0.035f),
                Name = "SelectedBlockNamePanel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK
            };

            var blockNameLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(-0.1325f, -0.322f),
                Size = new Vector2(0.0470270254f, 0.0266666654f),
                Name = "BlockNameLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.Afterburner
            };

            var groupTitleLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(0.17f, -0.27f),
                Size = new Vector2(0.0470270254f, 0.0266666654f),
                Name = "GroupTitleLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.Terminal_GroupTitle
            };

            var groupName = new MyGuiControlTextbox()
            {
                Position = new Vector2(0.165f, -0.23f),
                Size = new Vector2(0.29f, 0.052f),
                Name = "GroupName",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
            };

            var groupSave = new MyGuiControlButton()
            {
                Position = new Vector2(0.2f, -0.17f),
                Name = "GroupSave",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.TerminalButton_GroupSave
            };

            var groupDelete = new MyGuiControlButton()
            {
                Position = new Vector2(0.4f, -0.17f),
                Size = new Vector2(0.045f, 0.05666667f),
                Name = "GroupDelete",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisualStyle = MyGuiControlButtonStyleEnum.Close
            };


            var showAll = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.SquareSmall,
                position: new Vector2(-0.205f, -0.345f),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                buttonScale:0.5f)
                {
                    Name = "ShowAll",
                };

                 
            page.Controls.Add(functionalBlockSearch);
            page.Controls.Add(functionalBlockSearchClear);
            page.Controls.Add(functionalBlockListbox);
            page.Controls.Add(control);
            page.Controls.Add(selectedBlockNamePanel);
            page.Controls.Add(blockNameLabel);
            page.Controls.Add(groupTitleLabel);
            page.Controls.Add(groupName);
            page.Controls.Add(groupSave);
            page.Controls.Add(showAll);
            page.Controls.Add(groupDelete);
        }
Пример #21
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();
                    }
                }
            }
        }
        private void TriggersListBoxOnItemDoubleClicked(MyGuiControlListbox listBox)
        {
            if (listBox.SelectedItems.Count == 0) return;

            // Set the selected trigger to the selected one
            var item = listBox.SelectedItems[0];
            var trigger = (MyAreaTriggerComponent) item.UserData;

            m_triggerManipulator.SelectedTrigger = trigger;
            // Reset the GUI data
            if (m_triggerManipulator.SelectedTrigger != null)
            {
                var areaTrigger = (MyAreaTriggerComponent) m_triggerManipulator.SelectedTrigger;

                // Set textbox Text ... not the easy way....
                m_helperStringBuilder.Clear();
                m_helperStringBuilder.Append(areaTrigger.Name);
                m_selectedTriggerNameBox.SetText(m_helperStringBuilder);
            }
        }
        void m_factionList_ItemsSelected(MyGuiControlListbox obj)
        {
            if (m_factionList.SelectedItems.Count > 0)
            {
                var selectedItem = m_factionList.SelectedItems[0];
                var faction = (MyFaction)selectedItem.UserData;
                RefreshFactionChatHistory(faction);

                var factions = MySession.Static.Factions;
                var localFaction = factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId);
                if (localFaction != null)
                {
                    MyFactionChatHistory factionChat = MyChatSystem.FindFactionChatHistory(faction.FactionId, localFaction.FactionId);
                    if (factionChat != null)
                    {
                        factionChat.UnreadMessageCount = 0;
                        UpdateFactionList(true);
                    }
                }

                m_chatbox.SetText(m_emptyText);
            }
        }
 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;
     }
 }
Пример #25
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyRemoteControl>())
                return;
            base.CreateTerminalControls();
            var controlBtn = new MyTerminalControlButton<MyRemoteControl>("Control", MySpaceTexts.ControlRemote, MySpaceTexts.Blank, (b) => b.RequestControl());
            controlBtn.Enabled = r => r.CanControl();
            controlBtn.SupportsMultipleBlocks = false;
            var action = controlBtn.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(controlBtn);

            
            var autoPilotSeparator = new MyTerminalControlSeparator<MyRemoteControl>();
            MyTerminalControlFactory.AddControl(autoPilotSeparator);

            var autoPilot = new MyTerminalControlOnOffSwitch<MyRemoteControl>("AutoPilot", MySpaceTexts.BlockPropertyTitle_AutoPilot, MySpaceTexts.Blank);
            autoPilot.Getter = (x) => x.m_autoPilotEnabled;
            autoPilot.Setter = (x, v) => x.SetAutoPilotEnabled(v);
            autoPilot.Enabled = r => r.CanEnableAutoPilot();
            autoPilot.EnableToggleAction();
            autoPilot.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(autoPilot);

            var collisionAv = new MyTerminalControlOnOffSwitch<MyRemoteControl>("CollisionAvoidance", MySpaceTexts.BlockPropertyTitle_CollisionAvoidance, MySpaceTexts.Blank);
            collisionAv.Getter = (x) => x.m_useCollisionAvoidance;
            collisionAv.Setter = (x, v) => x.SetCollisionAvoidance(v);
            collisionAv.Enabled = r => true;
            collisionAv.EnableToggleAction();
            collisionAv.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(collisionAv);

            var dockignMode = new MyTerminalControlOnOffSwitch<MyRemoteControl>("DockingMode", MySpaceTexts.BlockPropertyTitle_EnableDockingMode, MySpaceTexts.Blank);
            dockignMode.Getter = (x) => x.m_dockingModeEnabled;
            dockignMode.Setter = (x, v) => x.SetDockingMode(v);
            dockignMode.Enabled = r => r.IsWorking;
            dockignMode.EnableToggleAction();
            dockignMode.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(dockignMode);

            var cameraList = new MyTerminalControlCombobox<MyRemoteControl>("CameraList", MySpaceTexts.BlockPropertyTitle_AssignedCamera, MySpaceTexts.Blank);
            cameraList.ComboBoxContentWithBlock = (x, list) => x.FillCameraComboBoxContent(list);
            cameraList.Getter = (x) => (long)x.m_bindedCamera;
            cameraList.Setter = (x, y) => x.m_bindedCamera.Value = y;
            MyTerminalControlFactory.AddControl(cameraList);
            m_cameraList = cameraList;

            var flightMode = new MyTerminalControlCombobox<MyRemoteControl>("FlightMode", MySpaceTexts.BlockPropertyTitle_FlightMode, MySpaceTexts.Blank);
            flightMode.ComboBoxContent = (x) => FillFlightModeCombo(x);
            flightMode.Getter = (x) => (long)x.m_currentFlightMode.Value;
            flightMode.Setter = (x, v) => x.ChangeFlightMode((FlightMode)v);
            flightMode.SetSerializerRange((int)MyEnum<FlightMode>.Range.Min, (int)MyEnum<FlightMode>.Range.Max);
            MyTerminalControlFactory.AddControl(flightMode);

            var directionCombo = new MyTerminalControlCombobox<MyRemoteControl>("Direction", MySpaceTexts.BlockPropertyTitle_ForwardDirection, MySpaceTexts.Blank);
            directionCombo.ComboBoxContent = (x) => FillDirectionCombo(x);
            directionCombo.Getter = (x) => (long)x.m_currentDirection.Value;
            directionCombo.Setter = (x, v) => x.ChangeDirection((Base6Directions.Direction)v);
            MyTerminalControlFactory.AddControl(directionCombo);

            if (MyFakes.ENABLE_VR_REMOTE_BLOCK_AUTOPILOT_SPEED_LIMIT)
            {
                var sliderSpeedLimit = new MyTerminalControlSlider<MyRemoteControl>("SpeedLimit", MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit,
                    MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit);
                sliderSpeedLimit.SetLimits(1, 200);
                sliderSpeedLimit.DefaultValue = MyObjectBuilder_RemoteControl.DEFAULT_AUTOPILOT_SPEED_LIMIT;
                sliderSpeedLimit.Getter = (x) => x.m_autopilotSpeedLimit;
                sliderSpeedLimit.Setter = (x, v) => x.m_autopilotSpeedLimit.Value = v;
                sliderSpeedLimit.Writer = (x, sb) => sb.Append(MyValueFormatter.GetFormatedFloat(x.m_autopilotSpeedLimit, 0));
                sliderSpeedLimit.EnableActions();
                MyTerminalControlFactory.AddControl(sliderSpeedLimit);
            }

            var waypointList = new MyTerminalControlListbox<MyRemoteControl>("WaypointList", MySpaceTexts.BlockPropertyTitle_Waypoints, MySpaceTexts.Blank, true);
            waypointList.ListContent = (x, list1, list2) => x.FillWaypointList(list1, list2);
            waypointList.ItemSelected = (x, y) => x.SelectWaypoint(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_waypointGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)waypointList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(waypointList);


            var toolbarButton = new MyTerminalControlButton<MyRemoteControl>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_AutoPilotToolbarOpen, MySpaceTexts.BlockPropertyPopup_AutoPilotToolbarOpen,
                delegate(MyRemoteControl self)
                {
                    var actions = self.m_selectedWaypoints[0].Actions;
                    if (actions != null)
                    {
                        for (int i = 0; i < actions.Length; i++)
                        {
                            if (actions[i] != null)
                            {
                                self.m_actionToolbar.SetItemAtIndex(i, actions[i]);
                            }
                        }
                    }

                    self.m_actionToolbar.ItemChanged += self.Toolbar_ItemChanged;
                    if (MyGuiScreenCubeBuilder.Static == null)
                    {
                        MyToolbarComponent.CurrentToolbar = self.m_actionToolbar;
                        MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                        MyToolbarComponent.AutoUpdate = false;
                        screen.Closed += (source) =>
                        {
                            MyToolbarComponent.AutoUpdate = true;
                            self.m_actionToolbar.ItemChanged -= self.Toolbar_ItemChanged;
                            self.m_actionToolbar.Clear();
                        };
                        MyGuiSandbox.AddScreen(screen);
                    }
                });
            toolbarButton.Enabled = r => r.m_selectedWaypoints.Count == 1;
            toolbarButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(toolbarButton);

            var removeBtn = new MyTerminalControlButton<MyRemoteControl>("RemoveWaypoint", MySpaceTexts.BlockActionTitle_RemoveWaypoint, MySpaceTexts.Blank, (b) => b.RemoveWaypoints());
            removeBtn.Enabled = r => r.CanRemoveWaypoints();
            removeBtn.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(removeBtn);

            var moveUp = new MyTerminalControlButton<MyRemoteControl>("MoveUp", MySpaceTexts.BlockActionTitle_MoveWaypointUp, MySpaceTexts.Blank, (b) => b.MoveWaypointsUp());
            moveUp.Enabled = r => r.CanMoveWaypointsUp();
            moveUp.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveUp);

            var moveDown = new MyTerminalControlButton<MyRemoteControl>("MoveDown", MySpaceTexts.BlockActionTitle_MoveWaypointDown, MySpaceTexts.Blank, (b) => b.MoveWaypointsDown());
            moveDown.Enabled = r => r.CanMoveWaypointsDown();
            moveDown.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveDown);

            var addButton = new MyTerminalControlButton<MyRemoteControl>("AddWaypoint", MySpaceTexts.BlockActionTitle_AddWaypoint, MySpaceTexts.Blank, (b) => b.AddWaypoints());
            addButton.Enabled = r => r.CanAddWaypoints();
            addButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(addButton);

            var gpsList = new MyTerminalControlListbox<MyRemoteControl>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);
            gpsList.ListContent = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_gpsGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)gpsList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(gpsList);

            foreach (var direction in m_directionNames)
            {
                var setDirectionAction = new MyTerminalAction<MyRemoteControl>(MyTexts.Get(direction.Value).ToString(), MyTexts.Get(direction.Value), OnAction, null, MyTerminalActionIcons.TOGGLE);
                setDirectionAction.Enabled = (b) => b.IsWorking;
                setDirectionAction.ParameterDefinitions.Add(TerminalActionParameter.Get((byte)direction.Key));
                MyTerminalControlFactory.AddAction(setDirectionAction);
            }

            var resetButton = new MyTerminalControlButton<MyRemoteControl>("Reset", MySpaceTexts.BlockActionTitle_WaypointReset, MySpaceTexts.BlockActionTooltip_WaypointReset, (b) => b.ResetWaypoint());
            resetButton.Enabled = r => r.IsWorking;
            resetButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(resetButton);

            var copyButton = new MyTerminalControlButton<MyRemoteControl>("Copy", MySpaceTexts.BlockActionTitle_RemoteCopy, MySpaceTexts.Blank, (b) => b.CopyAutopilotSetup());
            copyButton.Enabled = r => r.IsWorking;
            copyButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(copyButton);

            var pasteButton = new MyTerminalControlButton<MyRemoteControl>("Paste", MySpaceTexts.BlockActionTitle_RemotePaste, MySpaceTexts.Blank, (b) => b.PasteAutopilotSetup());
            pasteButton.Enabled = r => r.IsWorking && MyRemoteControl.m_clipboard != null;
            pasteButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(pasteButton);
        }
        private void blockListbox_ItemSelected(MyGuiControlListbox sender)
        {
            Debug.Assert(sender == m_blockListbox);
            m_oldGroups.Clear();
            m_oldGroups.AddList(m_currentGroups);
            m_currentGroups.Clear();
            m_tmpGroup.Blocks.Clear();

            foreach (var item in sender.SelectedItems)
            {
                if (item.UserData is MyBlockGroup)
                    m_currentGroups.Add((MyBlockGroup)item.UserData);
                else if (item.UserData is MyTerminalBlock)
                {
                    CurrentBlocks.Add(item.UserData as MyTerminalBlock);
                }
                else
                    Debug.Fail("Terminal list must contain only Functional blocks and groups.");
            }
            for (int i = 0; i < m_currentGroups.Count; i++)
            {
                if (m_oldGroups.Contains(m_currentGroups[i]) && m_currentGroups[i].Blocks.Intersect(CurrentBlocks).Count() != 0)
                    continue;
                foreach (var b in m_currentGroups[i].Blocks)
                {
                    if (!CurrentBlocks.Contains(b))
                        CurrentBlocks.Add(b);
                }
            }
            SelectBlocks();
        }
Пример #27
0
        private void CreateChatPageControls(MyGuiControlTabPage chatPage)
        {
            chatPage.Name = "PageComms";
            chatPage.TextEnum = MySpaceTexts.TerminalTab_Chat;

            float left = -0.4625f;
            float right = -left;
            
            float top = -0.34f;

            int rowCount = 11;

            float width = 0.35f;
            //defined based on row count
            float height = 0;

            float margin = 0.02f;

            var playerLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(left, top),
                Name = "PlayerLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text = MyTexts.GetString(MyCommonTexts.ScreenCaptionPlayers)
            };
            chatPage.Controls.Add(playerLabel);

            top += playerLabel.GetTextSize().Y + 0.01f;

            var playerList = new MyGuiControlListbox()
            {
                Position = new Vector2(left, top),
                Size = new Vector2(width, 0f),
                Name = "PlayerListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                VisibleRowsCount = rowCount
            };
            chatPage.Controls.Add(playerList);

            height = playerList.ItemSize.Y * rowCount;
            top += height + margin;
            rowCount = 4;

            var factionLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(left, top),
                Name = "PlayerLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text = MyTexts.GetString(MyCommonTexts.Factions)
            };
            chatPage.Controls.Add(factionLabel);

            top += playerLabel.GetTextSize().Y + 0.01f;

            var factionsList = new MyGuiControlListbox()
            {
                Position = new Vector2(left, top),
                Size = new Vector2(width, 0f),
                Name = "FactionListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                VisibleRowsCount = rowCount
            };
            chatPage.Controls.Add(factionsList);

            top = -0.34f;
            width = 0.6f;
            height = 0.515f;
            margin = 0.038f;

            var chatboxPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                Position = new Vector2(right, top),
                Size = new Vector2(width, height),
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_NEUTRAL,
            };

            chatPage.Controls.Add(chatboxPanel);

            var chatHistory = new MyGuiControlMultilineText(
                position: new Vector2(right, top + 0.005f),
                size: new Vector2(width - 0.01f, height - 0.01f),
                backgroundColor: null,
                font: MyFontEnum.Blue,
                textScale: 0.95f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                contents: null);
            chatHistory.Name = "ChatHistory";
            chatHistory.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            chatHistory.TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            chatPage.Controls.Add(chatHistory);

            top += height + margin;
            height = 0.05f;
            var chatbox = new MyGuiControlTextbox()
            {
                Position = new Vector2(right, top),
                Size = new Vector2(width, height),
                Name = "Chatbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER
            };

            chatPage.Controls.Add(chatbox);

            width = 0.75f;
            top += height + margin;
            height = 0.05f;
            var sendButton = new MyGuiControlButton()
            {
                Position = new Vector2(right, top),
                Text = "Send",
                Name = "SendButton",
                Size = new Vector2(width, height),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
            };

            chatPage.Controls.Add(sendButton);
        }
        private MyGuiControlListbox CreateListBox()
        {
            var listBox = new MyGuiControlListbox(visualStyle: MyGuiControlListboxStyleEnum.Blueprints)
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Size = new Vector2(1f, BUTTON_SIZE.Y * 4) // Just about the size of 4 entries, nothing accurate
            };
            listBox.MultiSelect = false;
            listBox.Enabled = true;
            listBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);
            listBox.VisibleRowsCount = 5;

            Controls.Add(listBox);

            return listBox;
        }
        public void Close()
        {
            if (m_terminalSystem != null)
            {
                if (m_blockListbox != null)
                {
                    ClearBlockList();
                    m_blockListbox.ItemsSelected -= blockListbox_ItemSelected;
                }

                m_terminalSystem.BlockAdded -= TerminalSystem_BlockAdded;
                m_terminalSystem.BlockRemoved -= TerminalSystem_BlockRemoved;
                m_terminalSystem.GroupAdded -= TerminalSystem_GroupAdded;
                m_terminalSystem.GroupRemoved -= TerminalSystem_GroupRemoved;
            }

            if (m_tmpGroup != null)
            {
                m_tmpGroup.Blocks.Clear();
            }

            m_controlsParent = null;
            m_blockListbox = null;
            m_blockNameLabel = null;
            m_terminalSystem = null;
            m_currentGroups.Clear();
        }
Пример #30
0
 protected void CallResultCallback(MyGuiControlListbox.Item val)
 {
     callBack(val);
 }
        public void Init(IMyGuiControlsParent controlsParent, MyPlayer controller, MyCubeGrid grid, MyTerminalBlock currentBlock, MyGridColorHelper colorHelper)
        {
            m_controlsParent = controlsParent;
            m_controller = controller;
            m_colorHelper = colorHelper;

            if (grid == null)
            {
                foreach (var control in controlsParent.Controls)
                    control.Visible = false;

                var label = MyGuiScreenTerminal.CreateErrorLabel(MySpaceTexts.ScreenTerminalError_ShipNotConnected, "ErrorMessage");
                controlsParent.Controls.Add(label);
                return;
            }

            m_terminalSystem = grid.GridSystems.TerminalSystem;
            m_tmpGroup = new MyBlockGroup(grid);

            m_blockSearch = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearch");
            m_blockSearch.TextChanged += blockSearch_TextChanged;
            m_blockSearchClear = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearchClear");
            m_blockSearchClear.ButtonClicked += blockSearchClear_ButtonClicked;
            m_blockListbox = (MyGuiControlListbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockListbox");
            m_blockNameLabel = (MyGuiControlLabel)m_controlsParent.Controls.GetControlByName("BlockNameLabel");
            m_blockNameLabel.Text = "";
            m_groupName = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("GroupName");
            m_groupName.TextChanged += m_groupName_TextChanged;

            m_showAll = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("ShowAll");
            m_showAll.Selected = m_showAllTerminalBlocks;
            m_showAll.ButtonClicked += showAll_Clicked;
            m_showAll.SetToolTip(MySpaceTexts.Terminal_ShowAllInTerminal);
            m_showAll.IconRotation = 0f;
            m_showAll.Icon = new MyGuiHighlightTexture
                {
                    Normal = @"Textures\GUI\Controls\button_hide.dds",
                    Highlight = @"Textures\GUI\Controls\button_unhide.dds",
                    SizePx = new Vector2(40f, 40f),
                };
            m_showAll.Size = new Vector2(0, 0);

            m_showAll.HighlightType = MyGuiControlHighlightType.FORCED;
            m_showAll.IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            m_groupSave = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupSave");
            m_groupSave.TextEnum = MySpaceTexts.TerminalButton_GroupSave;
            m_groupSave.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            m_groupSave.ButtonClicked += groupSave_ButtonClicked;
            m_groupDelete = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupDelete");
            m_groupDelete.ButtonClicked += groupDelete_ButtonClicked;
            m_groupDelete.Enabled = false;

            m_blockListbox.ItemsSelected += blockListbox_ItemSelected;

            RefreshBlockList();

            m_terminalSystem.BlockAdded += TerminalSystem_BlockAdded;
            m_terminalSystem.BlockRemoved += TerminalSystem_BlockRemoved;
            m_terminalSystem.GroupAdded += TerminalSystem_GroupAdded;
            m_terminalSystem.GroupRemoved += TerminalSystem_GroupRemoved;
            if (currentBlock != null)
                SelectBlocks(new MyTerminalBlock[] { currentBlock });
        }
Пример #32
0
        public MyGuiDetailScreenSteam(Action<MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreen parent , MyGuiCompositeTexture 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;
            }
        }
Пример #33
0
        static MyJumpDrive()
        {
            var jumpButton = new MyTerminalControlButton<MyJumpDrive>("Jump", MySpaceTexts.BlockActionTitle_Jump, MySpaceTexts.Blank, (x) => x.RequestJump());
            jumpButton.Enabled = (x) => x.CanJump;
            jumpButton.SupportsMultipleBlocks = false;
            // Can only be called from toolbar of cockpit
            jumpButton.Visible = (x) => false;
            var action = jumpButton.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel, MyToolbarType.Character, MyToolbarType.Seat };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(jumpButton);

            var recharging = new MyTerminalControlOnOffSwitch<MyJumpDrive>("Recharge", MySpaceTexts.BlockPropertyTitle_Recharge, MySpaceTexts.Blank);
            recharging.Getter = (x) => x.m_isRecharging;
            recharging.Setter = (x, v) => x.m_isRecharging.Value = v;
            recharging.EnableToggleAction();
            recharging.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(recharging);

            var maxDistanceSlider = new MyTerminalControlSlider<MyJumpDrive>("JumpDistance", MySpaceTexts.BlockPropertyTitle_JumpDistance, MySpaceTexts.Blank);
            maxDistanceSlider.SetLimits(0f, 100f);
            maxDistanceSlider.DefaultValue = 100f;
            maxDistanceSlider.Enabled = (x) => x.m_jumpTarget == null;
            maxDistanceSlider.Getter = (x) => x.m_jumpDistanceRatio;
            maxDistanceSlider.Setter = (x, v) =>
                {
                    x.m_jumpDistanceRatio.Value = v;
                };
            maxDistanceSlider.Writer = (x, v) =>
                {
                    v.AppendFormatedDecimal((x.m_jumpDistanceRatio / 100f).ToString("P0") + " (", (float)x.ComputeMaxDistance() / 1000f, 0, " km").Append(")");
                };
            maxDistanceSlider.EnableActions(0.01f);
            MyTerminalControlFactory.AddControl(maxDistanceSlider);


            var selectedTarget = new MyTerminalControlListbox<MyJumpDrive>("SelectedTarget", MySpaceTexts.BlockPropertyTitle_DestinationGPS, MySpaceTexts.Blank, false, 1);
            selectedTarget.ListContent = (x, list1, list2) => x.FillSelectedTarget(list1, list2);
            MyTerminalControlFactory.AddControl(selectedTarget);

            var removeBtn = new MyTerminalControlButton<MyJumpDrive>("RemoveBtn", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (x) => x.RemoveSelected());
            removeBtn.Enabled = (x) => x.CanRemove();
            MyTerminalControlFactory.AddControl(removeBtn);

            var selectBtn = new MyTerminalControlButton<MyJumpDrive>("SelectBtn", MyCommonTexts.SelectBlueprint, MySpaceTexts.Blank, (x) => x.SelectTarget());
            selectBtn.Enabled = (x) => x.CanSelect();
            MyTerminalControlFactory.AddControl(selectBtn);

            var gpsList = new MyTerminalControlListbox<MyJumpDrive>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);
            gpsList.ListContent = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            MyTerminalControlFactory.AddControl(gpsList);
            if (!MySandboxGame.IsDedicated)
            {
                m_gpsGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)gpsList.GetGuiControl()).PropertyControl;
            }
        }
Пример #34
0
        public MyGuiDetailScreenLocal(Action<MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreenBase parent , MyGuiCompositeTexture 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;
            }
        }