private void OKButton_Clicked(MyGuiControlButton sender)
        {
            bool itemSet = false;
            for (int i = 0; i < MyToolbarComponent.CurrentToolbar.SlotCount; ++i)
            {
                var item = MyToolbarComponent.CurrentToolbar.GetSlotItem(i);
                if (item != null && item.Equals(Item))
                {
                    MyToolbarComponent.CurrentToolbar.SetItemAtIndex(i, Item);
                    if (item.WantsToBeActivated)
                        MyToolbarComponent.CurrentToolbar.ActivateItemAtSlot(i);
                    itemSet = true;
                    break;
                }
            }

            if (itemSet)
                return;

            for (int i = 0; i < MyToolbarComponent.CurrentToolbar.SlotCount; ++i)
            {
                if (MyToolbarComponent.CurrentToolbar.GetSlotItem(i) == null)
                { 
                    MyToolbarComponent.CurrentToolbar.SetItemAtIndex(i, Item);
                    if (Item.WantsToBeActivated)
                        MyToolbarComponent.CurrentToolbar.ActivateItemAtSlot(i);
                    break;
                }
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MySpaceTexts.ScreenCaptionNewWorld);

            Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.147f);
            if (MyPerGameSettings.EnableScenarios)
            {
                menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.11f);
            }

            Vector2 buttonDelta = new Vector2(0.15f, 0);

            //MyStringId? otherButtonsForbidden = null;
            //MyStringId newGameText = MySpaceTexts.StartDemo;
            int buttonPositionCounter = 0;

            //  Quickstart
            var quickstartButton = new MyGuiControlButton(
                position: menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                text: MyTexts.Get(MySpaceTexts.ScreenNewWorldButtonQuickstart),
                toolTip: MyTexts.GetString(MySpaceTexts.ToolTipNewWorldQuickstart),
                onButtonClick: OnQuickstartClick);

            //  Custom Game
            var customGameButton = new MyGuiControlButton(
                position: menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                text: MyTexts.Get(MySpaceTexts.ScreenNewWorldButtonCustomWorld),
                toolTip: MyTexts.GetString(MySpaceTexts.ToolTipNewWorldCustomWorld),
                onButtonClick: OnCustomGameClick);          
            Controls.Add(quickstartButton);
            Controls.Add(customGameButton);

            if (MyPerGameSettings.EnableScenarios)
            {
                //  scenarios
                var scenarioButton = new MyGuiControlButton(
                    position: menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                    text: MyTexts.Get(MySpaceTexts.ScreenCaptionScenario),
                    //toolTip: MyTexts.GetString(MySpaceTexts.ToolTipNewWorldCustomWorld),
                    onButtonClick: OnScenarioGameClick);

                Controls.Add(scenarioButton);
            }

            if (MyFakes.ENABLE_BATTLE_SYSTEM)
            {
                var battleButton = new MyGuiControlButton(
                    position: menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                    text: MyTexts.Get(MySpaceTexts.ScreenButtonBattle),
                    //toolTip: MyTexts.GetString(MySpaceTexts.ToolTipNewWorldCustomWorld),
                    onButtonClick: OnBattleClick);

                Controls.Add(battleButton);

            }

            CloseButtonEnabled = true;
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.10f), text: "Select the amount and type of items to spawn in your inventory", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));
            m_amountTextbox = new MyGuiControlTextbox(new Vector2(-0.2f, 0.0f), null, 9, null, MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiControlTextboxType.DigitsOnly);
            m_items = new MyGuiControlCombobox(new Vector2(0.2f, 0.0f), new Vector2(0.3f, 0.05f), null, null, 10, null);
            m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm"));
            m_cancelButton = new MyGuiControlButton(new Vector2(-0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel"));

            foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions())
            {
                var physicalItemDef = definition as MyPhysicalItemDefinition;
                if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false)
                    continue;

                int key = m_physicalItemDefinitions.Count;
                m_physicalItemDefinitions.Add(physicalItemDef);
                m_items.AddItem(key, definition.DisplayNameText);
            }

            this.Controls.Add(m_amountTextbox);
            this.Controls.Add(m_items);
            this.Controls.Add(m_confirmButton);
            this.Controls.Add(m_cancelButton);

            m_amountTextbox.Text = string.Format("{0}", m_lastAmount);
            m_items.SelectItemByIndex(m_lastSelectedItem);

            m_confirmButton.ButtonClicked += confirmButton_OnButtonClick;
            m_cancelButton.ButtonClicked += cancelButton_OnButtonClick;
        }
 protected override void OnStartClicked(MyGuiControlButton sender)
 {
     Debug.Assert(!Sync.IsServer);
     //joining into running game:
     MySyncScenario.OnPrepareScenarioFromLobby(-1);
     CloseScreen();
 }
        public void BuildControls()
        {
            MyGuiControlParent parent = new MyGuiControlParent(size: new Vector2(Size.Value.X - 0.05f, Size.Value.Y-0.1f));
            MyGuiControlScrollablePanel scrollPanel = new MyGuiControlScrollablePanel(parent);
            scrollPanel.ScrollbarVEnabled = true;
            scrollPanel.Size = new Vector2(Size.Value.X - 0.05f, 0.8f);
            Controls.Add(scrollPanel);

            Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE;
            Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f);

            //AddCaption(MySpaceTexts.ScreenCaptionAdvancedSettings);
            // Ok/Cancel
            m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: CancelButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            float buttonsOffset = 0.055f;

            var canJoinrunningLabel = MakeLabel(MySpaceTexts.ScenarioSettings_CanJoinRunning);
            m_canJoinRunning = new MyGuiControlCheckbox();
            m_canJoinRunning.Position = new Vector2(-scrollPanel.Size.X / 2 + buttonsOffset, -scrollPanel.Size.Y / 2 + buttonsOffset);
            canJoinrunningLabel.Position = new Vector2(m_canJoinRunning.Position.X + buttonsOffset, m_canJoinRunning.Position.Y);
            m_canJoinRunning.IsChecked = MySession.Static.Settings.CanJoinRunning;
            parent.Controls.Add(m_canJoinRunning);
            parent.Controls.Add(canJoinrunningLabel);

            CloseButtonEnabled = true;
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            var fileName = MakeScreenFilepath("DialogAmount");
            var fsPath = Path.Combine(MyFileSystem.ContentPath, fileName);

            MyObjectBuilder_GuiScreen objectBuilder;
            Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeXML<MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder);
            Init(objectBuilder);

            m_amountTextbox = (MyGuiControlTextbox)Controls.GetControlByName("AmountTextbox");
            m_increaseButton = (MyGuiControlButton)Controls.GetControlByName("IncreaseButton");
            m_decreaseButton = (MyGuiControlButton)Controls.GetControlByName("DecreaseButton");
            m_confirmButton  = (MyGuiControlButton)Controls.GetControlByName("ConfirmButton");
            m_cancelButton   = (MyGuiControlButton)Controls.GetControlByName("CancelButton");
            m_errorLabel     = (MyGuiControlLabel)Controls.GetControlByName("ErrorLabel");
            m_captionLabel = (MyGuiControlLabel)Controls.GetControlByName("CaptionLabel");
            m_captionLabel.Text = null;
            m_captionLabel.TextEnum = m_caption;

            m_errorLabel.Visible = false;

            m_amountTextbox.TextChanged    += amountTextbox_TextChanged;
            m_increaseButton.ButtonClicked += increaseButton_OnButtonClick;
            m_decreaseButton.ButtonClicked += decreaseButton_OnButtonClick;
            m_confirmButton.ButtonClicked  += confirmButton_OnButtonClick;
            m_cancelButton.ButtonClicked   += cancelButton_OnButtonClick;

            RefreshAmountTextbox();
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.10f), text: "Select gps you want to reach. (Dont use for grids with subgrids.)", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));
            m_prefabs = new MyGuiControlCombobox(new Vector2(0.2f, 0.0f), new Vector2(0.3f, 0.05f), null, null, 10, null);
            m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm"));
            m_cancelButton = new MyGuiControlButton(new Vector2(-0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel"));

            List<IMyGps> outlist = new List<IMyGps>();
            MySession.Static.Gpss.GetGpsList(MySession.Static.LocalPlayerId, outlist);
            foreach (var prefab in outlist)
            {
                int key = m_prefabDefinitions.Count;
                m_prefabDefinitions.Add(prefab);
                m_prefabs.AddItem(key, prefab.Name);
            }

            this.Controls.Add(m_prefabs);
            this.Controls.Add(m_confirmButton);
            this.Controls.Add(m_cancelButton);

            m_confirmButton.ButtonClicked += confirmButton_OnButtonClick;
            m_cancelButton.ButtonClicked += cancelButton_OnButtonClick;
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            

            AddCaption(MyCommonTexts.ScreenCaptionWorkshopTags);

            Vector2 origin = new Vector2(0f, -0.025f * (m_activeTags.Count + 2));
            Vector2 offset = new Vector2(0f,  0.05f);

            m_checkboxes.Clear();

            foreach (var pair in m_activeTags)
            {
                AddLabeledCheckbox(origin += offset, pair.Key, pair.Value);
                if (m_typeTag == MySteamWorkshop.WORKSHOP_MOD_TAG)
                {
                    var name = pair.Key.Replace(" ", string.Empty);
                    var path = Path.Combine(MyFileSystem.ContentPath, "Textures", "GUI", "Icons", "buttons", name + ".dds");
                    if (File.Exists(path))
                    {
                        AddIcon(origin + new Vector2(-0.05f, 0f), path, new Vector2(0.04f, 0.05f));
                    }
                }
            }

            origin += offset;

            Controls.Add(m_okButton = MakeButton(origin += offset, MyCommonTexts.Ok, MyCommonTexts.Ok, OnOkClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER));
            Controls.Add(m_cancelButton = MakeButton(origin, MyCommonTexts.Cancel, MyCommonTexts.Cancel, OnCancelClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            CloseButtonEnabled = true;
        }
 protected override void OnOkButtonClick(MyGuiControlButton sender)
 {
     int? seconds = StrToInt(m_textboxTime.Text);
     Debug.Assert(seconds != null, "incorrect value of time");
     if (seconds != null)
         ((MyTriggerNoSpawn)m_trigger).LimitInSeconds = (int)seconds;
     base.OnOkButtonClick(sender);
 }
 protected override void OnOkButtonClick(MyGuiControlButton sender)
 {
     int? lives = StrToInt(m_lives.Text);
     Debug.Assert(lives!=null,"incorrect value of lives");
     if (lives != null)
         ((MyTriggerLives)m_trigger).LivesLeft = (int)lives;
     base.OnOkButtonClick(sender);
 }
        public void OnDx9VideoClick(MyGuiControlButton sender)
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenOptions.OnVideoClick START");

            MyGuiSandbox.AddScreen(new MyGuiScreenOptionsVideoSpace());

            MySandboxGame.Log.WriteLine("MyGuiScreenOptions.OnVideoClick END");
        }
 protected override void OnOkButtonClick(MyGuiControlButton sender)
 {
     int? minutes = StrToInt(m_textboxTime.Text);
     Debug.Assert(minutes!=null,"incorrect value of time");
     if (minutes != null)
         ((MyTriggerTimeLimit)m_trigger).LimitInMinutes = (int)minutes;
     base.OnOkButtonClick(sender);
 }
 protected override void OnOkButtonClick(MyGuiControlButton sender)
 {
     double? radius = StrToDouble(m_radius.Text);
     if (radius!=null)
         ((MyTriggerPositionReached)m_trigger).Radius = (double)radius;
     if (m_coordsChanged)
         ((MyTriggerPositionReached)m_trigger).TargetPos = m_coords;
     base.OnOkButtonClick(sender);
 }
 private void OnClick_UpgradeBuildLevel(MyGuiControlButton button)
 {
     var ship = GetTargetShip();
     foreach (var block in ship.GetBlocks())
     {
         block.UpgradeBuildLevel();
         block.UpdateVisual();
     }
 }
 private void OnClick_SetMinBuildLevel(MyGuiControlButton button)
 {
     var ship = GetTargetShip();
     foreach (var block in ship.GetBlocks())
     {
         block.SetToConstructionSite();
         block.UpdateVisual();
     }
 }
        protected override void OnStartClicked(MyGuiControlButton sender)
        {
            Debug.Assert(Sync.IsServer);

            MySession.Static.Settings.CanJoinRunning = false;
            if (!MySession.Static.Settings.CanJoinRunning)
                MyMultiplayer.Static.SetLobbyType(SteamSDK.LobbyTypeEnum.Private);
            MyScenarioSystem.Static.PrepareForStart();
            CloseScreen();
        }
        private void OnClick_ResetStructuralSimulation(MyGuiControlButton button)
        {
            foreach (var entity in MyEntities.GetEntities())
            {
                var grid = entity as MyCubeGrid;
                if (grid == null)
                    continue;

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

            AddCaption(MySpaceTexts.ScreenCaptionLoadWorld);

            var origin = new Vector2(-0.4375f, -0.3f);
            Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;

            m_sessionsTable = new MyGuiControlTable();
            m_sessionsTable.Position = origin + new Vector2(buttonSize.X * 1.1f, 0f);
            m_sessionsTable.Size = new Vector2(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 0.15f);
            m_sessionsTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_sessionsTable.ColumnsCount = 2;
            m_sessionsTable.VisibleRowsCount = 17;
            m_sessionsTable.ItemSelected += OnTableItemSelected;
            m_sessionsTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick;
            m_sessionsTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick;
            m_sessionsTable.SetCustomColumnWidths(new float[] { 0.65f, 0.35f });
            m_sessionsTable.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
            m_sessionsTable.SetColumnComparison(1, (a, b) => ((DateTime)a.UserData).CompareTo((DateTime)b.UserData));
            Controls.Add(m_sessionsTable);

            Vector2 buttonOrigin = origin + buttonSize * 0.5f;
            Vector2 buttonDelta = MyGuiConstants.MENU_BUTTONS_POSITION_DELTA;

            // Continue last game
            // Load
            // Edit
            // Save
            // Delete
            Controls.Add(m_continueLastSave = MakeButton(buttonOrigin + buttonDelta * 0, MySpaceTexts.LoadScreenButtonContinueLastGame, OnContinueLastGameClick));
            Controls.Add(m_loadButton = MakeButton(buttonOrigin + buttonDelta * 1, MySpaceTexts.LoadScreenButtonLoad, OnLoadClick));
            Controls.Add(m_editButton = MakeButton(buttonOrigin + buttonDelta * 2, MySpaceTexts.LoadScreenButtonEditSettings, OnEditClick));
            Controls.Add(m_saveButton = MakeButton(buttonOrigin + buttonDelta * 3, MySpaceTexts.LoadScreenButtonSaveAs, OnSaveAsClick));
            Controls.Add(m_deleteButton = MakeButton(buttonOrigin + buttonDelta * 4, MySpaceTexts.LoadScreenButtonDelete, OnDeleteClick));
            Controls.Add(m_publishButton = MakeButton(buttonOrigin + buttonDelta * 6, MySpaceTexts.LoadScreenButtonPublish, OnPublishClick));

            m_publishButton.SetToolTip(MyTexts.GetString(MySpaceTexts.LoadScreenButtonTooltipPublish));

            m_continueLastSave.Enabled = false;
            m_continueLastSave.DrawCrossTextureWhenDisabled = false;
            m_loadButton.DrawCrossTextureWhenDisabled = false;
            m_editButton.DrawCrossTextureWhenDisabled = false;
            m_deleteButton.DrawCrossTextureWhenDisabled = false;
            m_saveButton.DrawCrossTextureWhenDisabled = false;
            m_publishButton.DrawCrossTextureWhenDisabled = false;

            CloseButtonEnabled = true;

            if (m_state == StateEnum.ListLoaded)
                m_state = StateEnum.ListNeedsReload;
        }
        private void OnOpenInWorkshopClick(MyGuiControlButton obj)
        {
            var selectedRow = m_worldsTable.SelectedRow;
            if (selectedRow == null)
                return;

            var world = (MySteamWorkshop.SubscribedItem)selectedRow.UserData;
            if (world == null)
                return;

            string url = string.Format(MySteamConstants.URL_WORKSHOP_VIEW_ITEM_FORMAT, world.PublishedFileId);
            MyGuiSandbox.OpenUrlWithFallback(url, "Steam Workshop");
        }
        protected void OnOkClick(MyGuiControlButton sender)
        {
            m_shortcut.Text = m_shortcut.Text.Replace(" ", string.Empty);
            m_name.Text = m_name.Text.Trim();

            if (m_shortcut.Text.Length != 3)
            {
                ShowErrorBox(MyTexts.Get(MyCommonTexts.MessageBoxErrorFactionsTag));
                return;
            }

            if (MySession.Static.Factions.FactionTagExists(m_shortcut.Text, m_editFaction))
            {
                ShowErrorBox(MyTexts.Get(MyCommonTexts.MessageBoxErrorFactionsTagAlreadyExists));
                return;
            }

            if (m_name.Text.Length < 4)
            {
                ShowErrorBox(MyTexts.Get(MyCommonTexts.MessageBoxErrorFactionsNameTooShort));
                return;
            }

            if (MySession.Static.Factions.FactionNameExists(m_name.Text, m_editFaction))
            {
                ShowErrorBox(MyTexts.Get(MyCommonTexts.MessageBoxErrorFactionsNameAlreadyExists));
                return;
            }

            if (m_editFaction != null)
            {
                MySession.Static.Factions.EditFaction(
                    factionId: m_editFaction.FactionId,
                    tag: m_shortcut.Text,
                    name: m_name.Text,
                    desc: m_desc.Text,
                    privateInfo: m_privInfo.Text);

                CloseScreenNow();
                return;
            }

            MySession.Static.Factions.CreateFaction(
                founderId: MySession.Static.LocalPlayerId,
                tag: m_shortcut.Text,
                name: m_name.Text,
                desc: m_desc.Text,
                privateInfo: m_privInfo.Text);

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

            AddCaption(MyCommonTexts.ScreenCaptionLoadWorld);

            var origin = new Vector2(-0.4375f, -0.3f);
            Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;

            m_saveBrowser = new MyGuiControlSaveBrowser();
            m_saveBrowser.Position = origin + new Vector2(buttonSize.X * 1.1f, 0f);
            m_saveBrowser.Size = new Vector2(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 0.15f);
            m_saveBrowser.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_saveBrowser.VisibleRowsCount = 17;
            m_saveBrowser.ItemSelected += OnTableItemSelected;
            m_saveBrowser.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick;
            m_saveBrowser.ItemConfirmed += OnTableItemConfirmedOrDoubleClick;
            Controls.Add(m_saveBrowser);

            Vector2 buttonOrigin = origin + buttonSize * 0.5f;
            Vector2 buttonDelta = MyGuiConstants.MENU_BUTTONS_POSITION_DELTA;

            // Continue last game
            // Load
            // Edit
            // Save
            // Delete
            Controls.Add(m_continueLastSave = MakeButton(buttonOrigin + buttonDelta * 0, MyCommonTexts.LoadScreenButtonContinueLastGame, OnContinueLastGameClick));
            Controls.Add(m_loadButton = MakeButton(buttonOrigin + buttonDelta * 1, MyCommonTexts.LoadScreenButtonLoad, OnLoadClick));
            Controls.Add(m_editButton = MakeButton(buttonOrigin + buttonDelta * 2, MyCommonTexts.LoadScreenButtonEditSettings, OnEditClick));
            Controls.Add(m_saveButton = MakeButton(buttonOrigin + buttonDelta * 3, MyCommonTexts.LoadScreenButtonSaveAs, OnSaveAsClick));
            Controls.Add(m_deleteButton = MakeButton(buttonOrigin + buttonDelta * 4, MyCommonTexts.LoadScreenButtonDelete, OnDeleteClick));
            Controls.Add(MakeButton(buttonOrigin + buttonDelta * 6, MyCommonTexts.ScreenMenuButtonSubscribedWorlds, OnWorkshopClick));
            m_publishButton = MakeButton(buttonOrigin + buttonDelta * 7, MyCommonTexts.LoadScreenButtonPublish, OnPublishClick);
            if (!MyFakes.XB1_PREVIEW)
            {
                Controls.Add(m_publishButton);
            }
            Controls.Add(m_backupsButton = MakeButton(buttonOrigin + buttonDelta * 8, MyCommonTexts.LoadScreenButtonBackups, OnBackupsButtonClick));

            m_publishButton.SetToolTip(MyTexts.GetString(MyCommonTexts.LoadScreenButtonTooltipPublish));

            m_continueLastSave.DrawCrossTextureWhenDisabled = false;
            m_loadButton.DrawCrossTextureWhenDisabled = false;
            m_editButton.DrawCrossTextureWhenDisabled = false;
            m_deleteButton.DrawCrossTextureWhenDisabled = false;
            m_saveButton.DrawCrossTextureWhenDisabled = false;
            m_publishButton.DrawCrossTextureWhenDisabled = false;

            CloseButtonEnabled = true;
        }
        private void RemoveAllAsteroids(MyGuiControlButton sender)
        {
            MyCsgShapePlanetShapeAttributes shapeAttributes = new MyCsgShapePlanetShapeAttributes();

            shapeAttributes.Seed = 12345;
            shapeAttributes.Diameter = 60;
            shapeAttributes.Radius = 60 / 2.0f;
            shapeAttributes.DeviationScale = 0.003f;
            float maxHillSize = 10;

            float planetHalfDeviation = (shapeAttributes.Diameter * shapeAttributes.DeviationScale) / 2.0f;
            float hillHalfDeviation = planetHalfDeviation * maxHillSize;
            float canyonHalfDeviation = 1;


            float averagePlanetRadius = shapeAttributes.Radius - hillHalfDeviation;

            float outerRadius = averagePlanetRadius + hillHalfDeviation;
            float innerRadius = averagePlanetRadius - canyonHalfDeviation;

            float atmosphereRadius = MathHelper.Max(outerRadius, averagePlanetRadius * 1.08f);
            float minPlanetRadius = MathHelper.Min(innerRadius, averagePlanetRadius - planetHalfDeviation * 2 * 2.5f);

            MyCsgShapePlanetMaterialAttributes materialAttributes = new MyCsgShapePlanetMaterialAttributes();
            materialAttributes.OreStartDepth = innerRadius;
            materialAttributes.OreEndDepth = innerRadius;
            materialAttributes.OreEndDepth = MathHelper.Max(materialAttributes.OreEndDepth, 0);
            materialAttributes.OreStartDepth = MathHelper.Max(materialAttributes.OreStartDepth, 0);

            materialAttributes.OreProbabilities = new MyOreProbability[10];

            for (int i = 0; i < 10; ++i)
            {
                materialAttributes.OreProbabilities[i] = new MyOreProbability();
                materialAttributes.OreProbabilities[i].OreName = "Ice_01";
                materialAttributes.OreProbabilities[i].CummulativeProbability = 0.0f;
            }

            shapeAttributes.AveragePlanetRadius = averagePlanetRadius;

            IMyStorageDataProvider dataProvider = MyCompositeShapeProvider.CreatePlanetShape(0, ref shapeAttributes, maxHillSize, ref materialAttributes);
            IMyStorage storage = new MyOctreeStorage(dataProvider, MyVoxelCoordSystems.FindBestOctreeSize(shapeAttributes.Diameter));
            MyStorageDataCache cache = new MyStorageDataCache();
            cache.Resize(storage.Size);
            Vector3I start = Vector3I.Zero;
            Vector3I end = storage.Size;
            storage.ReadRange(cache, MyStorageDataTypeFlags.Content, 1, ref start, ref end);
            dataProvider.ReleaseHeightMaps();
        }
        public MyGuiControlVoxelHandSettings()
            : base(size: new Vector2(0.25f, 0.4f),
                   backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_LARGE_DEFAULT.Texture),
                   originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
        {
            m_labelSettings = new MyGuiControlLabel()
            {
                Position = new Vector2(-0.1f, -0.1875f),
                TextEnum = MyCommonTexts.VoxelHandSettingScreen_ShapeSettings,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Font = MyFontEnum.ScreenCaption,
            };

            OKButton = new MyGuiControlButton() { Position = new Vector2(0f, 0.19f), TextEnum = MyCommonTexts.Ok, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM };
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls");

            bool showRightControls = !(MySession.ControlledEntity is MyShipController) || MyToolbarComponent.GlobalBuilding;
            //Disable right buttons if current spectator is official spectator
            if (MySession.Static.SurvivalMode)
                showRightControls &= !(MySession.IsCameraUserControlledSpectator() && !MyInput.Static.ENABLE_DEVELOPER_KEYS && MySession.Static.Settings.EnableSpectator);

            m_smallShipButton = (MyGuiControlButton)Controls.GetControlByName("ButtonSmall");
            m_smallShipButton.Visible = showRightControls;
            m_smallShipButton.ButtonClicked += smallShipButton_OnButtonClick;

            m_largeShipButton = (MyGuiControlButton)Controls.GetControlByName("ButtonLarge");
            m_largeShipButton.Visible = showRightControls;
            m_largeShipButton.ButtonClicked += largeShipButton_OnButtonClick;

            m_stationButton = (MyGuiControlButton)Controls.GetControlByName("ButtonStation");
            m_stationButton.Visible = showRightControls;
            m_stationButton.ButtonClicked += stationButton_OnButtonClick;

            if (m_screenCubeGrid != null)
            {
                m_smallShipButton.Visible = false;
                m_stationButton.Visible = false;
                m_largeShipButton.Visible = false;
            }

            m_blockInfoSmall = new MyGuiControlBlockInfo(false, false);
            m_blockInfoSmall.Visible = false;
            m_blockInfoSmall.IsActiveControl = false;
            m_blockInfoSmall.BlockInfo = new MyHudBlockInfo();
            m_blockInfoSmall.Position = new Vector2(0.28f, -0.04f);
            m_blockInfoSmall.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Controls.Add(m_blockInfoSmall);
            m_blockInfoLarge = new MyGuiControlBlockInfo(false, true);
            m_blockInfoLarge.Visible = false;
            m_blockInfoLarge.IsActiveControl = false;
            m_blockInfoLarge.BlockInfo = new MyHudBlockInfo();
            m_blockInfoLarge.Position = new Vector2(0.28f, -0.06f);
            m_blockInfoLarge.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Controls.Add(m_blockInfoLarge);

            ProfilerShort.End();
        }
        public MyGuiScreenTriggerBlockDestroyed(MyTrigger trig) : base(trig,new Vector2(0.5f,0.8f))
        {
            trigger=(MyTriggerBlockDestroyed)trig;
            AddCaption(MySpaceTexts.GuiTriggerCaptionBlockDestroyed);

            var layout = new MyLayoutTable(this);
            layout.SetColumnWidthsNormalized(10, 30, 3, 30, 10);
            layout.SetRowHeightsNormalized(20, 35, 6, 4, 4, 5, 33);

            m_selectedBlocks = new MyGuiControlTable();
            m_selectedBlocks.VisibleRowsCount = 8;
            m_selectedBlocks.ColumnsCount = 1;
            m_selectedBlocks.SetCustomColumnWidths(new float[]{1});
            m_selectedBlocks.SetColumnName(0, MyTexts.Get(MySpaceTexts.GuiTriggerBlockDestroyed_ColumnName));

            layout.AddWithSize(m_selectedBlocks, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 1, colSpan: 3);

            m_buttonPaste = new MyGuiControlButton(
                text: MyTexts.Get(MySpaceTexts.GuiTriggerPasteBlocks),
                visualStyle: MyGuiControlButtonStyleEnum.Rectangular,
                onButtonClick: OnPasteButtonClick
                );
            m_buttonPaste.SetToolTip(MySpaceTexts.GuiTriggerPasteBlocksTooltip);
            layout.AddWithSize(m_buttonPaste, MyAlignH.Left, MyAlignV.Top, 2, 1, rowSpan: 1, colSpan: 1);

            m_buttonDelete = new MyGuiControlButton(
                text: MyTexts.Get(MySpaceTexts.GuiTriggerDeleteBlocks),
                visualStyle: MyGuiControlButtonStyleEnum.Rectangular,
                onButtonClick: OnDeleteButtonClick);
            layout.AddWithSize(m_buttonDelete, MyAlignH.Left, MyAlignV.Top, 2, 3, rowSpan: 1, colSpan: 1);

            m_labelSingleMessage = new MyGuiControlLabel(
                text: MyTexts.Get(MySpaceTexts.GuiTriggerBlockDestroyedSingleMessage).ToString()
                );
            layout.AddWithSize(m_labelSingleMessage, MyAlignH.Left, MyAlignV.Top, 3, 1, rowSpan: 1, colSpan: 1);
            m_textboxSingleMessage = new MyGuiControlTextbox(
                defaultText: trigger.SingleMessage,
                maxLength: 85);
            layout.AddWithSize(m_textboxSingleMessage, MyAlignH.Left, MyAlignV.Top, 4, 1, rowSpan: 1, colSpan: 3);

            foreach(var block in trigger.Blocks)
                AddRow(block.Key);
            m_tempSb.Clear().Append(trigger.SingleMessage);
            m_textboxSingleMessage.SetText(m_tempSb);

        }
        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;
        }
        private void DeleteItems(MyGuiControlButton sender)
        {
            var treeType = MyObjectBuilderType.Parse("MyObjectBuilder_Trees");
            var items = new System.Collections.Generic.HashSet<MyEntity>();

            foreach (var entity in Sandbox.Game.Entities.MyEntities.GetEntities())
            {
                if (entity.GetObjectBuilder().TypeId == treeType)
                {
                    items.Add(entity);
                }
            }

            foreach (var item in items)
            {
                item.Close();
            }
        }
 private void switchRagdoll(MyGuiControlButton obj)
 {
     MyCharacter playerCharacter = MySession.Static.LocalCharacter;
     if (PlayerRagdollMapper.IsActive)
     {
         if (playerCharacter.Physics.Ragdoll.IsKeyframed)
         {
             playerCharacter.Physics.Ragdoll.EnableConstraints();
             PlayerRagdollMapper.SetRagdollToDynamic();                    
         }
         else
         {
             playerCharacter.Physics.Ragdoll.DisableConstraints();
             PlayerRagdollMapper.SetRagdollToKeyframed();
         }
         
     }
 }
        public MyGuiScreenSaveAs(MyWorldInfo copyFrom, string sessionPath, List<string> existingSessionNames)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.5f, 0.35f))
        {
            EnabledBackgroundFade = true;

            AddCaption(MyCommonTexts.ScreenCaptionSaveAs);

            float textboxPositionY = -0.02f;

            m_nameTextbox = new MyGuiControlTextbox(
                position: new Vector2(0, textboxPositionY),
                defaultText: copyFrom.SessionName,
                maxLength: 75);

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

            Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.4f);
            Vector2 buttonOffset = new Vector2(0.01f, 0f);

            m_okButton.Position     = buttonOrigin - buttonOffset;
            m_cancelButton.Position = buttonOrigin + buttonOffset;

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

            m_nameTextbox.MoveCarriageToEnd();
            m_copyFrom = copyFrom;
            m_sessionPath = sessionPath;
            m_existingSessionNames = existingSessionNames;

            CloseButtonEnabled = true;
            CloseButtonOffset = new Vector2(-0.005f, 0.0035f);
            OnEnterCallback = OnEnterPressed;
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            base.m_position = new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.25f, 0.5f);

            var layout = new MyLayoutVertical(this, 35f);

            layout.Advance(20);

            {
                layout.Add(new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.BotSettingsScreen_Title)), MyAlignH.Center);
            }

            layout.Advance(30);

            {
                var enableDebuggingCheckBox = new MyGuiControlCheckbox(isChecked: MyDebugDrawSettings.DEBUG_DRAW_BOTS);
                enableDebuggingCheckBox.IsCheckedChanged += enableDebuggingCheckBox_IsCheckedChanged;
                layout.Add(new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.BotSettingsScreen_EnableBotsDebugging)), MyAlignH.Left, advance: false);
                layout.Add(enableDebuggingCheckBox, MyAlignH.Right);
            }

            layout.Advance(15);

            {
                MyGuiControlButton nextButton = new MyGuiControlButton(
                    text: MyTexts.Get(MyCommonTexts.BotSettingsScreen_NextBot),
                    onButtonClick: nextButton_OnButtonClick);
                MyGuiControlButton previousButton = new MyGuiControlButton(
                    text: MyTexts.Get(MyCommonTexts.BotSettingsScreen_PreviousBot),
                    onButtonClick: previousButton_OnButtonClick);
                layout.Add(nextButton, previousButton);
            }

            layout.Advance(30);

            {
                layout.Add(new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Close), onButtonClick: OnCloseClicked), MyAlignH.Center);
            }
        }
Beispiel #31
0
 private void closeButton_OnButtonClick(MyGuiControlButton sender)
 {
     CloseScreen();
 }