Commit 4aee470a authored by hex's avatar hex

download qq avatar with https

parent 4694efba
Pipeline #37630 failed
using UnityEngine;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using YGOSharp.Network.Enums;
using System.Threading;
using UnityEngine;
using YGOSharp.Network.Enums;
public class Room : WindowServantSP
{
......@@ -23,20 +23,26 @@ public class Room : WindowServantSP
void onSelected()
{
Config.Set("deckInUse", superScrollView.selectedString);
if (selftype < realPlayers.Length && realPlayers[selftype] != null && realPlayers[selftype].getIfPreped())
if (
selftype < realPlayers.Length
&& realPlayers[selftype] != null
&& realPlayers[selftype].getIfPreped()
)
{
TcpHelper.CtosMessage_HsNotReady();
TcpHelper.CtosMessage_UpdateDeck(new YGOSharp.Deck("deck/" + superScrollView.selectedString + ".ydk"));
TcpHelper.CtosMessage_UpdateDeck(
new YGOSharp.Deck("deck/" + superScrollView.selectedString + ".ydk")
);
TcpHelper.CtosMessage_HsReady();
}
}
void printFile()
{
string deckInUse = Config.Get("deckInUse","wizard");
string deckInUse = Config.Get("deckInUse", "wizard");
superScrollView.clear();
FileInfo[] fileInfos = (new DirectoryInfo("deck")).GetFiles();
if (Config.Get(sort,"1") == "1")
if (Config.Get(sort, "1") == "1")
{
Array.Sort(fileInfos, UIHelper.CompareTime);
}
......@@ -52,7 +58,9 @@ public class Room : WindowServantSP
{
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) == deckInUse)
{
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
superScrollView.add(
fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)
);
}
}
}
......@@ -65,7 +73,9 @@ public class Room : WindowServantSP
{
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) != deckInUse)
{
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
superScrollView.add(
fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)
);
}
}
}
......@@ -151,22 +161,24 @@ public class Room : WindowServantSP
public void StocMessage_HsPlayerEnter(BinaryReader r)
{
string name = r.ReadUnicode(20);
int pos = r.ReadByte()&3;//Fuck this
int pos = r.ReadByte() & 3; //Fuck this
RoomPlayer player = new RoomPlayer();
player.name = name;
player.prep = false;
if (Program.I().mycard.isMatching && name != "********") // athletic match name mask
{
(new Thread(() =>
(
new Thread(() =>
{
string errorMessage = MyCardHelper.DownloadFace(name);
if (errorMessage != null)
Program.PrintToChat(InterString.Get("头像加载失败: ") + errorMessage);
else if(isShowed)
else if (isShowed)
realize();
else if(Program.I().ocgcore.isShowed && Program.I().ocgcore.gameInfo)
else if (Program.I().ocgcore.isShowed && Program.I().ocgcore.gameInfo)
Program.I().ocgcore.gameInfo.realize();
})).Start();
})
).Start();
}
roomPlayers[pos] = player;
realize();
......@@ -181,7 +193,7 @@ public class Room : WindowServantSP
if (player < 4)
{
if (UIHelper.fromStringToBool(Config.Get("ignoreOP_","0")) == true)
if (UIHelper.fromStringToBool(Config.Get("ignoreOP_", "0")) == true)
return;
if (mode != 2)
{
......@@ -206,7 +218,7 @@ public class Room : WindowServantSP
}
else
{
if (UIHelper.fromStringToBool(Config.Get("ignoreWatcher_","0")) == true)
if (UIHelper.fromStringToBool(Config.Get("ignoreWatcher_", "0")) == true)
return;
}
AddChatMsg(str, player);
......@@ -214,15 +226,16 @@ public class Room : WindowServantSP
public void StocMessage_DeckCount(BinaryReader r)
{
int deck0=r.ReadInt16();
int extra0=r.ReadInt16();
int side0=r.ReadInt16();
int deck1=r.ReadInt16();
int extra1=r.ReadInt16();
int side1=r.ReadInt16();
string str= InterString.Get("对方主卡组:[?]张", deck1.ToString()) +
InterString.Get(",额外卡组:[?]张", extra1.ToString()) +
InterString.Get(",副卡组:[?]张", side1.ToString());
int deck0 = r.ReadInt16();
int extra0 = r.ReadInt16();
int side0 = r.ReadInt16();
int deck1 = r.ReadInt16();
int extra1 = r.ReadInt16();
int side1 = r.ReadInt16();
string str =
InterString.Get("对方主卡组:[?]张", deck1.ToString())
+ InterString.Get(",额外卡组:[?]张", extra1.ToString())
+ InterString.Get(",副卡组:[?]张", side1.ToString());
AddChatMsg(str, 10);
}
......@@ -313,7 +326,7 @@ public class Room : WindowServantSP
string roomname;
string player1 = "";
string player2 = "";
string hoststr=String.Empty;
string hoststr = String.Empty;
List<string[]> roomList = new List<string[]>();
for (ushort i = 0; i < count; i++)
{
......@@ -321,8 +334,8 @@ public class Room : WindowServantSP
byte[] temp = r.ReadBytes(64);
roomname = Encoding.UTF8.GetString(temp);
roomname = roomname.Trim(new char[] { '\0' });
int room_status = Convert.ToInt16(BitConverter.ToString(r.ReadBytes(1), 0),16);
int room_duel_count = Convert.ToInt16(BitConverter.ToString(r.ReadBytes(1), 0),16);
int room_status = Convert.ToInt16(BitConverter.ToString(r.ReadBytes(1), 0), 16);
int room_duel_count = Convert.ToInt16(BitConverter.ToString(r.ReadBytes(1), 0), 16);
int room_turn_count = Convert.ToInt16(BitConverter.ToString(r.ReadBytes(1), 0), 16);
temp = r.ReadBytes(128);
player1 = Encoding.UTF8.GetString(temp);
......@@ -354,24 +367,47 @@ public class Room : WindowServantSP
player2_lp.ToString(),
hoststr,
room_status.ToString(),
roomTag
roomTag,
};
switch (room_status)
{
case 0:
{
hoststr = "[EFD334][未开始][FFFFFF] " + strings[11] +"[FFFFFF]"+ strings[5] + " VS " + strings[6];
hoststr =
"[EFD334][未开始][FFFFFF] "
+ strings[11]
+ "[FFFFFF]"
+ strings[5]
+ " VS "
+ strings[6];
break;
}
case 1:
{
hoststr = "[A978ED][G:" + strings[0] + ",T:" + strings[1] + "][FFFFFF] " + strings[11] +"[FFFFFF]" + strings[5] + " VS " + strings[6];
hoststr =
"[A978ED][G:"
+ strings[0]
+ ",T:"
+ strings[1]
+ "][FFFFFF] "
+ strings[11]
+ "[FFFFFF]"
+ strings[5]
+ " VS "
+ strings[6];
break;
}
case 2:
{
hoststr = "[A978ED][G:" + strings[0] + ",Siding][FFFFFF] " + strings[11] + "[FFFFFF]" + strings[5] + " VS " + strings[6];
hoststr =
"[A978ED][G:"
+ strings[0]
+ ",Siding][FFFFFF] "
+ strings[11]
+ "[FFFFFF]"
+ strings[5]
+ " VS "
+ strings[6];
break;
}
default:
......@@ -389,19 +425,22 @@ public class Room : WindowServantSP
string RoomNameFormatter(string roomname)
{
string roomTag=String.Empty;
string roomTag = String.Empty;
List<string> tags = new List<string>();
if (Regex.IsMatch(roomname, @"^S,RANDOM#\d{1,}"))
{
roomTag = "[8AE57E][Duel] ";
return roomTag;
}
else if(Regex.IsMatch(roomname, @"^M,RANDOM#\d{1,}"))
else if (Regex.IsMatch(roomname, @"^M,RANDOM#\d{1,}"))
{
roomTag = "[42C1EC][Match] ";
return roomTag;
}
else if(Regex.IsMatch(roomname, @"^AI#\S{0,},\d{1,}")|| Regex.IsMatch(roomname, @"^AI\S{0,}#\d{1,}"))
else if (
Regex.IsMatch(roomname, @"^AI#\S{0,},\d{1,}")
|| Regex.IsMatch(roomname, @"^AI\S{0,}#\d{1,}")
)
{
roomTag = "[5E71FF][AI] ";
return roomTag;
......@@ -438,7 +477,6 @@ public class Room : WindowServantSP
else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}T[,#])?(?(1)|(^T[#,]))"))
{
tags.Add("[D14291][TAG] ");
}
}
else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}TO[,#])?(?(1)|(^TO[#,]))"))
......@@ -446,7 +484,6 @@ public class Room : WindowServantSP
if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}OT[,#])?(?(1)|(^OT[#,]))"))
{
tags.Add("[11C69C][TCG/OCG]");
}
else
{
......@@ -475,15 +512,16 @@ public class Room : WindowServantSP
{
tags.Add("[42C1EC][Match]");
}
if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}S[,#])?(?(1)|(^S[#,]))")){
if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}S[,#])?(?(1)|(^S[#,]))"))
{
tags.Add("[8AE57E][Duel]");
}
}
roomTag = String.Join("", tags.ToArray())+" ";
roomTag = String.Join("", tags.ToArray()) + " ";
if (roomTag == " ")
{
roomTag ="[ "+roomname+" ] ";
roomTag = "[ " + roomname + " ] ";
}
if (roomTag.Length > 150)
{
......@@ -513,14 +551,13 @@ public class Room : WindowServantSP
public void StocMessage_DuelStart(BinaryReader r)
{
Program.I().ocgcore.setDefaultReturnServant();
needSide = false;
joinWithReconnect = true;
if (Program.I().deckManager.isShowed)
{
Program.I().deckManager.hide();
RMSshow_onlyYes("",InterString.Get("更换副卡组成功,请等待对手更换副卡组。"),null);
RMSshow_onlyYes("", InterString.Get("更换副卡组成功,请等待对手更换副卡组。"), null);
}
if (isShowed)
{
......@@ -544,24 +581,53 @@ public class Room : WindowServantSP
is_host = ((type >> 4) & 0xf) != 0;
if (is_host)
{
if (selftype < 4 && roomPlayers[selftype] != null) {
if (selftype < 4 && roomPlayers[selftype] != null)
{
roomPlayers[selftype].prep = false;
}
UIHelper.shiftButton(startButton(), true);
lazyRoom.start.localScale = Vector3.one;
lazyRoom.ready.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f + 30f, 0);
lazyRoom.duelist.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f, 0);
lazyRoom.observer.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f, 0);
lazyRoom.start.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f, 0);
lazyRoom.ready.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f + 30f,
0
);
lazyRoom.duelist.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f,
0
);
lazyRoom.observer.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f - 30f,
0
);
lazyRoom.start.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f - 30f - 30f,
0
);
}
else
{
UIHelper.shiftButton(startButton(), false);
lazyRoom.start.localScale = Vector3.zero;
lazyRoom.ready.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f, 0);
lazyRoom.duelist.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f, 0);
lazyRoom.observer.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f, 0);
lazyRoom.start.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f - 30f, 0);
lazyRoom.duelist.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f - 30f,
0
);
lazyRoom.observer.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f - 30f - 30f,
0
);
lazyRoom.start.localPosition = new Vector3(
lazyRoom.duelist.localPosition.x,
-94.2f - 30f - 30f - 30f,
0
);
}
realize();
}
......@@ -594,9 +660,10 @@ public class Room : WindowServantSP
}
public bool needSide = false;
public void StocMessage_TeammateSurrender(BinaryReader r)
{
if(Program.I().ocgcore.surrended)
if (Program.I().ocgcore.surrended)
RMSshow_none(InterString.Get("已申请投降,请等待队友同意。"));
else
RMSshow_none(InterString.Get("队友申请投降。若您同意,请点击投降按钮。"));
......@@ -609,12 +676,14 @@ public class Room : WindowServantSP
Program.I().ocgcore.surrended = false;
Program.I().ocgcore.returnServant = Program.I().deckManager;
needSide = true;
if(Program.I().ocgcore.condition != Ocgcore.Condition.duel || joinWithReconnect) { //Change side when reconnect
if (Program.I().ocgcore.condition != Ocgcore.Condition.duel || joinWithReconnect)
{ //Change side when reconnect
Program.I().ocgcore.onDuelResultConfirmed();
}
}
GameObject handres = null;
public void StocMessage_HandResult(BinaryReader r)
{
if (isShowed)
......@@ -625,7 +694,13 @@ public class Room : WindowServantSP
int opResult = r.ReadByte();
Program.I().new_ui_handShower.GetComponent<handShower>().me = meResult - 1;
Program.I().new_ui_handShower.GetComponent<handShower>().op = opResult - 1;
handres = create(Program.I().new_ui_handShower, Vector3.zero, Vector3.zero, false, Program.ui_main_2d);
handres = create(
Program.I().new_ui_handShower,
Vector3.zero,
Vector3.zero,
false,
Program.ui_main_2d
);
destroy(handres, 10f);
animationTime = 1300;
}
......@@ -634,15 +709,26 @@ public class Room : WindowServantSP
{
if (animationTime != 0)
{
Program.go(animationTime, () =>
Program.go(
animationTime,
() =>
{
RMSshow_FS("StocMessage_SelectTp", new messageSystemValue { hint = InterString.Get("先攻"), value = "first" }, new messageSystemValue { hint = InterString.Get("后攻"), value = "second" });
});
RMSshow_FS(
"StocMessage_SelectTp",
new messageSystemValue { hint = InterString.Get("先攻"), value = "first" },
new messageSystemValue { hint = InterString.Get("后攻"), value = "second" }
);
}
);
animationTime = 0;
}
else
{
RMSshow_FS("StocMessage_SelectTp", new messageSystemValue { hint = InterString.Get("先攻"), value = "first" }, new messageSystemValue { hint = InterString.Get("后攻"), value = "second" });
RMSshow_FS(
"StocMessage_SelectTp",
new messageSystemValue { hint = InterString.Get("先攻"), value = "first" },
new messageSystemValue { hint = InterString.Get("后攻"), value = "second" }
);
}
}
......@@ -679,26 +765,32 @@ public class Room : WindowServantSP
public void StocMessage_SelectHand(BinaryReader r)
{
if (animationTime != 0)
{
Program.go(animationTime, () =>
Program.go(
animationTime,
() =>
{
hide();
RMSshow_tp("StocMessage_SelectHand"
, new messageSystemValue { hint = "jiandao", value = "jiandao" }
, new messageSystemValue { hint = "shitou", value = "shitou" }
, new messageSystemValue { hint = "bu", value = "bu" });
});
RMSshow_tp(
"StocMessage_SelectHand",
new messageSystemValue { hint = "jiandao", value = "jiandao" },
new messageSystemValue { hint = "shitou", value = "shitou" },
new messageSystemValue { hint = "bu", value = "bu" }
);
}
);
animationTime = 0;
}
else
{
hide();
RMSshow_tp("StocMessage_SelectHand"
, new messageSystemValue { hint = "jiandao", value = "jiandao" }
, new messageSystemValue { hint = "shitou", value = "shitou" }
, new messageSystemValue { hint = "bu", value = "bu" });
RMSshow_tp(
"StocMessage_SelectHand",
new messageSystemValue { hint = "jiandao", value = "jiandao" },
new messageSystemValue { hint = "shitou", value = "shitou" },
new messageSystemValue { hint = "bu", value = "bu" }
);
}
}
......@@ -736,22 +828,78 @@ public class Room : WindowServantSP
switch (flag)
{
case 1: // DECKERROR_LFLIST
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(数量不符合禁限卡表)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get("(数量不符合禁限卡表)"),
null
);
break;
case 2: // DECKERROR_OCGONLY
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(OCG独有卡,不能在当前设置使用)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get("(OCG独有卡,不能在当前设置使用)"),
null
);
break;
case 3: // DECKERROR_TCGONLY
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(TCG独有卡,不能在当前设置使用)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get("(TCG独有卡,不能在当前设置使用)"),
null
);
break;
case 4: // DECKERROR_UNKNOWNCARD
if (code < 100000000)
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(服务器无法识别此卡,可能是服务器未更新)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get("(服务器无法识别此卡,可能是服务器未更新)"),
null
);
else
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(服务器无法识别此卡,可能是服务器不支持先行卡或此先行卡已正式更新)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get(
"(服务器无法识别此卡,可能是服务器不支持先行卡或此先行卡已正式更新)"
),
null
);
break;
case 5: // DECKERROR_CARDCOUNT
RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(数量过多)"), null);
RMSshow_onlyYes(
"",
InterString.Get(
"卡组非法,请检查:[?]",
YGOSharp.CardsManager.Get(code).Name
)
+ "\r\n"
+ InterString.Get("(数量过多)"),
null
);
break;
case 6: // DECKERROR_MAINCOUNT
RMSshow_onlyYes("", InterString.Get("主卡组数量应为40-60张"), null);
......@@ -768,7 +916,11 @@ public class Room : WindowServantSP
}
break;
case 3:
RMSshow_onlyYes("", InterString.Get("更换副卡组失败,请检查卡片张数是否一致。"), null);
RMSshow_onlyYes(
"",
InterString.Get("更换副卡组失败,请检查卡片张数是否一致。"),
null
);
break;
case 4:
r.ReadByte();
......@@ -850,17 +1002,11 @@ public class Room : WindowServantSP
Program.I().shiftToServant(Program.I().ocgcore);
}
public void StocMessage_CreateGame(BinaryReader r)
{
}
public void StocMessage_CreateGame(BinaryReader r) { }
public void StocMessage_LeaveGame(BinaryReader r)
{
}
public void StocMessage_LeaveGame(BinaryReader r) { }
public void StocMessage_TpResult(BinaryReader r)
{
}
public void StocMessage_TpResult(BinaryReader r) { }
public class RoomPlayer
{
......@@ -912,9 +1058,11 @@ public class Room : WindowServantSP
}
else
{
description += InterString.Get("/大师规则[?]", Program.I().ocgcore.MasterRule.ToString()) + "\r\n";
description +=
InterString.Get("/大师规则[?]", Program.I().ocgcore.MasterRule.ToString()) + "\r\n";
}
description += InterString.Get("禁限卡表:[?]", YGOSharp.BanlistManager.GetName(lflist)) + "\r\n";
description +=
InterString.Get("禁限卡表:[?]", YGOSharp.BanlistManager.GetName(lflist)) + "\r\n";
if (rule == 0)
{
description += InterString.Get("(OCG卡池)") + "\r\n";
......@@ -976,7 +1124,7 @@ public class Room : WindowServantSP
{
realPlayers[i].SetNotNull(true);
realPlayers[i].setName(roomPlayers[i].name);
realPlayers[i].SetIFcanKick(is_host&&(i != selftype));
realPlayers[i].SetIFcanKick(is_host && (i != selftype));
realPlayers[i].setIfMe(i == selftype);
realPlayers[i].setIfprepared(roomPlayers[i].prep);
if (mode != 2)
......@@ -1016,6 +1164,7 @@ public class Room : WindowServantSP
}
lazyRoom lazyRoom = null;
void ini()
{
for (int i = 0; i < 4; i++)
......@@ -1087,7 +1236,9 @@ public class Room : WindowServantSP
}
if (arg2)
{
TcpHelper.CtosMessage_UpdateDeck(new YGOSharp.Deck("deck/" + Config.Get("deckInUse","miaouwu") + ".ydk"));
TcpHelper.CtosMessage_UpdateDeck(
new YGOSharp.Deck("deck/" + Config.Get("deckInUse", "miaouwu") + ".ydk")
);
TcpHelper.CtosMessage_HsReady();
}
else
......@@ -1142,7 +1293,9 @@ public class Room : WindowServantSP
}
else
{
TcpHelper.CtosMessage_UpdateDeck(new YGOSharp.Deck("deck/" + Config.Get("deckInUse", "wizard") + ".ydk"));
TcpHelper.CtosMessage_UpdateDeck(
new YGOSharp.Deck("deck/" + Config.Get("deckInUse", "wizard") + ".ydk")
);
TcpHelper.CtosMessage_HsReady();
}
}
......@@ -1162,5 +1315,4 @@ public class Room : WindowServantSP
}
#endregion
}
......@@ -917,7 +917,7 @@ public class Servant
public void DownloadFace()
{
string url = "http://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100";
string url = "https://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100";
string facePath = "textures/face/" + nameFace + ".jpg";
// 如果输入的是一个完整的URL,则使用它
if (inputUrl.value.Length >= 4 && inputUrl.value.StartsWith("http"))
......@@ -939,6 +939,7 @@ public class Servant
if (success)
{
Debug.Log("头像下载成功,路径: " + facePath);
Program.PrintToChat("头像下载成功!");
// 将原来同步执行的刷新逻辑移动到这里
// 确保文件确实存在并且已经被下载完毕
if (File.Exists(facePath))
......@@ -961,6 +962,7 @@ public class Servant
else
{
Debug.LogError("头像下载失败: " + url);
Program.PrintToChat("头像下载失败: " + url);
}
}
)
......
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public class UIselectableList : MonoBehaviour {
public class UIselectableList : MonoBehaviour
{
public GameObject mod;
public UIPanel panel;
public UIScrollBar scrollBar;
private string m_selectedString;
public string selectedString
{
get
{
return m_selectedString;
}
get { return m_selectedString; }
set
{
if (m_selectedString != value)
......@@ -30,12 +28,14 @@ public class UIselectableList : MonoBehaviour {
UIScrollView uIScrollView;
float heightOfEach = 35;
public float preHeight = 0;
class selection
{
public string str = "";
public UIselectableListItem obj = null;
public bool selected = false;
}
List<selection> selections = new List<selection>();
float width = 0;
float height = 0;
......@@ -60,7 +60,6 @@ public class UIselectableList : MonoBehaviour {
height = panel.GetViewSize().y;
clear();
toTop();
}
void onScrollBarChange()
......@@ -133,16 +132,19 @@ public class UIselectableList : MonoBehaviour {
public void add(string item)
{
selections.Add(new selection
selections.Add(
new selection
{
str = item,
obj = null,
selected = false
});
selected = false,
}
);
needRefresh = true;
}
float pre = 0;
public void refresh()
{
float screenTop = panel.clipOffset.y + (height - heightOfEach) / 2f;
......@@ -159,7 +161,7 @@ public class UIselectableList : MonoBehaviour {
scrollBar.barSize = 0.1f;
}
float beginY = (height - heightOfEach) / 2f;
float endY = beginY + heightOfEach * selections.Count+preHeight - height;
float endY = beginY + heightOfEach * selections.Count + preHeight - height;
float allHeight = endY - beginY;
float curHeight = uIScrollView.transform.localPosition.y - beginY;
scrollBar.value = curHeight / allHeight;
......@@ -181,7 +183,9 @@ public class UIselectableList : MonoBehaviour {
}
else
{
currentItem.obj = MonoBehaviour.Instantiate<GameObject>(mod).GetComponent<UIselectableListItem>();
currentItem.obj = MonoBehaviour
.Instantiate<GameObject>(mod)
.GetComponent<UIselectableListItem>();
currentItem.obj.List = this;
currentItem.obj.transform.SetParent(panel.transform, false);
currentItem.obj.lable.width = (int)width - 10;
......@@ -213,9 +217,9 @@ public class UIselectableList : MonoBehaviour {
}
}
void Update () {
void Update()
{
refresh();
}
public void refreshForOneFrame()
......
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