void m_transferToCombobox_ItemSelected() { if (m_transferToCombobox.GetSelectedIndex() == -1) { return; } if (m_askForConfirmation) { long ownerKey = m_transferToCombobox.GetSelectedKey(); int ownerIndex = m_transferToCombobox.GetSelectedIndex(); var ownerName = m_transferToCombobox.GetItemByIndex(ownerIndex).Value; var messageBox = MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm), messageText : new StringBuilder().AppendFormat(MyTexts.GetString(MySpaceTexts.MessageBoxTextChangeOwner), ownerName.ToString()), focusedResult : MyGuiScreenMessageBox.ResultEnum.NO, callback : delegate(MyGuiScreenMessageBox.ResultEnum retval) { if (retval == MyGuiScreenMessageBox.ResultEnum.YES) { if (m_currentBlocks.Length > 0) { m_requests.Clear(); foreach (var block in m_currentBlocks) { if (block.IDModule != null) { if (block.OwnerId == 0 || block.OwnerId == MySession.LocalPlayerId) { m_requests.Add(new MySyncGrid.MySingleOwnershipRequest() { BlockId = block.EntityId, Owner = ownerKey }); } } } if (m_requests.Count > 0) { MySyncGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.None, m_requests); } } RecreateOwnershipControls(); UpdateOwnerGui(); } else { m_askForConfirmation = false; m_transferToCombobox.SelectItemByIndex(-1); m_askForConfirmation = true; } }); messageBox.CanHideOthers = false; MyGuiSandbox.AddScreen(messageBox); } else { UpdateOwnerGui(); } }
void m_transferToCombobox_ItemSelected() { if (m_transferToCombobox.GetSelectedIndex() == -1) { return; } if (m_askForConfirmation) { long ownerKey = m_transferToCombobox.GetSelectedKey(); int ownerIndex = m_transferToCombobox.GetSelectedIndex(); var ownerName = m_transferToCombobox.GetItemByIndex(ownerIndex).Value; var messageBox = MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), messageText : new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.MessageBoxTextChangeOwner), ownerName.ToString()), focusedResult : MyGuiScreenMessageBox.ResultEnum.NO, callback : delegate(MyGuiScreenMessageBox.ResultEnum retval) { if (retval == MyGuiScreenMessageBox.ResultEnum.YES) { if (m_currentBlocks.Length > 0) { m_requests.Clear(); foreach (var block in m_currentBlocks) { if (block.IDModule != null) { if (block.OwnerId == 0 || block.OwnerId == MySession.Static.LocalPlayerId) { m_requests.Add(new MyCubeGrid.MySingleOwnershipRequest() { BlockId = block.EntityId, Owner = ownerKey }); } } } if (m_requests.Count > 0) { if (MySession.Static.Settings.ScenarioEditMode && Sync.Players.IdentityIsNpc(ownerKey)) { MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.Faction, m_requests, MySession.Static.LocalPlayerId); } else if (MySession.Static.LocalPlayerId == ownerKey) { // this should not be changed to No share, without approval from a designer, see ticket https://app.asana.com/0/64822442925263/64356719169418 MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.Faction, m_requests, MySession.Static.LocalPlayerId); } else { MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.None, m_requests, MySession.Static.LocalPlayerId); } } } RecreateOwnershipControls(); UpdateOwnerGui(); } else { m_askForConfirmation = false; m_transferToCombobox.SelectItemByIndex(-1); m_askForConfirmation = true; } }); messageBox.CanHideOthers = false; MyGuiSandbox.AddScreen(messageBox); } else { UpdateOwnerGui(); } }
private void CreateLayersControls(MyGuiControlList list, float usableWidth) { var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_CreateLayer, OnCreateLayer); Controls.Remove(button); list.Controls.Add(button); button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_RemoveLayer, OnRemoveLayer); Controls.Remove(button); list.Controls.Add(button); m_materialLayerDeviationSeed = CreateSeedButton(list, m_materialLayerDeviationSeedValue, usableWidth); var layerNoiseLabel = CreateSliderWithDescription(list, usableWidth, 10f, 200.0f, "Layer deviation noise frequency", ref m_materialLayerDeviationNoise); m_materialLayerDeviationNoise.ValueChanged += (MyGuiControlSlider s) => { layerNoiseLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2); }; m_layerCombobox = AddCombo(); m_layerCombobox.ItemSelected += OnLayerCombobox_ItemSelected; Controls.Remove(m_layerCombobox); list.Controls.Add(m_layerCombobox); m_oreComboboxLabel = AddLabel("Layer ore", Vector4.One, m_scale); Controls.Remove(m_oreComboboxLabel); list.Controls.Add(m_oreComboboxLabel); m_oreComboboxLabel.Visible = false; m_oreCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMaterialDefinitions()) { m_oreCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId); } m_oreCombobox.ItemSelected += OnOreCombobox_ItemSelected; m_oreCombobox.SortItemsByValueText(); } m_oreCombobox.Visible = false; list.Controls.Add(m_oreCombobox); var layerStartLabel = CreateSliderWithDescription(list, usableWidth, -m_procAsteroidSizeValue * m_planetDeviationScaleValue, m_procAsteroidSizeValue * m_planetDeviationScaleValue, "Layer start", ref m_materialLayerStart); m_materialLayerStart.ValueChanged += (MyGuiControlSlider s) => { layerStartLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].StartHeight = s.Value; } if (s.Value > m_materialLayerEnd.Value) { m_materialLayerEnd.Value = s.Value; } }; var layerStartHeigthDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 100.0f, "Layer start height deviation", ref m_materialLayerStartHeigthDeviation); m_materialLayerStartHeigthDeviation.ValueChanged += (MyGuiControlSlider s) => { layerStartHeigthDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].HeightStartDeviation = s.Value; } }; var layerEndLabel = CreateSliderWithDescription(list, usableWidth, -m_procAsteroidSizeValue * m_planetDeviationScaleValue, m_procAsteroidSizeValue * m_planetDeviationScaleValue, "Layer end", ref m_materialLayerEnd); m_materialLayerEnd.ValueChanged += (MyGuiControlSlider s) => { layerEndLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].EndHeight = s.Value; } if (s.Value < m_materialLayerStart.Value) { m_materialLayerStart.Value = s.Value; } }; var layerHeigthDeviationLabel = CreateSliderWithDescription(list, usableWidth,0, 100.0f, "Layer end height deviation", ref m_materialLayerEndHeigthDeviation); m_materialLayerEndHeigthDeviation.ValueChanged += (MyGuiControlSlider s) => { layerHeigthDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].HeightEndDeviation = s.Value; } }; var layerAngleStartLabel = CreateSliderWithDescription(list, usableWidth, -1, 1, "Layer angle start", ref m_materialLayerAngleStart); m_materialLayerAngleStart.ValueChanged += (MyGuiControlSlider s) => { layerAngleStartLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].StartAngle = s.Value; } if (s.Value > m_materialLayerAngleEnd.Value) { m_materialLayerAngleEnd.Value = s.Value; } }; var layerStartAngleDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 1.0f, "Layer start angle deviation", ref m_materialLayerAngleStartDeviation); m_materialLayerAngleStartDeviation.ValueChanged += (MyGuiControlSlider s) => { layerStartAngleDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].AngleStartDeviation = s.Value; } }; var layerAngleEndLabel = CreateSliderWithDescription(list, usableWidth, -1, 1, "Layer angle end", ref m_materialLayerAngleEnd); m_materialLayerAngleEnd.ValueChanged += (MyGuiControlSlider s) => { layerAngleEndLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].EndAngle = s.Value; } if (s.Value < m_materialLayerAngleStart.Value) { m_materialLayerAngleStart.Value = s.Value; } }; var layerAngleDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 1.0f, "Layer end angle deviation", ref m_materialLayerAngleEndDeviation); m_materialLayerAngleEndDeviation.ValueChanged += (MyGuiControlSlider s) => { layerAngleDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].AngleEndDeviation = s.Value; } }; }