コード例 #1
0
        public MyGuiScreenScriptingTools() : base(
                new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f),
                SCREEN_SIZE,
                MyGuiConstants.SCREEN_BACKGROUND_COLOR,
                false)
        {
            CanBeHidden   = true;
            CanHideOthers = false;
            m_canCloseInCloseAllScreenCalls = true;
            m_canShareInput   = true;
            m_isTopScreen     = false;
            m_isTopMostScreen = false;

            // Create new manipulator with predicate for area triggers only
            m_triggerManipulator = new MyTriggerManipulator(trigger => trigger is MyAreaTriggerComponent);
            m_transformSys       = MySession.Static.GetComponent <MyEntityTransformationSystem>();
            m_transformSys.ControlledEntityChanged += TransformSysOnControlledEntityChanged;
            m_transformSys.RayCasted += TransformSysOnRayCasted;

            // Switch to spectator
            MySession.Static.SetCameraController(MyCameraControllerEnum.SpectatorFreeMouse);

            // Enable Debug draw when opened
            MyDebugDrawSettings.ENABLE_DEBUG_DRAW         = true;
            MyDebugDrawSettings.DEBUG_DRAW_UPDATE_TRIGGER = true;

            RecreateControls(true);
        }
コード例 #2
0
        public MyGuiIngameScriptsPage(Action <string> onScriptOpened, Func <string> getCodeFromEditor, Action close) :
            base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            EnabledBackgroundFade = true;
            OnClose = close;
            this.GetCodeFromEditor    = getCodeFromEditor;
            this.OnScriptOpened       = onScriptOpened;
            m_localBlueprintFolder    = Path.Combine(MyFileSystem.UserDataPath, SCRIPTS_DIRECTORY, "local");
            m_workshopBlueprintFolder = Path.Combine(MyFileSystem.UserDataPath, SCRIPTS_DIRECTORY, "workshop");

            if (!Directory.Exists(m_localBlueprintFolder))
            {
                Directory.CreateDirectory(m_localBlueprintFolder);
            }

            if (!Directory.Exists(m_workshopBlueprintFolder))
            {
                Directory.CreateDirectory(m_workshopBlueprintFolder);
            }

            m_scriptList.Items.Clear();

            GetLocalScriptNames(m_subscribedItemsList.Count == 0);
            RecreateControls(true);

            m_scriptList.ItemsSelected     += OnSelectItem;
            m_scriptList.ItemDoubleClicked += OnItemDoubleClick;
            OnEnterCallback += Ok;

            m_searchBox.TextChanged += OnSearchTextChange;
        }
コード例 #3
0
        public MyGuiScreenDebugSpawnMenu() :
            base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            CanBeHidden   = true;
            CanHideOthers = false;
            m_canCloseInCloseAllScreenCalls = true;
            m_canShareInput   = true;
            m_isTopScreen     = false;
            m_isTopMostScreen = false;

            Screens = new Screen[] {
                new Screen()
                {
                    Name    = MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids),
                    Creator = CreateAsteroidsSpawnMenu
                },
                new Screen()
                {
                    Name    = MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids),
                    Creator = CreateProceduralAsteroidsSpawnMenu
                },
                new Screen()
                {
                    Name    = MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Planets),
                    Creator = CreatePlanetsSpawnMenu
                },
                new Screen()
                {
                    Name    = MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_EmptyVoxelMap),
                    Creator = CreateEmptyVoxelMapSpawnMenu
                }
            };

            RecreateControls(true);
        }
コード例 #4
0
 protected MyGuiScreenDebugBase(Vector4?backgroundColor = null, bool isTopMostScreen = false)
     : this(new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.16f, 0.5f), new Vector2(0.32f, 1.0f), backgroundColor ?? 0.85f * Color.Black.ToVector4(), isTopMostScreen)
 {
     m_closeOnEsc           = true;
     m_drawEvenWithoutFocus = true;
     m_isTopMostScreen      = false;
     CanHaveFocus           = false;
     m_isTopScreen          = true;
 }
コード例 #5
0
        public MyGuiScreenAdminMenu()
            : base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            CanBeHidden   = true;
            CanHideOthers = false;
            m_canCloseInCloseAllScreenCalls = true;
            m_canShareInput   = true;
            m_isTopScreen     = false;
            m_isTopMostScreen = false;

            RecreateControls(true);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        public MyGuiBlueprintScreen(MyGridClipboard clipboard) :
            base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            if (!Directory.Exists(m_localBlueprintFolder))
            {
                Directory.CreateDirectory(m_localBlueprintFolder);
            }

            if (!Directory.Exists(m_workshopBlueprintFolder))
            {
                Directory.CreateDirectory(m_workshopBlueprintFolder);
            }
            m_blueprintList.Items.Clear();
            GetLocalBlueprintNames(m_downloadFromSteam);

            if (m_downloadFromSteam)
            {
                m_downloadFromSteam = false;
            }

            RecreateControls(true);

            m_blueprintList.ItemsSelected     += OnSelectItem;
            m_blueprintList.ItemDoubleClicked += OnItemDoubleClick;
            m_blueprintList.ItemMouseOver     += OnMouseOverItem;
            OnEnterCallback         += Ok;
            m_searchBox.TextChanged += OnSearchTextChange;

            if (clipboard != null)
            {
                m_clipboard = clipboard;
            }
            else
            {
                System.Diagnostics.Debug.Fail("Clipboard shouldn't be null!");
                m_clipboard = Sandbox.Game.Entities.MyCubeBuilder.Static.Clipboard;
            }
        }
コード例 #8
0
        //  Draw all screens
        public void Draw()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiSandbox::Draw");

            ProfilerShort.Begin("ScreenManager.Draw");
            MyScreenManager.Draw();
            ProfilerShort.End();

            m_debugText.Clear();

            if (MyInput.Static.ENABLE_DEVELOPER_KEYS && MySandboxGame.Config.DebugComponentsInfo != MyDebugComponent.MyDebugComponentInfoState.NoInfo)
            {
                var  h = 0f;
                var  i = 0;
                bool drawBackground = false;

                MyDebugComponent.ResetFrame();

                foreach (var userInputComponent in UserDebugInputComponents)
                {
                    if (userInputComponent.Enabled)
                    {
                        if (h == 0)
                        {
                            m_debugText.AppendLine("Debug input:");
                            m_debugText.AppendLine();
                            h += 0.0630f;
                        }
                        m_debugText.ConcatFormat("{0} (Ctrl + numPad{1})", UserDebugInputComponents[i].GetName(), i);
                        m_debugText.AppendLine();
                        h += 0.0265f;
                        if (MySession.Static != null)
                        {
                            userInputComponent.DispatchUpdate();
                        }
                        userInputComponent.Draw();
                        drawBackground = true;
                    }
                    ++i;
                }

                if (drawBackground)
                {
                    MyGuiManager.DrawSpriteBatch(@"Textures\GUI\Controls\rectangle_dark_center.dds",
                                                 new Vector2(MyGuiManager.GetMaxMouseCoord().X, 0f),
                                                 new Vector2(MyGuiManager.MeasureString(MyFontEnum.White, m_debugText, 1f).X + 0.012f, h),
                                                 new Color(0, 0, 0, 130),
                                                 MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
                    MyGuiManager.DrawString(MyFontEnum.White, m_debugText, new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.01f, 0f), 1f, Color.White, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
                }
            }

            bool hwCursor = MyVideoSettingsManager.IsHardwareCursorUsed();

            var screenWithFocus = MyScreenManager.GetScreenWithFocus();

            if (((screenWithFocus != null) && (screenWithFocus.GetDrawMouseCursor() == true)) || (MyScreenManager.InputToNonFocusedScreens && MyScreenManager.GetScreensCount() > 1))
            {
#if XB1
                SetMouseCursorVisibility(false, false);
                DrawMouseCursor(GetMouseOverTexture(screenWithFocus));
#else
                SetMouseCursorVisibility(hwCursor, false);

                if (!hwCursor || MyFakes.FORCE_SOFTWARE_MOUSE_DRAW)
                {
                    DrawMouseCursor(GetMouseOverTexture(screenWithFocus));
                }
#endif
            }
            else
            {
                if (hwCursor)
                {
                    if (screenWithFocus != null)
                    {
                        SetMouseCursorVisibility(screenWithFocus.GetDrawMouseCursor());
                    }
                }
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
コード例 #9
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            Vector2 cbOffset         = new Vector2(-0.05f, 0.0f);
            Vector2 controlPadding   = new Vector2(0.02f, 0.02f);   // X: Left & Right, Y: Bottom & Top
            Vector2 multilinePadding = new Vector2(0.008f, 0.005f); // X: Left, Y: Bottom & Top

            float textScale     = 0.8f;
            float separatorSize = 0.02f;
            float usableWidth   = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2;
            float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f;

            m_currentPosition    = -m_size.Value / 2.0f;
            m_currentPosition   += controlPadding;
            m_currentPosition.Y += hiddenPartTop;
            m_scale              = textScale;

            var caption = AddCaption(MyCommonTexts.ScreenDebugOfficial_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop));

            m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y * 2.0f;

            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_EnableDebugDraw, () => MyDebugDrawSettings.ENABLE_DEBUG_DRAW, (bool b) => MyDebugDrawSettings.ENABLE_DEBUG_DRAW = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);

            m_currentPosition.Y += separatorSize;

            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_ModelDummies, () => MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES, (bool b) => MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);
            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_MountPoints, () => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS, (bool b) => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS    = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);
            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_PhysicsPrimitives, () => MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_SHAPES, (bool b) => { MyDebugDrawSettings.DEBUG_DRAW_PHYSICS |= b; MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_SHAPES = b; }, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);

            m_currentPosition.Y += separatorSize;

            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_ReloadTextures, ReloadTextures);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_ReloadModels, ReloadModels);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_SavePrefab, SavePrefab, MyClipboardComponent.Static != null ? MyClipboardComponent.Static.Clipboard.HasCopiedGrids() : false, MyCommonTexts.ToolTipSaveShip);

            // Don't enable the SE bot debugging in official builds yet
            if (MyPerGameSettings.Game == GameEnum.ME_GAME || !MyFinalBuildConstants.IS_OFFICIAL)
            {
                CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_BotSettings, OpenBotsScreen);
            }

            AddSubcaption(MyTexts.GetString(MyCommonTexts.ScreenDebugOfficial_ErrorLogCaption), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f));

            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_OpenErrorLog, CreateErrorLogScreen);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_CopyErrorLogToClipboard, CopyErrorLogToClipboard);

            m_currentPosition.Y += separatorSize;

            Vector2 textboxSize = (MyGuiManager.GetMaxMouseCoord() / 2.0f) - m_currentPosition;

            textboxSize.X        = usableWidth;
            textboxSize.Y       -= controlPadding.Y;
            m_currentPosition.X += multilinePadding.X / 2.0f;

            // Because multiline text does not allow padding
            var textBackground = new MyGuiControlPanel(m_currentPosition - multilinePadding, textboxSize + new Vector2(multilinePadding.X, multilinePadding.Y * 2.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            textBackground.BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST;
            Controls.Add(textBackground);

            var text = AddMultilineText(size: textboxSize);

            if (MyDefinitionErrors.GetErrors().Count() == 0)
            {
                text.AppendText(MyTexts.Get(MyCommonTexts.ScreenDebugOfficial_NoErrorText));
            }
            else
            {
                var errors          = MyDefinitionErrors.GetErrors();
                var errorDictionary = new Dictionary <string, Tuple <int, TErrorSeverity> >();

                // Count the number of most severe error per mod
                // Errors are already sorted by severity, so the first one per mod is the most severe
                foreach (var error in errors)
                {
                    var modName = error.ModName ?? "Local Content";

                    if (errorDictionary.ContainsKey(modName))
                    {
                        if (errorDictionary[modName].Item2 == error.Severity)
                        {
                            var info = errorDictionary[modName];
                            errorDictionary[modName] = new Tuple <int, TErrorSeverity>(info.Item1 + 1, info.Item2);
                        }
                    }
                    else
                    {
                        errorDictionary[modName] = new Tuple <int, TErrorSeverity>(1, error.Severity);
                    }
                }

                // Convert to list and sort to make sure most severe is displayed first
                var errorList = new List <Tuple <string, int, TErrorSeverity> >();
                foreach (var entry in errorDictionary)
                {
                    errorList.Add(new Tuple <string, int, TErrorSeverity>(entry.Key, entry.Value.Item1, entry.Value.Item2));
                }

                Comparison <Tuple <string, int, TErrorSeverity> > comp = (e1, e2) => e2.Item3 - e1.Item3;
                errorList.Sort(comp);

                foreach (var error in errorList)
                {
                    var errorText = new StringBuilder();
                    errorText.Append(error.Item1);
                    errorText.Append(" [");
                    if (error.Item3 == TErrorSeverity.Critical)
                    {
                        errorText.Append(MyDefinitionErrors.Error.GetSeverityName(error.Item3, false));
                        errorText.Append("]");
                    }
                    else
                    {
                        errorText.Append(error.Item2.ToString());
                        errorText.Append(" ");
                        errorText.Append(MyDefinitionErrors.Error.GetSeverityName(error.Item3, error.Item2 != 1));
                        errorText.Append("]");
                    }
                    text.AppendText(errorText, text.Font, text.TextScaleWithLanguage, MyDefinitionErrors.Error.GetSeverityColor(error.Item3).ToVector4());
                    text.AppendLine();
                }
            }
        }
コード例 #10
0
 protected MyGuiScreenDebugBase(Vector4?backgroundColor, bool isTopMostScreen) :
     this(new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.16f, 0.5f), new Vector2(0.32f, 1.0f), backgroundColor, isTopMostScreen)
 {
 }