public void Dispose() { TextureExtensions.Unhook((Texture)this.TextureAtlas); this.TextureAtlas.Dispose(); foreach (Trile trile in this.Triles.Values) { trile.Dispose(); } }
protected override void UnloadContent() { if (this.text == null) { return; } TextureExtensions.Unhook((Texture)this.text); this.text.Dispose(); }
public void Dispose() { if (this.Texture != null) { TextureExtensions.Unhook((Texture)this.Texture); this.Texture.Dispose(); } this.Texture = (Texture2D)null; this.Timing = (AnimationTiming)null; }
private void OnTextChanged(bool update) { float num1 = 2f; string str = this.textString; this.textString = this.originalString; SpriteFont spriteFont = this.Font == SpeechFont.Pixel ? this.FontManager.Big : this.zuishFont; if (this.Font == SpeechFont.Zuish) { this.textString = this.textString.Replace(" ", " "); } float scale = !Culture.IsCJK || this.Font != SpeechFont.Pixel ? 1f : this.FontManager.SmallFactor; bool flag1 = this.GraphicsDevice.DisplayMode.Width < 1280 && this.Font == SpeechFont.Pixel; float num2 = 0.0f; if (this.Font != SpeechFont.Zuish) { float num3 = update ? 0.9f : 0.85f; num2 = FezMath.Dot(this.Origin - this.CameraManager.InterpolatedCenter, FezMath.RightVector(this.CameraManager.Viewpoint)); float val1 = flag1 ? Math.Max((float)(-(double)num2 * 16.0 * (double)this.CameraManager.PixelsPerTrixel + 640.0 * (double)num3), 50f) * 0.6666667f : Math.Max((float)(-(double)num2 * 16.0 * (double)this.CameraManager.PixelsPerTrixel + 640.0 * (double)num3), 50f) / (this.CameraManager.PixelsPerTrixel / 2f); if (this.GameState.InMap) { val1 = 500f; } float num4 = Math.Max(val1, 70f); List <GlyphTextRenderer.FilledInGlyph> glyphLocations; string text = this.GTR.FillInGlyphs(this.textString, out glyphLocations); if (Culture.IsCJK) { scale /= 2f; } StringBuilder stringBuilder = new StringBuilder(WordWrap.Split(text, spriteFont, num4 / scale)); if (Culture.IsCJK) { scale *= 2f; } bool flag2 = true; int index1 = 0; for (int index2 = 0; index2 < stringBuilder.Length; ++index2) { if (flag2 && (int)stringBuilder[index2] == 94) { for (int startIndex = index2; startIndex < index2 + glyphLocations[index1].Length; ++startIndex) { if ((int)stringBuilder[startIndex] == 13 || (int)stringBuilder[startIndex] == 10) { stringBuilder.Remove(startIndex, 1); --startIndex; } } stringBuilder.Remove(index2, glyphLocations[index1].Length); stringBuilder.Insert(index2, glyphLocations[index1].OriginalGlyph); ++index1; } else { flag2 = (int)stringBuilder[index2] == 32 || (int)stringBuilder[index2] == 13 || (int)stringBuilder[index2] == 10; } } this.textString = ((object)stringBuilder).ToString(); if (!update) { this.distanceFromCenterAtTextChange = num2; } } if (update && (str == this.textString || (double)Math.Abs(this.distanceFromCenterAtTextChange - num2) < 1.5)) { this.textString = str; } else { if (Culture.IsCJK && this.Font == SpeechFont.Pixel) { if ((double)SettingsManager.GetViewScale(this.GraphicsDevice) < 1.5) { spriteFont = this.FontManager.Small; } else { spriteFont = this.FontManager.Big; scale /= 2f; } scale *= num1; } bool multilineGlyphs; Vector2 vector2_1 = this.GTR.MeasureWithGlyphs(spriteFont, this.textString, scale, out multilineGlyphs); if (!Culture.IsCJK && multilineGlyphs) { spriteFont.LineSpacing += 8; bool flag2 = multilineGlyphs; vector2_1 = this.GTR.MeasureWithGlyphs(spriteFont, this.textString, scale, out multilineGlyphs); multilineGlyphs = flag2; } float num3 = 1f; if (Culture.IsCJK && this.Font == SpeechFont.Pixel) { num3 = num1; } this.scalableMiddleSize = vector2_1 + Vector2.One * 4f * 2f * num3 + Vector2.UnitX * 4f * 2f * num3; if (this.Font == SpeechFont.Zuish) { this.scalableMiddleSize += Vector2.UnitY * 2f; } int width = (int)this.scalableMiddleSize.X; int height = (int)this.scalableMiddleSize.Y; if (Culture.IsCJK && this.Font == SpeechFont.Pixel) { scale *= 2f; width *= 2; height *= 2; } Vector2 vector2_2 = this.scalableMiddleSize; if (this.text != null) { TextureExtensions.Unhook((Texture)this.text); this.text.Dispose(); } this.text = new RenderTarget2D(this.GraphicsDevice, width, height, false, this.GraphicsDevice.PresentationParameters.BackBufferFormat, this.GraphicsDevice.PresentationParameters.DepthStencilFormat, this.GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents); this.GraphicsDevice.SetRenderTarget(this.text); GraphicsDeviceExtensions.PrepareDraw(this.GraphicsDevice); this.GraphicsDevice.Clear(ClearOptions.Target, ColorEx.TransparentWhite, 1f, 0); Vector2 vector2_3 = Culture.IsCJK ? new Vector2(4f * num1) : Vector2.Zero; if (Culture.IsCJK) { GraphicsDeviceExtensions.BeginLinear(this.spriteBatch); } else { GraphicsDeviceExtensions.BeginPoint(this.spriteBatch); } if (this.Font == SpeechFont.Pixel) { this.GTR.DrawString(this.spriteBatch, spriteFont, this.textString, FezMath.Round(vector2_2 / 2f - vector2_1 / 2f + vector2_3), this.TextColor, scale); } else { this.spriteBatch.DrawString(spriteFont, this.textString, vector2_2 / 2f - vector2_1 / 2f, this.TextColor, 0.0f, Vector2.Zero, this.scalableMiddleSize / vector2_2, SpriteEffects.None, 0.0f); } this.spriteBatch.End(); this.GraphicsDevice.SetRenderTarget((RenderTarget2D)null); if (this.Font == SpeechFont.Zuish) { float num4 = this.scalableMiddleSize.X; this.scalableMiddleSize.X = this.scalableMiddleSize.Y; this.scalableMiddleSize.Y = num4; } if (Culture.IsCJK && this.Font == SpeechFont.Pixel) { this.scalableMiddleSize /= num1; } this.scalableMiddleSize /= 16f; this.scalableMiddleSize -= Vector2.One; this.textMesh.SamplerState = !Culture.IsCJK || this.Font != SpeechFont.Pixel ? SamplerState.PointClamp : SamplerState.AnisotropicClamp; this.textGroup.Texture = (Texture)this.text; this.oldCamPos = this.CameraManager.InterpolatedCenter; this.lastUsedOrigin = this.Origin; if (Culture.IsCJK || !multilineGlyphs) { return; } spriteFont.LineSpacing -= 8; } }