private void SendMessageFromChatTextBox()
        {
            m_chatTextbox.GetText(m_editBoxStringBuilder.Clear());
            string message = m_editBoxStringBuilder.ToString();

            SendChatMessage(message);

            m_chatTextbox.SetText(m_editBoxStringBuilder.Clear());
        }
Exemple #2
0
        void OnTextChanged(MyGuiControlTextbox obj)
        {
            m_tmpText.Clear();
            obj.GetText(m_tmpText);

            foreach (var item in TargetBlocks)
            {
                SetValue(item, m_tmpText);
            }
        }
Exemple #3
0
        /// <summary>
        /// Adds the property for naming formats to the textBox
        /// </summary>
        /// <param name="textBox">TextBox</param>
        /// <param name="property">Property</param>
        /// <returns>The resulting text in the text box</returns>
        private string AddNameProperty(MyGuiControlTextbox textBox, string property)
        {
            var sb = new StringBuilder();

            textBox.GetText(sb);
            sb.Append("[" + property + "]");
            textBox.SetText(sb);

            return(sb.ToString());
        }
        private void FilterGpsList(MyGuiControlTextbox obj)
        {
            this.radioButtonGroup.SelectByKey(0);
            StringBuilder stringBuilder = new StringBuilder();

            obj.GetText(stringBuilder);
            string text = stringBuilder.ToString();
            SortedList <string, IMyGps> sortedList = new SortedList <string, IMyGps>();

            string[] array = text.ToLower().Split(new char[]
            {
                ' '
            });
            if (text != null)
            {
                using (IEnumerator <KeyValuePair <string, IMyGps> > enumerator = this.gpsList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <string, IMyGps> keyValuePair = enumerator.Current;
                        string text2 = keyValuePair.Value.Name.ToString().ToLower();
                        bool   flag  = true;
                        foreach (string text3 in array)
                        {
                            if (!text2.Contains(text3.ToLower()))
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (flag)
                        {
                            sortedList.Add(keyValuePair.Key, keyValuePair.Value);
                        }
                    }
                    goto IL_DE;
                }
            }
            sortedList = this.gpsList;
            IL_DE:
            this.gpsCombobox.ClearItems();
            foreach (KeyValuePair <string, IMyGps> keyValuePair2 in sortedList)
            {
                this.gpsCombobox.AddItem((long)this.gpsList.IndexOfKey(keyValuePair2.Key), keyValuePair2.Key, null, null, true);
            }
            if (this.gpsCombobox.GetItemsCount() > 0)
            {
                this.gpsCombobox.SelectItemByIndex(0);
            }
        }
Exemple #5
0
 private bool trySync()
 {//takes current right side values of name, description and coordinates, compares them against record with previous hash and synces if necessary
     if (m_previousHash != null && (m_needsSyncName || m_needsSyncDesc || m_needsSyncX || m_needsSyncY || m_needsSyncZ))
     {
         if (MySession.Static.Gpss.ExistsForPlayer(MySession.Static.LocalPlayerId))
         {
             if (IsNameOk(m_panelInsName.Text) && IsCoordOk(m_xCoord.Text) && IsCoordOk(m_yCoord.Text) && IsCoordOk(m_zCoord.Text))
             {
                 Dictionary <int, MyGps> insList;
                 insList = MySession.Static.Gpss[MySession.Static.LocalPlayerId];
                 MyGps ins;
                 if (insList.TryGetValue((int)m_previousHash, out ins))
                 {
                     if (m_needsSyncName)
                     {
                         ins.Name = m_panelInsName.Text;
                     }
                     if (m_needsSyncDesc)
                     {
                         ins.Description = m_panelInsDesc.Text;
                     }
                     StringBuilder str = new StringBuilder();
                     if (m_needsSyncX)
                     {
                         m_xCoord.GetText(str);
                         ins.Coords.X = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture), 2);
                     }
                     str.Clear();
                     if (m_needsSyncY)
                     {
                         m_yCoord.GetText(str);
                         ins.Coords.Y = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture), 2);
                     }
                     str.Clear();
                     if (m_needsSyncZ)
                     {
                         m_zCoord.GetText(str);
                         ins.Coords.Z = Math.Round(double.Parse(str.ToString(), System.Globalization.CultureInfo.InvariantCulture), 2);
                     }
                     m_syncedGps = ins;
                     MySession.Static.Gpss.SendModifyGps(MySession.Static.LocalPlayerId, ins);
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
        /// <summary>
        /// Action to spawn a planet
        /// </summary>
        /// <param name="coordSpawn">If the planet should be spawned at coordinates instead of direct placement</param>
        private void OnSpawnPlanet(bool coordSpawn = false)
        {
            StringBuilder name = new StringBuilder();

            m_nameBox.GetText(name);
            if (name.ToString().Trim().Length <= 3)
            {
                MyPluginGuiHelper.DisplayError("The name must be at least 4 letters long", "Error");
                return;
            }

            if (coordSpawn)
            {
                MyGuiScreenDialogCoordinate coordinateInput = new MyGuiScreenDialogCoordinate("Planet coordinate");

                coordinateInput.OnConfirmed += delegate(Vector3D coord)
                {
                    MySystemPlanet p = new MySystemPlanet()
                    {
                        CenterPosition = coord,
                        SubtypeId      = ((MyPlanetGeneratorDefinition)m_planetDefList.GetLastSelected().UserData).Id.SubtypeId.ToString(),
                        Generated      = false,
                        DisplayName    = name.ToString().Trim(),
                        Diameter       = m_planetSizeSlider.Value
                    };

                    SpawnPlanet(p, coord);
                };

                MyGuiSandbox.AddScreen(coordinateInput);
                return;
            }

            float          size   = m_planetSizeSlider.Value;
            MySystemPlanet planet = new MySystemPlanet()
            {
                CenterPosition = Vector3D.Zero,
                SubtypeId      = ((MyPlanetGeneratorDefinition)m_planetDefList.GetLastSelected().UserData).Id.SubtypeId.ToString(),
                Generated      = false,
                DisplayName    = name.ToString().Trim(),
                Diameter       = size
            };

            MyPluginItemsClipboard.Static.Activate(planet, SpawnPlanet, size);

            CloseScreenNow();
        }
        void m_chatbox_TextChanged(MyGuiControlTextbox obj)
        {
            m_chatboxText.Clear();
            obj.GetText(m_chatboxText);
            if (m_chatboxText.Length == 0)
            {
                m_sendButton.Enabled = false;
            }
            else
            {
                if (MySession.Static.LocalCharacter != null)
                {
                    m_sendButton.Enabled = true;
                }

                if (m_chatboxText.Length > MyChatConstants.MAX_CHAT_STRING_LENGTH)
                {
                    m_chatboxText.Length = MyChatConstants.MAX_CHAT_STRING_LENGTH;
                    m_chatbox.SetText(m_chatboxText);
                }
            }
        }
        private void GenerateData(out MySystemAsteroids instance, out MyAsteroidSphereData data)
        {
            if (m_parentObjectListBox.SelectedItems.Count <= 0)
            {
                instance = null;
                data     = null;
                return;
            }
            var           selectedParent = m_parentObjectListBox.SelectedItems[m_parentObjectListBox.SelectedItems.Count - 1];
            var           parentItem     = selectedParent.UserData as MySystemObject;
            StringBuilder name           = new StringBuilder();

            m_nameBox.GetText(name);

            instance = new MySystemAsteroids();
            instance.AsteroidTypeName = MyAsteroidSphereProvider.TYPE_NAME;
            instance.CenterPosition   = parentItem.CenterPosition;
            instance.AsteroidSize     = new MySerializableMinMax((int)m_asteroidSizesSlider.CurrentMin, (int)m_asteroidSizesSlider.CurrentMax);
            instance.ParentId         = parentItem.Id;
            instance.DisplayName      = name.ToString();

            data = GetDataFromGui();
        }
        /// <summary>
        /// Generates the whole data for the currently edited asteroid ring from the values in the spawn menu
        /// </summary>
        /// <param name="ringData">The out value for the ring data</param>
        /// <param name="systemObject">The out value for the system object</param>
        private void GenerateAsteroidData(out MyAsteroidRingData ringData, out MySystemAsteroids systemObject)
        {
            if (m_parentObjectListBox.SelectedItems.Count <= 0)
            {
                ringData     = null;
                systemObject = null;
                return;
            }
            var           selectedParent = m_parentObjectListBox.SelectedItems[m_parentObjectListBox.SelectedItems.Count - 1];
            var           parentItem     = selectedParent.UserData as MySystemObject;
            StringBuilder name           = new StringBuilder();

            m_nameBox.GetText(name);

            systemObject = new MySystemAsteroids();
            systemObject.AsteroidTypeName = MyAsteroidRingProvider.Static.GetTypeName();
            systemObject.CenterPosition   = parentItem.CenterPosition + m_offset;
            systemObject.AsteroidSize     = new MySerializableMinMax((int)m_asteroidSizesSlider.CurrentMin, (int)m_asteroidSizesSlider.CurrentMax);
            systemObject.DisplayName      = name.ToString();
            systemObject.ParentId         = parentItem.Id;

            ringData = GenerateAsteroidRing();
        }
        public bool CreateSpawnMenu(float usableWidth, MyGuiControlParentTableLayout parentTable, MyPluginAdminMenu adminScreen)
        {
            m_parentScreen = adminScreen;

            if (m_fetchedStarSytem == null)
            {
                MyGuiControlRotatingWheel loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero);
                loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;

                adminScreen.Controls.Add(loadingWheel);

                MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem)
                {
                    m_fetchedStarSytem         = starSystem;
                    adminScreen.ShouldRecreate = true;
                });
                return(true);
            }

            MyGuiControlLabel label = new MyGuiControlLabel(null, null, "Parent objects");

            parentTable.AddTableRow(label);

            m_parentObjectListBox = new MyGuiControlListbox();
            m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder("System center"), userData: m_fetchedStarSytem.CenterObject));
            m_parentObjectListBox.VisibleRowsCount = 8;
            m_parentObjectListBox.Size             = new Vector2(usableWidth, m_parentObjectListBox.Size.Y);
            m_parentObjectListBox.SelectAllVisible();
            m_parentObjectListBox.ItemsSelected += OnParentItemClicked;

            foreach (var obj in m_fetchedStarSytem.CenterObject.GetAllChildren())
            {
                if (obj.Type == MySystemObjectType.PLANET || obj.Type == MySystemObjectType.MOON)
                {
                    m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj));
                }
            }

            parentTable.AddTableRow(m_parentObjectListBox);

            parentTable.AddTableSeparator();

            m_radiusSlider               = new MyGuiControlClickableSlider(width: usableWidth - 0.1f, minValue: 0, maxValue: 1, labelSuffix: " km", showLabel: true);
            m_radiusSlider.Enabled       = false;
            m_radiusSlider.ValueChanged += delegate
            {
                RenderSpherePreview(GetDataFromGui());
            };

            parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Radius"));
            parentTable.AddTableRow(m_radiusSlider);

            m_widthSlider               = new MyGuiControlClickableSlider(null, 0, 1, usableWidth - 0.1f, 0.5f, showLabel: true, labelSuffix: " km");
            m_widthSlider.Enabled       = false;
            m_widthSlider.ValueChanged += delegate
            {
                RenderSpherePreview(GetDataFromGui());
            };

            parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Width"));
            parentTable.AddTableRow(m_widthSlider);

            m_asteroidSizesSlider         = new MyGuiControlRangedSlider(32, 1024, 32, 1024, true, width: usableWidth - 0.1f, showLabel: true);
            m_asteroidSizesSlider.Enabled = false;

            parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Asteroid size range"));
            parentTable.AddTableRow(m_asteroidSizesSlider);

            m_nameBox      = new MyGuiControlTextbox();
            m_nameBox.Size = new Vector2(usableWidth, m_nameBox.Size.Y);

            parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Name"));
            parentTable.AddTableRow(m_nameBox);

            m_spawnButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Spawn sphere", delegate
            {
                StringBuilder name = new StringBuilder();
                m_nameBox.GetText(name);
                if (name.Length < 4)
                {
                    MyPluginGuiHelper.DisplayError("Name must be at least 4 letters long", "Error");
                    return;
                }

                MySystemAsteroids instance;
                MyAsteroidSphereData data;
                GenerateData(out instance, out data);

                if (instance == null || data == null)
                {
                    MyPluginGuiHelper.DisplayError("Could not generate asteroid sphere. No data found.", "Error");
                    return;
                }

                MyAsteroidSphereProvider.Static.AddInstance(instance, data, delegate(bool success)
                {
                    if (!success)
                    {
                        MyPluginGuiHelper.DisplayError("Sphere could not be added, because an object with the same id already exists. This error should not occour, so please try again.", "Error");
                    }
                    else
                    {
                        MyPluginGuiHelper.DisplayMessage("Sphere was created successfully.", "Success");
                        m_parentScreen.ForceFetchStarSystem = true;
                        m_parentScreen.ShouldRecreate       = true;
                    }
                });
            });

            parentTable.AddTableSeparator();

            parentTable.AddTableRow(m_spawnButton);

            return(true);
        }
        private void SendMessage()
        {
            //Cannot send any message if local character is missing
            if (MySession.Static.LocalCharacter == null)
            {
                return;
            }

            m_chatboxText.Clear();
            m_chatbox.GetText(m_chatboxText);

            MyDebug.AssertDebug(m_chatboxText.Length > 0, "Length of chat text should be positive");
            MyDebug.AssertDebug(m_chatboxText.Length <= MyChatConstants.MAX_CHAT_STRING_LENGTH, "Length of chat text should not exceed maximum allowed");

            var history = MyChatSystem.GetChatHistory(MySession.Static.LocalPlayerId);

            if (m_playerList.SelectedItems.Count > 0)
            {
                var selectedItem = m_playerList.SelectedItems[0];

                if (selectedItem == m_globalItem)
                {
                    //messages entered in the global chat history should be treated as normal ingame chat
                    if (MyMultiplayer.Static != null)
                    {
                        MyMultiplayer.Static.SendChatMessage(m_chatboxText.ToString());
                    }
                    else
                    {
                        MyHud.Chat.ShowMessage(MySession.Static.LocalHumanPlayer == null ? "Player" : MySession.Static.LocalHumanPlayer.DisplayName, m_chatboxText.ToString());
                    }

                    //add the message to history
                    //MySession.Static.GlobalChatHistory.GlobalChatHistory.Chat.Enqueue(new MyGlobalChatItem
                    //{
                    //    IdentityId = MySession.Static.LocalPlayerId,
                    //    Text = m_chatboxText.ToString()
                    //});

                    RefreshGlobalChatHistory();
                }
                else if (selectedItem == m_broadcastItem)
                {
                    MySession.Static.LocalCharacter.SendNewGlobalMessage(MySession.Static.LocalHumanPlayer.Id, m_chatboxText.ToString());
                }
                else
                {
                    var playerIdentity = (MyIdentity)selectedItem.UserData;

                    MySession.Static.ChatHistory[MySession.Static.LocalPlayerId].AddPlayerChatItem(new MyPlayerChatItem(m_chatboxText.ToString(), MySession.Static.LocalPlayerId, MySession.Static.ElapsedGameTime, false), playerIdentity.IdentityId);
                    RefreshPlayerChatHistory(playerIdentity);
                }
            }
            else if (m_factionList.SelectedItems.Count > 0)
            {
                var toSendTo      = new Dictionary <long, bool>();
                var selectedItem  = m_factionList.SelectedItems[0];
                var targetFaction = (MyFaction)selectedItem.UserData;

                foreach (var member in targetFaction.Members)
                {
                    toSendTo.Add(member.Value.PlayerId, false);
                }

                if (!targetFaction.IsMember(MySession.Static.LocalPlayerId))
                {
                    var localFaction = MySession.Static.Factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId);
                    if (localFaction != null)
                    {
                        foreach (var member in localFaction.Members)
                        {
                            toSendTo.Add(member.Value.PlayerId, false);
                        }
                    }
                }

                var factionChatItem = new MyFactionChatItem(m_chatboxText.ToString(), MySession.Static.LocalPlayerId, MySession.Static.ElapsedGameTime, toSendTo);

                //This has to exist!
                var currentFaction = MySession.Static.Factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId);

                MySession.Static.LocalCharacter.SendNewFactionMessage(targetFaction.FactionId, currentFaction.FactionId, factionChatItem);

                RefreshFactionChatHistory(targetFaction);
            }

            m_chatbox.SetText(m_emptyText);
        }
        public bool CreateSpawnMenu(float usableWidth, MyGuiControlParentTableLayout parentTable, MyPluginAdminMenu adminScreen)
        {
            m_parentScreen            = adminScreen;
            m_offset                  = Vector3D.Zero;
            m_currentSelectedAsteroid = null;

            if (m_fetchedStarSytem == null)
            {
                MyGuiControlRotatingWheel m_loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero);
                m_loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;

                adminScreen.Controls.Add(m_loadingWheel);

                MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem)
                {
                    m_fetchedStarSytem         = starSystem;
                    adminScreen.ShouldRecreate = true;
                });
                return(true);
            }

            MyGuiControlLabel label = new MyGuiControlLabel(null, null, "Parent objects");

            parentTable.AddTableRow(label);

            m_parentObjectListBox = new MyGuiControlListbox();
            m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder("System center"), userData: m_fetchedStarSytem.CenterObject));
            m_parentObjectListBox.VisibleRowsCount = 8;
            m_parentObjectListBox.Size             = new Vector2(usableWidth, m_parentObjectListBox.Size.Y);
            m_parentObjectListBox.SelectAllVisible();
            m_parentObjectListBox.ItemsSelected += OnParentItemClicked;

            foreach (var obj in m_fetchedStarSytem.CenterObject.GetAllChildren())
            {
                if (obj.Type == MySystemObjectType.PLANET || obj.Type == MySystemObjectType.MOON)
                {
                    m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj));
                }
            }

            parentTable.AddTableRow(m_parentObjectListBox);

            var row = new MyGuiControlParentTableLayout(2, false, Vector2.Zero);

            m_snapToParentCheck                   = new MyGuiControlCheckbox();
            m_snapToParentCheck.IsChecked         = m_snapToParent;
            m_snapToParentCheck.IsCheckedChanged += delegate
            {
                m_snapToParent         = m_snapToParentCheck.IsChecked;
                m_zoomInButton.Enabled = m_snapToParent;
            };

            row.AddTableRow(m_snapToParentCheck, new MyGuiControlLabel(null, null, "Snap camera to parent"));

            row.ApplyRows();

            parentTable.AddTableRow(row);

            parentTable.AddTableSeparator();

            GenerateRingSettingElements(usableWidth, parentTable);

            m_nameBox      = new MyGuiControlTextbox();
            m_nameBox.Size = new Vector2(usableWidth, m_nameBox.Size.Y);

            parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Name"));
            parentTable.AddTableRow(m_nameBox);

            m_zoomInButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Zoom to ring", delegate
            {
                if (m_snapToParent)
                {
                    m_parentScreen.CameraLookAt(GenerateAsteroidRing().CenterPosition, new Vector3D(0, 0, (m_radiusSlider.Value + m_widthSlider.Value) * 2000));
                }
            });

            parentTable.AddTableRow(m_zoomInButton);

            m_offsetToCoordButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Offset to coordinate", delegate
            {
                var coordMessage          = new MyGuiScreenDialogCoordinate("Enter coordinate to offset the center of the ring from its parent");
                coordMessage.OnConfirmed += delegate(Vector3D coord)
                {
                    m_offset = coord;
                    UpdateRingVisual(GenerateAsteroidRing());
                };
                MyGuiSandbox.AddScreen(coordMessage);
            });

            parentTable.AddTableRow(m_offsetToCoordButton);

            m_spawnRingButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Add ring", delegate
            {
                StringBuilder name = new StringBuilder();
                m_nameBox.GetText(name);
                if (name.Length < 4)
                {
                    MyPluginGuiHelper.DisplayError("Name must be at least 4 letters long", "Error");
                    return;
                }

                MySystemAsteroids instance;
                MyAsteroidRingData ring;
                GenerateAsteroidData(out ring, out instance);

                if (ring == null || instance == null)
                {
                    MyPluginGuiHelper.DisplayError("Could not generate asteroid ring. No data found.", "Error");
                    return;
                }

                MyAsteroidRingProvider.Static.AddInstance(instance, ring, delegate(bool success)
                {
                    if (!success)
                    {
                        MyPluginGuiHelper.DisplayError("Ring could not be added, because an object with the same id already exists. This error should not occour, so please try again.", "Error");
                    }
                    else
                    {
                        MyPluginGuiHelper.DisplayMessage("Ring was created successfully.", "Success");
                        m_parentScreen.ForceFetchStarSystem = true;
                        m_parentScreen.ShouldRecreate       = true;
                    }
                });
            });

            parentTable.AddTableRow(m_spawnRingButton);

            return(true);
        }
Exemple #13
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            var caption = AddCaption("SEWorldGenPlugin global settings");

            caption.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            caption.Position    = new Vector2(0, SIZE.Y / -2 + PADDING.Y);

            MyGuiControlButton OkButton = new MyGuiControlButton(null, VRage.Game.MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, "Saves the global settings file now and exits this menu", VRage.MyTexts.Get(MyCommonTexts.Ok), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, OnOkButtonClicked);

            OkButton.Position = new Vector2(0, SIZE.Y / 2 - PADDING.Y);
            Controls.Add(OkButton);

            MyGuiControlSeparatorList separators = new MyGuiControlSeparatorList();

            separators.AddHorizontal(SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X);
            separators.AddHorizontal(new Vector2(SIZE.X / -2 + PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X);
            Controls.Add(separators);

            MyGuiControlParentTableLayout parent = new MyGuiControlParentTableLayout(2, overflowColumns: true, minWidth: WIDTH);

            parent.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            var moonsLabel      = new MyGuiControlLabel(null, null, "Moons");
            var gasGiantLabel   = new MyGuiControlLabel(null, null, "Gas giants");
            var sunLabel        = new MyGuiControlLabel(null, null, "Suns");
            var mandatoryLabel  = new MyGuiControlLabel(null, null, "Mandatory planets and moons");
            var blacklistLabel  = new MyGuiControlLabel(null, null, "Blacklisted planets and moons");
            var planetNameLabel = new MyGuiControlLabel(null, null, "Planet name format");
            var moonNameLabel   = new MyGuiControlLabel(null, null, "Moon name format");
            var beltNameLabel   = new MyGuiControlLabel(null, null, "Belt name format");

            #region Tables

            ///Moons table
            m_moonDefsTable = new MyGuiControlTable();
            m_moonDefsTable.VisibleRowsCount = 8;
            m_moonDefsTable.Size             = new Vector2(WIDTH, m_moonDefsTable.Size.Y);
            m_moonDefsTable.ColumnsCount     = 1;
            m_moonDefsTable.SetCustomColumnWidths(new float[] { WIDTH });
            m_moonDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID"));

            var addMoonBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Moon", delegate
            {
                OpenEnterIdDialog(m_moonDefsTable, delegate(string name)
                {
                    MySettings.Static.Settings.MoonDefinitions.Add(name);
                });
            });
            var remMoonBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Moon", delegate
            {
                MySettings.Static.Settings.MoonDefinitions.Remove(m_moonDefsTable.SelectedRow.UserData as string);
                m_moonDefsTable.RemoveSelectedRow();
            });

            remMoonBtn.Enabled = false;

            m_moonDefsTable.FocusChanged += delegate
            {
                remMoonBtn.Enabled = m_moonDefsTable.HasFocus && m_moonDefsTable.SelectedRow != null;
            };
            m_moonDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args)
            {
                remMoonBtn.Enabled = m_moonDefsTable.HasFocus && m_moonDefsTable.SelectedRow != null;
            };

            parent.AddTableRow(moonsLabel);
            parent.AddTableRow(m_moonDefsTable);
            parent.AddTableRow(addMoonBtn, remMoonBtn);

            parent.AddTableSeparator();

            ///Gas giant table
            m_gasGiantsDefsTable = new MyGuiControlTable();
            m_gasGiantsDefsTable.VisibleRowsCount = 8;
            m_gasGiantsDefsTable.Size             = new Vector2(WIDTH, m_gasGiantsDefsTable.Size.Y);
            m_gasGiantsDefsTable.ColumnsCount     = 1;
            m_gasGiantsDefsTable.SetCustomColumnWidths(new float[] { WIDTH });
            m_gasGiantsDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID"));

            MyGuiControlParentTableLayout gasGiantBtns = new MyGuiControlParentTableLayout(2, padding: new Vector2(0));
            var addGasGiantBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Gas Giant", delegate
            {
                OpenEnterIdDialog(m_gasGiantsDefsTable, delegate(string name)
                {
                    MySettings.Static.Settings.GasGiantDefinitions.Add(name);
                });
            });
            var remGasGiantBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Gas Giant", delegate
            {
                MySettings.Static.Settings.GasGiantDefinitions.Remove(m_gasGiantsDefsTable.SelectedRow.UserData as string);
                m_gasGiantsDefsTable.RemoveSelectedRow();
            });

            remGasGiantBtn.Enabled = false;

            m_gasGiantsDefsTable.FocusChanged += delegate
            {
                remGasGiantBtn.Enabled = m_gasGiantsDefsTable.HasFocus && m_gasGiantsDefsTable.SelectedRow != null;
            };
            m_gasGiantsDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args)
            {
                remGasGiantBtn.Enabled = table.SelectedRow != null;
            };

            parent.AddTableRow(gasGiantLabel);
            parent.AddTableRow(m_gasGiantsDefsTable);
            parent.AddTableRow(addGasGiantBtn, remGasGiantBtn);

            parent.AddTableSeparator();

            ///Suns table
            m_sunDefsTable = new MyGuiControlTable();
            m_sunDefsTable.VisibleRowsCount = 8;
            m_sunDefsTable.Size             = new Vector2(WIDTH, m_sunDefsTable.Size.Y);
            m_sunDefsTable.ColumnsCount     = 1;
            m_sunDefsTable.SetCustomColumnWidths(new float[] { WIDTH });
            m_sunDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID"));

            var addSunBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Sun", delegate
            {
                OpenEnterIdDialog(m_sunDefsTable, delegate(string name)
                {
                    MySettings.Static.Settings.SunDefinitions.Add(name);
                });
            });
            var remSunBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Sun", delegate
            {
                MySettings.Static.Settings.SunDefinitions.Remove(m_sunDefsTable.SelectedRow.UserData as string);
                m_sunDefsTable.RemoveSelectedRow();
            });

            remSunBtn.Enabled = false;

            m_sunDefsTable.FocusChanged += delegate
            {
                remSunBtn.Enabled = m_sunDefsTable.HasFocus && m_sunDefsTable.SelectedRow != null;
            };
            m_sunDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args)
            {
                remSunBtn.Enabled = table.SelectedRow != null;
            };

            parent.AddTableRow(sunLabel);
            parent.AddTableRow(m_sunDefsTable);
            parent.AddTableRow(addSunBtn, remSunBtn);

            parent.AddTableSeparator();

            ///Mandatory table
            m_mandatoryDefsTable = new MyGuiControlTable();
            m_mandatoryDefsTable.VisibleRowsCount = 8;
            m_mandatoryDefsTable.Size             = new Vector2(WIDTH, m_mandatoryDefsTable.Size.Y);
            m_mandatoryDefsTable.ColumnsCount     = 1;
            m_mandatoryDefsTable.SetCustomColumnWidths(new float[] { WIDTH });
            m_mandatoryDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID"));

            var addMandatoryBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Mandatory", delegate
            {
                OpenEnterIdDialog(m_mandatoryDefsTable, delegate(string name)
                {
                    MySettings.Static.Settings.MandatoryPlanetDefinitions.Add(name);
                });
            });
            var remMandatoryBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Mandatory", delegate
            {
                MySettings.Static.Settings.MandatoryPlanetDefinitions.Remove(m_mandatoryDefsTable.SelectedRow.UserData as string);
                m_mandatoryDefsTable.RemoveSelectedRow();
            });

            remMandatoryBtn.Enabled = false;

            m_mandatoryDefsTable.FocusChanged += delegate
            {
                remMandatoryBtn.Enabled = m_mandatoryDefsTable.HasFocus && m_mandatoryDefsTable.SelectedRow != null;
            };
            m_mandatoryDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args)
            {
                remMandatoryBtn.Enabled = table.SelectedRow != null;
            };

            parent.AddTableRow(mandatoryLabel);
            parent.AddTableRow(m_mandatoryDefsTable);
            parent.AddTableRow(addMandatoryBtn, remMandatoryBtn);

            parent.AddTableSeparator();

            ///Blacklist table
            m_blacklistDefsTable = new MyGuiControlTable();
            m_blacklistDefsTable.VisibleRowsCount = 8;
            m_blacklistDefsTable.Size             = new Vector2(WIDTH, m_blacklistDefsTable.Size.Y);
            m_blacklistDefsTable.ColumnsCount     = 1;
            m_blacklistDefsTable.SetCustomColumnWidths(new float[] { WIDTH });
            m_blacklistDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID"));

            var addBlacklistBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add to Blacklist", delegate
            {
                OpenEnterIdDialog(m_blacklistDefsTable, delegate(string name)
                {
                    MySettings.Static.Settings.BlacklistedPlanetDefinitions.Add(name);
                });
            });
            var remBlacklistBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove from Blacklist", delegate
            {
                MySettings.Static.Settings.BlacklistedPlanetDefinitions.Remove(m_blacklistDefsTable.SelectedRow.UserData as string);
                m_blacklistDefsTable.RemoveSelectedRow();
            });

            remBlacklistBtn.Enabled = false;

            m_blacklistDefsTable.FocusChanged += delegate
            {
                remBlacklistBtn.Enabled = m_blacklistDefsTable.HasFocus && m_blacklistDefsTable.SelectedRow != null;
            };
            m_blacklistDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args)
            {
                remBlacklistBtn.Enabled = table.SelectedRow != null;
            };

            parent.AddTableRow(blacklistLabel);
            parent.AddTableRow(m_blacklistDefsTable);
            parent.AddTableRow(addBlacklistBtn, remBlacklistBtn);

            #endregion

            parent.AddTableSeparator();

            #region NameFormats

            ///Planet name box
            m_planetNameBox              = new MyGuiControlTextbox();
            m_planetNameBox.Size         = new Vector2(WIDTH, m_planetNameBox.Size.Y);
            m_planetNameBox.TextChanged += delegate
            {
                StringBuilder s = new StringBuilder();
                m_planetNameBox.GetText(s);
                MySettings.Static.Settings.PlanetNameFormat = s.ToString();
            };

            MyGuiControlParentTableLayout formatButtons = new MyGuiControlParentTableLayout(3, padding: new Vector2(0));
            var planetNameButtons1 = new MyGuiControlButton[3];
            var planetNameButtons2 = new MyGuiControlButton[3];
            planetNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER);
            });
            planetNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN);
            });
            planetNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK);
            });
            planetNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER);
            });
            planetNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER);
            });
            planetNameButtons2[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add id", delegate
            {
                MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_ID);
            });

            m_planetNameBox.TextChanged += delegate(MyGuiControlTextbox t)
            {
                var sb = new StringBuilder();
                t.GetText(sb);

                MySettings.Static.Settings.PlanetNameFormat = sb.ToString();
            };

            formatButtons.AddTableRow(planetNameButtons1);
            formatButtons.AddTableRow(planetNameButtons2);
            formatButtons.ApplyRows();

            parent.AddTableRow(planetNameLabel);
            parent.AddTableRow(m_planetNameBox);
            parent.AddTableRow(formatButtons);

            parent.AddTableSeparator();

            ///Moon name box
            m_moonNameBox              = new MyGuiControlTextbox();
            m_moonNameBox.Size         = new Vector2(WIDTH, m_moonNameBox.Size.Y);
            m_moonNameBox.TextChanged += delegate
            {
                StringBuilder s = new StringBuilder();
                m_moonNameBox.GetText(s);
                MySettings.Static.Settings.MoonNameFormat = s.ToString();
            };

            MyGuiControlParentTableLayout formatButtonsMoon = new MyGuiControlParentTableLayout(3, padding: new Vector2(0));
            var moonNameButtons1 = new MyGuiControlButton[3];
            var moonNameButtons2 = new MyGuiControlButton[3];
            moonNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER);
            });
            moonNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN);
            });
            moonNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK);
            });
            moonNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER);
            });
            moonNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER);
            });
            moonNameButtons2[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add id", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_ID);
            });
            var btnExtra = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add parent name", delegate
            {
                MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_PARENT);
            });

            m_moonNameBox.TextChanged += delegate(MyGuiControlTextbox t)
            {
                var sb = new StringBuilder();
                t.GetText(sb);

                MySettings.Static.Settings.MoonNameFormat = sb.ToString();
            };

            formatButtonsMoon.AddTableRow(moonNameButtons1);
            formatButtonsMoon.AddTableRow(moonNameButtons2);
            formatButtonsMoon.AddTableRow(btnExtra);
            formatButtonsMoon.ApplyRows();

            parent.AddTableRow(moonNameLabel);
            parent.AddTableRow(m_moonNameBox);
            parent.AddTableRow(formatButtonsMoon);

            parent.AddTableSeparator();

            ///Belt name box
            m_beltNameBox              = new MyGuiControlTextbox();
            m_beltNameBox.Size         = new Vector2(WIDTH, m_beltNameBox.Size.Y);
            m_beltNameBox.TextChanged += delegate
            {
                StringBuilder s = new StringBuilder();
                m_beltNameBox.GetText(s);
                MySettings.Static.Settings.BeltNameFormat = s.ToString();
            };

            MyGuiControlParentTableLayout formatButtonsBelt = new MyGuiControlParentTableLayout(3, padding: new Vector2(0));
            var beltNameButtons1 = new MyGuiControlButton[3];
            var beltNameButtons2 = new MyGuiControlButton[2];
            beltNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate
            {
                MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER);
            });
            beltNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate
            {
                MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN);
            });
            beltNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate
            {
                MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK);
            });
            beltNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate
            {
                MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER);
            });
            beltNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate
            {
                MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER);
            });

            m_beltNameBox.TextChanged += delegate(MyGuiControlTextbox t)
            {
                var sb = new StringBuilder();
                t.GetText(sb);

                MySettings.Static.Settings.BeltNameFormat = sb.ToString();
            };

            formatButtonsBelt.AddTableRow(beltNameButtons1);
            formatButtonsBelt.AddTableRow(beltNameButtons2);
            formatButtonsBelt.ApplyRows();

            parent.AddTableRow(beltNameLabel);
            parent.AddTableRow(m_beltNameBox);
            parent.AddTableRow(formatButtonsBelt);
            #endregion
            parent.ApplyRows();

            Vector2 start = SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT * 2;
            Vector2 end   = new Vector2(SIZE.X / 2 - PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT * 2;

            MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(parent);
            scrollPane.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            scrollPane.ScrollbarVEnabled = true;
            scrollPane.Size     = end - start;
            scrollPane.Position = start;

            Controls.Add(scrollPane);
        }
        /// <summary>
        /// Refresh the controls and regenerate gui elements
        /// </summary>
        /// <param name="constructor">Is run from constructor</param>
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            MyGuiControlLabel caption = new MyGuiControlLabel(null, null, m_caption);

            caption.OriginAlign = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            caption.Position    = new Vector2(0, Size.Value.Y / -2 + PADDING.Y);

            Controls.Add(caption);

            MyGuiControlParentTableLayout table = new MyGuiControlParentTableLayout(6, true, PADDING);

            table.AddTableSeparator();

            m_xBox = new MyGuiControlTextbox(type: MyGuiControlTextboxType.DigitsOnly);
            m_yBox = new MyGuiControlTextbox(type: MyGuiControlTextboxType.DigitsOnly);
            m_zBox = new MyGuiControlTextbox(type: MyGuiControlTextboxType.DigitsOnly);

            m_xBox.Size = new Vector2(0.1f, m_xBox.Size.Y);
            m_yBox.Size = new Vector2(0.1f, m_yBox.Size.Y);
            m_zBox.Size = new Vector2(0.1f, m_zBox.Size.Y);

            m_xBox.SetText(new StringBuilder("0"));
            m_yBox.SetText(new StringBuilder("0"));
            m_zBox.SetText(new StringBuilder("0"));

            table.AddTableRow(new MyGuiControlLabel(text: "X:"), m_xBox, new MyGuiControlLabel(text: "Y:"), m_yBox, new MyGuiControlLabel(text: "Z:"), m_zBox);

            table.AddTableSeparator();

            table.ApplyRows();

            table.Position    = new Vector2(0, caption.Position.Y + caption.Size.Y + PADDING.Y);
            table.OriginAlign = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;

            Controls.Add(table);

            m_okButton                = new MyGuiControlButton();
            m_okButton.Text           = MyCommonTexts.Ok.ToString();
            m_okButton.OriginAlign    = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_okButton.Position       = new Vector2(-PADDING.X, Size.Value.Y / 2 - PADDING.Y);
            m_okButton.ButtonClicked += delegate
            {
                var    xb = new StringBuilder();
                var    yb = new StringBuilder();
                var    zb = new StringBuilder();
                double x  = 0;
                double y  = 0;
                double z  = 0;
                m_xBox.GetText(xb);
                m_yBox.GetText(yb);
                m_zBox.GetText(zb);
                if (double.TryParse(xb.ToString(), out x) && double.TryParse(yb.ToString(), out y) && double.TryParse(zb.ToString(), out z))
                {
                    OnConfirmed?.Invoke(new Vector3D(x, y, z));
                    CloseScreen();
                }
                else
                {
                    m_errorLabel.Visible = true;
                }
            };

            m_cancelButton                = new MyGuiControlButton();
            m_cancelButton.Text           = MyCommonTexts.Cancel.ToString();
            m_cancelButton.OriginAlign    = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_cancelButton.Position       = new Vector2(PADDING.X, Size.Value.Y / 2 - PADDING.Y);
            m_cancelButton.ButtonClicked += delegate
            {
                CloseScreen();
            };

            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);


            m_errorLabel             = new MyGuiControlLabel(null, null, "Those are not valid coordinates.", font: "Red");
            m_errorLabel.OriginAlign = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_errorLabel.Position    = new Vector2(Size.Value.X / -2 + PADDING.X, m_xBox.Position.Y + m_xBox.Size.Y);
            m_errorLabel.Visible     = false;

            Controls.Add(m_errorLabel);
        }