//implementation without RegularExpressions
 public static void ParseText(string text, ref MyGuiControlMultilineText label)
 {
     try
     {
         var substrings = text.Split(']');
         foreach (var substring in substrings)
         {
             var textAndMarkup = substring.Split('[');
             if (textAndMarkup.Length == 2)
             {
                 label.AppendText(textAndMarkup[0]);
                 var indexOfSpace = textAndMarkup[1].IndexOf(' ');
                 if (indexOfSpace != -1) 
                 {
                     label.AppendLink(textAndMarkup[1].Substring(0, indexOfSpace), textAndMarkup[1].Substring(indexOfSpace + 1));
                 }
                 else
                 {
                     System.Diagnostics.Debug.Assert(false);
                     label.AppendText(textAndMarkup[1]);
                 }
             } else {
                 label.AppendText(substring);
             }
         }
     }
     catch
     {
     }
 }
            public void CutText(MyGuiControlMultilineText sender)
            {
                //First off, we have to copy
                CopyText(sender);

                //Then we cut the text away from the form
                EraseText(sender);
            }
Example #3
0
            public void CopyText(MyGuiControlMultilineText sender)
            {
                ClipboardText = Regex.Replace(sender.Text.ToString().Substring(Start, Length), "\n", "\r\n");
                Thread myth;

                myth = new Thread(new System.Threading.ThreadStart(CopyToClipboard));
                myth.ApartmentState = ApartmentState.STA;
                myth.Start();
            }
Example #4
0
            public void EraseText(MyGuiControlMultilineText sender)
            {
                if (Start == End)
                {
                    return;
                }
                StringBuilder prefix = new StringBuilder(sender.Text.ToString().Substring(0, Start));
                StringBuilder suffix = new StringBuilder(sender.Text.ToString().Substring(End));

                sender.CarriagePositionIndex = Start;
                sender.Text = prefix.Append(suffix);
            }
            public void CopyText(MyGuiControlMultilineText sender)
            {
                ClipboardText = Regex.Replace(sender.Text.ToString().Substring(Start, Length), "\n", "\r\n");

                if (!string.IsNullOrEmpty(ClipboardText))
                {
                    Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(ClipboardText));
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                }
            }
 private static void ParseMarkup(MyGuiControlMultilineText label, string markup)
 {
     var s = m_markupRegex.Match(markup);
     if (s.Value.Contains('|'))
     {
         var sub = s.Value.Substring(5);
         var split = sub.Split('|');
         var match = m_digitsRegex.Matches(split[1]);
         int width, height;
         if(int.TryParse(match[0].Value, out width) && int.TryParse(match[1].Value, out height))
             label.AppendImage(split[0], MyGuiManager.GetNormalizedSizeFromScreenSize(new VRageMath.Vector2(width, height)), Vector4.One);
     }
     else
         label.AppendLink(s.Value.Substring(0, s.Value.IndexOf(' ')), s.Value.Substring(s.Value.IndexOf(' ') + 1));
 }
Example #7
0
            public void CopyText(MyGuiControlMultilineText sender)
            {
#if !XB1
                ClipboardText = Regex.Replace(sender.Text.ToString().Substring(Start, Length), "\n", "\r\n");

                if (!string.IsNullOrEmpty(ClipboardText))
                {
                    Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(ClipboardText));
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                }
#else
                Debug.Assert(false, "Clipboard not supported on XB1.");
#endif
            }
        public MyHudControlChat(Vector2 position, Vector2 size)
        {
            m_chatMultilineControl = new MyGuiControlMultilineText(
                position: position,
                size: size,
                backgroundColor: null,
                font: MyFontEnum.White,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                contents: null,
                drawScrollbar: false,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            //m_chatMultilineControl.BackgroundTexture = MyGuiConstants.TEXTURE_MESSAGEBOX_BACKGROUND_BLUE.Texture;
            m_chatMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;

            Elements.Add(m_chatMultilineControl);
        }
        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;
        }
 public static void ParseText(string text, ref MyGuiControlMultilineText label)
 {
     try
     {
         var texts = m_splitRegex.Split(text);
         var matches = m_splitRegex.Matches(text);
         for (int i = 0; i < matches.Count || i < texts.Count(); i++)
         {
             if (i < texts.Count())
                 label.AppendText(m_stringCache.Clear().Append(texts[i]));
             if (i < matches.Count)
                 ParseMarkup(label, matches[i].Value);
         }
     }
     catch
     {
     }
 }
Example #11
0
            public void PasteText(MyGuiControlMultilineText sender)
            {
                //First we erase the selection
                EraseText(sender);
                var    prefix = sender.Text.ToString().Substring(0, sender.CarriagePositionIndex);
                var    suffix = sender.Text.ToString().Substring(sender.CarriagePositionIndex);
                Thread myth;

                myth = new Thread(new System.Threading.ThreadStart(PasteFromClipboard));
                myth.ApartmentState = ApartmentState.STA;
                myth.Start();

                //We have to wait for the thread to end to make sure we got the text
                myth.Join();

                sender.Text = new StringBuilder(prefix).Append(Regex.Replace(ClipboardText, "\r\n", " \n")).Append(suffix);
                sender.CarriagePositionIndex = prefix.Length + ClipboardText.Length;
                Reset(sender);
            }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            var layout = new MyLayoutTable(this);
            layout.SetColumnWidthsNormalized(50, 250, 150, 250, 50);
            layout.SetRowHeightsNormalized(50, 450, 30, 50);

            m_mainLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.GuiScenarioDescription), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            layout.AddWithSize(m_mainLabel, MyAlignH.Left, MyAlignV.Center, 0, 1, colSpan: 3);
            //BRIEFING:
            m_descriptionBox = new MyGuiControlMultilineText(
                position: new Vector2(0.0f, 0.0f),
                size: new Vector2(0.2f, 0.2f),
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: false);
            layout.AddWithSize(m_descriptionBox, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 1, colSpan: 3);

            m_okButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                size: new Vector2(200, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnOkClicked);
            layout.AddWithSize(m_okButton, MyAlignH.Left, MyAlignV.Top, 2, 2);
        }
        public void Draw(MyGuiControlMultilineText control)
        {
            if (Visible)
            {
                if (IsDirty)
                {
                    control.Clear();
                    control.AppendText(CameraName);
                    control.AppendLine();
                    control.AppendText(ShipName);

                    IsDirty = false;
                }
            }
            else
            {
                if (IsDirty)
                {
                    control.Clear();
                    IsDirty = false;
                }
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_scale = 0.7f;

            AddCaption("System debug", Color.Yellow.ToVector4());
            AddShareFocusHint();


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

            AddLabel("System", Color.Yellow.ToVector4(), 1.2f);

            //System debugging
            AddCheckBox("Simulate slow update", null, MemberHelper.GetMember(() => MyFakes.SIMULATE_SLOW_UPDATE));
            AddButton(new StringBuilder("Force GC"), onClick: OnClick_ForceGC);
            AddCheckBox("Pause physics", null, MemberHelper.GetMember(() => MyFakes.PAUSE_PHYSICS));
            AddButton(new StringBuilder("Step physics"), (button) => MyFakes.STEP_PHYSICS = true);
            AddSlider("Simulation speed", 0.001f, 3f, null, MemberHelper.GetMember(() => MyFakes.SIMULATION_SPEED));

            m_currentPosition.Y += 0.01f;
            m_havokStatsMultiline = AddMultilineText(textScale: 0.8f);
        }
        protected void CreateTextField()
        {
            var textPosition = new Vector2(-0.325f, -0.175f) + m_offset;
            var textSize = new Vector2(0.175f, 0.175f);
            var padding = new Vector2(0.005f, 0f);

            var textBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, textPosition, textSize, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            m_textField = new MyGuiControlMultilineText();
            m_textField = AddMultilineText(offset: textPosition + padding, textScale: m_textScale, size: textSize - padding);

            RefreshTextField();
        }
        public override void RecreateControls(bool constructor)
        {
            //This is probably very wrong!
            m_screenScale = (MyGuiManager.GetHudSize().X / MyGuiManager.GetHudSize().Y) / MyGuiConstants.SAFE_ASPECT_RATIO;

            m_size = new Vector2(m_screenScale, 0.5f);

            base.RecreateControls(constructor);
            Vector4 consoleTextColor = new Vector4(1, 1, 0, 1);
            float consoleTextScale = 1f;
            
            m_commandLine = new MyGuiControlTextbox
            (
                position: new Vector2(0, 0.25f),
                textColor: consoleTextColor
            );

            m_commandLine.Position -= new Vector2(0, m_commandLine.Size.Y + m_margin.Y/2);
            m_commandLine.Size = new Vector2(m_screenScale, m_commandLine.Size.Y) - 2 * m_margin;
            m_commandLine.ColorMask = new Vector4(0, 0, 0, 0.5f);
            m_commandLine.VisualStyle = MyGuiControlTextboxStyleEnum.Debug;
            m_commandLine.TextChanged += commandLine_TextChanged;
            m_commandLine.Name = "CommandLine";


            m_autoComplete = new MyGuiControlContextMenu();
            m_autoComplete.ItemClicked += autoComplete_ItemClicked;
            m_autoComplete.Deactivate();
            m_autoComplete.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_autoComplete.ColorMask = new Vector4(0, 0, 0, .5f);
            m_autoComplete.AllowKeyboardNavigation = true;
            m_autoComplete.Name = "AutoComplete";

            m_displayScreen = new MyGuiControlMultilineText
            (
                position: new Vector2(-0.5f * m_screenScale, -0.25f) + m_margin,
                size: new Vector2(m_screenScale, 0.5f - m_commandLine.Size.Y) - 2 * m_margin,
                font: MyFontEnum.Debug,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: true
            );

            m_displayScreen.TextColor = Color.Yellow;
            m_displayScreen.TextScale = consoleTextScale;
            m_displayScreen.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_displayScreen.Text = MyConsole.DisplayScreen;
            m_displayScreen.ColorMask = new Vector4(0, 0, 0, .5f);
            m_displayScreen.Name = "DisplayScreen";

            Controls.Add(m_displayScreen);
            Controls.Add(m_commandLine);
            Controls.Add(m_autoComplete);
        }
        public override void RecreateControls(bool constructor)
        {
            var titlePos = new Vector2(0f, -0.3f);
            var descSize = m_descSize;
            var descPosition = new Vector2(-descSize.X/2, titlePos.Y + 0.10f);
            var objSize = new Vector2(0.2f, 0.3f);
            var objOffset = new Vector2(0.32f, 0f);
            var padding = new Vector2(0.005f, 0f);

            var curObjPos = new Vector2(0f, titlePos.Y + 0.05f);

            base.RecreateControls(constructor);

            CloseButtonEnabled = true;

            m_okButton = new MyGuiControlButton(position: new Vector2(0f, 0.29f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: m_okButtonCaption , onButtonClick: OkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(m_okButton);

            m_titleLabel = new MyGuiControlLabel(text: m_missionTitle, position: titlePos, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, textScale: 1.5f);
            Controls.Add(m_titleLabel);
            
            m_currentObjectiveLabel = new MyGuiControlLabel(position: curObjPos, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, textScale: 1f);
            Controls.Add(m_currentObjectiveLabel);
            SetCurrentObjective(m_currentObjective);
 

            m_descriptionBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, descPosition, descSize, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            m_descriptionBox = AddMultilineText(offset: descPosition + padding, size: descSize, selectable: false);
            m_descriptionBox.Text = new StringBuilder(m_description);
        }
Example #18
0
 public void SelectAll(MyGuiControlMultilineText sender)
 {
     m_startIndex = 0;
     m_endIndex   = sender.Text.Length;
     sender.CarriagePositionIndex = sender.Text.Length;
 }
Example #19
0
 public void Reset(MyGuiControlMultilineText sender)
 {
     m_startIndex = m_endIndex = MathHelper.Clamp(sender.CarriagePositionIndex, 0, sender.Text.Length);
 }
        public void Close()
        {
            UnregisterEvents();

            // left controls
            m_selectedFaction = null;

            m_tableFactions     = null;
            m_buttonCreate      = null;
            m_buttonJoin        = null;
            m_buttonCancelJoin  = null;
            m_buttonLeave       = null;
            m_buttonSendPeace   = null;
            m_buttonCancelPeace = null;
            m_buttonAcceptPeace = null;
            m_buttonMakeEnemy   = null;

            // right controls
            m_labelFactionName   = null;
            m_labelFactionDesc   = null;
            m_labelFactionPriv   = null;
            m_labelMembers       = null;
            m_labelAutoAcceptMember = null;
            m_labelAutoAcceptPeace  = null;
            m_checkAutoAcceptMember = null;
            m_checkAutoAcceptPeace  = null;
            m_textFactionDesc    = null;
            m_textFactionPriv    = null;
            m_tableMembers       = null;
            m_buttonKick         = null;
            m_buttonAcceptJoin   = null;

            m_controlsParent = null;
        }
        protected MyGuiControlMultilineText AddMultilineText(Vector2? size = null, Vector2? offset = null, float textScale = 1.0f, bool selectable = false)
        {
            Vector2 textboxSize = size ?? this.Size ?? new Vector2(0.5f, 0.5f);

            MyGuiControlMultilineText textbox = new MyGuiControlMultilineText(
                position: offset ?? Vector2.Zero,
                size: textboxSize,
                //backgroundColor: m_defaultColor,
                //textScale: this.m_scale * textScale,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: selectable,
                font: MyFontEnum.Blue);

            //textbox.BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_BACKGROUND;
            //textbox.TextSize = new Vector2(0.2f, 0.2f);
            return textbox;
        }
 public void EraseText(MyGuiControlMultilineText sender)
 {
     if (Start == End)
         return;
     StringBuilder prefix = new StringBuilder(sender.Text.ToString().Substring(0, Start));
     StringBuilder suffix = new StringBuilder(sender.Text.ToString().Substring(End));
     sender.CarriagePositionIndex = Start;
     sender.Text = prefix.Append(suffix);
 }
        internal MyGuiControlGenericFunctionalBlock(MyTerminalBlock[] blocks) :
            base(canHaveFocus: true,
                 allowFocusingElements: true,
                 isActiveControl: false)
        {
            this.m_currentBlocks = blocks;

            m_separatorList = new MyGuiControlSeparatorList();
            Elements.Add(m_separatorList);

            m_terminalControlList             = new MyGuiControlList();
            m_terminalControlList.VisualStyle = MyGuiControlListStyleEnum.Simple;
            m_terminalControlList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            m_terminalControlList.Position    = new Vector2(0.1f, 0.1f);
            Elements.Add(m_terminalControlList);

            m_blockPropertiesMultilineText = new MyGuiControlMultilineText(
                position: new Vector2(0.049f, -0.195f),
                size: new Vector2(0.39f, 0.635f),
                font: MyFontEnum.Blue,
                textScale: 0.85f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
                );
            m_blockPropertiesMultilineText.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockPropertiesMultilineText.Text        = new StringBuilder();
            Elements.Add(m_blockPropertiesMultilineText);

            m_transferToCombobox = new MyGuiControlCombobox(
                Vector2.Zero,
                new Vector2(0.15f, 0.1f),
                null, null);
            m_transferToCombobox.ItemSelected += m_transferToCombobox_ItemSelected;
            Elements.Add(m_transferToCombobox);

            m_shareModeCombobox = new MyGuiControlCombobox(
                Vector2.Zero,
                new Vector2(0.25f, 0.1f),
                null, null);
            m_shareModeCombobox.ItemSelected += m_shareModeCombobox_ItemSelected;
            Elements.Add(m_shareModeCombobox);

            m_ownershipLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_Owner) + ":");
            Elements.Add(m_ownershipLabel);

            m_ownerLabel = new MyGuiControlLabel(
                Vector2.Zero, null, String.Empty);
            Elements.Add(m_ownerLabel);

            m_transferToLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_TransferTo));
            Elements.Add(m_transferToLabel);

            if (MySession.Static.CreativeMode)
            {
                var     topLeftRelative = Vector2.One * -0.5f;
                Vector2 leftColumnSize  = new Vector2(0.3f, 0.55f);
                var     position        = topLeftRelative + new Vector2(leftColumnSize.X + 0.503f, 0.42f);

                m_npcButton = new MyGuiControlButton(
                    position,
                    MyGuiControlButtonStyleEnum.Tiny,
                    new Vector2(0.1f, 0.1f),
                    null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyTexts.GetString(MyCommonTexts.AddNewNPC), new StringBuilder("+"),
                    MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, true,
                    OnNewNpcClick, GuiSounds.MouseClick, 0.75f);
                Elements.Add(m_npcButton);
            }


            RecreateBlockControls();
            RecreateOwnershipControls();

            if (m_currentBlocks.Length > 0)
            {
                m_currentBlocks[0].PropertiesChanged += block_PropertiesChanged;
            }

            foreach (var block in m_currentBlocks)
            {
                block.OwnershipChanged  += block_OwnershipChanged;
                block.VisibilityChanged += block_VisibilityChanged;
            }

            Sync.Players.IdentitiesChanged += Players_IdentitiesChanged;

            UpdateDetailedInfo();

            Size = new Vector2(0.595f, 0.64f);
        }
 public void SelectAll(MyGuiControlMultilineText sender)
 {
     m_startIndex = 0;
     m_endIndex = sender.Text.Length;
     sender.CarriagePositionIndex = sender.Text.Length;
 }
 public void Reset(MyGuiControlMultilineText sender)
 {
     m_startIndex = m_endIndex = MathHelper.Clamp(sender.CarriagePositionIndex, 0, sender.Text.Length);
 }
        protected virtual MyGuiControlMultilineText AddMultilineText(Vector2? size = null, Vector2? offset = null, float textScale = 1.0f, bool selectable = false, MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
        {
            Vector2 textboxSize = size ?? this.Size ?? new Vector2(1.2f, 0.5f);

            MyGuiControlMultilineText textbox = null;
            if (m_enableEdit)
            {
                textbox = new MyGuiControlMultilineEditableText(
                    position: textboxSize / 2.0f + (offset ?? Vector2.Zero),
                    size: textboxSize,
                    backgroundColor: Color.White.ToVector4(),
                    textAlign: textAlign,
                    textBoxAlign: textBoxAlign,
                    font: MyFontEnum.White);
            }
            else
            {
                textbox = new MyGuiControlMultilineText(
                    position: textboxSize / 2.0f + (offset ?? Vector2.Zero),
                    size: textboxSize,
                    backgroundColor: Color.White.ToVector4(),
                    textAlign: textAlign,
                    textBoxAlign: textBoxAlign,
                    selectable: m_enableEdit,
                    font: MyFontEnum.White);
            }

            Controls.Add(textbox);

            return textbox;
        }
        protected void CreateDescription()
        {
            var descPosition = new Vector2(-0.325f, 0.015f) + m_offset;
            var descSize = new Vector2(0.67f, 0.15f);
            var padding = new Vector2(0.005f, 0f);

            var descriptionBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, descPosition, descSize, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            m_descriptionField = AddMultilineText(offset: descPosition + padding, textScale: m_textScale, size: descSize - (padding + new Vector2(0f, 0.005f)), selectable: false);

            RefreshDescriptionField();
        }
            public void PasteText(MyGuiControlMultilineText sender)
            {
                //First we erase the selection
                EraseText(sender);
                var prefix = sender.Text.ToString().Substring(0, sender.CarriagePositionIndex);
                var suffix = sender.Text.ToString().Substring(sender.CarriagePositionIndex);
                Thread myth;

                myth = new Thread(new System.Threading.ThreadStart(PasteFromClipboard));
                myth.ApartmentState = ApartmentState.STA;
                myth.Start();

                //We have to wait for the thread to end to make sure we got the text
                myth.Join();

                sender.Text = new StringBuilder(prefix).Append(Regex.Replace(ClipboardText, "\r\n", " \n")).Append(suffix);
                sender.CarriagePositionIndex = prefix.Length + ClipboardText.Length;
                Reset(sender);
            }
        protected virtual void BuildControls()
        {
            Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE;
            Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f);

            AddCaption(MySpaceTexts.ScreenCaptionScenario);

            //RIGHT:
            int numControls = 0;

            var nameLabel = MakeLabel(MySpaceTexts.Name);
            var descriptionLabel = MakeLabel(MySpaceTexts.Description);
            var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty);
            var onlineModeLabel = MakeLabel(MySpaceTexts.WorldSettings_OnlineMode);
            m_maxPlayersLabel = MakeLabel(MySpaceTexts.MaxPlayers);

            float width = 0.284375f + 0.025f;

            m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH);
            m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH);
            m_difficultyCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));
            m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy);
            m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal);
            m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard);

            m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));
            m_maxPlayersSlider = new MyGuiControlSlider(
                position: Vector2.Zero,
                width: m_onlineMode.Size.X,
                minValue: 2,
                maxValue: 16,
                labelText: new StringBuilder("{0}").ToString(),
                labelDecimalPlaces: 0,
                labelSpaceWidth: 0.05f,
                intValue: true
                );

            m_scenarioTypesList = new MyGuiControlList();


            //BUTTONS
            m_removeButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRemove), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_publishButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f + m_removeButton.Size.X, 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonPublish), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_createButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2*(0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonCreateNew), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_browseWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3*(0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

            m_refreshButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.0f, m_removeButton.Size.Y+0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRefresh), 
                onButtonClick: OnRefreshButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_openInWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2((0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_okButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Ok), 
                onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Cancel), 
                onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

            m_onlineMode.ItemSelected += OnOnlineModeSelect;
            m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MySpaceTexts.WorldSettings_OnlineModeOffline);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MySpaceTexts.WorldSettings_OnlineModePrivate);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MySpaceTexts.WorldSettings_OnlineModeFriends);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MySpaceTexts.WorldSettings_OnlineModePublic);


            m_nameTextbox.TextChanged += m_nameTextbox_TextChanged;

            // Add controls in pairs; label first, control second. They will be laid out automatically this way.
            Controls.Add(nameLabel);
            Controls.Add(m_nameTextbox);
            //m_nameTextbox.Enabled = false;
            Controls.Add(descriptionLabel);
            Controls.Add(m_descriptionTextbox);
            //m_descriptionTextbox.Enabled = false;
            Controls.Add(difficultyLabel);
            Controls.Add(m_difficultyCombo);
            m_difficultyCombo.Enabled = false;

            Controls.Add(onlineModeLabel);
            Controls.Add(m_onlineMode);
            m_onlineMode.Enabled = false;
            Controls.Add(m_maxPlayersLabel);
            Controls.Add(m_maxPlayersSlider);


            float labelSize = 0.12f;

            float MARGIN_TOP = 0.1f;
            float MARGIN_LEFT = 0.42f;// m_isNewGame ? 0.315f : 0.08f;

            // Automatic layout.
            Vector2 originL, originC;
            Vector2 controlsDelta = new Vector2(0f, 0.052f);
            float rightColumnOffset;
            originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP);
            originC = originL + new Vector2(labelSize, 0f);
            rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f;

            foreach (var control in Controls)
            {
                control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                if (control is MyGuiControlLabel)
                    control.Position = originL + controlsDelta * numControls;
                else
                    control.Position = originC + controlsDelta * numControls++;
            }
            //BRIEFING:
            //var textBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, new Vector2(0f,0f), new Vector2(0.43f, 0.422f), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            //textBackgroundPanel.InnerHeight = 6;
            MyGuiControlParent briefing = new MyGuiControlParent();//new Vector2(0f, 0f), new Vector2(0.43f, 0.422f));

            var briefingScrollableArea = new MyGuiControlScrollablePanel(
                scrolledControl: briefing)
            {
                Name = "BriefingScrollableArea",
                ScrollbarVEnabled = true,
                Position = new Vector2(-0.02f, -0.12f),
                Size = new Vector2(0.43f, 0.422f),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
            };
            Controls.Add(briefingScrollableArea);
            //inside scrollable area:
            m_descriptionBox = AddMultilineText(offset: new Vector2(0.0f, 0.0f), size: new Vector2(1f, 1f), selectable: false);
            briefing.Controls.Add(m_descriptionBox);

            //LEFT:
            m_scenarioTable = new MyGuiControlTable();
            m_scenarioTable.Position = new Vector2(-0.42f, -0.5f+MARGIN_TOP);
            m_scenarioTable.Size = new Vector2(0.38f, 1.8f);
            m_scenarioTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_scenarioTable.VisibleRowsCount = 20;
            m_scenarioTable.ColumnsCount = 2;
            m_scenarioTable.SetCustomColumnWidths(new float[] { 0.085f, 0.905f });
            m_scenarioTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.Name));
            m_scenarioTable.ItemSelected += OnTableItemSelected;
            //m_scenarioTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick;
            //m_scenarioTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick;
            Controls.Add(m_scenarioTable);
            //BUTTONS:
            Controls.Add(m_removeButton);
            m_removeButton.Enabled = false;
            Controls.Add(m_publishButton);
            m_publishButton.Enabled = false;
            Controls.Add(m_createButton);
            m_createButton.Enabled = false;
            Controls.Add(m_browseWorkshopButton);
            m_browseWorkshopButton.Enabled = false;
            Controls.Add(m_refreshButton);
            Controls.Add(m_openInWorkshopButton);
            m_openInWorkshopButton.Enabled = false;
            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            CloseButtonEnabled = true;

            SetDefaultValues();
        }
        private void CreateFactionsPageControls(MyGuiControlTabPage page)
        {
            page.Name = "PageFactions";
            page.TextEnum = MySpaceTexts.TerminalTab_Factions;

            var left = -0.462f;
            var top = -0.34f;
            var spacingH = 0.0045f;
            var spacingV = 0.01f;
            var buttonSize = new Vector2(0.29f, 0.052f);
            var smallerBtn = new Vector2(0.13f, 0.04f);

            var factionsComposite = new MyGuiControlCompositePanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(0.4f, 0.69f),
                Name = "Factions"
            };
            left += spacingH;
            top += spacingV;

            var factionsPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionsComposite.Size.X - 0.01f, 0.035f),
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK
            };

            var factionsLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left + spacingH, top),
                size: factionsPanel.Size - new Vector2(0.01f, 0.01f),
                text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions)
            );
            top += factionsLabel.Size.Y + spacingV;

            var factionsTable = new MyGuiControlTable()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionsPanel.Size.X, 0.15f),
                Name = "FactionsTable",
                ColumnsCount = 3,
                VisibleRowsCount = 14,
            };
            factionsTable.SetCustomColumnWidths(new float[] { 0.16f, 0.75f, 0.09f });
            factionsTable.SetColumnName(0, MyTexts.Get(MyCommonTexts.Tag));
            factionsTable.SetColumnName(1, MyTexts.Get(MyCommonTexts.Name));
            top += factionsTable.Size.Y + spacingV;

            var createBtn      = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top)) { Name = "buttonCreate" };
            var joinBtn        = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonJoin" };
            var joinCancelBtn  = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonCancelJoin" };
            var leaveBtn       = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonLeave" };
            var sendPeaceBtn   = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonSendPeace" };
            var cancelPeaceBtn = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonCancelPeace" };
            var acceptPeaceBtn = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonAcceptPeace" };
            var enemyBtn       = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top + buttonSize.Y + spacingV)) { Name = "buttonEnemy" };

            page.Controls.Add(factionsComposite);
            page.Controls.Add(factionsPanel);
            page.Controls.Add(factionsLabel);
            page.Controls.Add(factionsTable);
            page.Controls.Add(createBtn);
            page.Controls.Add(joinBtn);
            page.Controls.Add(joinCancelBtn);
            page.Controls.Add(leaveBtn);
            page.Controls.Add(sendPeaceBtn);
            page.Controls.Add(cancelPeaceBtn);
            page.Controls.Add(acceptPeaceBtn);
            page.Controls.Add(enemyBtn);

            // Do the right side
            // reset left / top
            left = -0.0475f;
            top = -0.34f;

            var factionComposite = new MyGuiControlCompositePanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(-0.05f, top),
                Size = new Vector2(0.5f, 0.69f),
                Name = "compositeFaction"
            };
            left += spacingH;
            top += spacingV;

            var factionNamePanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionComposite.Size.X - 0.012f, 0.035f),
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK,
                Name = "panelFactionName"
            };

            var factionName = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left + spacingH, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionName" };
            top += factionsLabel.Size.Y + (2f * spacingV);
            var size = factionNamePanel.Size - new Vector2(0.14f, 0.01f);

            var factionDescLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionDesc" };
            top += factionDescLabel.Size.Y + spacingV;

            var factionDesc = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
                position: new Vector2(left, top),
                size: new Vector2(size.X, 0.08f)
            )
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Name = "textFactionDesc",
            };
            top += factionDesc.Size.Y + 2f * spacingV;

            var factionPrivateLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionPrivate" };
            top += factionPrivateLabel.Size.Y + spacingV;

            var factionPrivate = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
                position: new Vector2(left, top),
                size: new Vector2(size.X, 0.08f)
            )
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Name = "textFactionPrivate",
            };
            top += factionDesc.Size.Y + 0.0275f;

            var labelFactionMembers = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionMembers" };


            var checkAcceptEveryone = new MyGuiControlCheckbox(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                position: new Vector2(factionNamePanel.Position.X + factionNamePanel.Size.X, top + spacingV)
            ) { Name = "checkFactionMembersAcceptEveryone" };

            var labelAcceptEveryone = new MyGuiControlLabel(
             originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
             position: new Vector2(checkAcceptEveryone.Position.X - checkAcceptEveryone.Size.X - spacingH, top),
             size: labelFactionMembers.Size - new Vector2(0.01f, 0.01f)
         ) { Name = "labelFactionMembersAcceptEveryone" };


            var labelAcceptPeace = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2((17 * spacingH), top),
                size: labelFactionMembers.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionMembersAcceptPeace" };

            var checkAcceptPeace = new MyGuiControlCheckbox(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                position: new Vector2((47 * spacingH), top + spacingV)
            ) { Name = "checkFactionMembersAcceptPeace" };



            top += factionPrivateLabel.Size.Y + spacingV;

            var membersTable = new MyGuiControlTable()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(size.X, 0.15f),
                Name = "tableMembers",
                ColumnsCount = 2,
                VisibleRowsCount = 8,
                HeaderVisible = false
            };
            membersTable.SetCustomColumnWidths(new float[] { 0.7f, 0.3f });
            membersTable.SetColumnName(0, MyTexts.Get(MyCommonTexts.Name));
            membersTable.SetColumnName(1, MyTexts.Get(MyCommonTexts.Status));

            var btnSpacing = smallerBtn.Y + spacingV;
            var editBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, factionDesc.Position.Y)) { Name = "buttonEdit" };
            var promBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y)) { Name = "buttonPromote" };
            var kickBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + btnSpacing)) { Name = "buttonKick" };
            var acceptJoin = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 2f * btnSpacing)) { Name = "buttonAcceptJoin" };
            var demote = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 3f * btnSpacing)) { Name = "buttonDemote" };
            //var acceptPeace = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,    position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 2f * btnSpacing)) { Name = "buttonAcceptPeace" };
            var addNpcToFaction = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 4f * btnSpacing)) { Name = "buttonAddNpc" };

            page.Controls.Add(factionComposite);
            page.Controls.Add(factionNamePanel);
            page.Controls.Add(factionName);
            page.Controls.Add(factionDescLabel);
            page.Controls.Add(factionDesc);
            page.Controls.Add(factionPrivateLabel);
            page.Controls.Add(factionPrivate);
            page.Controls.Add(labelFactionMembers);
            page.Controls.Add(labelAcceptEveryone);
            page.Controls.Add(labelAcceptPeace);
            page.Controls.Add(checkAcceptEveryone);
            page.Controls.Add(checkAcceptPeace);
            page.Controls.Add(membersTable);

            page.Controls.Add(editBtn);
            page.Controls.Add(promBtn);
            page.Controls.Add(kickBtn);
            page.Controls.Add(demote);
            page.Controls.Add(acceptJoin);
            page.Controls.Add(addNpcToFaction);
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_toolbarControl = new MyGuiControlToolbar();
            m_toolbarControl.Position = new Vector2(0.5f, 0.99f);
            m_toolbarControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
            m_toolbarControl.IsActiveControl = false;
            Elements.Add(m_toolbarControl);
            m_textScale = MyGuiConstants.HUD_TEXT_SCALE * MyGuiManager.LanguageTextScale;

            var style = new MyGuiControlBlockInfo.MyControlBlockInfoStyle()
            {
                BlockNameLabelFont = MyFontEnum.White,
                EnableBlockTypeLabel = true,
                ComponentsLabelText = MySpaceTexts.HudBlockInfo_Components,
                ComponentsLabelFont = MyFontEnum.Blue,
                InstalledRequiredLabelText = MySpaceTexts.HudBlockInfo_Installed_Required,
                InstalledRequiredLabelFont = MyFontEnum.Blue,
                RequiredLabelText = MyCommonTexts.HudBlockInfo_Required,
                IntegrityLabelFont = MyFontEnum.White,
                IntegrityBackgroundColor = new Vector4(78 / 255.0f, 116 / 255.0f, 137 / 255.0f, 1.0f),
                IntegrityForegroundColor = new Vector4(0.5f, 0.1f, 0.1f, 1),
                IntegrityForegroundColorOverCritical = new Vector4(118 / 255.0f, 166 / 255.0f, 192 / 255.0f, 1.0f),
                LeftColumnBackgroundColor = new Vector4(46 / 255.0f, 76 / 255.0f, 94 / 255.0f, 1.0f),
                TitleBackgroundColor = new Vector4(72 / 255.0f, 109 / 255.0f, 130 / 255.0f, 1.0f),
                ComponentLineMissingFont = MyFontEnum.Red,
                ComponentLineAllMountedFont = MyFontEnum.White,
                ComponentLineAllInstalledFont = MyFontEnum.Blue,
                ComponentLineDefaultFont = MyFontEnum.White,
                ComponentLineDefaultColor = new Vector4(0.6f, 0.6f, 0.6f, 1f),
                ShowAvailableComponents = false,
                EnableBlockTypePanel = true,
            };
            m_blockInfo = new MyGuiControlBlockInfo(style);
            m_blockInfo.IsActiveControl = false;
            Controls.Add(m_blockInfo);

            m_questlogControl = new MyGuiControlQuestlog(new Vector2(20f, 20f));
            m_questlogControl.IsActiveControl = false;
            m_questlogControl.RecreateControls();
            Controls.Add(m_questlogControl);

            m_chatControl = new MyHudControlChat(MyHud.Chat, Vector2.Zero, new Vector2(0.4f, 0.28f), visibleLinesCount: 12);
            Elements.Add(m_chatControl);

            m_cameraInfoMultilineControl = new MyGuiControlMultilineText(
                position: Vector2.Zero,
                size: new Vector2(0.4f, 0.25f),
                backgroundColor: null,
                font: MyFontEnum.White,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                contents: null,
                drawScrollbar: false,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_cameraInfoMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Elements.Add(m_cameraInfoMultilineControl);

            m_rotatingWheelControl = new MyGuiControlRotatingWheel(position: new Vector2(0.5f, 0.85f));

            Controls.Add(m_rotatingWheelControl);

            Vector2 buildModePosition = new Vector2(0.5f, 0.02f);
            buildModePosition = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref buildModePosition);
            m_buildModeLabel = new MyGuiControlLabel(
                position: buildModePosition,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                font: MyFontEnum.White,
                text: MyTexts.GetString(MyCommonTexts.Hud_BuildMode));
            Controls.Add(m_buildModeLabel);

            m_blocksLeft = new MyGuiControlLabel(
                position: new Vector2(0.238f, 0.89f),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                font: MyFontEnum.White,
                text: MyHud.BlocksLeft.GetStringBuilder().ToString()
                );
            Controls.Add(m_blocksLeft);

            m_relayNotification = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_relayNotification.TextEnum = MyCommonTexts.Multiplayer_IndirectConnection;
            m_relayNotification.Visible = false;
            Controls.Add(m_relayNotification);
            var offset = new Vector2(0, m_relayNotification.Size.Y);
            m_noMsgSentNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Debug, text: MyTexts.GetString(MyCommonTexts.Multiplayer_LastMsg), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noMsgSentNotification.Visible = false;
            Controls.Add(m_noMsgSentNotification);
            offset += new Vector2(0, m_noMsgSentNotification.Size.Y);
            m_noConnectionNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Red, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noConnectionNotification.TextEnum = MyCommonTexts.Multiplayer_NoConnection;
            m_noConnectionNotification.Visible = false;
            Controls.Add(m_noConnectionNotification);

            m_serverSavingNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_serverSavingNotification.TextEnum = MyCommonTexts.SavingPleaseWait;
            m_serverSavingNotification.Visible = false;
            Controls.Add(m_serverSavingNotification);

            MyHud.ReloadTexts();
        }
        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);
        }
        public void Init(IMyGuiControlsParent controlsParent)
        {
            m_controlsParent = controlsParent;
            RefreshUserInfo();

            m_tableFactions = (MyGuiControlTable)controlsParent.Controls.GetControlByName("FactionsTable");
            m_tableFactions.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
            m_tableFactions.SetColumnComparison(1, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
            m_tableFactions.ItemSelected += OnFactionsTableItemSelected;
            RefreshTableFactions();
            m_tableFactions.SortByColumn(1);

            m_buttonCreate      = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCreate");
            m_buttonJoin        = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonJoin");
            m_buttonCancelJoin  = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelJoin");
            m_buttonLeave       = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonLeave");
            m_buttonSendPeace   = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonSendPeace");
            m_buttonCancelPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelPeace");
            m_buttonAcceptPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptPeace");
            m_buttonMakeEnemy   = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEnemy");

            m_buttonCreate.ShowTooltipWhenDisabled = true;

            m_buttonCreate.TextEnum      = MySpaceTexts.TerminalTab_Factions_Create;
            m_buttonJoin.TextEnum        = MySpaceTexts.TerminalTab_Factions_Join;
            m_buttonCancelJoin.TextEnum  = MySpaceTexts.TerminalTab_Factions_CancelJoin;
            m_buttonLeave.TextEnum       = MySpaceTexts.TerminalTab_Factions_Leave;
            m_buttonSendPeace.TextEnum   = MySpaceTexts.TerminalTab_Factions_Friend;
            m_buttonCancelPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_CancelPeaceRequest;
            m_buttonAcceptPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_AcceptPeaceRequest;
            m_buttonMakeEnemy.TextEnum   = MySpaceTexts.TerminalTab_Factions_Enemy;


            m_buttonJoin.SetToolTip(MySpaceTexts.TerminalTab_Factions_JoinToolTip);
            m_buttonSendPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_FriendToolTip);

            m_buttonCreate.ButtonClicked      += OnCreateClicked;
            m_buttonJoin.ButtonClicked        += OnJoinClicked;
            m_buttonCancelJoin.ButtonClicked  += OnCancelJoinClicked;
            m_buttonLeave.ButtonClicked       += OnLeaveClicked;
            m_buttonSendPeace.ButtonClicked   += OnFriendClicked;
            m_buttonCancelPeace.ButtonClicked += OnCancelPeaceRequestClicked;
            m_buttonAcceptPeace.ButtonClicked += OnAcceptFriendClicked;
            m_buttonMakeEnemy.ButtonClicked   += OnEnemyClicked;

            // RIGHT SIDE
            m_labelFactionName      = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionName");
            m_labelFactionDesc      = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionDesc");
            m_labelFactionPriv      = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionPrivate");
            m_labelMembers          = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembers");
            m_labelAutoAcceptMember = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptEveryone");
            m_labelAutoAcceptPeace  = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptPeace");

            m_labelFactionDesc.Text      = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_CreateFactionDescription).ToString();
            m_labelFactionPriv.Text      = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Private).ToString();
            m_labelMembers.Text          = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Members).ToString();
            m_labelAutoAcceptMember.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAccept).ToString();
            m_labelAutoAcceptPeace.Text  = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequest).ToString();

            m_labelAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip);
            m_labelAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip);

            m_textFactionDesc = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionDesc");
            m_textFactionPriv = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionPrivate");

            m_textFactionDesc.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK;
            m_textFactionPriv.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK;

            m_tableMembers = (MyGuiControlTable)controlsParent.Controls.GetControlByName("tableMembers");
            m_tableMembers.SetColumnComparison(1, (a, b) => ((int)((MyMemberComparerEnum)a.UserData)).CompareTo((int)((MyMemberComparerEnum)b.UserData)));
            m_tableMembers.ItemSelected += OnTableItemSelected;

            m_checkAutoAcceptMember = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptEveryone");
            m_checkAutoAcceptPeace  = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptPeace");

            m_checkAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip);
            m_checkAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip);

            m_checkAutoAcceptMember.IsCheckedChanged += OnAutoAcceptChanged;
            m_checkAutoAcceptPeace.IsCheckedChanged  += OnAutoAcceptChanged;

            m_buttonEdit       = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEdit");
            m_buttonPromote    = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonPromote");
            m_buttonKick       = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonKick");
            m_buttonAcceptJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptJoin");
            m_buttonDemote     = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonDemote");
            m_buttonAddNpc = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAddNpc");

            m_buttonEdit.TextEnum       = MyCommonTexts.Edit;
            m_buttonPromote.TextEnum    = MyCommonTexts.Promote;
            m_buttonKick.TextEnum       = MyCommonTexts.Kick;
            m_buttonAcceptJoin.TextEnum = MyCommonTexts.Accept;
            m_buttonDemote.TextEnum     = MyCommonTexts.Demote;
            m_buttonAddNpc.TextEnum = MySpaceTexts.AddNpcToFaction;
            m_buttonAddNpc.SetToolTip(MySpaceTexts.AddNpcToFactionHelp);

            m_buttonEdit.ButtonClicked       += OnCreateClicked;
            m_buttonPromote.ButtonClicked    += OnPromotePlayerClicked;
            m_buttonKick.ButtonClicked       += OnKickPlayerClicked;
            m_buttonAcceptJoin.ButtonClicked += OnAcceptJoinClicked;
            m_buttonDemote.ButtonClicked     += OnDemoteClicked;
            m_buttonAddNpc.ButtonClicked += OnNewNpcClicked;

            MySession.Static.Factions.FactionCreated           += OnFactionCreated;
            MySession.Static.Factions.FactionEdited            += OnFactionEdited;
            MySession.Static.Factions.FactionStateChanged      += OnFactionsStateChanged;
            MySession.Static.Factions.FactionAutoAcceptChanged += OnAutoAcceptChanged;

            Refresh();
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            string filepath = MakeScreenFilepath("MedicalsScreen");
            MyObjectBuilder_GuiScreen objectBuilder;

            var fsPath = Path.Combine(MyFileSystem.ContentPath, filepath);
            MyObjectBuilderSerializer.DeserializeXML<MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder);
            Init(objectBuilder);

            m_multilineRespawnWhenShipReady = new MyGuiControlMultilineText()
            {
                Position = new Vector2(0, -0.5f * Size.Value.Y + 80f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                Size = new Vector2(Size.Value.X * 0.85f, 75f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                Font = MyFontEnum.Red,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP,
                TextAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            };

            Controls.Add(m_multilineRespawnWhenShipReady);

            UpdateRespawnShipLabel();

            m_respawnsTable = new MyGuiControlTable();
            m_respawnsTable.Position = new Vector2(0, -0.01f);
            m_respawnsTable.Size = new Vector2(550f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1.3f);
            m_respawnsTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            m_respawnsTable.VisibleRowsCount = 17;
            Controls.Add(m_respawnsTable);

            m_respawnsTable.ColumnsCount = 2;
            m_respawnsTable.ItemSelected += OnTableItemSelected;
            m_respawnsTable.ItemDoubleClicked += OnTableItemDoubleClick;
            m_respawnsTable.SetCustomColumnWidths(new float[] { 0.50f, 0.50f });

            m_respawnsTable.SetColumnName(0, MyTexts.Get(MySpaceTexts.Name));
            m_respawnsTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.ScreenMedicals_OwnerTimeoutColumn));

            m_labelNoRespawn = new MyGuiControlLabel()
            {
                Position = new Vector2(0, -0.35f),
                ColorMask = Color.Red,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP
            };
            Controls.Add(m_labelNoRespawn);

            m_respawnButton = new MyGuiControlButton(
                            position: new Vector2(-0.1f, 0.35f),
                            text: MyTexts.Get(MySpaceTexts.Respawn),
                            onButtonClick: onRespawnClick
                            );
            Controls.Add(m_respawnButton);

            m_refreshButton = new MyGuiControlButton(
                          position: new Vector2(0.1f, 0.35f),
                          text: MyTexts.Get(MySpaceTexts.Refresh),
                          onButtonClick: onRefreshClick
                          );
            Controls.Add(m_refreshButton);

            m_noRespawnText = new MyGuiControlMultilineText(
                            position: new Vector2(-0.02f, -0.19f),
                            size: new Vector2(0.32f, 0.5f),
                            contents: MyTexts.Get(MySpaceTexts.ScreenMedicals_NoRespawnPossible),
                            textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                            font: MyFontEnum.Red
                            );
            Controls.Add(m_noRespawnText);

            RefreshRespawnPoints();
        }
Example #35
0
 private MultilineData ComputeLineDataFromString(string value)
 {
     MultilineData ret;
     ret.data = value;
     
     MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(size: new Vector2(QuestlogSize.X * 0.92f, 1), drawScrollbar: false);
     textBox.Visible = false;
     textBox.TextScale = 0.9f;
     textBox.AppendText(value);
     
     ret.lines = textBox.NumberOfRows;
     return ret;
 }
Example #36
0
        public MyGuiControlNews():
            base(isActiveControl: true,
            canHaveFocus: false,
            allowFocusingElements: true)
        {
            m_news = new List<MyNewsEntry>();

            m_labelTitle = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP) {
                Name = "Title"
            };
            m_labelDate = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP) {
                Name = "Date"
            };
            m_separator = new MyGuiControlSeparatorList() {
                Name = "Separator",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER
            };
            m_textNewsEntry = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f,
                drawScrollbar: true)
            {
                Name = "NewsEntry",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            };
            m_textNewsEntry.OnLinkClicked += OnLinkClicked;
            m_bottomPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_PAGING_BACKGROUND,
                Name = "BottomPanel",
            };
            m_labelPages = new MyGuiControlLabel(
                text: new StringBuilder("{0}/{1}  ").ToString(),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) {
                Name = "Pages"
            };
            m_buttonPrev = new MyGuiControlButton(
                visualStyle: MyGuiControlButtonStyleEnum.ArrowLeft,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                onButtonClick: (b) => UpdateCurrentEntryIndex(-1)) {
                Name = "Previous"
            };
            m_buttonNext = new MyGuiControlButton(
                visualStyle: MyGuiControlButtonStyleEnum.ArrowRight,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                onButtonClick: (b) => UpdateCurrentEntryIndex(+1)) {
                Name = "Next"
            };
            m_textError = new MyGuiControlMultilineText(
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                font: MyFontEnum.Red) {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                Name = "Error"
            };
            m_backgroundPanel = new MyGuiControlCompositePanel()
            {
                ColorMask = new Vector4(1f, 1f, 1f, 0.69f),
                BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_BACKGROUND
            };

            m_wheelLoading = new MyGuiControlRotatingWheel(multipleSpinningWheels: MyPerGameSettings.GUI.MultipleSpinningWheels);

            Elements.Add(m_backgroundPanel);
            Elements.Add(m_labelTitle);
            Elements.Add(m_labelDate);
            Elements.Add(m_separator);
            Elements.Add(m_textNewsEntry);
            Elements.Add(m_bottomPanel);
            Elements.Add(m_labelPages);
            Elements.Add(m_buttonPrev);
            Elements.Add(m_buttonNext);
            Elements.Add(m_textError);
            Elements.Add(m_wheelLoading);

            if (false)
            {
                m_textNewsEntry.BorderEnabled = true;
                m_labelPages.BorderEnabled = true;
                m_bottomPanel.BorderEnabled = true;
                m_buttonPrev.BorderEnabled = true;
                m_buttonNext.BorderEnabled = true;
                m_textError.BorderEnabled = true;
                m_wheelLoading.BorderEnabled = true;
            }

            RefreshState();
            UpdatePositionsAndSizes();
            RefreshShownEntry();

            try
            {
                m_newsSerializer = new XmlSerializer(typeof(MyNews));
            }
            finally
            {
                DownloadNews();   
            }
        }
 public void CopyText(MyGuiControlMultilineText sender)
 {
     ClipboardText = Regex.Replace(sender.Text.ToString().Substring(Start, Length), "\n", "\r\n");
     Thread myth;
     myth = new Thread(new System.Threading.ThreadStart(CopyToClipboard));
     myth.ApartmentState = ApartmentState.STA;
     myth.Start();
 }
Example #38
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            Vector2 buttonSize  = MyGuiControlButton.GetVisualStyle(m_style.ButtonStyle).NormalTexture.MinSizeGui;
            Vector2 captionSize = MyGuiManager.MeasureString(m_style.CaptionFont, m_messageCaption, MyGuiConstants.DEFAULT_TEXT_SCALE);

            //  Message box caption
            var padding = m_style.BackgroundTexture.PaddingSizeGui;
            MyGuiControlLabel captionLabel = new MyGuiControlLabel(
                position: new Vector2(0, -0.5f * m_size.Value.Y + padding.Y),
                text: m_messageCaption.ToString(),
                font: m_style.CaptionFont,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);

            Controls.Add(captionLabel);

            //  Message box text
            m_messageBoxText = new MyGuiControlMultilineText(
                position: Vector2.Zero,
                size: new Vector2(m_size.Value.X - 2 * padding.X, m_size.Value.Y - (2 * padding.Y + captionSize.Y + buttonSize.Y)),
                backgroundColor: Vector4.One,
                contents: m_messageText,
                textScale: MyGuiConstants.DEFAULT_TEXT_SCALE,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                font: m_style.TextFont);

            Controls.Add(m_messageBoxText);

            //  Buttons
            float            buttonY       = 0.5f * m_size.Value.Y - padding.Y;
            float            buttonOffsetX = 0.05f;
            MyGuiControlBase yesButton     = null;
            MyGuiControlBase noButton      = null;
            MyGuiControlBase cancelButton  = null;

            switch (m_buttonType)
            {
            case MyMessageBoxButtonsType.NONE:
            case MyMessageBoxButtonsType.NONE_TIMEOUT:
                break;

            case MyMessageBoxButtonsType.OK:
                Controls.Add(yesButton = MakeButton(new Vector2(0, buttonY), m_style, m_okButtonText, OnYesClick, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM));
                break;

            case MyMessageBoxButtonsType.YES_NO:
            case MyMessageBoxButtonsType.YES_NO_TIMEOUT:
                Controls.Add(yesButton = MakeButton(new Vector2(-buttonOffsetX, buttonY), m_style, m_yesButtonText, OnYesClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM));
                Controls.Add(noButton  = MakeButton(new Vector2(buttonOffsetX, buttonY), m_style, m_noButtonText, OnNoClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM));
                break;

            case MyMessageBoxButtonsType.YES_NO_CANCEL:
                Controls.Add(yesButton    = MakeButton(new Vector2(-(buttonOffsetX + buttonSize.X * 0.5f), buttonY), m_style, m_yesButtonText, OnYesClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM));
                Controls.Add(noButton     = MakeButton(new Vector2(0, buttonY), m_style, m_noButtonText, OnNoClick, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM));
                Controls.Add(cancelButton = MakeButton(new Vector2((buttonOffsetX + buttonSize.X * 0.5f), buttonY), m_style, m_cancelButtonText, OnCancelClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM));
                break;

            default:
                throw new InvalidBranchException();
                break;
            }

            switch (m_focusedResult)
            {
            case ResultEnum.YES:
                FocusedControl = yesButton;
                break;

            case ResultEnum.NO:
                FocusedControl = noButton;
                break;

            case ResultEnum.CANCEL:
                FocusedControl = cancelButton;
                break;
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            Vector2 loadingTextSize = MyGuiManager.MeasureString(m_fontId,
                MyTexts.Get(MyCommonTexts.LoadingPleaseWaitUppercase), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);
            m_wheel = new MyGuiControlRotatingWheel(
                MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.06f + loadingTextSize.Y),
                MyGuiConstants.ROTATING_WHEEL_COLOR,
                MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                m_rotatingWheelTexture,
                false,
                MyPerGameSettings.GUI.MultipleSpinningWheels);

            StringBuilder contents;

            if(!string.IsNullOrEmpty(m_customTextFromConstructor))
                contents = new StringBuilder(m_customTextFromConstructor);
            else
                contents = MyTexts.Get(m_currentQuote.Text);

            m_quoteTextControl = new MyGuiControlMultilineText(
                position: Vector2.One * 0.5f,
                size: new Vector2(0.9f, 0.2f),
                backgroundColor: Vector4.One,
                font: m_fontId,
                textScale: 1.0f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                contents: contents,
                drawScrollbar: false);
            m_quoteTextControl.BorderEnabled = false;
            m_quoteTextControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
            m_quoteTextControl.TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;

            Controls.Add(m_wheel);
            RefreshQuote();
        }
            public void CutText(MyGuiControlMultilineText sender)
            {
                //First off, we have to copy
                CopyText(sender);

                //Then we cut the text away from the form
                EraseText(sender);
            }