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 ...@@ -917,7 +917,7 @@ public class Servant
public void DownloadFace() 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"; string facePath = "textures/face/" + nameFace + ".jpg";
// 如果输入的是一个完整的URL,则使用它 // 如果输入的是一个完整的URL,则使用它
if (inputUrl.value.Length >= 4 && inputUrl.value.StartsWith("http")) if (inputUrl.value.Length >= 4 && inputUrl.value.StartsWith("http"))
...@@ -939,6 +939,7 @@ public class Servant ...@@ -939,6 +939,7 @@ public class Servant
if (success) if (success)
{ {
Debug.Log("头像下载成功,路径: " + facePath); Debug.Log("头像下载成功,路径: " + facePath);
Program.PrintToChat("头像下载成功!");
// 将原来同步执行的刷新逻辑移动到这里 // 将原来同步执行的刷新逻辑移动到这里
// 确保文件确实存在并且已经被下载完毕 // 确保文件确实存在并且已经被下载完毕
if (File.Exists(facePath)) if (File.Exists(facePath))
...@@ -961,6 +962,7 @@ public class Servant ...@@ -961,6 +962,7 @@ public class Servant
else else
{ {
Debug.LogError("头像下载失败: " + url); Debug.LogError("头像下载失败: " + url);
Program.PrintToChat("头像下载失败: " + url);
} }
} }
) )
......
using UnityEngine; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System; using UnityEngine;
public class UIselectableList : MonoBehaviour { public class UIselectableList : MonoBehaviour
{
public GameObject mod; public GameObject mod;
public UIPanel panel; public UIPanel panel;
public UIScrollBar scrollBar; public UIScrollBar scrollBar;
private string m_selectedString; private string m_selectedString;
public string selectedString public string selectedString
{ {
get get { return m_selectedString; }
{
return m_selectedString;
}
set set
{ {
if (m_selectedString != value) if (m_selectedString != value)
...@@ -30,12 +28,14 @@ public class UIselectableList : MonoBehaviour { ...@@ -30,12 +28,14 @@ public class UIselectableList : MonoBehaviour {
UIScrollView uIScrollView; UIScrollView uIScrollView;
float heightOfEach = 35; float heightOfEach = 35;
public float preHeight = 0; public float preHeight = 0;
class selection class selection
{ {
public string str = ""; public string str = "";
public UIselectableListItem obj = null; public UIselectableListItem obj = null;
public bool selected = false; public bool selected = false;
} }
List<selection> selections = new List<selection>(); List<selection> selections = new List<selection>();
float width = 0; float width = 0;
float height = 0; float height = 0;
...@@ -60,7 +60,6 @@ public class UIselectableList : MonoBehaviour { ...@@ -60,7 +60,6 @@ public class UIselectableList : MonoBehaviour {
height = panel.GetViewSize().y; height = panel.GetViewSize().y;
clear(); clear();
toTop(); toTop();
} }
void onScrollBarChange() void onScrollBarChange()
...@@ -133,16 +132,19 @@ public class UIselectableList : MonoBehaviour { ...@@ -133,16 +132,19 @@ public class UIselectableList : MonoBehaviour {
public void add(string item) public void add(string item)
{ {
selections.Add(new selection selections.Add(
new selection
{ {
str = item, str = item,
obj = null, obj = null,
selected = false selected = false,
}); }
);
needRefresh = true; needRefresh = true;
} }
float pre = 0; float pre = 0;
public void refresh() public void refresh()
{ {
float screenTop = panel.clipOffset.y + (height - heightOfEach) / 2f; float screenTop = panel.clipOffset.y + (height - heightOfEach) / 2f;
...@@ -159,7 +161,7 @@ public class UIselectableList : MonoBehaviour { ...@@ -159,7 +161,7 @@ public class UIselectableList : MonoBehaviour {
scrollBar.barSize = 0.1f; scrollBar.barSize = 0.1f;
} }
float beginY = (height - heightOfEach) / 2f; 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 allHeight = endY - beginY;
float curHeight = uIScrollView.transform.localPosition.y - beginY; float curHeight = uIScrollView.transform.localPosition.y - beginY;
scrollBar.value = curHeight / allHeight; scrollBar.value = curHeight / allHeight;
...@@ -181,7 +183,9 @@ public class UIselectableList : MonoBehaviour { ...@@ -181,7 +183,9 @@ public class UIselectableList : MonoBehaviour {
} }
else else
{ {
currentItem.obj = MonoBehaviour.Instantiate<GameObject>(mod).GetComponent<UIselectableListItem>(); currentItem.obj = MonoBehaviour
.Instantiate<GameObject>(mod)
.GetComponent<UIselectableListItem>();
currentItem.obj.List = this; currentItem.obj.List = this;
currentItem.obj.transform.SetParent(panel.transform, false); currentItem.obj.transform.SetParent(panel.transform, false);
currentItem.obj.lable.width = (int)width - 10; currentItem.obj.lable.width = (int)width - 10;
...@@ -213,9 +217,9 @@ public class UIselectableList : MonoBehaviour { ...@@ -213,9 +217,9 @@ public class UIselectableList : MonoBehaviour {
} }
} }
void Update () { void Update()
{
refresh(); refresh();
} }
public void refreshForOneFrame() 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