void m_shareModeCombobox_ItemSelected() { if (!m_canChangeShareMode) { return; } m_canChangeShareMode = false; bool updateVisuals = false; MyOwnershipShareModeEnum shareMode = (MyOwnershipShareModeEnum)m_shareModeCombobox.GetSelectedKey(); if (m_currentBlocks.Length > 0) { m_requests.Clear(); foreach (var block in m_currentBlocks) { if (block.IDModule != null) { if (shareMode >= 0 && (block.OwnerId == MySession.Static.LocalPlayerId)) { m_requests.Add(new MyCubeGrid.MySingleOwnershipRequest() { BlockId = block.EntityId, Owner = block.IDModule.Owner }); updateVisuals = true; } } } if (m_requests.Count > 0) { MyCubeGrid.ChangeOwnersRequest(shareMode, m_requests, MySession.Static.LocalPlayerId); } } m_canChangeShareMode = true; if (updateVisuals) { block_PropertiesChanged(null); } }
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 RecreateServerLimitInfo(MyGuiControlList list) { var identity = MySession.Static.Players.TryGetIdentity(MySession.Static.LocalPlayerId); int built; if (MySession.Static.MaxBlocksPerPlayer > 0 || MySession.Static.BlockTypeLimits.Keys.Count > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Overview), textScale: 1.3f); list.Controls.Add(totalBlocksLabel); } if (MySession.Static.MaxBlocksPerPlayer > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), identity.BlocksBuilt, MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower))); list.Controls.Add(totalBlocksLabel); } foreach (var blockType in MySession.Static.BlockTypeLimits) { identity.BlockTypeBuilt.TryGetValue(blockType.Key, out built); var definition = Sandbox.Definitions.MyDefinitionManager.Static.TryGetDefinitionGroup(blockType.Key); if (definition == null) continue; MyGuiControlLabel blockTypeLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), built, MySession.Static.GetBlockTypeLimit(blockType.Key), definition.Any.DisplayNameText)); list.Controls.Add(blockTypeLabel); } foreach (var grid in m_infoGrids) { grid.OnAuthorshipChanged -= grid_OnAuthorshipChanged; } m_infoGrids.Clear(); identity.LockBlocksBuiltByGrid.AcquireExclusive(); for (int i = 0; i < identity.BlocksBuiltByGrid.Count; i++) { var grid = identity.BlocksBuiltByGrid.ElementAt(i); MyGuiControlParent panel = new MyGuiControlParent(); if (m_infoGrids.Count == 0) { MyGuiControlSeparatorList infoSeparator = new MyGuiControlSeparatorList(); infoSeparator.AddHorizontal(new Vector2(-0.2f, -0.052f), 0.4f, width: 0.004f); panel.Controls.Add(infoSeparator); } MyGuiControlLabel gridNameLabel = new MyGuiControlLabel(text: grid.Key.DisplayName, textScale: 0.9f); MyGuiControlLabel gridBlockCountLabel = new MyGuiControlLabel(text: String.Format("{0} {1}", grid.Value, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)), textScale: 0.9f); MyGuiControlLabel assignLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Assign), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f); MyGuiControlCombobox assignCombobox = new MyGuiControlCombobox(originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, size: new Vector2(0.11f, 0.008f)); MyGuiControlSeparatorList lineSeparator = new MyGuiControlSeparatorList(); gridNameLabel.Position = new Vector2(-0.15f, -0.025f); gridBlockCountLabel.Position = new Vector2(-0.15f, 0.000f); assignLabel.Position = new Vector2(0.035f, 0.025f); assignCombobox.Position = new Vector2(0.15f, 0.025f); assignCombobox.ItemSelected += delegate() { assignCombobox_ItemSelected(grid.Key, m_playerIds[(int)assignCombobox.GetSelectedKey()]); }; m_playerIds.Clear(); foreach (var player in MySession.Static.Players.GetOnlinePlayers()) { if (MySession.Static.LocalHumanPlayer != player) { assignCombobox.AddItem(m_playerIds.Count, player.DisplayName); m_playerIds.Add(player.Id); } } lineSeparator.AddHorizontal(new Vector2(-0.15f, 0.05f), 0.3f, width: 0.002f); panel.Controls.Add(gridNameLabel); panel.Controls.Add(gridBlockCountLabel); panel.Controls.Add(assignLabel); panel.Controls.Add(assignCombobox); panel.Controls.Add(lineSeparator); if (MySession.Static.EnableRemoteBlockRemoval) { MyGuiControlLabel deleteOwnedBlocksLabel = new MyGuiControlLabel( text: MyTexts.GetString(MySpaceTexts.buttonRemove), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f); MyGuiControlButton deleteOwnedBlocksButton = new MyGuiControlButton( text: new StringBuilder("X"), onButtonClick: deleteOwnedBlocksButton_ButtonClicked, buttonIndex: m_infoGrids.Count, visualStyle: MyGuiControlButtonStyleEnum.SquareSmall, originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); deleteOwnedBlocksLabel.Position = new Vector2(0.11f, -0.02f); deleteOwnedBlocksButton.Position = new Vector2(0.15f, -0.02f); panel.Controls.Add(deleteOwnedBlocksLabel); panel.Controls.Add(deleteOwnedBlocksButton); } grid.Key.OnAuthorshipChanged += grid_OnAuthorshipChanged; m_infoGrids.Add(grid.Key); panel.Size = new Vector2(panel.Size.X, 0.09f); list.Controls.Add(panel); } identity.LockBlocksBuiltByGrid.ReleaseExclusive(); }
void CueVolumeCurveChanged(MyGuiControlCombobox combobox) { if (m_canUpdateValues) { m_currentCue.VolumeCurve = (MyCurveType)combobox.GetSelectedKey(); } }
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(); } }