Commit dde96b6a authored by hex's avatar hex

Adapt to special-shaped screen

parent c3613e75
Pipeline #39586 failed
......@@ -549,12 +549,12 @@ public class Program : MonoBehaviour
{
if (loadAction(path))
{
Debug.Log("Successfully loaded: " + path);
// Debug.Log("Successfully loaded: " + path);
return true;
}
}
}
Debug.LogError("Failed to load file: " + fileName);
// Debug.LogError("Failed to load file: " + fileName);
return false;
}
......
......@@ -40,7 +40,7 @@ public class GameTextureManager
private static Thread _ioThread;
private static bool _isRunning = false;
public static bool IsInitialized = false;
public static bool IsInitialized = false;
// 内部结构体,用于传递下载任务
internal struct DownloadRequest
......@@ -239,7 +239,7 @@ public class GameTextureManager
}
catch (Exception e)
{
Debug.LogError("Failed to read file: " + path + ". Error: " + e.Message);
// Debug.LogError("Failed to read file: " + path + ". Error: " + e.Message);
pic.rawData = null; // 确保失败时rawData为null
}
}
......@@ -305,20 +305,20 @@ public class GameTextureManager
{
if (success)
{
Debug.Log("Download successful, reading file: " + request.FilePath);
// Debug.Log("Download successful, reading file: " + request.FilePath);
try
{
request.PicResource.rawData = File.ReadAllBytes(request.FilePath);
}
catch (Exception ex)
{
Debug.LogError("Failed to read downloaded file: " + ex.Message);
// Debug.LogError("Failed to read downloaded file: " + ex.Message);
request.PicResource.rawData = null;
}
}
else
{
Debug.LogWarning("Download failed for card: " + request.PicResource.code);
// Debug.LogWarning("Download failed for card: " + request.PicResource.code);
request.PicResource.rawData = null;
}
......@@ -709,9 +709,9 @@ public class GameTextureManager
// 标记为初始化完成
IsInitialized = true;
Debug.Log("[GameTextureManager] Assets initialized successfully.");
// Debug.Log("[GameTextureManager] Assets initialized successfully.");
}
// NEW: 这个方法现在只负责启动后台线程
public static void StartBackgroundThread()
{
......@@ -721,7 +721,7 @@ public class GameTextureManager
_ioThread = new Thread(IoThreadRun);
_ioThread.IsBackground = true; // 确保主程序退出时线程也退出
_ioThread.Start();
Debug.Log("[GameTextureManager] Background I/O thread started.");
// Debug.Log("[GameTextureManager] Background I/O thread started.");
}
}
#endregion
......
......@@ -11,7 +11,7 @@ public static class GlobalCertificateManager
// 注册全局的证书验证回调
ServicePointManager.ServerCertificateValidationCallback =
MyRemoteCertificateValidationCallback;
Debug.Log("全局证书验证回调已注册,将接受所有HTTPS证书。");
// Debug.Log("全局证书验证回调已注册,将接受所有HTTPS证书。");
}
/// <summary>
......
......@@ -27,9 +27,9 @@ public class UnityFileDownloader
}
catch (Exception e)
{
Debug.LogError("Failed to create directory for " + filePath + ". Error: " + e.Message);
if (onComplete != null) onComplete.Invoke(false);
yield break; // 提前退出协程
// Debug.LogError("Failed to create directory for " + filePath + ". Error: " + e.Message);
if (onComplete != null) onComplete.Invoke(false);
yield break; // 提前退出协程
}
string tempFilePath = filePath + ".tmp";
......@@ -38,7 +38,7 @@ public class UnityFileDownloader
File.Delete(tempFilePath);
}
Debug.Log(string.Format("Downloading: {0} -> {1}", url, filePath));
// Debug.Log(string.Format("Downloading: {0} -> {1}", url, filePath));
using (UnityWebRequest uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET))
{
......@@ -63,7 +63,7 @@ public class UnityFileDownloader
File.Delete(filePath);
}
File.Move(tempFilePath, filePath);
Debug.Log(string.Format("下载成功: {0} -> {1}", url, filePath));
// Debug.Log(string.Format("下载成功: {0} -> {1}", url, filePath));
if (onComplete != null)
{
......@@ -72,7 +72,7 @@ public class UnityFileDownloader
}
else
{
Debug.LogError(string.Format("下载失败: {0}\n错误信息: {1}", url, uwr.error));
// Debug.LogError(string.Format("下载失败: {0}\n错误信息: {1}", url, uwr.error));
if (File.Exists(tempFilePath))
{
File.Delete(tempFilePath);
......@@ -103,7 +103,7 @@ public class UnityFileDownloader
string etagFilePath = filePath + ".etag";
string localEtag = null;
bool localFileExists = File.Exists(filePath);
// 1. 读取本地ETag(如果存在)
if (File.Exists(etagFilePath))
{
......@@ -111,69 +111,69 @@ public class UnityFileDownloader
{
localEtag = File.ReadAllText(etagFilePath);
}
catch(Exception e)
catch (Exception e)
{
Debug.LogWarning(string.Format("读取本地ETag文件失败: {0}. Error: {1}. 将强制更新。", etagFilePath, e.Message));
// Debug.LogWarning(string.Format("读取本地ETag文件失败: {0}. Error: {1}. 将强制更新。", etagFilePath, e.Message));
localEtag = null; // 读取失败则当做不存在
}
}
// 2. 发送HEAD请求获取服务器ETag
Debug.Log(string.Format("[HEAD] 正在检查: {0}", Path.GetFileName(filePath)));
// Debug.Log(string.Format("[HEAD] 正在检查: {0}", Path.GetFileName(filePath)));
UnityWebRequest headRequest = UnityWebRequest.Head(url);
yield return headRequest.SendWebRequest();
if (headRequest.isNetworkError || headRequest.isHttpError)
{
Debug.LogError(string.Format("[HEAD] 请求失败: {0}\n错误: {1}", url, headRequest.error));
// Debug.LogError(string.Format("[HEAD] 请求失败: {0}\n错误: {1}", url, headRequest.error));
if (onComplete != null) onComplete.Invoke(false);
yield break;
}
string serverEtag = headRequest.GetResponseHeader("ETag");
if (string.IsNullOrEmpty(serverEtag))
{
Debug.LogError(string.Format("[HEAD] 服务器未提供ETag头信息: {0}", url));
// Debug.LogError(string.Format("[HEAD] 服务器未提供ETag头信息: {0}", url));
if (onComplete != null) onComplete.Invoke(false);
yield break;
}
Debug.Log(string.Format("版本比较: Local ETag='{0}', Server ETag='{1}'", localEtag, serverEtag));
// Debug.Log(string.Format("版本比较: Local ETag='{0}', Server ETag='{1}'", localEtag, serverEtag));
// 3. 比较ETag
if (localFileExists && !string.IsNullOrEmpty(localEtag) && localEtag.Equals(serverEtag))
{
Debug.Log(string.Format("[OK] 文件已是最新版本: {0}", Path.GetFileName(filePath)));
// Debug.Log(string.Format("[OK] 文件已是最新版本: {0}", Path.GetFileName(filePath)));
if (onComplete != null) onComplete.Invoke(true); // 已是最新,也算成功
yield break;
}
// 4. ETag不匹配或本地文件不存在,执行下载
Debug.Log(string.Format("发现新版本或本地文件不存在,开始下载: {0}", Path.GetFileName(filePath)));
// Debug.Log(string.Format("发现新版本或本地文件不存在,开始下载: {0}", Path.GetFileName(filePath)));
// --- Chaining Coroutine to get the result ---
bool downloadSucceeded = false;
// 创建一个回调,用于从DownloadFileAsync获取其执行结果
Action<bool> downloadCallback = delegate(bool success)
Action<bool> downloadCallback = delegate (bool success)
{
downloadSucceeded = success;
};
// 调用下载协程,并等待它完成
yield return DownloadFileAsync(url, filePath, downloadCallback, onProgress);
// --- Coroutine finished, now check the result ---
// 5. 下载完成后,更新ETag并回调
if (downloadSucceeded)
{
try
{
File.WriteAllText(etagFilePath, serverEtag);
Debug.Log(string.Format("成功保存新的ETag到: {0}", etagFilePath));
// Debug.Log(string.Format("成功保存新的ETag到: {0}", etagFilePath));
if (onComplete != null) onComplete.Invoke(true); // 下载并保存ETag成功
}
catch(Exception e)
catch (Exception e)
{
Debug.LogError(string.Format("保存ETag文件失败: {0}. Error: {1}", etagFilePath, e.Message));
// Debug.LogError(string.Format("保存ETag文件失败: {0}. Error: {1}", etagFilePath, e.Message));
if (onComplete != null) onComplete.Invoke(false); // ETag保存失败,算整体失败
}
}
......
......@@ -203,13 +203,7 @@ public class DeckManager : ServantWithCardDescription
{
base.applyShowArrangement();
Program.cameraFacing = true;
// UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_");
// tex.height = Screen.height;
// Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
// new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0)
// );
// gameObjectSearch.transform.DOMove(targetPos, 0.6f);
// --- 1. 获取UI元素和安全区域 ---
UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_");
Rect safeArea = Screen.safeArea;
......@@ -516,17 +510,6 @@ public class DeckManager : ServantWithCardDescription
/// </summary>
private const float DETAILED_SEARCH_PANEL_WIDTH = 230f;
/// <summary>
/// 主搜索面板距离屏幕右边缘的距离 (基于其中心点)
/// </summary>
private const float MAIN_PANEL_MARGIN_RIGHT = MAIN_SEARCH_PANEL_WIDTH / 2;
/// <summary>
/// 详细搜索面板滑出后,与主搜索面板组合的总宽度 (用于计算位置)
/// </summary>
private const float COMBINED_PANEL_WIDTH =
MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH + 115f; // 115f 是原始代码中的一个偏移/间距值
/// <summary>
/// 摄像机右侧需要避让的边距 (当只有主搜索面板时)
/// </summary>
......@@ -538,104 +521,6 @@ public class DeckManager : ServantWithCardDescription
/// </summary>
private const float CAMERA_MARGIN_RIGHT_DETAILED = DETAILED_SEARCH_PANEL_WIDTH;
// -----------------------------------------------------------------
// void refreshDetail()
// {
// if (gameObjectDetailedSearch != null)
// {
// if (isShowed)
// {
// if (Screen.height < 700)
// {
// gameObjectDetailedSearch.transform.localScale = new Vector3(
// Screen.height / 700f,
// Screen.height / 700f,
// Screen.height / 700f
// );
// if (detailShowed)
// {
// gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
// Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
// new Vector3(
// Screen.width
// - MAIN_SEARCH_PANEL_WIDTH
// - DETAILED_SEARCH_PANEL_WIDTH
// - 115f * Screen.height / 700f,
// Screen.height * 0.5f,
// 0
// )
// );
// gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
// reShowBar(
// 0,
// MAIN_SEARCH_PANEL_WIDTH
// + DETAILED_SEARCH_PANEL_WIDTH * Screen.height / 700f
// );
// }
// else
// {
// gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
// Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
// new Vector3(
// Screen.width
// - MAIN_SEARCH_PANEL_WIDTH
// - DETAILED_SEARCH_PANEL_WIDTH
// - 115f * Screen.height / 700f,
// Screen.height * 1.5f,
// 0
// )
// );
// gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
// reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
// }
// }
// else
// {
// gameObjectDetailedSearch.transform.localScale = Vector3.one;
// if (detailShowed)
// {
// gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
// Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
// new Vector3(
// Screen.width - COMBINED_PANEL_WIDTH,
// Screen.height * 0.5f,
// 0
// )
// );
// gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
// reShowBar(0, MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH);
// }
// else
// {
// gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
// Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
// new Vector3(
// Screen.width - COMBINED_PANEL_WIDTH,
// Screen.height * 1.5f,
// 0
// )
// );
// gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
// reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
// }
// }
// }
// else
// {
// gameObjectDetailedSearch.transform.localScale = Vector3.zero;
// }
// }
// }
// 在 DeckManager.cs 文件中
void refreshDetail()
{
if (gameObjectDetailedSearch == null || !isShowed)
......@@ -690,7 +575,7 @@ public class DeckManager : ServantWithCardDescription
// 逻辑:安全区右边缘 - 主面板宽度 - 详细面板宽度的一半(考虑缩放)
float visibleTargetX = safeAreaRightEdgeX - searchPanelActualWidth - (DETAILED_SEARCH_PANEL_WIDTH / 2f * scaleFactor);
Debug.Log("visibleTargetX: " + visibleTargetX);
// Debug.Log("visibleTargetX: " + visibleTargetX);
// “隐藏时”的目标 Y 坐标,把它移动到屏幕顶部之外
float hiddenTargetY = Screen.height * 1.5f;
......@@ -1680,16 +1565,6 @@ public class DeckManager : ServantWithCardDescription
private void camrem()
{
// float l = Program.I().cardDescription.width + ((float)Screen.width) * 0.03f;
// float r = Screen.width - 230f;
// if (detailShowed)
// {
// if (gameObjectDetailedSearch != null)
// {
// // [修改] 使用常量替换硬编码的 230
// r -= CAMERA_MARGIN_RIGHT_DETAILED * gameObjectDetailedSearch.transform.localScale.x;
// }
// }
// 获取安全区域
Rect safeArea = Screen.safeArea;
......
......@@ -144,7 +144,7 @@ public class selectReplay : WindowServantSP
var collection = TcpHelper.readPackagesInRecord(path);
foreach (var item in collection)
{
Debug.Log(item.Fuction);
// Debug.Log(item.Fuction);
if (item.Fuction == (int)YGOSharp.OCGWrapper.Enums.GameMessage.sibyl_replay)
{
returnValue = item.Data.reader.ReadToEnd();
......@@ -156,7 +156,7 @@ public class selectReplay : WindowServantSP
{
Debug.Log(e);
}
Debug.Log(returnValue);
// Debug.Log(returnValue);
return returnValue;
}
......
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