Example #1
0
        /// <summary>
        /// Creates a new <see cref="CamView"/> and initializes it with the specified <see cref="CamViewState"/>.
        /// </summary>
        /// <param name="initStateTypeId"></param>
        public CamView CreateCamView(string initStateTypeId = null)
        {
            CamView cam = new CamView(this.camViews.Count, initStateTypeId);

            this.camViews.Add(cam);
            cam.FormClosed += delegate(object sender, FormClosedEventArgs e) { this.camViews.Remove(sender as CamView); };

            if (!this.isLoading)
            {
                cam.Show(DualityEditorApp.MainForm.MainDockPanel);
                if (cam.Pane != null)
                {
                    cam.Pane.Activate();
                    if (cam.RenderableControl != null)
                    {
                        cam.RenderableControl.Focus();
                    }
                    else
                    {
                        cam.Focus();
                    }
                }
            }
            return(cam);
        }
Example #2
0
        private void Sandbox_Entering(object sender, EventArgs e)
        {
            CamView gameView = null;

            if (this.camViews.Count == 0)
            {
                gameView = this.CreateCamView();
                gameView.SetCurrentState(typeof(CamViewStates.GameViewCamViewState));
            }
            else
            {
                gameView = this.camViews.FirstOrDefault(v => v.ActiveState.GetType() == typeof(CamViewStates.GameViewCamViewState));
                if (gameView != null && gameView.RenderableControl != null)
                {
                    gameView.RenderableControl.Focus();
                }
            }
        }
Example #3
0
        public CamView RequestCamView(string initStateTypeName = null)
        {
            CamView cam = new CamView(this.camViews.Count, initStateTypeName);
            this.camViews.Add(cam);
            cam.FormClosed += delegate(object sender, FormClosedEventArgs e) { this.camViews.Remove(sender as CamView); };

            if (!this.isLoading)
            {
                cam.Show(DualityEditorApp.MainForm.MainDockPanel);
                if (cam.Pane != null)
                {
                    cam.Pane.Activate();
                    if (cam.LocalGLControl != null)
                        cam.LocalGLControl.Focus();
                    else
                        cam.Focus();
                }
            }
            return cam;
        }
Example #4
0
		public void MakeDualityTarget()
		{
			if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated) return;

			activeCamView = this;

			Control mainControl = (this.graphicsControl != null ? this.graphicsControl.Control : null) ?? this;
			DualityApp.TargetResolution = new Vector2(mainControl.ClientSize.Width, mainControl.ClientSize.Height);
			DualityApp.Mouse.Source = this;
			DualityApp.Keyboard.Source = this;

			SoundListener localListener = this.CameraObj.GetComponent<SoundListener>();
			if (localListener != null && localListener.Active)
				localListener.MakeCurrent();
		}
Example #5
0
		protected override void OnClosed(EventArgs e)
		{
			base.OnClosed(e);

			// If this was the active Camera View, stop assuming this.
			if (activeCamView == this)
				activeCamView = null;

			if (this.nativeCamObj != null)
				this.nativeCamObj.Dispose();

			this.UnregisterEditorEvents();

			this.SetCurrentState((CamViewState)null);
		}