Commit ab7b6822 authored by mercury233's avatar mercury233

update picture loading

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