/// <summary>
        /// Generates multiline text control indicating that block is not available.
        /// </summary>
        /// <param name="blockSizeLarge">Is block size large.</param>
        /// <returns>Multiline text control with block not available info.</returns>
        private MyGuiControlMultilineText GenerateSizeNotAvailableText(bool blockSizeLarge)
        {
            MyGuiControlMultilineText textControl = new MyGuiControlMultilineText(size: new Vector2(0.2f, 0.1f), font: MyFontEnum.Red, showTextShadow: true, textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            string blockTypeLabelText             = MyTexts.GetString(!blockSizeLarge ? MySpaceTexts.HudBlockInfo_LargeShip_Station : MySpaceTexts.HudBlockInfo_SmallShip);

            textControl.AppendText(string.Format(MyTexts.GetString(MySpaceTexts.BlockSize_NotAvailable), blockTypeLabelText));
            return(textControl);
        }
Exemple #2
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

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

            var fsPath = Path.Combine(MyFileSystem.ContentPath, filepath);

            Sandbox.Common.ObjectBuilders.Serializer.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_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);

            RefreshRespawnPoints();
        }
Exemple #3
0
        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: Common.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);
        }
        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();
        }
        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();
        }
        private 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,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: selectable,
                font: MyFontEnum.Blue);

            return(textbox);
        }
Exemple #7
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);
        }
Exemple #8
0
        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;
        }
        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 override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            Vector2 loadingTextSize = MyGuiManager.MeasureString(m_font,
                                                                 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_font,
                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();
        }
Exemple #12
0
        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));
            }
        }
        public sealed override void RecreateControls(bool constructor)
        {
            Elements.Clear();

            this.m_backgroundTexture = MyGuiConstants.TEXTURE_MESSAGEBOX_BACKGROUND_INFO.Texture;
            this.m_backgroundColor   = new Vector4(0, 0, 0, 0.5f);     // Grey, half opacity
            this.m_size     = new Vector2(_screenScale, 0.5f);         // Half the screen, drop down from the top
            this.m_position = new Vector2(0.5f, 0.25f);                // HorizontalCenter / Quarter vertical

            base.RecreateControls(constructor);

            Vector4 value     = new Vector4(1f, 1f, 1f, 1f);
            float   textScale = 1f;

            _textBox             = new MyGuiControlTextbox(new Vector2?(new Vector2(0f, 0.25f)), null, 512, new Vector4?(value), 0.8f, MyGuiControlTextboxType.Normal, MyGuiControlTextboxStyleEnum.Default);
            _textBox.Position   -= new Vector2(0f, _textBox.Size.Y + _margin.Y / 2f);
            _textBox.Size        = new Vector2(_screenScale, _textBox.Size.Y) - 2f * _margin;
            _textBox.ColorMask   = new Vector4(0f, 0f, 0f, 0.5f);
            _textBox.VisualStyle = MyGuiControlTextboxStyleEnum.Default;
            _textBox.Name        = "HaE CMD";

            _displayScreen             = new MyGuiControlMultilineText(new Vector2?(new Vector2(-0.5f * _screenScale, -0.25f) + _margin), new Vector2?(new Vector2(_screenScale, 0.5f - _textBox.Size.Y) - 2f * _margin), null, "Debug", 0.8f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, null, true, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, null, true, false, null, null);
            _displayScreen.TextColor   = Color.White;
            _displayScreen.TextScale   = textScale;
            _displayScreen.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            _displayScreen.Text        = HaEConsole.Instance.displayScreen;
            _displayScreen.ColorMask   = new Vector4(0f, 0f, 0f, 0.5f);
            _displayScreen.Name        = "DisplayScreen";

            _logo = new MyGuiControlImage(new Vector2?(new Vector2(0.46f * _screenScale, -0.24f)), new Vector2?(new Vector2(0.05f, _screenScale * 0.05f)), null, null, new string[]
            {
                $"{HaEConstants.pluginFolder}\\Assets\\logo.png"
            }, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            _logo.ColorMask = new Vector4(1f, 1f, 1f, 0.5f);
            _logo.SetToolTip("HaE PluginCore");

            this.Controls.Add(_textBox);
            this.Controls.Add(_displayScreen);
            this.Controls.Add(_logo);
        }
Exemple #14
0
 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.Length; i++)
         {
             if (i < texts.Length)
             {
                 label.AppendText(m_stringCache.Clear().Append(texts[i]));
             }
             if (i < matches.Count)
             {
                 ParseMarkup(label, matches[i].Value);
             }
         }
     }
     catch
     {
     }
 }
        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 virtual void GetDescriptionText(MyGuiControlMultilineText textbox)
        {
            textbox.Visible = true;
            textbox.Clear();
            if (string.IsNullOrEmpty(Description))
            {
                if (string.IsNullOrEmpty(Tooltip))
                {
                    textbox.AppendText("No description");
                }
                else
                {
                    textbox.AppendText(CapLength(Tooltip, 1000));
                }
                return;
            }
            else
            {
                string text      = CapLength(Description, 1000);
                int    textStart = 0;
                foreach (Match m in Regex.Matches(text, @"https?:\/\/(www\.)?[\w-.]{2,256}\.[a-z]{2,4}\b[\w-.@:%\+~#?&//=]*"))
                {
                    int textLen = m.Index - textStart;
                    if (textLen > 0)
                    {
                        textbox.AppendText(text.Substring(textStart, textLen));
                    }

                    textbox.AppendLink(m.Value, m.Value);
                    textStart = m.Index + m.Length;
                }

                if (textStart < text.Length)
                {
                    textbox.AppendText(text.Substring(textStart));
                }
            }
        }
        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;
                }
            }
        }
Exemple #18
0
        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);
        }
        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       = MySpaceTexts.Edit;
            m_buttonPromote.TextEnum    = MySpaceTexts.Promote;
            m_buttonKick.TextEnum       = MySpaceTexts.Kick;
            m_buttonAcceptJoin.TextEnum = MySpaceTexts.Accept;
            m_buttonDemote.TextEnum     = MySpaceTexts.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 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();
        }
Exemple #21
0
        public void RecreateControls()
        {
            if (QuestInfo == null || Elements == null)
            {
                return;
            }
            Elements.Clear();

            Vector2 topleft    = -this.Size / 2;
            Vector2 textOffset = new Vector2(0.015f, 0.015f);

            // Title
            MyGuiControlLabel title = new MyGuiControlLabel();

            title.Text        = QuestInfo.QuestTitle;
            title.Position    = topleft + textOffset;
            title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            title.Visible     = true;
            Elements.Add(title);

            // Pages
            if (QuestInfo.MaxPages != 0)
            {
                MyGuiControlLabel numbers = new MyGuiControlLabel();
                numbers.Text        = QuestInfo.Page + "/" + QuestInfo.MaxPages;
                numbers.Position    = topleft + Vector2.UnitX * this.Size - textOffset * new Vector2(1, -1);
                numbers.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                Elements.Add(numbers);
            }

            // Separator
            MyGuiControlSeparatorList m_separator;

            m_separator = new MyGuiControlSeparatorList();
            m_separator.AddHorizontal(topleft + textOffset + new Vector2(0, 0.03f), this.Size.X - 2 * textOffset.X, 0.003f); // Title separator
            m_separator.Visible = true;
            Elements.Add(m_separator);

            // Details
            var rowOffset = new Vector2(0, 0.025f);

            string[] details = QuestInfo.GetQuestGetails();
            int      idx     = 0;

            for (int i = 0; i < details.Length; i++)
            {
                if (details[i] == null)
                {
                    continue;
                }
                MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(
                    size: new Vector2(Size.X * 0.92f, rowOffset.Y * 5),
                    position: topleft + textOffset + new Vector2(0, 0.04f) + rowOffset * idx,
                    textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    //Debug purpose
                    //backgroundColor: Vector4.One,
                    //backgroundTexture: BackgroundTexture,
                    drawScrollbar: false
                    );
                textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                textBox.TextScale   = 0.9f;
                textBox.AppendText(details[i]);
                textBox.Visible = true;
                idx            += textBox.NumberOfRows;
                Elements.Add(textBox);
            }
        }
        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                    = MySpaceTexts.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_chatControl = new MyHudControlChat(MyHud.Chat, Vector2.Zero, new Vector2(0.4f, 0.25f));
            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(MySpaceTexts.Hud_BuildMode));
            Controls.Add(m_buildModeLabel);

            m_relayNotification          = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_relayNotification.TextEnum = MySpaceTexts.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(MySpaceTexts.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 = MySpaceTexts.Multiplayer_NoConnection;
            m_noConnectionNotification.Visible  = false;
            Controls.Add(m_noConnectionNotification);
            MyHud.ReloadTexts();
        }
        public MyGuiScreenMission(MyMission missionBase, bool canDecline = true)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.75f, 0.75f))
        {
            Debug.Assert(missionBase != null);
            m_mission           = missionBase;
            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\MissionAcceptBackground", flags: TextureFlags.IgnoreQuality);
            m_size = new Vector2(1010 / 1600f, 855 / 1200f);

            // Title
            var titleLabel = new MyGuiControlLabel(
                this,
                new Vector2(0, -0.3052f),
                null,
                MyTextsWrapperEnum.Mission,
                MyGuiConstants.LABEL_TEXT_COLOR,
                MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            // append mission name to the title of the screen
            titleLabel.UpdateParams(new[] { missionBase.Name });
            Controls.Add(titleLabel);

            // mission description on the left
            Controls.Add(new MyGuiControlLabel(
                             this,
                             new Vector2(-m_size.Value.X / 4.5f, -0.2501f),
                             null, MyTextsWrapperEnum.Description,
                             MyGuiConstants.LABEL_TEXT_COLOR, .8f,
                             MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));



            var multiLineText = new MyGuiControlMultilineText(
                this,
                new Vector2(-m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f),
                new Vector2(370 / 1600f, 489 / 1200f),
                null,
                MyGuiManager.GetFontMinerWarsBlue(), .66f,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                m_mission.DescriptionTemp, false, true);


            Controls.Add(multiLineText);
            multiLineText.ScrollbarOffset = 71 / 1600f;


            // mission objectives (submissions) on the right
            Controls.Add(new MyGuiControlLabel(
                             this,
                             new Vector2(m_size.Value.X / 4.5f, -0.2501f),
                             null, MyTextsWrapperEnum.Objectives,
                             MyGuiConstants.LABEL_TEXT_COLOR, .8f,
                             MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            var objectives = new StringBuilder();

            foreach (MyObjective t in m_mission.Objectives)
            {
                objectives.Append("- ");
                objectives.Append(t.DescriptionTemp.ToString());
                objectives.AppendLine("\n");
                //objectives.AppendLine();
            }

            var textControl = new MyGuiControlMultilineText(
                this,
                new Vector2(m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f),
                new Vector2(370 / 1600f, 489 / 1200f),
                null,
                MyGuiManager.GetFontMinerWarsBlue(), .66f,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                objectives, false, true)
            {
                ScrollbarOffset = 64 / 1600f
            };


            Controls.Add(textControl);

            textControl.Clear();
            textControl.AppendText(objectives);


            var okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE,
                                                  MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                  MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Accept,
                                                  MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnAccept_Click,
                                                  true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(okButton);



            // decline button
            if (canDecline)
            {
                var declineButton = new MyGuiControlButton(this, new Vector2(0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE,
                                                           MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                           MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Decline,
                                                           MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnDecline_Click,
                                                           true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
                Controls.Add(declineButton);
            }
            else
            {
                m_closeOnEsc = canDecline;
            }
        }
        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_nameTextbox.Enabled        = false;
            m_descriptionTextbox         = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH);
            m_descriptionTextbox.Enabled = false;
            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_onlineMode.Enabled = false;
            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: OnPublishButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_editButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2 * (0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonEdit),
                                                  onButtonClick: OnEditButtonClick, 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: OnBrowseWorkshopClick, 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_editButton);
            m_editButton.Enabled = false;
            Controls.Add(m_browseWorkshopButton);
            Controls.Add(m_refreshButton);
            Controls.Add(m_openInWorkshopButton);
            m_openInWorkshopButton.Enabled = false;
            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            CloseButtonEnabled = true;

            SetDefaultValues();
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            var layout = new MyLayoutTable(this);

            layout.SetColumnWidthsNormalized(50, 300, 300, 300, 300, 300, 50);
            layout.SetRowHeightsNormalized(50, 450, 70, 70, 70, 400, 70, 70, 50);

            //BRIEFING:
            MyGuiControlParent briefing = new MyGuiControlParent();
            var briefingScrollableArea  = new MyGuiControlScrollablePanel(
                scrolledControl: briefing)
            {
                Name = "BriefingScrollableArea",
                ScrollbarVEnabled   = true,
                OriginAlign         = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture   = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
            };

            layout.AddWithSize(briefingScrollableArea, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 4, colSpan: 3);
            //inside scrollable area:
            m_descriptionBox = new MyGuiControlMultilineText(
                position: new Vector2(-0.227f, 5f),
                size: new Vector2(briefingScrollableArea.Size.X - 0.02f, 11f),
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: false);
            briefing.Controls.Add(m_descriptionBox);

            m_connectedPlayers                  = new MyGuiControlTable();
            m_connectedPlayers.Size             = new Vector2(490f, 150f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_connectedPlayers.VisibleRowsCount = 8;
            m_connectedPlayers.ColumnsCount     = 2;
            m_connectedPlayers.SetCustomColumnWidths(new float[] { 0.7f, 0.3f });
            m_connectedPlayers.SetColumnName(0, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerName));
            m_connectedPlayers.SetColumnName(1, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerStatus));

            m_kickPlayerButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Kick), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                        size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnKick2Clicked);
            m_kickPlayerButton.Enabled = CanKick();

            m_timeoutLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.GuiScenarioTimeout), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            TimeoutCombo = new MyGuiControlCombobox();
            TimeoutCombo.ItemSelected += OnTimeoutSelected;
            TimeoutCombo.AddItem(3, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout3min));
            TimeoutCombo.AddItem(5, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout5min));
            TimeoutCombo.AddItem(10, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout10min));
            TimeoutCombo.AddItem(-1, MyTexts.Get(MySpaceTexts.GuiScenarioTimeoutUnlimited));
            TimeoutCombo.SelectItemByIndex(0);
            TimeoutCombo.Enabled = Sync.IsServer;

            m_canJoinRunningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScenarioSettings_CanJoinRunningShort), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_canJoinRunning      = new MyGuiControlCheckbox();

            m_canJoinRunningLabel.Enabled = false;
            m_canJoinRunning.Enabled      = false;

            m_startButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioStart), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                   size: new Vector2(200, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnStartClicked);
            m_startButton.Enabled = Sync.IsServer;

            m_chatControl = new MyHudControlChat(
                MyHud.Chat,
                size: new Vector2(1400f, 300f) / MyGuiConstants.GUI_OPTIMAL_SIZE,
                font: MyFontEnum.DarkBlue,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                backgroundColor: MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR,
                contents: null,
                drawScrollbar: true,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_chatControl.BorderEnabled = true;
            m_chatControl.BorderColor   = Color.CornflowerBlue;

            m_chatTextbox               = new MyGuiControlTextbox(maxLength: ChatMessageBuffer.MAX_MESSAGE_SIZE);
            m_chatTextbox.Size          = new Vector2(1400f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_chatTextbox.TextScale     = 0.8f;
            m_chatTextbox.VisualStyle   = MyGuiControlTextboxStyleEnum.Default;
            m_chatTextbox.EnterPressed += ChatTextbox_EnterPressed;

            m_sendChatButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioSend), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                      size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnSendChatClicked);


            layout.AddWithSize(m_connectedPlayers, MyAlignH.Left, MyAlignV.Top, 1, 4, rowSpan: 2, colSpan: 2);

            layout.AddWithSize(m_kickPlayerButton, MyAlignH.Left, MyAlignV.Center, 2, 5);
            layout.AddWithSize(m_timeoutLabel, MyAlignH.Left, MyAlignV.Center, 3, 4);
            layout.AddWithSize(TimeoutCombo, MyAlignH.Left, MyAlignV.Center, 3, 5);

            layout.AddWithSize(m_canJoinRunningLabel, MyAlignH.Left, MyAlignV.Center, 4, 4);
            layout.AddWithSize(m_canJoinRunning, MyAlignH.Right, MyAlignV.Center, 4, 5);

            layout.AddWithSize(m_chatControl, MyAlignH.Left, MyAlignV.Top, 5, 1, rowSpan: 1, colSpan: 5);

            layout.AddWithSize(m_chatTextbox, MyAlignH.Left, MyAlignV.Top, 6, 1, rowSpan: 1, colSpan: 4);
            layout.AddWithSize(m_sendChatButton, MyAlignH.Right, MyAlignV.Top, 6, 5);

            layout.AddWithSize(m_startButton, MyAlignH.Left, MyAlignV.Top, 7, 2);
        }
        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;

            m_blockInfo = new MyGuiControlBlockInfo();
            m_blockInfo.IsActiveControl = false;
            Controls.Add(m_blockInfo);

            m_chatControl = new MyHudControlChat(Vector2.Zero, new Vector2(0.4f, 0.25f));
            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(MySpaceTexts.Hud_BuildMode));
            Controls.Add(m_buildModeLabel);

            m_relayNotification          = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_relayNotification.TextEnum = MySpaceTexts.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(MySpaceTexts.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 = MySpaceTexts.Multiplayer_NoConnection;
            m_noConnectionNotification.Visible  = false;
            Controls.Add(m_noConnectionNotification);
            MyHud.ReloadTexts();
        }
Exemple #27
0
        private void InitRightSide()
        {
            Vector2 originL;

            originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP);

            var screenSize         = m_size.Value;
            var layoutSize         = new Vector2(screenSize.X / 2 - originL.X, screenSize.Y - MARGIN_TOP - MARGIN_BOTTOM);
            var columnWidthLabel   = layoutSize.X * 0.25f;
            var columnWidthControl = layoutSize.X - columnWidthLabel;
            var rowHeight          = 0.052f;
            var leftHeight         = layoutSize.Y - 4 * rowHeight;
            var descriptionMargin  = 0.005f;

            m_tableLayout = new MyLayoutTable(this, originL, layoutSize);
            m_tableLayout.SetColumnWidthsNormalized(columnWidthLabel, columnWidthControl);
            m_tableLayout.SetRowHeightsNormalized(rowHeight, rowHeight, rowHeight, rowHeight, leftHeight);

            m_nameLabel               = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.Name), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM, position: new Vector2(0, 0.2f));
            m_nameTextbox             = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH);
            m_nameTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            m_nameTextbox.Enabled     = false;

            float width = m_nameTextbox.Size.X;

            m_difficultyLabel         = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.Difficulty), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);
            m_difficultyCombo         = new MyGuiControlCombobox(size: new Vector2(width, 0.04f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);
            m_difficultyCombo.Enabled = false;
            m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy);
            m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal);
            m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard);

            m_onlineModeLabel    = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.WorldSettings_OnlineMode), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);
            m_onlineMode         = new MyGuiControlCheckbox(originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);
            m_onlineMode.Enabled = false;

            m_descriptionMultilineText = new MyGuiControlMultilineText(
                selectable: false,
                font: MyFontEnum.Blue)
            {
                Name         = "BriefingMultilineText",
                Position     = new Vector2(-0.009f, -0.115f),
                Size         = new Vector2(0.419f, 0.412f),
                OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                TextAlign    = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            };

            var panel = new MyGuiControlCompositePanel()
            {
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
            };


            m_tableLayout.Add(m_nameLabel, MyAlignH.Left, MyAlignV.Center, 0, 0);
            m_tableLayout.Add(m_difficultyLabel, MyAlignH.Left, MyAlignV.Center, 2, 0);
            m_tableLayout.Add(m_onlineModeLabel, MyAlignH.Left, MyAlignV.Center, 3, 0);

            m_tableLayout.Add(m_nameTextbox, MyAlignH.Left, MyAlignV.Center, 0, 1);
            m_tableLayout.Add(m_difficultyCombo, MyAlignH.Left, MyAlignV.Center, 2, 1);
            m_tableLayout.Add(m_onlineMode, MyAlignH.Left, MyAlignV.Center, 3, 1);

            m_tableLayout.Add(panel, MyAlignH.Left, MyAlignV.Top, 4, 0, 1, 2);
            m_tableLayout.Add(m_descriptionMultilineText, MyAlignH.Left, MyAlignV.Top, 4, 0, 1, 2);
            m_descriptionMultilineText.Position = new Vector2(panel.Position.X + descriptionMargin, panel.Position.Y);
            panel.Size = new Vector2(m_nameTextbox.Size.X + columnWidthLabel, m_tableLayout.GetCellSize(4, 0).Y + 0.01f);
            m_descriptionMultilineText.Size = new Vector2(panel.Size.X - descriptionMargin, m_tableLayout.GetCellSize(4, 0).Y - descriptionMargin + 0.01f);

            var buttonsOrigin = m_size.Value / 2 - new Vector2(0.365f, 0.03f);
            var buttonSize    = MyGuiConstants.BACK_BUTTON_SIZE;
            // Ok/Cancel
            var okButton     = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.055f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            var cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.055f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

            Controls.Add(okButton);
            Controls.Add(cancelButton);

            CloseButtonEnabled = true;
        }
        protected virtual void BuildControls()
        {
            AddCaption(ScreenCaption);

            // side menu
            {
                var nameLabel        = MakeLabel(MyCommonTexts.Name);
                var descriptionLabel = MakeLabel(MyCommonTexts.Description);

                m_nameTextbox                = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH);
                m_nameTextbox.Enabled        = false;
                m_descriptionTextbox         = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH);
                m_descriptionTextbox.Enabled = false;

                Vector2 originL;
                Vector2 controlsDelta = new Vector2(0f, 0.052f);
                originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP);

                var screenSize         = m_size.Value;
                var layoutSize         = screenSize / 2 - originL;
                var columnWidthLabel   = layoutSize.X * 0.25f;
                var columnWidthControl = layoutSize.X - columnWidthLabel;
                var rowHeight          = 0.052f;
                layoutSize.Y = rowHeight * 5;

                m_sideMenuLayout = new MyLayoutTable(this, originL, layoutSize);
                m_sideMenuLayout.SetColumnWidthsNormalized(columnWidthLabel, columnWidthControl);
                m_sideMenuLayout.SetRowHeightsNormalized(rowHeight, rowHeight, rowHeight, rowHeight, rowHeight);

                m_sideMenuLayout.Add(nameLabel, MyAlignH.Left, MyAlignV.Top, 0, 0);
                m_sideMenuLayout.Add(m_nameTextbox, MyAlignH.Left, MyAlignV.Top, 0, 1);
                m_sideMenuLayout.Add(descriptionLabel, MyAlignH.Left, MyAlignV.Top, 1, 0);
                m_sideMenuLayout.Add(m_descriptionTextbox, MyAlignH.Left, MyAlignV.Top, 1, 1);
            }

            // briefing
            {
                var briefingPanel = new MyGuiControlPanel()
                {
                    Name              = "BriefingPanel",
                    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
                };
                Controls.Add(briefingPanel);

                m_descriptionBox = new MyGuiControlMultilineText(
                    selectable: false,
                    font: MyFontEnum.Blue)
                {
                    Name         = "BriefingMultilineText",
                    Position     = new Vector2(-0.009f, -0.115f),
                    Size         = new Vector2(0.419f, 0.412f),
                    OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    TextAlign    = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                };
                Controls.Add(m_descriptionBox);
            }

            // buttons
            {
                int     buttonRowCount    = 2;
                int     buttonColumnCount = 4;
                Vector2 buttonSize        = new Vector2(300f / 1600f, 70f / 1200f);
                Vector2 buttonsOrigin     = m_size.Value / 2 - new Vector2(0.83f, 0.16f);
                Vector2 buttonOffset      = new Vector2(0.01f, 0.01f);
                Vector2 buttonLayoutSize  = new Vector2((buttonSize.X + buttonOffset.X) * (buttonColumnCount), (buttonSize.Y + buttonOffset.Y) * (buttonRowCount));
                m_buttonsLayout = new MyLayoutTable(this, buttonsOrigin, buttonLayoutSize);

                float[] columnWidths = Enumerable.Repeat(buttonSize.X + buttonOffset.X, buttonColumnCount).ToArray();
                m_buttonsLayout.SetColumnWidthsNormalized(columnWidths);
                float[] rowHeights = Enumerable.Repeat(buttonSize.Y + buttonOffset.Y, buttonRowCount).ToArray();
                m_buttonsLayout.SetRowHeightsNormalized(rowHeights);

                m_okButton     = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick);
                m_cancelButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick);

                m_buttonsLayout.Add(m_okButton, MyAlignH.Left, MyAlignV.Top, 1, 2);
                m_buttonsLayout.Add(m_cancelButton, MyAlignH.Left, MyAlignV.Top, 1, 3);
            }

            // left menu
            {
                m_scenarioTable = CreateScenarioTable();
                Controls.Add(m_scenarioTable);
            }
        }
Exemple #29
0
 public override void GetDescriptionText(MyGuiControlMultilineText textbox)
 {
     textbox.Visible = false;
     textbox.Clear();
 }
        public MyGuiControlScreenSwitchPanel(MyGuiScreenBase owner, StringBuilder ownerDescription)
        {
            var currentPosition = Vector2.Zero;

            var descriptingText = new MyGuiControlMultilineText
            {
                OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                Position     = new Vector2(owner.Size.Value.X / 2 - 0.015f, 0.113f),
                Size         = new Vector2(owner.Size.Value.X - 0.1f, 0.03f),
                TextAlign    = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                Text         = ownerDescription,
                Font         = "DarkBlue"
            };

            var campaignButton = new MyGuiControlButton(
                position: currentPosition,
                textScale: MyGuiConstants.MAIN_MENU_BUTTON_TEXT_SCALE,
                text: MyTexts.Get(MyCommonTexts.ScreenCaptionNewGame),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                onButtonClick: OnCampaignButtonClick
                );

            currentPosition.X += campaignButton.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X;
            var customWorldButton = new MyGuiControlButton(
                position: currentPosition,
                textScale: MyGuiConstants.MAIN_MENU_BUTTON_TEXT_SCALE,
                text: MyTexts.Get(MyCommonTexts.ScreenCaptionCustomWorld),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                onButtonClick: OnCustomWorldButtonClick
                );

            currentPosition.X += customWorldButton.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X;
            var worshopWorldsButton = new MyGuiControlButton(
                position: currentPosition,
                textScale: MyGuiConstants.MAIN_MENU_BUTTON_TEXT_SCALE,
                text: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                onButtonClick: OnWorshopButtonClick
                );

            var separator = new MyGuiControlSeparatorList();

            separator.AddHorizontal(new Vector2(0.02f, 0.083f), owner.Size.Value.X - 0.07f);
            separator.AddHorizontal(new Vector2(0.02f, 0.14f), owner.Size.Value.X - 0.07f);

            if (owner is MyGuiScreenNewGame)
            {
                owner.FocusedControl = campaignButton;
            }
            else if (owner is MyGuiScreenWorldSettings)
            {
                owner.FocusedControl = customWorldButton;
            }
            else if (owner is MyGuiScreenLoadSubscribedWorld)
            {
                owner.FocusedControl = worshopWorldsButton;
            }

            Controls.Add(descriptingText);
            Controls.Add(separator);
            Controls.Add(campaignButton);
            Controls.Add(customWorldButton);
            Controls.Add(worshopWorldsButton);

            var offset = new Vector2(0.013f, 0.02f);

            Position = -owner.Size.Value / 2 + offset;

            owner.Controls.Add(this);
        }