diff --git a/SEWorldGenPlugin/GUI/AdminMenu/SubMenus/MyPlanetSpawnMenu.cs b/SEWorldGenPlugin/GUI/AdminMenu/SubMenus/MyPlanetSpawnMenu.cs index 0afe197..a6f2d72 100644 --- a/SEWorldGenPlugin/GUI/AdminMenu/SubMenus/MyPlanetSpawnMenu.cs +++ b/SEWorldGenPlugin/GUI/AdminMenu/SubMenus/MyPlanetSpawnMenu.cs @@ -37,6 +37,11 @@ public class MyPlanetSpawnMenu : MyPluginAdminMenuSubMenu /// private MyGuiControlButton m_spawnPlanetButton; + /// + /// Button to spawn the planet at a given coordinate + /// + private MyGuiControlButton m_spawnAtCoordButton; + public override void Close() { } @@ -87,6 +92,9 @@ public override void RefreshInternals(MyGuiControlParentTableLayout parent, floa parent.AddTableRow(new MyGuiControlLabel(text: "Name")); parent.AddTableRow(m_nameBox); + + parent.AddTableSeparator(); + m_spawnPlanetButton = MyPluginGuiHelper.CreateDebugButton(maxWidth, "Spawn planet", delegate (MyGuiControlButton button) { OnSpawnPlanet(); @@ -94,13 +102,50 @@ public override void RefreshInternals(MyGuiControlParentTableLayout parent, floa m_spawnPlanetButton.Enabled = true; m_spawnPlanetButton.SetToolTip("Activates the mode to spawn the planet where you place it"); - parent.AddTableSeparator(); + m_spawnAtCoordButton = MyPluginGuiHelper.CreateDebugButton(maxWidth, "Spawn planet at coordinates", delegate (MyGuiControlButton button) + { + OnSpawnPlanetCoord(); + }); parent.AddTableRow(m_spawnPlanetButton); + parent.AddTableRow(m_spawnAtCoordButton); + LoadPlanetDefs(); } + /// + /// Spawns the planet at a fixed coordinate + /// + private void OnSpawnPlanetCoord() + { + 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; + } + + 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); + } + /// /// Action to spawn a planet ///