private void TryCreateTargets() { if (this.LevelManager.Name == null) return; if (this.LevelManager.BlinkingAlpha) { if (!this.Enabled) { this.ownedHandle = this.TargetRenderingManager.TakeTarget(); this.newFrameBuffer = this.TargetRenderingManager.TakeTarget(); } this.Enabled = true; } else { if (this.Enabled) { this.TargetRenderingManager.ReturnTarget(this.ownedHandle); this.ownedHandle = (RenderTargetHandle) null; this.TargetRenderingManager.ReturnTarget(this.newFrameBuffer); this.newFrameBuffer = (RenderTargetHandle) null; } this.Enabled = false; } }
public override void Initialize() { base.Initialize(); if (!this.CaptureScreen) return; this.RtHandle = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.RtHandle.Target); }
public FarawayTransition(Game game) : base(game) { this.DrawOrder = 1; ITargetRenderingManager renderingManager = ServiceHelper.Get<ITargetRenderingManager>(); this.SkyRt = renderingManager.TakeTarget(); renderingManager.ScheduleHook(this.DrawOrder, this.SkyRt.Target); }
public override void Update(GameTime gameTime) { ScreenshotTaker screenshotTaker = this; int num = screenshotTaker.screenshotScheduled | this.KeyboardProvider.GetKeyState(Keys.F2) == FezButtonState.Pressed ? 1 : 0; screenshotTaker.screenshotScheduled = num != 0; if (!this.screenshotScheduled) return; this.rt = this.TRM.TakeTarget(); this.TRM.ScheduleHook(this.DrawOrder, this.rt.Target); }
public override void Draw(GameTime gameTime) { if (!this.screenshotScheduled || this.rt == null || !this.TRM.IsHooked(this.rt.Target)) return; this.TRM.Resolve(this.rt.Target, false); using (FileStream fileStream = new FileStream(string.Format("C:\\Screenshot_{0:000}.png", (object) this.counter++), FileMode.Create)) this.rt.Target.SaveAsPng((Stream) fileStream, this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height); this.TRM.ReturnTarget(this.rt); this.rt = (RenderTargetHandle) null; this.screenshotScheduled = false; }
public override void Initialize() { base.Initialize(); this.GameState.InCutscene = this.GameState.ForceTimePaused = false; this.PlayerManager.Action = ActionType.SleepWake; this.PlayerManager.LookingDirection = HorizontalDirection.Left; this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * -3f / 16f; this.sZoomToHouse = this.CMProvider.Get(CM.Intro).Load<SoundEffect>("Sounds/Intro/ZoomToHouse"); SoundEffectExtensions.Emit(this.sZoomToHouse); this.zoomRtHandle = this.TargetRenderingManager.TakeTarget(); this.TargetRenderingManager.ScheduleHook(this.DrawOrder, this.zoomRtHandle.Target); }
public override void Draw(GameTime gameTime) { if (this.GameState.Loading || this.GameState.SkipRendering) { if (this.backgroundRth == null || !this.TargetRenderer.IsHooked(this.backgroundRth.Target)) return; this.TargetRenderer.Resolve(this.backgroundRth.Target, true); GraphicsDeviceExtensions.SetBlendingMode(this.GraphicsDevice, BlendingMode.Opaque); this.combineEffect.LeftTexture = this.combineEffect.RightTexture = (Texture2D) this.backgroundRth.Target; this.TargetRenderer.DrawFullscreen((BaseEffect) this.combineEffect); GraphicsDeviceExtensions.SetBlendingMode(this.GraphicsDevice, BlendingMode.Alphablending); } else if (!this.GameState.StereoMode) { if (this.rightRT != null || this.leftRT != null) { this.TargetRenderer.ReturnTarget(this.leftRT); this.TargetRenderer.ReturnTarget(this.rightRT); this.leftRT = this.rightRT = (RenderTargetHandle) null; } if (this.backgroundRth != null) { this.TargetRenderer.Resolve(this.backgroundRth.Target, false); GraphicsDeviceExtensions.SetBlendingMode(this.GraphicsDevice, BlendingMode.Opaque); this.TargetRenderer.DrawFullscreen((Texture) this.backgroundRth.Target, Matrix.Identity); this.TargetRenderer.ReturnTarget(this.backgroundRth); GraphicsDeviceExtensions.SetBlendingMode(this.GraphicsDevice, BlendingMode.Alphablending); } this.backgroundRth = (RenderTargetHandle) null; if (this.needsReset) BaseEffect.EyeSign = Vector3.Zero; this.DoDraw(); } else { if (this.rightRT == null || this.leftRT == null) { this.rightRT = this.TargetRenderer.TakeTarget(); this.leftRT = this.TargetRenderer.TakeTarget(); } if (this.backgroundRth == null) { this.backgroundRth = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.backgroundRth.Target); } else { this.needsReset = true; this.DoStereo(this.LevelManager.Size / 2f, this.LevelManager.Size, new Action(this.DoFullDraw), (Texture) null); } } }
protected override void Dispose(bool disposing) { this.IsDisposed = true; while (!this.PlayerManager.CanControl) this.PlayerManager.CanControl = true; this.SoundManager.PlayNewSong(); this.SoundManager.PlayNewAmbience(); this.SoundManager.MusicVolumeFactor = 1f; this.TargetRenderingManager.ReturnTarget(this.zoomRtHandle); this.TargetRenderingManager.UnscheduleHook(this.zoomRtHandle.Target); this.zoomRtHandle = (RenderTargetHandle) null; base.Dispose(disposing); }
public override void Initialize() { base.Initialize(); this.MakeDot(); this.RtHandle = this.TargetRenderer.TakeTarget(); this.VignetteEffect = new VignetteEffect(); this.ScanlineEffect = new ScanlineEffect(); this.NoiseTexture = this.CMProvider.Get(CM.EndCutscene).Load<Texture2D>("Other Textures/noise"); this.sAppear = this.CMProvider.Get(CM.EndCutscene).Load<SoundEffect>("Sounds/Ending/Cutscene64/DotAppear"); this.sStartMove = this.CMProvider.Get(CM.EndCutscene).Load<SoundEffect>("Sounds/Ending/Cutscene64/DotStartMove"); this.sProgressiveAppear = this.CMProvider.Get(CM.EndCutscene).Load<SoundEffect>("Sounds/Ending/Cutscene64/DotsProgressiveAppear"); this.sNoise = this.CMProvider.Get(CM.EndCutscene).Load<SoundEffect>("Sounds/Ending/Cutscene64/WhiteNoise"); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.RtHandle != null) { this.TargetRenderer.ReturnTarget(this.RtHandle); this.RtHandle = (RenderTargetHandle) null; } this.Faded = (Action) null; this.ScreenCaptured = (Action) null; this.WaitUntil = (Func<bool>) null; this.capturedScreen = (Texture) null; this.IsDisposed = true; }
public void ReturnTarget(RenderTargetHandle handle) { if (handle == null) { return; } if (this.IsHooked(handle.Target)) { this.Resolve(handle.Target, false); } else { this.UnscheduleHook(handle.Target); } handle.Locked = false; }
public override void Initialize() { base.Initialize(); this.FreezeRth = this.TargetRenderingManager.TakeTarget(); this.GlitchMesh = new Mesh() { Effect = (BaseEffect) new GlitchyPostEffect(), AlwaysOnTop = true, DepthWrites = false, Blending = new BlendingMode?(BlendingMode.Opaque), Culling = CullMode.None, SamplerState = SamplerState.PointWrap, Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/glitches/glitch_atlas")) }; this.GlitchMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) (this.Geometry = new ShaderInstancedIndexedPrimitives<VertexPositionTextureInstance, Matrix>(PrimitiveType.TriangleList, 60)); this.Geometry.Vertices = new VertexPositionTextureInstance[4] { new VertexPositionTextureInstance(Vector3.Zero, Vector2.Zero), new VertexPositionTextureInstance(new Vector3(0.0f, 1f, 0.0f), new Vector2(0.0f, 1f)), new VertexPositionTextureInstance(new Vector3(1f, 1f, 0.0f), new Vector2(1f, 1f)), new VertexPositionTextureInstance(new Vector3(1f, 0.0f, 0.0f), new Vector2(1f, 0.0f)) }; this.Geometry.Indices = new int[6] { 0, 1, 2, 0, 2, 3 }; this.random = RandomHelper.Random; this.Geometry.Instances = new Matrix[1000]; for (int index = 0; index < 1000; ++index) { float num1 = (float) this.random.Next(1, 5); float num2 = (float) this.random.Next(1, 3); bool flag = 0.75 > this.random.NextDouble(); this.Geometry.Instances[index] = new Matrix((float) RandomHelper.Random.Next(-8, 54), (float) RandomHelper.Random.Next(-8, 30), flag ? num1 : num2, flag ? num2 : num1, this.random.Next(0, 3) == 0 ? 1f : 0.0f, this.random.Next(0, 3) == 0 ? 1f : 0.0f, this.random.Next(0, 3) == 0 ? 1f : 0.0f, (float) this.random.Next(0, 2), this.random.Next(0, 3) == 0 ? 1f : 0.0f, this.random.Next(0, 3) == 0 ? 1f : 0.0f, this.random.Next(0, 3) == 0 ? 1f : 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } this.Geometry.MaximizeBuffers(1000); this.sGlitches = Enumerable.ToArray<SoundEffect>(Enumerable.Select<string, SoundEffect>(this.CMProvider.GetAllIn("Sounds/Intro\\Elders\\Glitches"), (Func<string, SoundEffect>) (x => this.CMProvider.CurrentLevel.Load<SoundEffect>(x)))); this.sTimestretches = Enumerable.ToArray<SoundEffect>(Enumerable.Select<string, SoundEffect>(this.CMProvider.GetAllIn("Sounds/Intro\\Elders\\Timestretches"), (Func<string, SoundEffect>) (x => this.CMProvider.CurrentLevel.Load<SoundEffect>(x)))); }
public RenderTargetHandle TakeTarget() { RenderTargetHandle renderTargetHandle1 = (RenderTargetHandle)null; foreach (RenderTargetHandle renderTargetHandle2 in this.fullscreenRTs) { if (!renderTargetHandle2.Locked) { renderTargetHandle1 = renderTargetHandle2; break; } } if (renderTargetHandle1 == null) { this.fullscreenRTs.Add(renderTargetHandle1 = new RenderTargetHandle() { Target = this.CreateFullscreenTarget() }); } renderTargetHandle1.Locked = true; return(renderTargetHandle1); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); this.TargetRenderer.ReturnTarget(this.RtHandle); this.RtHandle = (RenderTargetHandle) null; this.CloneMesh.Dispose(); this.DotMesh.Dispose(); this.CloneMesh = this.DotMesh = (Mesh) null; this.VignetteEffect.Dispose(); this.VignetteEffect = (VignetteEffect) null; this.ScanlineEffect.Dispose(); this.ScanlineEffect = (ScanlineEffect) null; this.DotEffect = (InstancedDotEffect) null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); this.GameState.FarawaySettings.Reset(); if (this.StartVolume.ActorSettings.WaterLocked) LiquidHost.Instance.EndTransition(); this.TargetRenderer.ReturnTarget(this.SkyRt); this.TargetRenderer.ReturnTarget(this.LevelRt); this.SkyRt = this.LevelRt = (RenderTargetHandle) null; ServiceHelper.RemoveComponent<FarawayTransition.LevelFader>(this.Fader); }
public LevelFader(Game game, RenderTargetHandle SkyRt, RenderTargetHandle LevelRt) : base(game) { this.DrawOrder = 1000; this.SkyRt = SkyRt; this.LevelRt = LevelRt; }
public override void Initialize() { base.Initialize(); this.PlayerManager.Hidden = true; this.PlayerManager.CanControl = false; this.GameState.FarawaySettings.InTransition = true; this.StartVolume = this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value]; if (this.StartVolume.ActorSettings == null) this.StartVolume.ActorSettings = new VolumeActorSettings(); float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice); this.OriginalRadius = this.CameraManager.Radius; this.GameState.FarawaySettings.DestinationRadius = this.DestinationRadius = (double) this.StartVolume.ActorSettings.DestinationRadius == 0.0 ? this.CameraManager.Radius : this.StartVolume.ActorSettings.DestinationRadius * viewScale; this.GameState.FarawaySettings.DestinationPixelsPerTrixel = this.StartVolume.ActorSettings.DestinationPixelsPerTrixel; this.GameState.FarawaySettings.SkyRt = this.SkyRt.Target; this.NextLevel = this.PlayerManager.NextLevel; this.LevelRt = this.TargetRenderer.TakeTarget(); ServiceHelper.AddComponent((IGameComponent) (this.Fader = new FarawayTransition.LevelFader(this.Game, this.SkyRt, this.LevelRt))); this.TargetRenderer.ScheduleHook(this.Fader.DrawOrder, this.LevelRt.Target); if (this.StartVolume.ActorSettings.WaterLocked) LiquidHost.Instance.StartTransition(); if (this.LevelManager.Rainy && RainHost.Instance != null) RainHost.Instance.StartTransition(); if (this.StartVolume.ActorSettings.DestinationSong != this.LevelManager.SongName) this.SoundManager.PlayNewSong((string) null, 10f); foreach (SoundEmitter soundEmitter in this.SoundManager.Emitters) soundEmitter.FadeOutAndDie(1f, false); SoundEffectExtensions.Emit(this.CMProvider.Global.Load<SoundEffect>("Sounds/Intro/ZoomToFarawayPlace")).Persistent = true; this.DotManager.ForceDrawOrder(1001); this.DotManager.Burrow(); }
private void Destroy() { if (this.Glitches != null) ServiceHelper.RemoveComponent<NesGlitches>(this.Glitches); this.Glitches = (NesGlitches) null; if (this.RtHandle != null) { this.TargetRenderer.UnscheduleHook(this.RtHandle.Target); this.TargetRenderer.ReturnTarget(this.RtHandle); } this.RtHandle = (RenderTargetHandle) null; if (this.SolidCubes != null) this.SolidCubes.Dispose(); this.SolidCubes = (Mesh) null; if (this.WhiteCube != null) this.WhiteCube.Dispose(); this.WhiteCube = (Mesh) null; if (this.RaysMesh != null) this.RaysMesh.Dispose(); if (this.FlareMesh != null) this.FlareMesh.Dispose(); this.RaysMesh = this.FlareMesh = (Mesh) null; if (this.InvertEffect != null) this.InvertEffect.Dispose(); this.InvertEffect = (InvertEffect) null; this.HexahedronAo = (ArtObjectInstance) null; this.FirstUpdate = true; this.sAmbientDrone = this.sAku = this.sZoomIn = this.sHexAppear = this.sCubeAppear = this.sMotorSpin1 = this.sMotorSpin2 = this.sMotorSpinAOK = this.sMotorSpinCrash = this.sRayWhiteout = (SoundEffect) null; this.eAku = this.eAmbient = this.eMotor = (SoundEmitter) null; this.ActivePhase = FinalRebuildHost.Phases.ZoomInNega; this.PhaseTime = 0.0f; this.GameState.SkipRendering = false; this.GameState.HideHUD = false; }
protected override void LoadContent() { this.lightingPostEffect = new LightingPostEffect(); this.lightMapsRth = this.TargetRenderingManager.TakeTarget(); this.TargetRenderingManager.PreDraw += new Action<GameTime>(this.PreDraw); }
public void ForceDraw() { RenderTarget2D renderTarget = (RenderTarget2D) null; bool flag1 = false; if ((double) this.EngineState.FarawaySettings.OriginFadeOutStep == 1.0 && this.RtHandle == null) { this.RtHandle = this.TargetRenderer.TakeTarget(); renderTarget = this.GraphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D; this.GraphicsDevice.SetRenderTarget(this.RtHandle.Target); this.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Black, 1f, 0); flag1 = true; this.RadiusAtFirstDraw = this.CameraManager.Radius; } else if (this.RtHandle != null && !this.EngineState.FarawaySettings.InTransition) { this.TargetRenderer.ReturnTarget(this.RtHandle); this.RtHandle = (RenderTargetHandle) null; } this.EngineState.SkyRender = true; Vector3 viewOffset = this.CameraManager.ViewOffset; this.CameraManager.ViewOffset -= viewOffset; GraphicsDevice graphicsDevice = this.GraphicsDevice; GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.Sky)); GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, BlendingMode.Maximum); bool flag2 = this.LevelManager.Name == "INDUSTRIAL_CITY"; if ((double) this.EngineState.FarawaySettings.OriginFadeOutStep < 1.0 || flag1 || (double) this.EngineState.FarawaySettings.DestinationCrossfadeStep > 0.0) { bool flag3 = (double) this.EngineState.FarawaySettings.DestinationCrossfadeStep > 0.0; if (!flag2 || this.flickering) { foreach (Mesh mesh in this.cloudMeshes) { if (flag3) mesh.Material.Opacity = this.EngineState.FarawaySettings.DestinationCrossfadeStep; float num = mesh.Material.Opacity; if ((double) this.EngineState.SkyOpacity != 1.0) mesh.Material.Opacity = num * this.EngineState.SkyOpacity; mesh.Draw(); mesh.Material.Opacity = num; } } } if (this.RtHandle != null) { if (flag1) { this.GraphicsDevice.SetRenderTarget(renderTarget); this.GraphicsDevice.Clear(Color.Black); } float num1 = ((double) this.EngineState.FarawaySettings.InterpolatedFakeRadius == 0.0 ? this.RadiusAtFirstDraw : this.EngineState.FarawaySettings.InterpolatedFakeRadius) / this.RadiusAtFirstDraw; Matrix matrix1 = new Matrix(1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 0.0f, 0.0f, -0.5f, -0.5f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f); Matrix matrix2 = new Matrix(num1, 0.0f, 0.0f, 0.0f, 0.0f, num1, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f); Matrix matrix3 = new Matrix(1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 0.0f, 0.0f, 0.5f, 0.5f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f); float num2 = num1 * (1f - this.EngineState.FarawaySettings.DestinationCrossfadeStep); this.TargetRenderer.DrawFullscreen((Texture) this.RtHandle.Target, matrix1 * matrix2 * matrix3, new Color(num2, num2, num2)); } if (!flag2 || this.flickering) { GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, BlendingMode.Screen); this.DrawBackground(); } if (this.stars.TextureMap != null && (double) this.stars.Material.Opacity > 0.0) { GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, BlendingMode.StarsOverClouds); float num = this.stars.Material.Opacity; this.stars.Material.Opacity = num * this.EngineState.SkyOpacity; this.stars.Draw(); this.stars.Material.Opacity = num; } this.GraphicsDevice.SamplerStates[0] = this.LevelManager.Sky.VerticalTiling ? SamplerState.PointWrap : SamplerStates.PointUWrapVClamp; GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, BlendingMode.Alphablending); if (this.LevelManager.Rainy || this.LevelManager.Sky.Name == "WATERFRONT") { int count = this.BgLayers.Groups.Count; int num1 = count / 3; for (int index1 = 0; index1 < 3; ++index1) { for (int index2 = index1 * num1; index2 < count && index2 < (index1 + 1) * num1; ++index2) { Group group = this.BgLayers.Groups[index2]; bool? alwaysOnTop = this.BgLayers.Groups[index2].AlwaysOnTop; int num2 = (alwaysOnTop.HasValue ? (alwaysOnTop.GetValueOrDefault() ? 1 : 0) : 0) == 0 ? 1 : 0; group.Enabled = num2 != 0; } GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?((StencilMask) (5 + index1))); this.BgLayers.Draw(); for (int index2 = index1 * num1; index2 < count && index2 < (index1 + 1) * num1; ++index2) this.BgLayers.Groups[index2].Enabled = false; } } else { if (this.LevelManager.Name != null && (this.LevelManager.BlinkingAlpha || this.LevelManager.WaterType == LiquidType.Sewer && this.EngineState.StereoMode)) { GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.SkyLayer1)); GraphicsDeviceExtensions.SetColorWriteChannels(graphicsDevice, ColorWriteChannels.None); this.LevelMaterializer.StaticPlanesMesh.AlwaysOnTop = true; this.LevelMaterializer.StaticPlanesMesh.DepthWrites = false; foreach (BackgroundPlane backgroundPlane in this.LevelMaterializer.LevelPlanes) backgroundPlane.Group.Enabled = backgroundPlane.Id < 0; this.LevelMaterializer.StaticPlanesMesh.Draw(); this.LevelMaterializer.StaticPlanesMesh.AlwaysOnTop = false; this.LevelMaterializer.StaticPlanesMesh.DepthWrites = true; foreach (BackgroundPlane backgroundPlane in this.LevelMaterializer.LevelPlanes) backgroundPlane.Group.Enabled = true; GraphicsDeviceExtensions.SetColorWriteChannels(graphicsDevice, ColorWriteChannels.All); GraphicsDeviceExtensions.PrepareStencilRead(graphicsDevice, CompareFunction.Equal, StencilMask.SkyLayer1); GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, BlendingMode.Alphablending); this.GraphicsDevice.SamplerStates[0] = this.LevelManager.Sky.VerticalTiling ? SamplerState.PointWrap : SamplerStates.PointUWrapVClamp; } foreach (Group group1 in this.BgLayers.Groups) { Group group2 = group1; bool? alwaysOnTop = group1.AlwaysOnTop; int num = (alwaysOnTop.HasValue ? (alwaysOnTop.GetValueOrDefault() ? 1 : 0) : 0) == 0 ? 1 : 0; group2.Enabled = num != 0; } this.BgLayers.Draw(); GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.None)); } this.CameraManager.ViewOffset += viewOffset; this.EngineState.SkyRender = false; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.rth == null) return; this.TargetRenderer.ReturnTarget(this.rth); this.rth = (RenderTargetHandle) null; }
public override void Initialize() { base.Initialize(); lock (TileTransition.Mutex) { if (TileTransition.sTransition == null) TileTransition.sTransition = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/CubeTransition"); } TileTransition tileTransition = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.Textured textured1 = new DefaultEffect.Textured(); textured1.ForcedProjectionMatrix = new Matrix?(Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60f), 1f, 0.1f, 100f)); textured1.ForcedViewMatrix = new Matrix?(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, -1.365f), new Vector3(0.0f, 0.0f, 0.0f), Vector3.Up)); DefaultEffect.Textured textured2 = textured1; mesh2.Effect = (BaseEffect) textured2; mesh1.DepthWrites = false; mesh1.AlwaysOnTop = true; mesh1.Blending = new BlendingMode?(BlendingMode.Opaque); Mesh mesh3 = mesh1; tileTransition.mesh = mesh3; for (int index1 = 0; index1 < 1; ++index1) { for (int index2 = 0; index2 < 1; ++index2) { float x = (float) index1 / 1f; float num1 = (float) (index1 + 1) / 1f; float y = (float) index2 / 1f; float num2 = (float) (index2 + 1) / 1f; bool flag1 = RandomHelper.Probability(0.5); bool flag2 = RandomHelper.Probability(0.5); Group group1 = this.mesh.AddGroup(); if (flag2) group1.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionTexture>(new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1f - x, 1f - y)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1f - num1, 1f - y)) }, new int[6] { 0, 2, 1, 2, 3, 1 }, PrimitiveType.TriangleList); else group1.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionTexture>(new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1f - x, 1f - y)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1f - num1, 1f - y)) }, new int[6] { 0, 2, 1, 2, 3, 1 }, PrimitiveType.TriangleList); group1.Scale = new Vector3(1f, 1f, (float) (1.0 / (flag2 ? 1.0 : 1.0))); group1.Position = new Vector3(x, y, 0.0f); group1.CustomData = (object) new TileTransition.TileData() { X = (x + RandomHelper.Centered(0.150000005960464)), Y = (y + RandomHelper.Centered(0.150000005960464)), B = false, Inverted = flag1, Vertical = flag2 }; group1.Material = new Material(); Group group2 = this.mesh.AddGroup(); if (flag2) { Group group3 = group2; VertexPositionTexture[] vertices = new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, flag1 ? 0.5f : -0.5f, -0.5f), new Vector2(1f - x, flag1 ? 1f - y : 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, flag1 ? 0.5f : -0.5f, -0.5f), new Vector2(1f - num1, flag1 ? 1f - y : 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, flag1 ? 0.5f : -0.5f, 0.5f), new Vector2(1f - x, flag1 ? 1f - num2 : 1f - y)), new VertexPositionTexture(new Vector3(0.5f, flag1 ? 0.5f : -0.5f, 0.5f), new Vector2(1f - num1, flag1 ? 1f - num2 : 1f - y)) }; int[] indices; if (!flag1) indices = new int[6] { 0, 2, 1, 2, 3, 1 }; else indices = new int[6] { 0, 1, 2, 2, 1, 3 }; int num3 = 0; IndexedUserPrimitives<VertexPositionTexture> indexedUserPrimitives = new IndexedUserPrimitives<VertexPositionTexture>(vertices, indices, (PrimitiveType) num3); group3.Geometry = (IIndexedPrimitiveCollection) indexedUserPrimitives; } else { Group group3 = group2; VertexPositionTexture[] vertices = new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, 0.5f, 0.5f), new Vector2(flag1 ? 1f - num1 : 1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, 0.5f, -0.5f), new Vector2(flag1 ? 1f - x : 1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, -0.5f, 0.5f), new Vector2(flag1 ? 1f - num1 : 1f - x, 1f - y)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, -0.5f, -0.5f), new Vector2(flag1 ? 1f - x : 1f - num1, 1f - y)) }; int[] indices; if (!flag1) indices = new int[6] { 0, 2, 1, 2, 3, 1 }; else indices = new int[6] { 0, 1, 2, 2, 1, 3 }; int num3 = 0; IndexedUserPrimitives<VertexPositionTexture> indexedUserPrimitives = new IndexedUserPrimitives<VertexPositionTexture>(vertices, indices, (PrimitiveType) num3); group3.Geometry = (IIndexedPrimitiveCollection) indexedUserPrimitives; } group2.Scale = new Vector3(1f, 1f, (float) (1.0 / (flag2 ? 1.0 : 1.0))); group2.Position = new Vector3(x, y, 0.0f); group2.CustomData = (object) new TileTransition.TileData() { X = (x + RandomHelper.Centered(0.150000005960464)), Y = (y + RandomHelper.Centered(0.150000005960464)), B = true, Inverted = flag1, Vertical = flag2 }; group2.Material = new Material(); } } this.mesh.Position = new Vector3(0.0f, 0.0f, 0.0f); this.textureA = this.TargetRenderer.TakeTarget(); this.textureB = this.TargetRenderer.TakeTarget(); foreach (Group group in this.mesh.Groups) group.Texture = !((TileTransition.TileData) group.CustomData).B ? (Texture) this.textureA.Target : (Texture) this.textureB.Target; this.TargetRenderer.ScheduleHook(this.DrawOrder, this.textureA.Target); SoundEffectExtensions.Emit(TileTransition.sTransition); }
protected override void Dispose(bool disposing) { if (this.oldTextureCache != null) { this.AoInstance.ArtObject.Cubemap = this.oldTextureCache; new ArtObjectMaterializer(this.AoInstance.ArtObject).RecomputeTexCoords(true); } this.LevelManager.ArtObjects.Remove(this.AoInstance.Id); this.AoInstance.SoftDispose(); this.GameState.SkyOpacity = 1f; this.PlayerManager.CanControl = true; if (this.InRtHandle != null) { this.TargetRenderingManager.UnscheduleHook(this.InRtHandle.Target); this.TargetRenderingManager.ReturnTarget(this.InRtHandle); } this.InRtHandle = (RenderTargetHandle) null; if (this.OutRtHandle != null) { this.TargetRenderingManager.UnscheduleHook(this.OutRtHandle.Target); this.TargetRenderingManager.ReturnTarget(this.OutRtHandle); } this.OutRtHandle = (RenderTargetHandle) null; this.HidingPlanes.Dispose(); this.GoldenCubes.Dispose(); this.AntiCubes.Dispose(); this.TomePages.Dispose(); this.Maps.Dispose(); this.Highlights.Dispose(); this.BlurEffect.Dispose(); if (this.eBackground != null && !this.eBackground.Dead) { this.eBackground.FadeOutAndDie(0.25f, false); this.eBackground = (SoundEmitter) null; } this.GameService.CloseScroll((string) null); if (!this.wasLowPass) this.SoundManager.FadeFrequencies(false); MenuCube.Instance = (MenuCube) null; base.Dispose(disposing); }
public override void Initialize() { base.Initialize(); this.GameState.MenuCubeIsZoomed = false; this.PlayerManager.CanControl = false; ArtObject artObject = this.CMProvider.Global.Load<ArtObject>("Art Objects/MENU_CUBEAO"); bool flag = true; if (this.LevelManager.WaterType == LiquidType.Sewer) { this.oldTextureCache = artObject.Cubemap; artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_GB"); } else if (this.LevelManager.WaterType == LiquidType.Lava) { this.oldTextureCache = artObject.Cubemap; artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_VIRTUAL"); } else if (this.LevelManager.BlinkingAlpha) { this.oldTextureCache = artObject.Cubemap; artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_CMY"); } else flag = false; if (flag) new ArtObjectMaterializer(artObject).RecomputeTexCoords(false); int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects); this.AoInstance = new ArtObjectInstance(artObject) { Id = key, Position = this.PlayerManager.Center }; this.AoInstance.Initialize(); this.AoInstance.Material = new Material(); this.LevelManager.ArtObjects.Add(key, this.AoInstance); this.AoInstance.Scale = new Vector3(0.0f); this.OriginalViewpoint = this.CameraManager.Viewpoint; this.OriginalCenter = this.CameraManager.Center; this.OriginalPixPerTrix = this.CameraManager.PixelsPerTrixel; this.OriginalRotation = FezMath.QuaternionFromPhi(FezMath.ToPhi(this.CameraManager.Viewpoint)); RenderTarget2D renderTarget = this.GraphicsDevice.GetRenderTargets().Length == 0 ? (RenderTarget2D) null : this.GraphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D; this.FillInPlanes(); this.CreateGoldenCubeFace(); this.CreateMapsFace(); this.CreateArtifactsFace(); this.CreateAntiCubeFace(); this.CreateHighlights(); this.CreateTomePages(); this.GraphicsDevice.SetRenderTarget(renderTarget); this.AntiCubes.Position = this.Maps.Position = this.HidingPlanes.Position = this.GoldenCubes.Position = this.AoInstance.Position; this.AntiCubes.Scale = this.Maps.Scale = this.HidingPlanes.Scale = this.GoldenCubes.Scale = this.AoInstance.Scale = new Vector3(0.0f); this.TransformArtifacts(); this.BlurEffect = new FastBlurEffect(); this.enterSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/EnterMenucubeOrMap"); this.exitSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ExitMenucubeOrMap"); this.zoomInSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ZoomIn"); this.zoomOutSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ZoomOut"); this.rotateLeftSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/RotateLeft"); this.rotateRightSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/RotateRight"); this.cursorSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/MoveCursorMenucube"); this.sBackground = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/MenuCubeBackground"); this.eBackground = SoundEffectExtensions.Emit(this.sBackground, true); SoundEffectExtensions.Emit(this.enterSound); this.AoVisibility = new List<bool>(); this.AoInstance.Hidden = true; this.AoInstance.Visible = false; this.GameService.CloseScroll((string) null); this.GameState.ShowScroll(MenuCubeFaceExtensions.GetTitle(this.Face), 0.0f, true); this.wasLowPass = this.SoundManager.IsLowPass; if (!this.wasLowPass) this.SoundManager.FadeFrequencies(true); this.InRtHandle = this.TargetRenderingManager.TakeTarget(); this.OutRtHandle = this.TargetRenderingManager.TakeTarget(); this.TargetRenderingManager.ScheduleHook(this.DrawOrder, this.InRtHandle.Target); }
private void TryInitialize() { this.Destroy(); this.Visible = this.Enabled = this.LevelManager.Name == "HEX_REBUILD"; if (!this.Enabled) return; this.GameState.HideHUD = true; this.CameraManager.ChangeViewpoint(Viewpoint.Right, 0.0f); this.PlayerManager.Background = false; ArtObject artObject = this.CMProvider.CurrentLevel.Load<ArtObject>("Art Objects/NEW_HEXAO"); int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects); this.HexahedronAo = new ArtObjectInstance(artObject) { Id = key }; this.LevelManager.ArtObjects.Add(key, this.HexahedronAo); this.HexahedronAo.Initialize(); this.HexahedronAo.Hidden = true; this.WhiteCube = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.WhiteCube.Rotation = this.CameraManager.Rotation * Quaternion.CreateFromRotationMatrix(Matrix.CreateLookAt(Vector3.One, Vector3.Zero, Vector3.Up)); this.WhiteCube.AddColoredBox(new Vector3(4f), Vector3.Zero, Color.White, true); FinalRebuildHost finalRebuildHost = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured(); litTextured1.Specular = true; litTextured1.Emissive = 0.5f; litTextured1.AlphaIsEmissive = true; DefaultEffect.LitTextured litTextured2 = litTextured1; mesh2.Effect = (BaseEffect) litTextured2; mesh1.Blending = new BlendingMode?(BlendingMode.Opaque); Mesh mesh3 = mesh1; finalRebuildHost.SolidCubes = mesh3; this.OriginalCubeRotation = this.SolidCubes.Rotation = this.WhiteCube.Rotation; ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Vector4> geometry1 = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.CubeShard)).Geometry; ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Vector4> geometry2 = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)).Geometry; this.sHexAppear = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/HexAppear"); this.sCubeAppear = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/CubeAppear"); this.sMotorSpin1 = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/MotorStart1"); this.sMotorSpin2 = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/MotorStart2"); this.sMotorSpinAOK = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/MotorStartAOK"); this.sMotorSpinCrash = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/MotorStartCrash"); this.sRayWhiteout = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/RayWhiteout"); this.sAku = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/Aku"); this.sZoomIn = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/ZoomIn"); this.sAmbientDrone = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/HexRebuild/AmbientDrone"); for (int index = 0; index < Math.Min(this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes, 64); ++index) { Vector3 vector3 = this.CubeOffsets[index]; ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Vector4> indexedPrimitives = index < this.GameState.SaveData.CubeShards ? geometry1 : geometry2; Group group = this.SolidCubes.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalTextureInstance>(Enumerable.ToArray<VertexPositionNormalTextureInstance>((IEnumerable<VertexPositionNormalTextureInstance>) indexedPrimitives.Vertices), indexedPrimitives.Indices, indexedPrimitives.PrimitiveType); group.Position = vector3; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) RandomHelper.Random.Next(0, 4) * 1.570796f); group.Enabled = false; group.Material = new Material(); } this.SolidCubes.Texture = this.LevelMaterializer.TrilesMesh.Texture; this.InvertEffect = new InvertEffect(); this.RaysMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.FlareMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/flare_alpha")), Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; this.FlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true); this.RtHandle = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.RtHandle.Target); ServiceHelper.AddComponent((IGameComponent) (this.Glitches = new NesGlitches(this.Game))); }
public override void Update(GameTime gameTime) { while (Scheduled.Count > 0) { Scheduled[0](); Scheduled.RemoveAt(0); } if ((--SkipLoading) == 0) { GameState.Loading = false; return; } if (GameState.Loading || GameState.InMap || GameState.InMenuCube || GameState.Paused || string.IsNullOrEmpty(LevelManager.Name)) { return; } if (ThumbnailScheduled) { if (ThumbnailRT == null) { ThumbnailRT = TRM.TakeTarget(); TRM.ScheduleHook(DrawOrder, ThumbnailRT.Target); } return; } SinceMouseMoved += (float) gameTime.ElapsedGameTime.TotalSeconds; if (MouseState.Movement.X != 0 || MouseState.Movement.Y != 0) { SinceMouseMoved = 0f; } TooltipWidget.Label = null; TooltipWidget.Position.X = MouseState.Position.X + 24f; TooltipWidget.Position.Y = MouseState.Position.Y; CursorHovering = false; Vector3 right = CameraManager.InverseView.Right; Vector3 up = CameraManager.InverseView.Up; Vector3 forward = CameraManager.InverseView.Forward; Ray ray = new Ray(GraphicsDevice.Viewport.Unproject(new Vector3(MouseState.Position.X, MouseState.Position.Y, 0.0f), CameraManager.Projection, CameraManager.View, Matrix.Identity), forward); float intersectionMin = float.MaxValue; HoveredTrile = null; //Ugly thread-safety workaround int trilesCount = LevelManager.Triles.Count; LevelManager.Triles.CopyTo(tmpTriles.Length < trilesCount ? (tmpTriles = new KeyValuePair<TrileEmplacement, TrileInstance>[trilesCount]) : tmpTriles, 0); for (int i = 0; i < trilesCount; i++) { TrileInstance trile = tmpTriles[i].Value; BoundingBox box = new BoundingBox(trile.Position, trile.Position + new Vector3(1f)); float? intersection = ray.Intersects(box); if (intersection.HasValue && intersection < intersectionMin) { HoveredTrile = trile; HoveredBox = box; intersectionMin = intersection.Value; } } HoveredAO = null; if (LevelEditorOptions.Instance.TooltipArtObjectInfo) { int aosCount = LevelManager.ArtObjects.Count; LevelManager.ArtObjects.CopyTo(tmpAOs.Length < aosCount ? (tmpAOs = new KeyValuePair<int, ArtObjectInstance>[aosCount]) : tmpAOs, 0); for (int i = 0; i < aosCount; i++) { ArtObjectInstance ao = tmpAOs[i].Value; float? intersection = ray.Intersects(ao.Bounds); if (intersection.HasValue && intersection < intersectionMin) { HoveredTrile = null; HoveredAO = ao; HoveredBox = ao.Bounds; intersectionMin = intersection.Value; } } } if (HoveredAO != null) { TooltipWidget.Label = HoveredAO.Id + ": " + HoveredAO.ArtObjectName; } TrilePickerWidget.Position.Y = GraphicsDevice.Viewport.Height - TrilePickerWidget.Size.Y; InfoWidget.Position.Y = TrilePickerWidget.Position.Y - InfoWidget.Size.Y; bool cursorInMenu = UpdateWidgets(gameTime, Widgets, true); if (DraggingWidget != null && (MouseState.LeftButton.State == MouseButtonStates.Dragging || MouseState.LeftButton.State == MouseButtonStates.DragEnded)) { DraggingWidget.Dragging(gameTime, MouseState.LeftButton.State); cursorInMenu = true; if (MouseState.LeftButton.State == MouseButtonStates.DragEnded) { DraggingWidget = null; } } if (cursorInMenu) { CursorHovering = true; return; } if (HoveredTrile != null) { HoveredFace = GetHoveredFace(HoveredBox, ray); CursorHovering = true; } if (MouseState.LeftButton.State == MouseButtonStates.Clicked) { bool unfocusWidget = true; if (HoveredTrile != null) { TrileEmplacement emplacement = new TrileEmplacement(HoveredTrile.Position - HoveredFace.AsVector()); if (FocusedWidget is TextFieldWidget) { ((TextFieldWidget) FocusedWidget).Text = emplacement.X + "; " + emplacement.Y + "; " + emplacement.Z; unfocusWidget = false; } else if (LevelManager.TrileSet != null && LevelManager.TrileSet.Triles.ContainsKey(TrileId)) { AddTrile(CreateNewTrile(TrileId, emplacement)); } } if (unfocusWidget) { if (FocusedWidget != null) { FocusedWidget.Unfocus(gameTime); } FocusedWidget = null; } } if (MouseState.RightButton.State == MouseButtonStates.Clicked && HoveredTrile != null) { LevelManager.ClearTrile(HoveredTrile); LevelMaterializer.CullInstances(); HoveredTrile = null; } if (MouseState.MiddleButton.State == MouseButtonStates.Clicked && HoveredTrile != null) { TrileId = HoveredTrile.TrileId; } CameraManager.PixelsPerTrixel = Math.Max(0.25f, CameraManager.PixelsPerTrixel + 0.25f * MouseState.WheelTurns); if (string.IsNullOrEmpty(TooltipWidget.Label)) { if (TooltipWidgetAdded) { Widgets.Remove(TooltipWidget); TooltipWidgetAdded = false; } } else { if (!TooltipWidgetAdded) { Widgets.Add(TooltipWidget); TooltipWidgetAdded = true; } } }
public override void Draw(GameTime gameTime) { if (GameState.Loading || GameState.InMap || GameState.InMenuCube || GameState.Paused || !FEZMod.Preloaded || string.IsNullOrEmpty(LevelManager.Name)) { return; } if (ThumbnailScheduled) { if (ThumbnailRT == null) { return; } TRM.Resolve(ThumbnailRT.Target, false); using (System.Drawing.Bitmap bitmap = ThumbnailRT.Target.ToBitmap()) { //float x = ThumbnailRT.Target.Width / 2 - ThumbnailSize / 2f; //float y = ThumbnailRT.Target.Height / 2 - ThumbnailSize / 2f; using (System.Drawing.Bitmap thumbnail = bitmap.Clone(new System.Drawing.Rectangle(ThumbnailX, ThumbnailY, ThumbnailSize, ThumbnailSize), bitmap.PixelFormat)) { using (FileStream fs = new FileStream(("other textures/map_screens/" + LevelManager.Name).Externalize() + ".png", FileMode.Create)) { thumbnail.Save(fs, ImageFormat.Png); } } } TRM.ReturnTarget(ThumbnailRT); ThumbnailRT = null; ThumbnailScheduled = false; FEZMod.CreatingThumbnail = false; //maybe show a flash or something; in the meantime simply don't render the editor return; } Viewport viewport = GraphicsDevice.Viewport; float viewScale = SettingsManager.GetViewScale(GraphicsDevice); float cursorScale = viewScale * 2f; Point cursorPosition = SettingsManager.PositionInViewport(MouseState); Texture2D cursor = MouseState.LeftButton.State == MouseButtonStates.Dragging || MouseState.RightButton.State == MouseButtonStates.Dragging ? GrabbedCursor : (CursorHovering ? (MouseState.LeftButton.State == MouseButtonStates.Down || MouseState.RightButton.State == MouseButtonStates.Down ? ClickedCursor : CanClickCursor) : PointerCursor); if (cursor == CanClickCursor || cursor == ClickedCursor) { cursorPosition.X -= 8; } GraphicsDevice.SetBlendingMode(BlendingMode.Alphablending); SpriteBatch.BeginPoint(); foreach (GuiWidget widget in Widgets) { widget.GuiHandler = this; widget.Draw(gameTime); } SpriteBatch.Draw(cursor, new Vector2( (float) cursorPosition.X - cursorScale * 11.5f, (float) cursorPosition.Y - cursorScale * 8.5f ), new Rectangle?(), new Color(1f, 1f, 1f, FezMath.Saturate((float) (1.0 - ((double) SinceMouseMoved - 2.0)))), 0.0f, Vector2.Zero, cursorScale, SpriteEffects.None, 0.0f); SpriteBatch.End(); }
public RenderTargetHandle TakeTarget() { RenderTargetHandle renderTargetHandle1 = (RenderTargetHandle) null; foreach (RenderTargetHandle renderTargetHandle2 in this.fullscreenRTs) { if (!renderTargetHandle2.Locked) { renderTargetHandle1 = renderTargetHandle2; break; } } if (renderTargetHandle1 == null) this.fullscreenRTs.Add(renderTargetHandle1 = new RenderTargetHandle() { Target = this.CreateFullscreenTarget() }); renderTargetHandle1.Locked = true; return renderTargetHandle1; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); this.TargetRenderingManager.ReturnTarget(this.lightMapsRth); this.lightMapsRth = (RenderTargetHandle) null; }
public void ReturnTarget(RenderTargetHandle handle) { if (handle == null) return; if (this.IsHooked(handle.Target)) this.Resolve(handle.Target, false); else this.UnscheduleHook(handle.Target); handle.Locked = false; }
public override void Update(GameTime gameTime) { if (this.GameState.StereoMode != (this.DrawOrder == 1002)) { this.DrawOrder = this.GameState.StereoMode ? 1002 : 1001; this.OnDrawOrderChanged((object) this, EventArgs.Empty); } if (this.Visible) { if (this.GameState.StereoMode && this.rth == null) { this.rth = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.rth.Target); } else if (this.rth != null && !this.GameState.StereoMode) { this.TargetRenderer.ReturnTarget(this.rth); this.rth = (RenderTargetHandle) null; } } if (this.Visible || this.rth == null) return; this.TargetRenderer.ReturnTarget(this.rth); this.rth = (RenderTargetHandle) null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.textureA != null) { this.TargetRenderer.ReturnTarget(this.textureA); this.TargetRenderer.UnscheduleHook(this.textureA.Target); } if (this.textureB != null) { this.TargetRenderer.ReturnTarget(this.textureB); this.TargetRenderer.UnscheduleHook(this.textureB.Target); } this.textureA = this.textureB = (RenderTargetHandle) null; this.mesh.Dispose(); this.IsDisposed = true; TileTransition.CurrentTransition = (TileTransition) null; }