Skip to content

Commit

Permalink
Added GUI Checkbox, to disable or enable the snapping of the camera t…
Browse files Browse the repository at this point in the history
…o the currently selected planet, to add an asteroid ring.
  • Loading branch information
thorwin99 committed Sep 8, 2020
1 parent 9ff5259 commit f130364
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions SEWorldGenPlugin/GUI/PluginAdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class PluginAdminMenu : MyGuiScreenAdminMenu
private static readonly Vector2 SCREEN_SIZE = new Vector2(0.4f, 1.2f);
private static readonly float HIDDEN_PART_RIGHT = 0.04f;

private static bool SNAP_CAMERA_TO_PLANET = true;

private long m_currentKey;
private long m_attachedEntity;

Expand Down Expand Up @@ -283,18 +285,37 @@ private void BuildRingMenu()
m_planetListBox = new MyGuiControlListbox(Vector2.Zero, VRage.Game.MyGuiControlListboxStyleEnum.Blueprints);
m_planetListBox.Size = new Vector2(num, 0f);
m_planetListBox.Enabled = true;
m_planetListBox.VisibleRowsCount = 8;
m_planetListBox.VisibleRowsCount = 7;
m_planetListBox.Position = m_planetListBox.Size / 2f + m_currentPosition;
m_planetListBox.ItemClicked += PlanetListItemClicked;
m_planetListBox.MultiSelect = false;

MyGuiControlSeparatorList separator = new MyGuiControlSeparatorList();
separator.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.83f / 2f, -0.00f), m_size.Value.X * 0.73f);
Controls.Add(separator);

m_currentPosition = m_planetListBox.GetPositionAbsoluteBottomLeft();
m_currentPosition.Y += 0.025f;

MyGuiControlLabel snapLabel = new MyGuiControlLabel(null, null, "Snap camera to planet");
snapLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
snapLabel.Position = m_currentPosition;

Controls.Add(snapLabel);

MyGuiControlCheckbox snapCamera = new MyGuiControlCheckbox();
snapCamera.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
snapCamera.IsCheckedChanged = snapCamera.IsCheckedChanged = (Action<MyGuiControlCheckbox>)Delegate.Combine(snapCamera.IsCheckedChanged, (Action<MyGuiControlCheckbox>)delegate (MyGuiControlCheckbox s)
{
SNAP_CAMERA_TO_PLANET = snapCamera.IsChecked;
});

snapCamera.IsChecked = SNAP_CAMERA_TO_PLANET;
snapCamera.Position = snapLabel.Position + new Vector2(snapLabel.Size.X, 0f);
Controls.Add(snapCamera);

m_currentPosition.Y += 0.045f;

MyGuiControlSeparatorList separator = new MyGuiControlSeparatorList();
separator.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.83f / 2f, -0.09f), m_size.Value.X * 0.73f);
Controls.Add(separator);

MyGuiControlParent myGuiControlParent = new MyGuiControlParent
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Expand Down Expand Up @@ -567,9 +588,9 @@ private void BuildRingMenu()

m_currentPosition.Y += m_optionsGroup.Size.Y;

MyGuiControlSeparatorList separator2 = new MyGuiControlSeparatorList();
/*MyGuiControlSeparatorList separator2 = new MyGuiControlSeparatorList();
separator2.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.83f / 2f, -0.00f), m_size.Value.X * 0.73f);
Controls.Add(separator2);
Controls.Add(separator2);*/

m_addRingButton = CreateDebugButton(0.284f, "Add ring to planet", OnAddRingToPlanetButton, true, MyPluginTexts.TOOLTIPS.ADMIN_ADD_RING_BUTTON);

Expand Down Expand Up @@ -690,7 +711,7 @@ private void PlanetListItemClicked(MyGuiControlListbox box)
{
MyEntityList.MyEntityListInfoItem myEntityListInfoItem = (MyEntityList.MyEntityListInfoItem)box.SelectedItems[box.SelectedItems.Count - 1].UserData;
m_attachedEntity = myEntityListInfoItem.EntityId;
if (!TryAttachCamera(myEntityListInfoItem.EntityId))
if (SNAP_CAMERA_TO_PLANET && !TryAttachCamera(myEntityListInfoItem.EntityId))
{
MySession.Static.SetCameraController(MyCameraControllerEnum.Spectator, null, myEntityListInfoItem.Position + Vector3.One * 50f);
}
Expand Down

0 comments on commit f130364

Please sign in to comment.