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();
            }
        }
Пример #2
0
        //  Sends input (keyboard/mouse) to screen which has focus (top-most)
        public void HandleInput()
        {
            ProfilerShort.Begin("MyGuiManager.HandleInput");
            try
            {
                if (MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F4))
                {
                    MyAnalyticsTracker.SendGameEnd("Alt+F4", MySandboxGame.TotalTimeInMilliseconds / 1000);

                    //  Exit application
                    MySandboxGame.ExitThreadSafe();
                    return;
                }

                //  Screenshot(s)
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SCREENSHOT))
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    TakeScreenshot();
                }

                bool newPressf12 = MyInput.Static.IsNewKeyPressed(MyKeys.F12);
                bool newPressf2  = MyInput.Static.IsNewKeyPressed(MyKeys.F2);
                if ((newPressf2 || newPressf12) && MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed())
                {
                    if (MySession.Static != null && MySession.Static.CreativeMode)
                    {
                        if (newPressf12)
                        {
                            MyDebugDrawSettings.DEBUG_DRAW_PHYSICS = !MyDebugDrawSettings.DEBUG_DRAW_PHYSICS;
                            if (!m_shapeRenderingMessageBoxShown)
                            {
                                m_shapeRenderingMessageBoxShown = true;
                                AddScreen(MyGuiSandbox.CreateMessageBox(
                                              messageCaption: new StringBuilder("PHYSICS SHAPES"),
                                              messageText: new StringBuilder("Enabled physics shapes rendering. This feature is for modders only and is not part of the gameplay.")));
                            }
                        }
                    }
                    else
                    {
                        AddScreen(MyGuiSandbox.CreateMessageBox(
                                      messageCaption: new StringBuilder("MODDING HELPER KEYS"),
                                      messageText: new StringBuilder("Use of helper key combinations for modders is only allowed in creative mode.")));
                    }
                    return;
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.H) && MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    if (MyFakes.ENABLE_NETGRAPH)
                    {
                        MyHud.IsNetgraphVisible = !MyHud.IsNetgraphVisible;
                    }
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.F11))
                {
                    if (MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        SwitchTimingScreen();
                    }
                }

                if (MyFakes.ENABLE_MISSION_SCREEN && MyInput.Static.IsNewKeyPressed(MyKeys.U))
                {
                    MyScreenManager.AddScreen(new MyGuiScreenMission());
                }

                if (!MyInput.Static.ENABLE_DEVELOPER_KEYS && Sync.MultiplayerActive && m_currentDebugScreen is MyGuiScreenDebugOfficial)
                {
                    RemoveScreen(m_currentDebugScreen);
                    m_currentDebugScreen = null;
                }

                bool inputHandled = false;

                if (MySession.Static != null && MySession.Static.CreativeMode ||
                    MyInput.Static.ENABLE_DEVELOPER_KEYS)
                {
                    F12Handling();
                }

                if (MyInput.Static.ENABLE_DEVELOPER_KEYS)
                {
                    //  Statistics screen
                    if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        SwitchStatisticsScreen();
                    }

                    if (MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed() &&
                        MyInput.Static.IsNewKeyPressed(MyKeys.Home))
                    {
                        throw new InvalidOperationException("Controlled crash");
                    }

                    // Forge GC to run
                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Pause) && MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        GC.Collect(GC.MaxGeneration);
                    }

                    if (MyInput.Static.IsAnyCtrlKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F2))
                    {
                        //Reload textures
                        if (MyInput.Static.IsKeyPress(MyKeys.LeftShift))
                        {
                            MyDefinitionManager.Static.ReloadDecalMaterials();
                            VRageRender.MyRenderProxy.ReloadTextures();
                        }
                        else
                        if (MyInput.Static.IsKeyPress(MyKeys.LeftAlt))
                        {
                            VRageRender.MyRenderProxy.ReloadModels();
                        }
                        else
                        {
                            VRageRender.MyRenderProxy.ReloadEffects();
                        }
                    }

                    //WS size
                    if (MyInput.Static.IsNewKeyPressed(MyKeys.F3) && MyInput.Static.IsKeyPress(MyKeys.LeftShift))
                    {
#if !XB1
                        WinApi.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
#endif // !XB1
                    }

                    inputHandled = HandleDebugInput();
                }

                if (!inputHandled)
                {
                    MyScreenManager.HandleInput();
                }
            }
            finally
            {
                ProfilerShort.End();
            }
        }
Пример #3
0
 public void BackToMainMenu()
 {
     AddIntroScreen();
     MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.MainMenu));
 }
Пример #4
0
        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();
            }
        }