Commit 9071f00b authored by mercury233's avatar mercury233

Merge branch 'patch-zip-texture' into 'master'

Patch zip texture

See merge request mycard/YGOProUnity_V2!2
parents 74e1072e 2c590715
Pipeline #13897 passed with stages
in 130 minutes and 21 seconds
using System;
using Ionic.Zip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
......@@ -752,6 +753,17 @@ public static class UIHelper
return pic;
}
public static async Task<Texture2D> GetTexture2DFromZipAsync(ZipFile zip, string file)
{
var pic = new Texture2D(0, 0);
MemoryStream stream = new MemoryStream();
ZipEntry entry = zip[file];
entry.Extract(stream);
//await Task.Run(() => { entry.Extract(stream); });
pic.LoadImage(stream.ToArray());
return pic;
}
internal static void shiftButton(UIButton btn, bool enabled)
{
if (enabled)
......
using System.Collections.Generic;
using Ionic.Zip;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;
......@@ -88,6 +89,26 @@ public class GameTextureManager
{
if (code == 0) return zero;
if (loadedPicture.TryGetValue(code, out var cached)) return await cached;
foreach (ZipFile zip in GameZipManager.Zips)
{
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
foreach (string file in zip.EntryFileNames)
{
foreach (var extname in new[] { ".png", ".jpg" })
{
var path = $"pics/{code}{extname}";
if (file.ToLower() == path)
{
var result = UIHelper.GetTexture2DFromZipAsync(zip, file);
loadedPicture.Add(code, result);
return await result;
}
}
}
}
foreach (var extname in new[] {".png", ".jpg"})
{
var path = $"picture/card/{code}{extname}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment