Initializes a new instance of the class. The editor.
(Editor editor)
| 386 | /// </summary> |
| 387 | /// <param name="editor">The editor.</param> |
| 388 | public GameWindow(Editor editor) |
| 389 | : base(editor, true, ScrollBars.None) |
| 390 | { |
| 391 | Title = "Game"; |
| 392 | Icon = editor.Icons.Play64; |
| 393 | AutoFocus = true; |
| 394 | |
| 395 | var task = MainRenderTask.Instance; |
| 396 | |
| 397 | // Setup viewport |
| 398 | _viewport = new ScaledRenderOutputControl(task) |
| 399 | { |
| 400 | AnchorPreset = AnchorPresets.StretchAll, |
| 401 | Offsets = Margin.Zero, |
| 402 | AutoFocus = false, |
| 403 | Parent = this |
| 404 | }; |
| 405 | task.PostRender += OnPostRender; |
| 406 | |
| 407 | // Override the game GUI root |
| 408 | _guiRoot = new GameRoot |
| 409 | { |
| 410 | Parent = _viewport |
| 411 | }; |
| 412 | RootControl.GameRoot = _guiRoot.UIRoot; |
| 413 | |
| 414 | SizeChanged += control => { ResizeViewport(); }; |
| 415 | |
| 416 | Editor.StateMachine.PlayingState.SceneDuplicating += PlayingStateOnSceneDuplicating; |
| 417 | Editor.StateMachine.PlayingState.SceneRestored += PlayingStateOnSceneRestored; |
| 418 | |
| 419 | // Link editor options |
| 420 | Editor.Options.OptionsChanged += OnOptionsChanged; |
| 421 | OnOptionsChanged(Editor.Options.Options); |
| 422 | |
| 423 | InputActions.Add(options => options.TakeScreenshot, () => Screenshot.Capture(string.Empty)); |
| 424 | InputActions.Add(options => options.DebuggerUnlockMouse, UnlockMouseInPlay); |
| 425 | InputActions.Add(options => options.ToggleFullscreen, () => { if (Editor.IsPlayMode) IsMaximized = !IsMaximized; }); |
| 426 | InputActions.Add(options => options.Play, Editor.Instance.Simulation.DelegatePlayOrStopPlayInEditor); |
| 427 | InputActions.Add(options => options.Pause, Editor.Instance.Simulation.RequestResumeOrPause); |
| 428 | InputActions.Add(options => options.StepFrame, Editor.Instance.Simulation.RequestPlayOneFrame); |
| 429 | #if USE_PROFILER |
| 430 | InputActions.Add(options => options.ProfilerStartStop, () => |
| 431 | { |
| 432 | bool recording = !Editor.Instance.Windows.ProfilerWin.LiveRecording; |
| 433 | Editor.Instance.Windows.ProfilerWin.LiveRecording = recording; |
| 434 | Editor.Instance.UI.AddStatusMessage($"Profiling {(recording ? "started" : "stopped")}."); |
| 435 | }); |
| 436 | InputActions.Add(options => options.ProfilerClear, () => |
| 437 | { |
| 438 | Editor.Instance.Windows.ProfilerWin.Clear(); |
| 439 | Editor.Instance.UI.AddStatusMessage("Profiling results cleared."); |
| 440 | }); |
| 441 | #endif |
| 442 | InputActions.Add(options => options.Save, () => |
| 443 | { |
| 444 | if (Editor.IsPlayMode) |
| 445 | return; |
nothing calls this directly
no test coverage detected