Ejemplo n.º 1
0
        public void Edit <T>(IAssetData asset)
        {
            IAssetDataForImage image = asset.AsImage();
            string             name  = Normalize(asset.AssetName) + ".4x";

            if (!ScaledAssets.ContainsKey(name))
            {
                ScaledAssets[name] = new Texture2DWrapper(image.Data, 4, name);
            }
            Texture2DWrapper wrapper = ScaledAssets[name];

            if (wrapper.Locale != asset.Locale)
            {
                Monitor.Log($"Upscaling {asset.AssetName} (Locale: {asset.Locale})");
                wrapper.Wrapped = Texture2DWrapper.ScaleUp(image.Data, wrapper.Scale);
                wrapper.Locale  = asset.Locale;
            }
            image.ReplaceWith(wrapper);
            Helper.Content.Load <Texture2D>(wrapper.Path, ContentSource.GameContent);
        }
 public static bool PatchImage(IAssetDataForImage __instance, Texture2D source, Rectangle?sourceArea, Rectangle?targetArea, PatchMode patchMode)
 {
     if (__instance.Data is Texture2DWrapper wrapper)
     {
         if (sourceArea.HasValue)
         {
             source = Texture2DWrapper.Crop(source, sourceArea.Value);
         }
         source = Texture2DWrapper.ScaleUp(source, wrapper.Scale);
         if (targetArea.HasValue)
         {
             targetArea = Texture2DWrapper.MultiplyRect(targetArea.Value, wrapper.Scale);
         }
         PropertyInfo Data = __instance.GetType().GetProperty("Data");
         Data.SetValue(__instance, wrapper.Wrapped);
         __instance.PatchImage(source, null, targetArea, patchMode);
         Data.SetValue(__instance, wrapper);
         return(false);
     }
     return(true);
 }