private void OnVideoModeChangedAndConfirm(MyVideoSettingsManager.ChangeResult result) { switch (result) { case MyVideoSettingsManager.ChangeResult.Success: m_waitingForConfirmation = true; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.YES_NO_TIMEOUT, messageText: MyTexts.Get(MySpaceTexts.DoYouWantToKeepTheseSettingsXSecondsRemaining), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm), callback: OnMessageBoxCallback, timeoutInMiliseconds: MyGuiConstants.VIDEO_OPTIONS_CONFIRMATION_TIMEOUT_IN_MILISECONDS)); break; case MyVideoSettingsManager.ChangeResult.NothingChanged: break; case MyVideoSettingsManager.ChangeResult.Failed: m_doRevert = true; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.SorryButSelectedSettingsAreNotSupportedByYourHardware), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError))); break; } }
private void OnVideoModeChanged(MyVideoSettingsManager.ChangeResult result) { WriteSettingsToControls(m_deviceSettingsOld, m_graphicsSettingsOld); ReadSettingsFromControls(ref m_deviceSettingsNew, ref m_graphicsSettingsNew); }
/// <summary> /// Draws fog (eg. background for notifications) at specified position in normalized GUI coordinates. /// </summary> public static void DrawFog(ref Vector2 centerPosition, ref Vector2 textSize) { Color color = new Color(0, 0, 0, (byte)(255 * 0.85f)); Vector2 fogFadeSize = textSize * new Vector2(1.4f, 3.0f); MyGuiManager.DrawSpriteBatch(MyGuiConstants.FOG_SMALL, centerPosition, fogFadeSize, color, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoSettingsManager.IsTripleHead()); }
private void DrawNotifications(int visibleCount) { var notificationPosition = Position; int textIdx = 0; for (int i = MAX_PRIORITY; i >= 0; --i) { List <MyHudNotificationBase> notifications; m_notificationsByPriority.TryGetValue(i, out notifications); if (notifications == null) { continue; } foreach (var notification in notifications) { if (!IsDrawn(notification)) { continue; } MyGuiManager.DrawString(notification.Font, m_texts[textIdx], notificationPosition, MyGuiSandbox.GetDefaultTextScaleWithLanguage(), Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoSettingsManager.IsTripleHead()); notificationPosition.Y += m_textSizes[textIdx].Y; ++textIdx; --visibleCount; if (visibleCount == 0) { return; } } } }
void OnVideoAdapterSelected() { int adapterIndex = (int)m_videoAdapterCombobox.GetSelectedKey(); { // AddDisplayModesToComboBox m_resolutionCombobox.ClearItems(); var duplicateFilter = new HashSet <Vector2I>(Vector2I.Comparer); foreach (var displayMode in MyVideoSettingsManager.Adapters[adapterIndex].SupportedDisplayModes) { duplicateFilter.Add(new Vector2I(displayMode.Width, displayMode.Height)); } m_resolutionsForAdapter.Clear(); m_resolutionsForAdapter.AddHashset(duplicateFilter); m_resolutionsForAdapter.Sort((a, b) => { // Sort by width, then height. if (a.X != b.X) { return(a.X.CompareTo(b.X)); } return(a.Y.CompareTo(b.Y)); }); // Also show any extra display modes we have (there shouldn't be any on official builds). foreach (var mode in MyVideoSettingsManager.DebugDisplayModes) { m_resolutionsForAdapter.Add(new Vector2I(mode.Width, mode.Height)); } var displayAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex); int resolutionToSelect = 0; int counter = 0; for (int i = 0; i < m_resolutionsForAdapter.Count; ++i) { var resolution = m_resolutionsForAdapter[i]; float aspectRatio = (float)resolution.X / (float)resolution.Y; var aspectId = MyVideoSettingsManager.GetClosestAspectRatio(aspectRatio); var aspectDetails = MyVideoSettingsManager.GetAspectRatio(aspectId); var aspectRatioText = aspectDetails.TextShort; var starsMark = aspectDetails.IsSupported ? (aspectId == displayAspectRatio.AspectRatioEnum) ? " ***" // recommended : "" // normal : " *"; // unsupported if (resolution.X == m_deviceSettingsOld.BackBufferWidth && resolution.Y == m_deviceSettingsOld.BackBufferHeight) { resolutionToSelect = counter; } m_resolutionCombobox.AddItem(counter++, new StringBuilder( string.Format("{0} x {1} - {2}{3}", resolution.X, resolution.Y, aspectRatioText, starsMark))); } m_resolutionCombobox.SelectItemByKey(resolutionToSelect); } { // UpdateRecommendecAspectRatioLabel MyAspectRatio recommendedAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex); StringBuilder sb = new StringBuilder(); sb.AppendFormat(MyTexts.GetString(MySpaceTexts.RecommendedAspectRatio), recommendedAspectRatio.TextShort); m_recommendAspectRatioLabel.Text = string.Format("*** {0}", sb); } }
private void Create() { bool dedicated = Sandbox.Engine.Platform.Game.IsDedicated; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); MyServiceManager.Instance.AddService <IMyGameService>(new MySteamService(dedicated, _appSteamId)); if (dedicated && !MyGameService.HasGameServer) { _log.Warn("Steam service is not running! Please reinstall dedicated server."); return; } SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupPerGameSettings(); MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MySessionComponentExtDebug.ForceDisable = true; MyPerGameSettings.SendLogToKeen = false; // SpaceEngineersGame.SetupAnalytics(); MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); _tweakGameSettings(); MyFileSystem.Reset(); MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath); // MyInitializer.InitCheckSum(); // Hook into the VRage plugin system for updates. _getVRagePluginList().Add(_torch); if (!MySandboxGame.IsReloading) { MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString()); } MySandboxGame.IsReloading = dedicated; // render init { IMyRender renderer = null; if (dedicated) { renderer = new MyNullRender(); } else { MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderQualityEnum.NORMAL); MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset) .PerformanceSettings.RenderSettings; MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer; if (graphicsRenderer == MySandboxGame.DirectX11RendererKey) { renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings)); if (!renderer.IsSupported) { MySandboxGame.Log.WriteLine( "DirectX 11 renderer not supported. No renderer to revert back to."); renderer = null; } } if (renderer == null) { throw new MyRenderException( "The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported); } MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); MyRenderProxy.GetRenderProfiler().SetAutocommit(false); MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? _log.Info("Setting up serializers"); MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null) { MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly); } MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); //typeof(MySandboxGame).GetMethod("Preallocate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); MyGlobalTypeMetadata.Static.Init(false); }
// Draw all screens public void Draw() { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiSandbox::Draw"); MyGuiManager.Camera = MySector.MainCamera != null ? MySector.MainCamera.WorldMatrix : VRageMath.MatrixD.Identity; MyGuiManager.CameraView = MySector.MainCamera != null ? MySector.MainCamera.ViewMatrix : VRageMath.MatrixD.Identity; MyTransparentGeometry.Camera = MyGuiManager.Camera; MyTransparentGeometry.CameraView = MyGuiManager.CameraView; 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)) { SetMouseCursorVisibility(hwCursor, false); if (!hwCursor || MyFakes.FORCE_SOFTWARE_MOUSE_DRAW) { DrawMouseCursor(GetMouseOverTexture(screenWithFocus)); } } else { if (hwCursor) { if (screenWithFocus != null) { SetMouseCursorVisibility(screenWithFocus.GetDrawMouseCursor()); } } } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }