Beispiel #1
0
 public void BackToMainMenu()
 {
     AddIntroScreen();
     MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.MainMenu));
 }
        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)
                            {
                                if (MySession.Static.Settings.ScenarioEditMode && Sync.Players.IdentityIsNpc(ownerKey))
                                {
                                    MySyncGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.Faction, m_requests);
                                }
                                else
                                {
                                    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();
            }
        }