Commit ab7b6822 authored by mercury233's avatar mercury233

update picture loading

parent a0c8e33c
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.RegularExpressions;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
...@@ -424,38 +425,35 @@ public class GameField : OCGobject ...@@ -424,38 +425,35 @@ public class GameField : OCGobject
fieldCode[player] = code; fieldCode[player] = code;
if (code > 0) if (code > 0)
{ {
Texture2D tex; Texture2D tex = null;
if (File.Exists("picture/field/" + code.ToString() + ".png")) bool found = false;
foreach (ZipFile zip in GameZipManager.Zips)
{ {
tex = UIHelper.getTexture2D("picture/field/" + code.ToString() + ".png"); if (zip.Name.ToLower().EndsWith("script.zip"))
} continue;
else if (File.Exists("picture/field/" + code.ToString() + ".jpg")) foreach (string file in zip.EntryFileNames)
{
tex = UIHelper.getTexture2D("picture/field/" + code.ToString() + ".jpg");
}
else
{
tex = null;
bool found = false;
foreach (ZipFile zip in GameZipManager.Zips)
{ {
foreach (string file in zip.EntryFileNames) if (Regex.IsMatch(file.ToLower(), "field/" + code.ToString() + "\\.(jpg|png)$"))
{ {
string file1 = file.ToLower(); MemoryStream ms = new MemoryStream();
if (file1.EndsWith(code.ToString() + ".jpg") && file1.Contains("field")) ZipEntry e = zip[file];
{ e.Extract(ms);
MemoryStream ms = new MemoryStream(); tex = new Texture2D(1024, 600);
ZipEntry e = zip[file]; tex.LoadImage(ms.ToArray());
e.Extract(ms); found = true;
tex = new Texture2D(1024, 600);
tex.LoadImage(ms.ToArray());
found = true;
break;
}
}
if (found)
break; break;
}
} }
if (found)
break;
}
if (tex == null)
{
tex = UIHelper.getTexture2D("picture/field/" + code.ToString() + ".png");
}
if (tex == null)
{
tex = UIHelper.getTexture2D("picture/field/" + code.ToString() + ".jpg");
} }
if (tex != null) if (tex != null)
{ {
......
...@@ -287,7 +287,7 @@ public class Program : MonoBehaviour ...@@ -287,7 +287,7 @@ public class Program : MonoBehaviour
}); });
go(300, () => go(300, () =>
{ {
InterString.initialize("config/translation.conf"); InterString.initialize("config/translation.conf");
GameTextureManager.initialize(); GameTextureManager.initialize();
Config.initialize("config/config.conf"); Config.initialize("config/config.conf");
...@@ -324,6 +324,8 @@ public class Program : MonoBehaviour ...@@ -324,6 +324,8 @@ public class Program : MonoBehaviour
foreach (ZipFile zip in GameZipManager.Zips) foreach (ZipFile zip in GameZipManager.Zips)
{ {
if (zip.Name.ToLower().EndsWith("script.zip"))
continue;
foreach (string file in zip.EntryFileNames) foreach (string file in zip.EntryFileNames)
{ {
if (file.ToLower().EndsWith(".conf")) if (file.ToLower().EndsWith(".conf"))
......
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