Advertisement
Ameisen

Untitled

Jan 1st, 2022
965
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [Harmonize(typeof(Microsoft.Xna.Framework.Graphics.RenderTarget2D), ".ctor", HarmonizeAttribute.Fixation.Prefix, PriorityLevel.Last)]
  2. internal static bool OnRenderTarget2DConstruct(
  3.     GraphicsDevice graphicsDevice,
  4.     int width,
  5.     int height,
  6.     bool mipMap,
  7.     ref SurfaceFormat preferredFormat,
  8.     ref DepthFormat preferredDepthFormat,
  9.     ref int preferredMultiSampleCount,
  10.     RenderTargetUsage usage,
  11.     bool shared,
  12.     int arraySize,
  13.     out bool __state
  14. ) {
  15.     var stackTrace = new StackTrace(skipFrames: 2, fNeedFileInfo: false);
  16.  
  17.     foreach (var frame in stackTrace.GetFrames()) {
  18.         var method = frame.GetMethod();
  19.         if (method?.DeclaringType != typeof(StardewValley.Game1)) {
  20.             continue;
  21.         }
  22.  
  23.         switch (method?.Name) {
  24.             case "SetWindowSize": {
  25.                 __state = true;
  26.                 GraphicsDevice device = null;
  27.                 if (!LastGraphicsDevice?.TryGetTarget(out device) ?? false || device is null) {
  28.                     return true;
  29.                 }
  30.  
  31.                 preferredMultiSampleCount = Config.DrawState.EnableMSAA ? 16 : 0;
  32.                 preferredDepthFormat = device.PresentationParameters.DepthStencilFormat;
  33.                 preferredFormat = device.PresentationParameters.BackBufferFormat;
  34.             } return true;
  35.  
  36.             case "Initialize":
  37.             case "allocateLightmap":
  38.             case "takeMapScreenshot": {
  39.                 __state = true;
  40.             } return true;
  41.         }
  42.     }
  43.  
  44.     __state = false;
  45.     return true;
  46. }
  47.  
  48. [Harmonize(typeof(Microsoft.Xna.Framework.Graphics.RenderTarget2D), ".ctor", HarmonizeAttribute.Fixation.Postfix, PriorityLevel.Last)]
  49. internal static void OnRenderTarget2DConstructPost(
  50.     RenderTarget2D __instance,
  51.     GraphicsDevice graphicsDevice,
  52.     int width,
  53.     int height,
  54.     bool mipMap,
  55.     SurfaceFormat preferredFormat,
  56.     DepthFormat preferredDepthFormat,
  57.     int preferredMultiSampleCount,
  58.     RenderTargetUsage usage,
  59.     bool shared,
  60.     int arraySize,
  61.     bool __state
  62. ) {
  63.     if (__state) {
  64.         __instance.Meta().IsSystemRenderTarget = true;
  65.     }
  66. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement