Commit 4aee470a authored by hex's avatar hex

download qq avatar with https

parent 4694efba
Pipeline #37630 failed
This diff is collapsed.
......@@ -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,13 +28,15 @@ 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>();
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()
......@@ -75,7 +74,7 @@ public class UIselectableList : MonoBehaviour {
uIScrollView.transform.localPosition.x,
Y,
uIScrollView.transform.localPosition.z
);
);
panel.clipOffset = new Vector2(0, -Y);
}
......@@ -95,7 +94,7 @@ public class UIselectableList : MonoBehaviour {
needRefresh = true;
}
public bool Selected()
public bool Selected()
{
bool returnValue = false;
foreach (var item in selections)
......@@ -115,7 +114,7 @@ public class UIselectableList : MonoBehaviour {
uIScrollView.transform.localPosition.x,
Y,
uIScrollView.transform.localPosition.z
);
);
panel.clipOffset = new Vector2(0, -Y);
if (select)
{
......@@ -133,16 +132,19 @@ public class UIselectableList : MonoBehaviour {
public void add(string item)
{
selections.Add(new selection
{
str = item,
obj = null,
selected = false
});
selections.Add(
new selection
{
str = item,
obj = null,
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;
......@@ -169,7 +171,7 @@ public class UIselectableList : MonoBehaviour {
scrollBar.gameObject.SetActive(false);
}
float screenButtom = screenTop - height + heightOfEach;
for (int i = 0; i < selections.Count; i++)
for (int i = 0; i < selections.Count; i++)
{
var currentItem = selections[i];
float currentY = -i * heightOfEach - preHeight;
......@@ -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