Commit 0f8cbd50 authored by nanahira's avatar nanahira

Add MyCard Face

parent acf17130
......@@ -103,4 +103,36 @@ public class MyCardHelper {
fail_reason = null;
return ret;
}
public static void DownloadFace(string name) {
try {
WWW www = new WWW("https://api.moecube.com/accounts/users/"+WWW.EscapeURL(name, Encoding.UTF8)+".avatar");
while (!www.isDone) {
if (Application.internetReachability == NetworkReachability.NotReachable || !string.IsNullOrEmpty(www.error))
{
return;
}
}
string result = www.text;
if(result == "{\"message\":\"Not Found\"}")
return;
DownloadFaceFromUrl(name, result);
} catch (Exception e) {
return;
}
}
private static void DownloadFaceFromUrl(string nameFace, string url)
{
string face = "textures/face/" + nameFace + ".png";
HttpDldFile df = new HttpDldFile();
df.Download(url, face);
if (File.Exists(face))
{
Texture2D Face = UIHelper.getTexture2D(face);
UIHelper.faces.Remove(nameFace);
UIHelper.faces.Add(nameFace, Face);
}
}
}
......@@ -5,6 +5,7 @@ using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using YGOSharp.Network.Enums;
using System.Threading;
public class Room : WindowServantSP
{
......@@ -163,6 +164,17 @@ public class Room : WindowServantSP
RoomPlayer player = new RoomPlayer();
player.name = name;
player.prep = false;
if (Program.I().mycard.isMatching && name != "********") //athletic match name mask
{
(new Thread(() =>
{
MyCardHelper.DownloadFace(name);
if(isShowed)
realize();
else if(Program.I().ocgcore.isShowed && Program.I().ocgcore.gameInfo)
Program.I().ocgcore.gameInfo.realize();
})).Start();
}
roomPlayers[pos] = player;
realize();
UIHelper.Flash();
......
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